Repository navigation
Conversation
## Motivation and Context `MCP::Client::Stdio` reads the server's stdout as UTF-8 and strips each frame before parsing it. `String#strip` raises for a UTF-8 string holding an invalid byte at either end on every supported Ruby, and anywhere in it from Ruby 3.2 on, and the read loop rescued only `JSON::ParserError`. A server writing such a frame therefore failed the awaited request with `ArgumentError` or `Encoding::CompatibilityError` instead of the transport's own `RequestHandlerError`, which callers rescue. The server transport strips its frames the same way and has the same change separately. Frames are now stripped as bytes. A frame that is not JSON fails the request with the transport's parse failure, as any other unparsable frame does, and a response holding such a byte in a value is returned with the byte kept. ## How Has This Been Tested? `test/mcp/client/stdio_test.rb`: a frame starting with an invalid byte and a response holding one in a value. Against the previous library the first raises `ArgumentError` and the second `Encoding::CompatibilityError`. ## Breaking Changes None.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
MCP::Client::Stdioreads the server's stdout as UTF-8 and strips each frame before parsing it.String#stripraises for a UTF-8 string holding an invalid byte at either end on every supported Ruby, and anywhere in it from Ruby 3.2 on, and the read loop rescued onlyJSON::ParserError. A server writing such a frame therefore failed the awaited request withArgumentErrororEncoding::CompatibilityErrorinstead of the transport's ownRequestHandlerError, which callers rescue. The server transport strips its frames the same way and has the same change separately.Frames are now stripped as bytes. A frame that is not JSON fails the request with the transport's parse failure, as any other unparsable frame does, and a response holding such a byte in a value is returned with the byte kept.
How Has This Been Tested?
test/mcp/client/stdio_test.rb: a frame starting with an invalid byte and a response holding one in a value. Against the previous library the first raisesArgumentErrorand the secondEncoding::CompatibilityError.Breaking Changes
None.
Types of changes
Checklist