Skip to content

mcp: limit SSE discover supportedVersions to SSE-defined revisions - #1121

Merged
guglielmo-san merged 2 commits into
modelcontextprotocol:mainfrom
arimu1:fix/sse-supported-versions-1112
Aug 5, 2026
Merged

guglielmo-san merged 2 commits into
modelcontextprotocol:mainfrom
arimu1:fix/sse-supported-versions-1112

Conversation

@arimu1

@arimu1 arimu1 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

NewSSEHandler sessions were advertising 2026-07-28 in server/discover supportedVersions. That revision only defines stdio and Streamable HTTP, not the deprecated HTTP+SSE binding, so Modern-first clients could negotiate a revision the transport cannot honour.

Changes

  • Implement ProtocolVersionSupporter on SSEServerTransport so filterSupportedVersions excludes >= 2026-07-28 (matching the streamable transport's version gate pattern).
  • In Server.discover, only set session InitializeParams when the requested version is actually supported by the transport. Without this, a discover probe that returns only legacy versions still marked the session initialized, and the client's fallback initialize failed with duplicate "initialize" received.
  • Tests: unit coverage for filtered SSE versions, plus an end-to-end Modern client → SSE fallback-to-initialize path.

Fixes #1112

Test plan

  • go test ./...
  • go test ./mcp/ -run 'TestSSE|TestInMemory_E2E_Discover|TestStreamableStateful_AcceptsDiscover|TestStreamableHTTP_E2E_Discover|TestClientConnectDiscover'

Assistance: human-reviewed AI assistance used for implementation.

@arimu1
arimu1 force-pushed the fix/sse-supported-versions-1112 branch from 319375e to 600f07b Compare August 4, 2026 00:16
@arimu1

arimu1 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (includes #1137 session leak fix and #1127 ProtocolVersion export).

Conflict resolution: kept main's discover InitializeParams gate (negotiateMutuallySupportedVersion >= 2026-07-28). Combined with this PR's SSEServerTransport.SupportsProtocolVersion filter, SSE discover still leaves the session uninitialized so Modern-first clients can fall back to legacy initialize.

Tip 600f07b · go test ./mcp/ green.

Comment thread mcp/server.go Outdated
Comment on lines +906 to +908
// With SSE ProtocolVersionSupporter filtering out 2026-07-28, negotiate
// returns a legacy revision so InitializeParams stays nil and Modern-first
// clients can fall back to the legacy initialize handshake (#1112).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would remove this comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed — agreed, the existing transport gate comment already covers this.

arimu1 added 2 commits August 5, 2026 20:13
HTTP+SSE is only defined by older MCP revisions. SSEServerTransport now
implements ProtocolVersionSupporter so server/discover does not advertise
2026-07-28 (stdio + Streamable HTTP only).

Also avoid marking the session initialized from discover when the
requested version is not transport-supported, so Modern-first clients can
fall back to the legacy initialize handshake over SSE.

Fixes modelcontextprotocol#1112
Address review: the SSE ProtocolVersionSupporter path is covered by
the existing transport gate comment; no need for the extra modelcontextprotocol#1112 note.
@arimu1
arimu1 force-pushed the fix/sse-supported-versions-1112 branch from 39d7f61 to 1e34846 Compare August 5, 2026 13:14
@guglielmo-san
guglielmo-san merged commit 958dfcc into modelcontextprotocol:main Aug 5, 2026
9 checks passed
@guglielmo-san

Copy link
Copy Markdown
Contributor

@arimu1 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.

SSE transport advertises 2026-07-28 in server/discover, but that revision only defines stdio and Streamable HTTP

2 participants