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 #1503

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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!

Tangerg added a commit to Tangerg/go-sdk that referenced this pull request Nov 6, 2026
Sync 6 upstream commits through df0f295: the new
ParseURLElicitationRequiredError (modelcontextprotocol#1495), the tools/call retry on
HeaderMismatch (modelcontextprotocol#1502), notifications without Mcp-Method (modelcontextprotocol#1504), the
cancelable ioConn write lock (modelcontextprotocol#1499), invalid_token in 401 challenges
(modelcontextprotocol#1507) and the ioConn frame cap that no longer depends on read
boundaries (modelcontextprotocol#1510).

modelcontextprotocol#1499 and modelcontextprotocol#1510 are the upstream form of the fork's transport fixes, so
ioConn now matches upstream except that canceling a write already in
progress still closes the connection, because the peer may hold part of
the frame. Upstream's tests replace the fork's duplicates of them; the
fork keeps its test for the in-progress cancellation. New pkg.go.dev
links in the docs use the fork's module path.
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