fix(happy-cli): use stateful StreamableHTTPServerTransport to prevent 500 errors#874
Open
Wshid wants to merge 1 commit intoslopus:mainfrom
Open
fix(happy-cli): use stateful StreamableHTTPServerTransport to prevent 500 errors#874Wshid wants to merge 1 commit intoslopus:mainfrom
Wshid wants to merge 1 commit intoslopus:mainfrom
Conversation
… on MCP tool calls The MCP SDK (>= 1.27.x) enforces that stateless transports (`sessionIdGenerator: undefined`) cannot be reused across requests, throwing "Stateless transport cannot be reused across requests". Since `startHappyServer` creates a single transport and reuses it for all incoming HTTP requests, every request after the first `initialize` silently returns HTTP 500, making `change_title` tool calls fail. Switching to stateful mode (`sessionIdGenerator: () => randomUUID()`) allows the transport to be safely reused across multiple requests.
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
The MCP server in
startHappyServer.tsusesStreamableHTTPServerTransportwithsessionIdGenerator: undefined(stateless mode). Since MCP SDK@modelcontextprotocol/sdk>= 1.27.x, stateless transports throw"Stateless transport cannot be reused across requests"after the first request.Because
startHappyServercreates a single transport and reuses it for all incoming HTTP requests, every request after the initialinitializesilently returns HTTP 500. This breaks thechange_titleMCP tool — Claude Code cannot rename chat sessions.Fix
Switch from stateless to stateful mode:
```diff
```
randomUUIDis already imported fromnode:cryptoin the same file.How to reproduce
happy)--mcp-config {"mcpServers":{"happy":{"type":"http","url":"http://127.0.0.1:{port}/"}}}mcp__happy__change_title→ fails with 500curl -X POST http://127.0.0.1:{port}/ -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}},"id":1}'→ HTTP 500Tested
yarn build✅yarn typecheck✅yarn test— 1 pre-existing failure inrunAcp.test.ts(unrelated log format mismatch)change_title