Repository navigation
Reject requests with a null id - #605
Closed
dominikklein wants to merge 1 commit into
Closed
dominikklein wants to merge 1 commit into
dominikklein wants to merge 1 commit into
Conversation
MCP doesn't allow a null request id, but a request with "id": null was run like a notification: the method executed and nothing was answered (202 over HTTP). It now gets Invalid Request (-32600) and the method doesn't run. A message without an id is still handled as a notification. Refs modelcontextprotocol#601.
Member
|
Closing in favor of #612, which refuses a null id the same way ( #612 also adds regression tests for an id-less Thank you for the report and the repro in #601 that showed the id-less call running as well. |
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.
MCP doesn't allow a null request id, but
"id": nullwas treated like a missing id: the method ran and nothing was answered, so over HTTP the client got a 202 with an empty body. Such a request now gets Invalid Request (-32600) and the method isn't called.valid_id?no longer acceptsnil(its error message drops "or null"), and the check only applies when theidkey is present, so a message without an id is still a notification. The HTTP transport's legacy path also routed these messages as notifications, so it checks for the key now too; on the 2026-07-28 path the error comes back as a 400.This covers the null-id part of #601. Requests sent without any id are still run as notifications; that's the separate question in the issue and is left open here. A notification method sent with
"id": nullis refused now as well, since by JSON-RPC rules that's a request.Refs #601.