Skip to content

mcp: Implement server-side support for discover method (SEP-2575)#987

Open
guglielmo-san wants to merge 42 commits into
mainfrom
guglielmoc/SEP-2567_2575_Stateless_MCP_part3
Open

mcp: Implement server-side support for discover method (SEP-2575)#987
guglielmo-san wants to merge 42 commits into
mainfrom
guglielmoc/SEP-2567_2575_Stateless_MCP_part3

Conversation

@guglielmo-san
Copy link
Copy Markdown
Contributor

@guglielmo-san guglielmo-san commented Jun 2, 2026

Summary

Part 3 of the SEP-2575 ("Make MCP Stateless") implementation. Builds on PR #975 which landed the client-side discover/fallback flow and the per-request _meta plumbing. This PR adds the server-side counterparts:

  • server/discover handler (replaces the stub),ProtocolVersionSupporter`
  • transport hook for per-transport version filtering,
  • transport-agnostic version validation and method-removal enforcement in ServerSession.handle,
  • HTTP-level wire compliance for SEP-2575 error codes/status codes,
  • bug fix in internal/jsonrpc2,processResult with an MCPGODEBUG opt-out for backward compatibility.

…t stateless protocol to stateless HTTP servers
…protocol version checking in server and tests
…rt headers and conditional SSE stream initialization
…ization, and correct session metadata mapping
…version propagation in client and transport layers
Resolved conflicts with these strategies:
- Took main's version for SEP-2575 client-side bits already merged via PR #975
  (the cleaner, reviewed version supersedes the part2/part3 in-progress code).
- Kept part3-unique additions:
  * Real server-side server/discover handler (replaces main's stub).
  * UnsupportedProtocolVersionData type per SEP-2575.
  * Server allows server/discover on stateful HTTP transport (stateless-only
    rejection exempts methodDiscover).
  * Rejection of methodSubscribe/methodUnsubscribe in the new protocol.
  * TestStreamableStateful_AcceptsDiscover regression test.
- Removed duplicate injectMeta in shared.go (main moved injection to per-method
  injectRequestMeta in client.go; the centralized helper was redundant).
- Removed duplicate Server.discover stub left behind by the merge.

Known failures (pre-existing test expectations, not regressions from the merge):
- TestMiddleware, ExampleLoggingTransport: written assuming Connect always
  triggers server/discover, but main's logic requires explicit opt-in via
  ClientSessionOptions{protocolVersion: protocolVersion20260630}.
- TestStreamableClientUnsupportedVersionFallback: requires a "Bad Request"
  substring fallback that part3 had but main removed. The structural fix is to
  parse the JSON-RPC error body in checkResponse and match by error.code.
@guglielmo-san guglielmo-san marked this pull request as ready for review June 4, 2026 10:21
…ate documentation for methodDiscover initialization logic
…rror handling, and enable stateless HTTP conformance server
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.

1 participant