mcp: Implement support for methodDiscover on client side#975
Draft
guglielmo-san wants to merge 34 commits into
Draft
mcp: Implement support for methodDiscover on client side#975guglielmo-san wants to merge 34 commits into
methodDiscover on client side#975guglielmo-san wants to merge 34 commits into
Conversation
…lidation and accessors
…est rejections and update associated tests
…ed regression tests
…t stateless protocol to stateless HTTP servers
…n the new protocol session
…t initialization and version negotiation
…protocol version checking in server and tests
… protocol version validation logic
…ata into requests
…/SEP-2575_Stateless_MCP_part2
… test metadata injection logic
…y in server request handling
…per for InitializeParams
…ready initialized
…rt headers and conditional SSE stream initialization
…ization, and correct session metadata mapping
…k triggers in MCP client
…acks and clarify KeepAlive constraints
…version propagation in client and transport layers
…discover implementation
…/SEP-2575_Stateless_MCP_part2
…tateless_MCP_part2
…njectMeta to injectRequestMeta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the client half of the SEP-2575 /
2026-06-30protocol on top ofpart 1 (which added per-request
_metavalidation on the server). This CL isclient-only; server-side
server/discoveris still aMethodNotFoundstub.Changes
server/discoverprobe inClient.Connect()(client.go). When thecaller opts into
protocolVersion >= 2026-06-30, the client probes theserver with
server/discoverbefore falling back to the legacyinitializehandshake. On success, the negotiated version is picked from
DiscoverResult.SupportedVersions ∩ supportedProtocolVersionsand storedin
ClientSession.state.InitializeResultso existing accessors keep working._metainjection (shared.go,injectRequestMeta). For>= 2026-06-30sessions every outgoing request gets the SEP-2575 triple(
protocolVersion,clientInfo,clientCapabilities) without overwritingcaller-set keys.
DiscoverParams/DiscoverResulttypes (protocol.go) matching theSEP schema, plus
methodDiscoverregistration and theDiscoverRequesttype alias.
setMCPHeadersnow falls back to a context-suppliedprotocol version when
initializedResultis still nil (needed so thediscover probe carries the
Mcp-Protocol-Versionheader); the standaloneGET SSE stream is skipped for
>= 2026-06-30(replaced in a follow-up bysubscriptions/listen).transport.gowraps closed-connection errors witherrors.Joinso callers can still inspect the underlying jsonrpc2 error(used to distinguish
UnsupportedProtocolVersionErrorfromErrServerClosing, both -32004).ServerSession.handleno longer pre-populatesstate.InitializeParamsfrom aserver/discoverrequest's_meta, so asubsequent fallback
initializeis not rejected as a duplicate.Fallback rules
Client falls back to the legacy
initializehandshake when discover returns:MethodNotFound(-32601),UnsupportedProtocolVersionError(-32004),Bad Request(substring-matched on the error message, to interopwith pre-2026-06-30 servers that 400 on the unknown
_meta.protocolVersion).Fixes #966