feat(client)!: support stateful streamable-HTTP servers - #18
Merged
TheGreatAxios merged 1 commit intoSep 27, 2026
Conversation
TheGreatAxios
added this pull request to stack #12
September 27, 2026 02:23
TheGreatAxios
force-pushed
the
cl-9454-mcp-support-stateful-streamable-http-servers-and-harden-json
branch
from
September 27, 2026 02:44
c050555 to
9dc9f6b
Compare
TheGreatAxios
force-pushed
the
cl-9454-mcp-support-stateful-streamable-http-servers-and-harden-json
branch
from
September 27, 2026 02:44
9dc9f6b to
1a6c11f
Compare
TheGreatAxios
force-pushed
the
cl-9454-mcp-support-stateful-streamable-http-servers-and-harden-json
branch
from
September 27, 2026 18:35
1a6c11f to
a651f08
Compare
mcpInitialize now sends notifications/initialized and returns an McpSession whose Mcp-Session-Id and MCP-Protocol-Version later requests carry. Discovery, mcpTools and the sidecar bundle pass it on, and reopen it after a failed call. A protocolVersion that is not printable ASCII is refused before it is echoed into a header, and a timed-out notification is an McpError. Non-JSON data frames are skipped, and only a message with result or error and no method counts as the response. e2e covers the official SDK's stateless and stateful server transports; the SDK is a devDependency only. BREAKING CHANGE: mcpInitialize returns McpSession instead of McpServerInfo.
TheGreatAxios
force-pushed
the
cl-9454-mcp-support-stateful-streamable-http-servers-and-harden-json
branch
from
September 27, 2026 18:49
a651f08 to
e13d7b3
Compare
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.
The client ignored
Mcp-Session-Idand never sentnotifications/initializedorMCP-Protocol-Version. Against the official SDK's stateful transport,initializeworked buttools/listand every sidecartools/callfailed with a 400. A non-JSONdata:frame threw a rawSyntaxError, and a server request reusing our id was taken as the response.Changes
mcpInitializesendsinitialize, thennotifications/initialized, and returns anMcpSession(protocolVersion,sessionId?,serverInfo?).McpClientOptions.sessionsendsMcp-Session-IdandMCP-Protocol-Versionon later requests.McpSessionis exported.mcpToolsand the sidecar bundle carry the session totools/listandtools/call.mcpToolsand the bundle open one session per server on first use and reopen it after a failed call, in case the server expired it. The discovery route'sserverInforesponse is unchanged.mcpInitializerefuses a serverprotocolVersionthat is not printable ASCII before echoing it intoMCP-Protocol-Version, and a timed-outnotifications/initializedis anMcpError. Both are tested and fail before the fix.data:frames are skipped. Only a message withresultorerrorand nomethodcounts as the response, for both SSE and JSON bodies.e2e/sdk-transport.test.tsruns discovery, the sidecar bundle andmcpToolsagainst@modelcontextprotocol/sdk's stateless and stateful streamable-HTTP server transports. The stateful cases fail before the fix. The SDK andzodare devDependencies only. Newtest:e2escript, run in CI.mcpInitializereturn type.Breaking
Yes, marked
!:mcpInitializereturnsMcpSessioninstead ofMcpServerInfo. It is part of the pending 0.2.0 release, so there is no extra version bump.Checks
bun run check,bun run test:e2e,bun run buildand the Node pack smoke pass locally.Closes CL-9454