Fix an incorrect result: null response to an id-bearing notification message#435
Open
koic wants to merge 1 commit into
Open
Conversation
…n message ## Motivation and Context A JSON-RPC notification carries no id and must not receive any response. When a client erroneously sent a notification-only method such as `notifications/cancelled` with an id, the server replied with a successful `result: null`, which is neither a valid MCP result nor a legal reply to a notification. Such a message is now treated as a request for a method that has no request handler and rejected with Method not found, matching the behavior of the TypeScript and Python SDKs. A well-formed notification that omits the id continues to receive no response. Fixes modelcontextprotocol#434. ## How Has This Been Tested? Added regression tests covering id-bearing `notifications/cancelled`, `notifications/initialized`, and `notifications/progress`, a batch that mixes an id-bearing notification with other messages, custom `notifications/*` methods, and the same case over the HTTP transport. ## Breaking Changes None for spec-conformant clients, which never put an id on a notification. The only behavioral change is that a malformed id-bearing notification now receives a Method not found error instead of a spurious `result: null`.
atesgoral
approved these changes
Jul 1, 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.
Motivation and Context
A JSON-RPC notification carries no id and must not receive any response. When a client erroneously sent a notification-only method such as
notifications/cancelledwith an id, the server replied with a successfulresult: null, which is neither a valid MCP result nor a legal reply to a notification.Such a message is now treated as a request for a method that has no request handler and rejected with Method not found, matching the behavior of the TypeScript and Python SDKs. A well-formed notification that omits the id continues to receive no response.
Fixes #434.
How Has This Been Tested?
Added regression tests covering id-bearing
notifications/cancelled,notifications/initialized, andnotifications/progress, a batch that mixes an id-bearing notification with other messages, customnotifications/*methods, and the same case over the HTTP transport.Breaking Changes
None for spec-conformant clients, which never put an id on a notification. The only behavioral change is that a malformed id-bearing notification now receives a Method not found error instead of a spurious
result: null.Types of changes
Checklist