Conversation
## Motivation and Context A `subscriptions/listen` request whose id, or one of whose honored resource URIs, is a string holding bytes that are not valid UTF-8 parses, since the JSON parser accepts such bytes, but cannot be written back as JSON. The transport answered 200, registered the stream, and then failed to encode the acknowledgement that echoes both; `JSON::GeneratorError` is not among the write errors the stream handles, so the registered entry was never removed and kept one of the `max_listen_subscriptions` slots until the transport closed. The acknowledgement is now encoded before the stream is committed to. An id that cannot be encoded is refused with HTTP 400 and JSON-RPC `-32600`, the error carrying a null id since the id itself cannot be written; an honored filter that cannot be encoded is refused with HTTP 400 and `-32602`. Neither registers a stream. ## How Has This Been Tested? New tests in `test/mcp/server/transports/streamable_http_transport_test.rb` send a listen request whose id and one whose resource URI hold an invalid byte, and check the 400 and that no stream is registered. Against the previous library both answer 200. Two more send the invalid URI to a server without the `subscribe` capability, which acknowledges without it, and to a transport at its stream cap, which answers 503 first. ## Breaking Changes None.
atesgoral
approved these changes
Oct 1, 2026
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
A
subscriptions/listenrequest whose id, or one of whose honored resource URIs, is a string holding bytes that are not valid UTF-8 parses, since the JSON parser accepts such bytes, but cannot be written back as JSON. The transport answered 200, registered the stream, and then failed to encode the acknowledgement that echoes both;JSON::GeneratorErroris not among the write errors the stream handles, so the registered entry was never removed and kept one of themax_listen_subscriptionsslots until the transport closed.The acknowledgement is now encoded before the stream is committed to. An id that cannot be encoded is refused with HTTP 400 and JSON-RPC
-32600, the error carrying a null id since the id itself cannot be written; an honored filter that cannot be encoded is refused with HTTP 400 and-32602. Neither registers a stream.How Has This Been Tested?
New tests in
test/mcp/server/transports/streamable_http_transport_test.rbsend a listen request whose id and one whose resource URI hold an invalid byte, and check the 400 and that no stream is registered. Against the previous library both answer 200.Two more send the invalid URI to a server without the
subscribecapability, which acknowledges without it, and to a transport at its stream cap, which answers 503 first.Breaking Changes
None.
Types of changes
Checklist