Repository navigation
Conversation
A client that negotiated a session can need JSON bodies just as much as a stateless one - it cannot parse an event stream at all - but json_response only applied to the stateless path, so every session-mode call came back as SSE. Peek the first message of the request-wise stream: a terminal response is answered as application/json, and any intermediate message (priming event, notification, server request) is replayed in front of the rest so the stream still carries it. Refs: MCP Streamable HTTP, Accept: application/json, text/event-stream.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
@gocamille is on triage rotation this week and is the reviewer for this one. Labels come from the PR labeler. Please review the change. Automated triage. Labels are a first pass and the assigned maintainer has the final say. |
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.
Problem
StreamableHttpServerConfig::json_responseonly applies to the stateless path(
serve_negotiated_request_directly). With a session (the defaultlegacy_session_mode, and any legacy-protocol client), every POST answer is framedas
text/event-stream, no matter what the client asked for.That matters because the transport also requires the client to declare both
media types:
So a client that declares
text/event-streamonly to satisfy the 406 check, andthen parses nothing but JSON, gets a correct
initializeand then stops — it cannotread any subsequent call. Concretely: Gemini's connector verification does exactly
that, opens a session (initialize +
notifications/initializedsucceed), and thennever reads
tools/list, reporting "cannot connect to this server".Change
Honour
json_responsein session mode too: peek the first message of therequest-wise stream.
application/json(jsonrpc_message_response),same as the stateless path already does;
message in front of the rest and keep the SSE framing, so no message is lost and
streaming clients are unaffected (
json_responsedefaults tofalse).Also updates the
json_responsedoc comment, which claimed stateless-only.Tests
cargo check -p rmcp --lib --features server— cleancargo test -p rmcp --lib --features server— 229 passedThe behaviour was validated against a real deployment: with this change, a client
that sends
Accept: application/json, text/event-streambut only parses JSONreceives
initialize,tools/list(~90 KiB catalogue) andtools/callasapplication/jsonwith a workingMcp-Session-Id, and proceeds to use the tools.Note: this is deliberately not relaxing the Accept requirement — that check is
spec-faithful; only the response framing was unreachable for these clients.