mcp: Implement support for SEP-2575 on client side#975
Merged
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
…njectMeta to injectRequestMeta
…atching version from descending order list
…stub documentation
…n transport connection closure handling
… automatic nil-params collapsing
methodDiscover on client side…400 for server/discover
…by handling unsupported version errors during discovery
| ErrUnknown = NewError(-32001, "unknown error") | ||
| // ErrServerClosing is returned for calls that arrive while the server is closing. | ||
| ErrServerClosing = NewError(-32004, "server is closing") | ||
| ErrServerClosing = NewError(-32006, "server is closing") |
Member
There was a problem hiding this comment.
oh, that's not nice . SDK claimed error codes which are now also used in the spec.
ErrClientClosing = NewError(-32003, "client is closing")will now mean MISSING_REQUIRED_CLIENT_CAPABILITY.
for the server side we can do mcgdebug for returning -32004 when server is closing for a session with and old protocol version.
I guess we need to handle it in internal/jsonrpc2/wire.go is-check looking not just at the code but at the message as well 😞
Contributor
Author
There was a problem hiding this comment.
I am not sure this is needed. The ErrClientClosing and ErrServerClosing are never sent over the wire and the error code is never returned to the calling function. Are only used internally in the client / server implementation.
…s nil parameter initialization
… discover negotiation
nahapetyan-serob
approved these changes
Jun 2, 2026
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. This CL is client-only; server-sideserver/discoveris still aMethodNotFoundstub.Changes
server/discoverprobe inClient.Connect()(client.go). When the caller opts intoprotocolVersion >= 2026-06-30, the client probes the server withserver/discoverbefore falling back to the legacyinitializehandshake.
_metainjection (shared.go,injectRequestMeta). For>= 2026-06-30sessions every outgoing request gets the SEP-2575 triple (protocolVersion,clientInfo,clientCapabilities).ServerSession.handleno longer pre-populatesstate.InitializeParamsfrom aserver/discoverrequest's_meta, so a subsequent fallbackinitializeis 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).
Fixes #966