feat(mcp): MCP 2026-07-28 legacy-compat shim - #103
Open
github-actions[bot] wants to merge 1 commit into
Open
Conversation
Consolidate the duplicated initialize payload, then use it to make this server properly detectable by future modern (2026-07-28) MCP clients. The server stays legacy-only — it still reports and speaks 2025-03-26. - Add mcpProtocolVersion constant and buildInitializeResult(); both the stdio and HTTP dispatchers now build the initialize body from it, so the two transports can no longer drift. "2025-03-26" appears once in the repo. - Implement server/discover on both transports, returning the initialize payload plus supportedProtocolVersions. Exempt it from the HTTP unrecognized-session 404 — it is a pre-session capability probe. - Return UnsupportedProtocolVersionError (-32022) with data.supported and data.requested when initialize declares a protocol version we don't speak. An omitted/empty version stays tolerated. Carried by new sendErrorWithData / httpJSONRPCErrorWithData variants so existing error call-sites are untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
AI ReviewAdds MCP 2026-07-28 legacy-compat shim: consolidates the duplicate initialize payload into shared helpers, implements Checklist
Build & test detail
Issues foundNo issues found. Design notes (informational, not blocking):
This review was generated automatically. A human maintainer should still make the merge decision. |
Collaborator
|
@claude review pls |
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.
Closes #99
Closes #96
Closes #97
Closes #98
Ships all three sub-tasks of the epic in one change, since #97 and #98 both
build directly on the helper introduced by #96.
What changed
#96 — consolidate the initialize payload (
mcp_server.go,mcp_http.go)mcpProtocolVersionconstant next tomcpServerVersion, with a commentexplaining why the two must not be merged.
buildInitializeResult()returns the sharedprotocolVersion/capabilities/serverInfobody; both the stdio and HTTP dispatchers nowcall it instead of carrying their own literal.
"2025-03-26"appearsexactly once in the repo — the constant definition.
#97 —
server/discoveron both transportscase "server/discover"in the stdio and HTTP dispatchers, returningbuildDiscoverResult()— the initialize payload plussupportedProtocolVersions: ["2025-03-26"].pre-session by definition, so it must answer whether the client sends no
Mcp-Session-Idor a stale one left over from a previous server process.TestMCPProtocol_ServerDiscoverMatchesInitializemarshals both payloads andcompares them, so the discover response can't silently diverge from
initialize.
capabilities.extensions: {}— per the issue, an empty extensions mapsignals nothing.
#98 —
UnsupportedProtocolVersionError(-32022)parseInitializeProtocolVersion()added as a sibling ofparseInitializeParamsso the existing signature and its tests areuntouched.
{code: -32022, message: "Unsupported protocol version", data: {supported, requested}}.Empty/missing/unparseable → tolerated, normal handshake.
mcpErrorgainsData interface{} \json:"data,omitempty"`, plus newsendErrorWithData/httpJSONRPCErrorWithDatavariants. Existing helpers and every-32601/-32602/-32603call-site are unchanged, so their responses stay byte-identical (omitemptykeepsdata` off the wire).registerHTTPSession, so a rejectedhandshake doesn't leave a session entry behind.
Nothing deferred by the epic was included: no modern stateless handling, no
dual-era dispatch, no extensions, no OAuth changes, no
Mcp-Session-Idremoval, and the reported protocol version is unchanged.
Verification
Live stdio smoke test against the real binary, matching the epic's checklist:
New tests:
TestMCPProtocol_ServerDiscover,TestMCPProtocol_ServerDiscoverMatchesInitialize,TestMCPProtocol_InitializeUnsupportedVersion,TestMCPProtocol_InitializeMissingVersion,TestHTTPDispatch_ServerDiscover,TestHTTPDispatch_InitializeUnsupportedVersion,TestHTTPDispatch_InitializeMissingVersion,TestHTTPHandlePost_ServerDiscover_ExemptFromSessionCheck,TestHTTPHandlePost_InitializeUnsupportedVersion_Returns200(pins that aJSON-RPC error still travels in a 200 body),
TestParseInitializeProtocolVersion,TestIsSupportedProtocolVersion,TestSupportedProtocolVersions_NotSharedAcrossCalls.Notes for the reviewer
10d46d3,4ace09c) don'ttouch the manifests — versions are bumped as one release commit by the
/releaseskill, which keeps the four manifests andCHANGELOG.mdinlock-step with the tag. Bumping here would collide with that. Flagging it in
case you'd rather fold a bump in.
mcpServerVersionis"2.3.5"while themanifests are at
2.10.0, despite the comment saying to keep them in sync —so
serverInfo.versionunder-reports. Fixing it changes every initializeresponse, which is out of scope for this epic; worth a separate issue.
version it never sends, so Claude Code / Codex sessions are unaffected.
I could not run
npm install -g . && claude plugin install ...in thisenvironment, so the end-to-end IDE check from the epic is still open.
🤖 Generated with Claude Code