Skip to content

mcp: reject discover when transport lacks version#1108

Open
piyushbag wants to merge 1 commit into
modelcontextprotocol:mainfrom
piyushbag:fix/discover-reject-unsupported-version
Open

mcp: reject discover when transport lacks version#1108
piyushbag wants to merge 1 commit into
modelcontextprotocol:mainfrom
piyushbag:fix/discover-reject-unsupported-version

Conversation

@piyushbag

Copy link
Copy Markdown
Contributor

Problem

On a stateful Streamable HTTP server, ServerSession.handle gates new-protocol requests against the global supportedProtocolVersions list. The transport-filtered list (via filterSupportedVersions / SupportsProtocolVersion) can omit 2026-07-28, yet server/discover still returned HTTP 200 with a DiscoverResult that excluded the probed version instead of UnsupportedProtocolVersionError.

Approach

Align the version gate in handle with the session's transport-filtered supportedVersions, matching what server/discover advertises. Rename and update the stateful regression test to expect HTTP 400 with CodeUnsupportedProtocolVersion.

Test plan

  • go test ./...
  • go test -race ./...
  • Updated TestStreamableStateful_DiscoverRejectsUnsupportedVersion

Fixes #1025

Use the session transport-filtered supportedVersions in
ServerSession.handle so stateful Streamable HTTP servers return
UnsupportedProtocolVersionError instead of a DiscoverResult that omits
the probed protocol version.
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.

(possible) 2026-07-28 spec violation: server/discover response without 2026-07-28 support

1 participant