fix(mcp): support MCP SDK 1.27+ by creating per-request transport#149
Open
jungdaesuh wants to merge 1 commit intoCaviraOSS:mainfrom
Open
fix(mcp): support MCP SDK 1.27+ by creating per-request transport#149jungdaesuh wants to merge 1 commit intoCaviraOSS:mainfrom
jungdaesuh wants to merge 1 commit intoCaviraOSS:mainfrom
Conversation
MCP SDK 1.27 introduced a guard that rejects re-initialization on a single StreamableHTTPServerTransport instance. The previous code shared one transport for all connections, which caused every client after the first to receive a 500 error. This broke Claude Code, Codex, and any other MCP client that connects to the server. Changes: - Upgrade @modelcontextprotocol/sdk from 1.22.0 to 1.27.1 - Create a fresh transport + server per request in mcp.ts (stateless mode requires no session state, so this is safe) - Align mcp_tools.ts zod import to "zod/v3" to match zod-to-json-schema's expected type universe, fixing TS2589 caused by the SDK upgrade Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
@modelcontextprotocol/sdkfrom 1.22.0 to 1.27.1 to support MCP protocol version2025-11-25(required by Claude Code 2.1.74+)mcp.ts: MCP SDK 1.27 rejects re-initialization on a singleStreamableHTTPServerTransportinstance ("Invalid Request: Server already initialized"). The previous code shared one transport for all connections, so only the first client could connect — every subsequentinitializerequest returned HTTP 500. Fixed by creating a fresh transport + server per request (safe in stateless mode withsessionIdGenerator: undefined).mcp_tools.ts: The SDK upgrade pulls in zod 3.25+ types that causeType instantiation is excessively deep and possibly infinitewhenzodToJsonSchemareceivesz.ZodType<any>from"zod". Fixed by importing from"zod/v3"to align withzod-to-json-schema's expected type universe.Test plan
tsc --noEmitpasses clean (no TS2589, no errors)initializerequests (verified 3 sequential clients all get 200 OK)StreamableHTTPClientTransport) connects and lists all 6 tools2025-11-25(compatible with Claude Code 2.1.74+)🤖 Generated with Claude Code