Repository navigation
Conversation
Streamable HTTP answers an accepted notification with 202 and no body,
but some servers send a body anyway, such as {}. HttpMcpClient parsed
that body as a JSON-RPC response and failed with "Missing required
members: [jsonrpc]". For notifications/initialized that failed
McpRemoteClient.initialize, so the remote server contributed no tools.
A notification has no JSON-RPC response, so discard the body, as
StdioMcpClient does. A short body of known length is read so the
connection can be reused; anything else, including a stream, is closed
unread so a misbehaving server cannot block the client or make it
buffer without bound.
psp65
force-pushed
the
fix-http-notification-body
branch
from
October 13, 2026 23:01
b2c6fb4 to
a528f29
Compare
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.
What behavior changes?
HttpMcpClient.exchangeno longer parses the response body of a notification (a request without an id). It returnsnull, asStdioMcpClientdoes.text/event-streamor one of unknown length, is closed unread. A misbehaving server can't block the client or make it buffer without bound.Why is this change needed?
Fixes #1412. A server that accepts
notifications/initializedwith202and a{}body madeMcpRemoteClient.initializefail withMissing required members: [jsonrpc], so the remote server contributed no tools. The spec requires 202 with no body, but the client loses nothing by tolerating one.How was this validated?
New
HttpMcpClientTestcases:testNotificationIgnoresBodyOfAcceptedResponse: a202with{}returnsnull.initializeSucceedsWhenInitializedNotificationIsAcceptedWithABody: a fullinitializeagainst such a server succeeds, and the next request works.testNotificationDoesNotReadAStreamingResponseBody: a never-ending event stream answering a notification doesn't blockexchange. It times out if the body is read in full.The first two fail without the fix.
./gradlew :mcp:mcp-server:test :mcp:mcp-server:integ :mcp:mcp-server:spotlessCheckpasses: 255 unit and 125 integration tests.What should reviewers focus on?
HttpMcpClient.exchangeanddiscardBody: the notification branch sits after the session-404 and non-2xx handling, so error bodies still surface. Also the 8 KiB threshold for reading versus closing.Additional Links
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.