fix(happy-cli): create fresh MCP server+transport per request for SDK >=1.26 compat#641
Closed
nikhilsitaram wants to merge 1 commit intoslopus:mainfrom
Closed
Conversation
… >=1.26 compat MCP SDK v1.26.0 forbids reusing stateless transports (sessionIdGenerator: undefined). The previous code created a single McpServer and transport at startup, then reused the transport for every incoming HTTP request. The first tool call succeeded, but subsequent calls failed with "Stateless transport cannot be reused". Changed to a factory pattern: each HTTP request creates its own McpServer and StreamableHTTPServerTransport, connects them, handles the request, then cleans up on connection close. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
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.
Summary
McpServer+StreamableHTTPServerTransportper HTTP request instead of sharing a single instanceProblem
MCP SDK v1.26.0 introduced a restriction that stateless transports (
sessionIdGenerator: undefined) cannot be reused across requests. The previous code created oneMcpServerand oneStreamableHTTPServerTransportat startup and reused them for all requests:The first tool call (e.g.,
mcp__happy__change_title) succeeds, but all subsequent calls fail with"Stateless transport cannot be reused".Fix
Factory pattern — each request gets its own server+transport pair, cleaned up on connection close:
Test plan
mcp__happy__change_titleworks on first callmcp__happy__change_titleworks on second and subsequent calls within the same session🤖 Generated with Claude Code