node: serve MCP stateless - #540
Merged
Merged
Conversation
MCP 2026-07-28 removed sessions, and the SDK serves it over HTTP only in stateless mode. A stateful handler also refused legacy-version clients that already send the per-request _meta protocol version tag, with -32022 for a version it lists as supported. Nothing on the node used sessions: no server-initiated notifications, no server-to-client requests, and the per-agent server is chosen per request.
Contributor
There was a problem hiding this comment.
Code Review
This pull request configures the MCP server handlers to run in stateless mode, removing sessions and serving over HTTP only. It updates the associated tests and documentation to reflect this change, including asserting that GET requests on /mcp return a 405 Method Not Allowed status. A review comment recommends updating the newly added integration test to use http.NewRequestWithContext with a timeout context to prevent potential test hangs, in accordance with the repository style guide.
Collaborator
|
I wonder if this can help us to simplify the code #387, I need to read more about MCP,.but seems this protocol does a lot of breaking changes |
The stateless MCP handler has no standalone SSE stream, so GET /mcp is 405 Method Not Allowed instead of the 400 the stateful handler returned. The unit test in internal/node was updated; this integration test still expected 400 and failed in CI.
The bridge holds no per-caller state: one id space, no broadcast side. A sessionless server does not mint or echo Mcp-Session-Id, and the node's own /mcp handler no longer does. Nothing reads the constant value it sent.
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.
MCP 2026-07-28 removed sessions, and the Go SDK serves that revision over HTTP only in stateless mode. Keeping the node's handler stateful had a second cost: the SDK refuses a legacy-version request that also carries the new per-request
_metaprotocol version tag, answering-32022for a version it lists as supported. Newer agent CLIs send that tag on old-protocol sessions, so they could not use the node at all.Nothing on the node used sessions: it sends no server-initiated notifications, makes no server-to-client requests, and the per-agent server is chosen per request, which stateless mode preserves.
GET /mcpnow answers405, which the spec reserves for servers without a standalone stream.internal/node/mcp.go: both handlers getStreamableHTTPOptions{Stateless: true}.initializewith header2025-11-25plus the_metatag is served and gets noMcp-Session-Id; it fails with-32022on the stateful handler.mcp_test.go:GET /mcpexpects405.node-api.md: the/mcprow says sessionless.Verified with an agent CLI that sends the tag, against a node built from this branch.