Skip to content

fix(mcp): use stateful transport to prevent 500 errors on Happy MCP server#807

Open
hztBUAA wants to merge 1 commit intoslopus:mainfrom
hztBUAA:fix/mcp-stateless-transport-reuse
Open

fix(mcp): use stateful transport to prevent 500 errors on Happy MCP server#807
hztBUAA wants to merge 1 commit intoslopus:mainfrom
hztBUAA:fix/mcp-stateless-transport-reuse

Conversation

@hztBUAA
Copy link

@hztBUAA hztBUAA commented Mar 3, 2026

Summary

  • The StreamableHTTPServerTransport in startHappyServer.ts was configured with sessionIdGenerator: undefined (stateless mode)
  • In MCP SDK v1.25+, stateless mode throws "Stateless transport cannot be reused across requests" on any request after the first one
  • This caused Claude Code to receive HTTP 500 errors when trying to discover tools (e.g. tools/list) after initialization, marking the Happy MCP server as "failed" and making mcp__happy__change_title unavailable
  • Fix: use a fixed session ID generator so the transport operates in stateful mode, allowing the single-client local connection to handle multiple requests

Root cause analysis

  1. Happy starts an HTTP MCP server on a random local port and passes it to Claude Code via --mcp-config
  2. Claude Code connects and sends initialize → succeeds (first request)
  3. Claude Code sends tools/list → the transport throws because stateless mode prohibits reuse → caught by the HTTP handler → returns 500
  4. Claude Code marks the MCP server as "failed"
  5. All mcp__happy__* tools become unavailable

Test plan

  • Verified the 500 error by manually curl-ing the running MCP server
  • Build and install the fixed version, start a happy session, and verify mcp__happy__change_title is available and functional

🤖 Generated with Claude Code

…erver

The StreamableHTTPServerTransport was configured with sessionIdGenerator: undefined
(stateless mode), which throws "Stateless transport cannot be reused across requests"
on any request after the first one. This caused Claude Code to receive 500 errors
when trying to list tools after initialization, marking the MCP server as "failed"
and making mcp__happy__change_title unavailable.

Fix: Use a fixed session ID generator so the transport operates in stateful mode,
allowing multiple requests to be handled by the same transport instance.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

1 participant