Repository navigation
mcp: do not require Mcp-Method on notifications - #1504
Merged
guglielmo-san merged 1 commit intoNov 5, 2026
Merged
Conversation
The 2026-07-28 Streamable HTTP spec requires Mcp-Method on requests only, and states that header requirements for notification POSTs are not defined by that revision. validateMcpHeaders applied the presence check to every *jsonrpc.Request, so a stateless server answered 400 (-32020) to a header-less notification that the spec and the TypeScript SDK accept with 202. Skip the presence check for notifications. A header that is present must still match the body. Fixes modelcontextprotocol#1503 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
guglielmo-san
approved these changes
Nov 5, 2026
Contributor
|
@toledompm thank you for the contribution! |
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.
The 2026-07-28 spec requires Mcp-Method on all requests and leaves header requirements for notification POSTs undefined. validateMcpHeaders applied the presence check to notifications too, so a stateless server answers 400 (-32020) to header-less notifications, which the TypeScript SDK accepts with 202. Claude Code 2.1.316 to 2.1.318 sends these.
This skips only the presence check for notifications. A header that is present must still match the body, the same exemption #1215 made for the _meta check. The existing "missing Mcp-Method header" test case built a request with no ID, so it was actually exercising a notification; it now has an ID.
Tests: unit cases for header-less and mismatched notifications in TestValidateMcpHeaders, and an HTTP-level 202 case in TestStreamableMcpHeaderValidation. go test ./... passes.
Fixes #1503
Written with AI assistance (Claude Code); I reviewed every line and can explain the change.
🤖 Generated with Claude Code