Echo request id in post-parse Streamable HTTP error responses#1687
Merged
tarekgh merged 1 commit intoJul 2, 2026
Merged
Conversation
On the Streamable HTTP transport, several JSON-RPC error responses were emitted with id null even after the request body had been parsed and its id was readable. This violates the base protocol responses rule (error responses must include the same id as the request, except when the id could not be read due to a malformed request) and SEP-2243's error response format for header validation failures. Thread the parsed request id through every post-parse error site on the POST path: the header validation failure (-32020 HeaderMismatch), the 2026-07-28 session-id rejection, the unsupported protocol version fallback, the new-session-only-via-initialize rejection, the stateless session-id rejection, and the session not found and forbidden cases. Pre-parse and malformed cases still return id null, which is correct. Add and strengthen conformance tests to assert the echoed id, while keeping the existing null-id guards for malformed and explicit-null-id requests. Fixes modelcontextprotocol#1677
Contributor
Author
|
CC @cclabadmin |
Contributor
Author
|
CC @jeffhandley |
jeffhandley
approved these changes
Jul 2, 2026
halter73
approved these changes
Jul 2, 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.
Summary
On the Streamable HTTP transport, several JSON-RPC error responses were emitted with
"id": nulleven after the request body had been successfully parsed and its id was readable. This violates the base protocol responses rule (error responses MUST include the same id as the request they correspond to, except when the id could not be read due to a malformed request) and SEP-2243's error response format for header validation failures, which echoes the request id.Fix
Thread the parsed request id through every post-parse error site on the POST path in
StreamableHttpHandler:-32020HeaderMismatch) - the reported caseMcp-Session-Idrejection (SEP-2567)-32001) and forbidden casesPre-parse failures (protocol version and accept header checks) and malformed requests (invalid JSON, explicit
id: null) still returnid: null, which is correct per the base protocol.Tests
Mcp-Nametest to assert the echoed id.All
ModelContextProtocol.AspNetCore.Testspass on net8.0, net9.0, and net10.0.Fixes #1677