Skip to content

Comments

fix(happy-cli): create per-request MCP transport for SDK >= 1.26.0#688

Open
davidrimshnick wants to merge 2 commits intoslopus:mainfrom
davidrimshnick:fix/mcp-stateless-transport-reuse
Open

fix(happy-cli): create per-request MCP transport for SDK >= 1.26.0#688
davidrimshnick wants to merge 2 commits intoslopus:mainfrom
davidrimshnick:fix/mcp-stateless-transport-reuse

Conversation

@davidrimshnick
Copy link

@davidrimshnick davidrimshnick commented Feb 21, 2026

Summary

  • @modelcontextprotocol/sdk@1.26.0 (released Feb 4, 2026) added a guard that throws when a stateless StreamableHTTPServerTransport is reused across requests
  • The Happy MCP server was creating a single transport at startup and reusing it for all incoming requests, causing HTTP 500 on every request after the first
  • This creates a fresh McpServer + StreamableHTTPServerTransport per request, following the SDK's own simpleStatelessStreamableHttp.ts example

Fixes #634

Test plan

  • Added unit tests in startHappyServer.test.ts that verify:
    • Server starts and returns correct url and tool names
    • Single MCP initialize request returns 200
    • Multiple sequential requests all return 200 (core regression — would have been 500 with the old single-transport approach on SDK >= 1.26.0)
  • Manual: install happy-coder with @modelcontextprotocol/sdk@1.26.0+, start a session, and verify mcp__happy__change_title works on repeated calls

🤖 Generated with Claude Code

davidrimshnick and others added 2 commits February 21, 2026 11:14
… crash

@modelcontextprotocol/sdk 1.26.0 added a guard that throws when a
stateless StreamableHTTPServerTransport is reused across requests.
The Happy MCP server was creating a single transport at startup and
reusing it, causing HTTP 500 on every request after the first.

Create a fresh McpServer + transport per request, following the SDK's
own simpleStatelessStreamableHttp.ts example.

Fixes slopus#634

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies that the Happy MCP server handles multiple sequential
requests without returning HTTP 500 — the core regression from
@modelcontextprotocol/sdk >= 1.26.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tools fail after first request (SDK v1.26+ stateless transport reuse)

1 participant