Skip to content

mcp: do not require Mcp-Method on notifications - #1504

Merged
guglielmo-san merged 1 commit into
modelcontextprotocol:mainfrom
toledompm:mcp-method-notifications
Nov 5, 2026
Merged

guglielmo-san merged 1 commit into
modelcontextprotocol:mainfrom
toledompm:mcp-method-notifications

Conversation

@toledompm

Copy link
Copy Markdown
Contributor

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

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
guglielmo-san merged commit caa354d into modelcontextprotocol:main Nov 5, 2026
10 checks passed
@guglielmo-san

Copy link
Copy Markdown
Contributor

@toledompm thank you for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp: streamable server requires Mcp-Method on notifications, which the 2026-07-28 spec does not

2 participants