Fix: Support multiple concurrent HTTP transports#1
Open
frank-ih wants to merge 1 commit into
Open
Conversation
The MCP server was using a singleton Server instance for all HTTP transport connections. When Chrome extension held an SSE connection, Claude Code's HTTP requests would fail with "Already connected to a transport" error. Solution: - Add createMcpServer() factory function that creates a NEW Server instance per HTTP transport - Modify HTTP route handlers (POST /mcp, GET /sse) to use createMcpServer() instead of getMcpServer() - Keep getMcpServer() for backward compatibility with stdio transport This allows Chrome extension and Claude Code to simultaneously connect to the HTTP server without conflicts. Co-Authored-By: Claude <[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.
Problem
The MCP server was using a singleton
Serverinstance for all HTTP transport connections. When Chrome extension held an SSE connection, Claude Code's HTTP requests would fail with:Root Cause
The
getMcpServer()function returned a singletonServerinstance that could only have ONE active transport connection at a time. When Chrome extension connected via SSE (using the singleton), Claude Code's subsequent HTTP request tried to connect to the same singleton, causing the error.Solution
Added
createMcpServer()factory function - Creates a NEWServerinstance per HTTP transport connection. This allows multiple concurrent connections without conflicts.Modified HTTP route handlers to use
createMcpServer():POST /mcp- Creates new server for each initialize requestGET /sse- Creates new server for each SSE connectionKept
getMcpServer()for backward compatibility with stdio transport (Chrome Native Messaging).Files Changed
src/mcp/mcp-server.ts- AddedcreateMcpServer()factorydist/mcp/mcp-server.js- Compiled outputdist/server/index.js- Updated route handlers to usecreateMcpServer()Testing
Co-Authored-By: Claude [email protected]