Repository navigation
Conversation
## Motivation and Context An error response for a request whose id could not be read, such as a body that is not JSON, an id that is neither a string nor an integer, or a POST the transport refuses before parsing it, carries `"id": null` (issue modelcontextprotocol#606). JSON-RPC 2.0 asks for that null, and MCP narrows it: the schema of 2025-11-25 and 2026-07-28 types the id of an error response as an optional string or integer, and the Streamable HTTP transport says the body of such a refusal may be a JSON-RPC error response that has no `id`. The TypeScript client refuses a null there at schema validation, and the conformance suite's wire-schema check reports it as a violation, except on a request the harness sent malformed on purpose. `JsonRpcHandler.error_response` and the transport's error bodies now leave the `id` member out when there is no id to echo; every id that was echoed before is echoed as before, only the null is gone. The TypeScript and Python servers still answer with a null, and the Python client requires the member, so on a refused POST it replaces the server's message with its own generic error where it used to carry it. Fixes modelcontextprotocol#606. ## How Has This Been Tested? `test/json_rpc_handler_test.rb`, `test/mcp/server_test.rb` and the stdio and Streamable HTTP transport tests check that the member is absent, and that a refused `initialize` carrying the integer id 0 still echoes it. Against the previous library the absence checks fail on the present member. ## Breaking Changes An error response for a request whose id could not be read has no `id` member instead of `"id": null`. The Python client requires the member, so on a refused POST it reports its own generic error in place of the server's message; the TypeScript client, whose schema refuses a null there, now parses such a body.
atesgoral
approved these changes
Oct 15, 2026
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.
Motivation and Context
An error response for a request whose id could not be read, such as a body that is not JSON, an id that is neither a string nor an integer, or a POST the transport refuses before parsing it, carries
"id": null(issue #606). JSON-RPC 2.0 asks for that null, and MCP narrows it: the schema of 2025-11-25 and 2026-07-28 types the id of an error response as an optional string or integer, and the Streamable HTTP transport says the body of such a refusal may be a JSON-RPC error response that has noid. The TypeScript client refuses a null there at schema validation, and the conformance suite's wire-schema check reports it as a violation, except on a request the harness sent malformed on purpose.JsonRpcHandler.error_responseand the transport's error bodies now leave theidmember out when there is no id to echo; every id that was echoed before is echoed as before, only the null is gone. The TypeScript and Python servers still answer with a null, and the Python client requires the member, so on a refused POST it replaces the server's message with its own generic error where it used to carry it.Fixes #606.
How Has This Been Tested?
test/json_rpc_handler_test.rb,test/mcp/server_test.rband the stdio and Streamable HTTP transport tests check that the member is absent, and that a refusedinitializecarrying the integer id 0 still echoes it. Against the previous library the absence checks fail on the present member.Breaking Changes
An error response for a request whose id could not be read has no
idmember instead of"id": null. The Python client requires the member, so on a refused POST it reports its own generic error in place of the server's message; the TypeScript client, whose schema refuses a null there, now parses such a body.Types of changes
Checklist