fix: use negotiated protocol version in server-sse-multiple-streams raw POSTs - #415
Merged
Merged
Conversation
The stateful server-sse-multiple-streams scenario hard-coded mcp-protocol-version: 2025-03-26 on its three raw concurrent POSTs instead of the version negotiated during initialize. A server that enforces the negotiated session version correctly returns 400 to all three POSTs, so the scenario false-failed before exercising the multi-stream behavior under test. Read transport.protocolVersion after client.connect() and use it for the raw POST headers, falling back to the run's spec version if the transport does not expose one. Add a regression test driving the scenario against a fixture server that 400s any request whose MCP-Protocol-Version header does not match what it negotiated. Fixes #412 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0178cz8nAyFRHQyq9cg2XgZz
commit: |
pcarleton
approved these changes
Jul 27, 2026
pcarleton
marked this pull request as ready for review
July 27, 2026 10:59
pcarleton
pushed a commit
that referenced
this pull request
Jul 27, 2026
…ts (#416) * fix: use negotiated protocol version in sse-polling raw requests The server-sse-polling scenario hard-coded mcp-protocol-version: 2025-11-25 on its raw tools/call POST and Last-Event-ID reconnection GET instead of the version negotiated during initialize — the same bug class as #412. A server that enforces the negotiated session version rejects those requests once it negotiates any other version. Read transport.protocolVersion after client.connect() and use it for both raw request headers, falling back to the run's spec version, mirroring the sse-multiple-streams fix (#415). Add a regression test whose fixture server down-negotiates to 2025-06-18 and 400s any request whose MCP-Protocol-Version header does not match, so a fix that hard-codes the latest version cannot pass. Follow-up to #415. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0178cz8nAyFRHQyq9cg2XgZz * test: harden sse-polling regression fixture per review panel Enforce session id alongside protocol version in the fixture, record Last-Event-ID presence per GET so the SDK's automatic standalone GET cannot satisfy the reconnect assertion, normalize the header type instead of casting, return a descriptive 400 body on the GET path, add Allow to 405s, use the spec-shaped empty-data priming event, and read sessionId via the SDK's public getter in the scenario. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0178cz8nAyFRHQyq9cg2XgZz --------- Co-authored-by: Claude <noreply@anthropic.com>
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.
Before
Running the stable
server-sse-multiple-streamsscenario against a stateful server that enforces the protocol version negotiated during initialize (as the MCP lifecycle requires) false-failed with:The scenario initialized through the SDK's
StreamableHTTPClientTransport(negotiating e.g.2025-11-25), but its three raw concurrent follow-up POSTs hard-codedmcp-protocol-version: 2025-03-26. A version-enforcing server correctly rejected all three, so the scenario failed before ever exercising the multi-stream concurrency behavior under test.After
The raw POSTs carry the version actually negotiated during initialize, so the scenario passes against version-enforcing servers and tests what it is meant to test. Servers that don't enforce the version are unaffected.
How
In
src/scenarios/server/sse-multiple-streams.ts, afterclient.connect(transport)the scenario now reads the SDK transport's publicprotocolVersiongetter intonegotiatedProtocolVersion(alongside the existing session-id extraction) and uses it for the statefulmcp-protocol-versionrequest header, falling back to the run'sspecVersionif the transport exposes none. The stateless (draft) branch is unchanged.src/scenarios/server/sse-multiple-streams.test.tsadds regression coverage: a fixture HTTP server (built in the test file, following the pattern inhttp-standard-headers.test.ts) stores theprotocolVersionit returns from initialize and 400s any later request whoseMCP-Protocol-Versionheader doesn't match. The scenario now passes against it (verified to fail with the previous hard-coded header), and a second test pins that the fixture rejects the supported-but-non-negotiated2025-03-26.Fixes #412