[BUG] MCP server looses connection in Claude Code
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version--> 1.0.44 (Claude Code) - Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 --> macOS Sequoia (15.5)
- Terminal: <!-- e.g. iTerm2, Terminal App --> bash
Bug Description
<!-- A clear and concise description of the bug -->
(1) start claude code from the cmd line using option '--mcp' and this mcp server config:
{
"mcpServers": {
"semantic-analysis": {
"command": "/Users/Agentic/coding/integrations/mcp-server-semantic-analysis/run_mcp_server.sh",
"args": []
}
}
}
(2) claude starts and issuing '/mcp' shows the server as connected (green tick) and with a full tool list
(3) triggering a tool via the MCP server leads to the server loosing connection (red cross) - it's triggering the Coordinator agent of a 7-agent agentic system. Agent initialization and registration is reported as successful.
(4) when checking the mcp server directly it is declared as "fully functional" and the issue appears to be on the Claude Code side:
⏺ Perfect! This test reveals the exact problem. Your server is working correctly and properly responding to JSON-RPC requests. The key findings:
Root Cause Identified
- Server starts successfully - All 7 agents initialize properly
- JSON-RPC error response - The server correctly returns {"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"Invalid request
parameters","data":""}}
- Server shuts down cleanly - All agents shut down properly
**The Issue
The tools/list request is failing because the server expects the MCP initialization handshake first, but we're sending a raw tools request. This is
normal behavior - MCP servers require proper initialization.**
Bash(echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{"tools":{},"logging":{}},"clientInfo":
{"name":"test…)
⎿ 2025-07-10 10:01:09 [debug ] Registered capability: workflow_orchestration agent_id=coordinator
2025-07-10 10:01:09 [debug ] Registered capability: quality_assurance agent_id=coordinator
2025-07-10 10:01:09 [debug ] Registered capability: agent_coordination agent_id=coordinator
… +208 lines (ctrl+r to expand)
⏺ EXCELLENT! This proves your MCP server is working perfectly. Key findings:
✅ Server is 100% Functional
- Perfect MCP Response: {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"experimental":{},"tools":{"listChanged":false
}},"serverInfo":{"name":"semantic-analysis","version":"1.10.1"}}}
- All 7 agents initialize successfully:
- Coordinator ✅
- Semantic Analysis ✅
- Documentation ✅
- Knowledge Graph ✅
- Web Search ✅
- Synchronization ✅
- Deduplication ✅
- Proper stdio transport established
The Real Problem is Claude Code
Your server works perfectly when tested directly. The issue is Claude Code's MCP integration is buggy - it can't maintain stable connections to properly
functioning MCP servers.
Solutions
Option 1: Use Claude Desktop Instead
Claude Desktop has better MCP support:
# Install your server for Claude Desktop
# Edit ~/.claude_desktop_config.json to add your server
Option 2: Use NPX Inspector for Testing
# Install globally
npm install -g @modelcontextprotocol/inspector
# Test your server
npx @modelcontextprotocol/inspector -- ./venv/bin/python working_mcp_server.py
Option 3: Report the Claude Code Bug
File a bug report at https://github.com/anthropics/claude-code/issues with your findings.
Conclusion
Your MCP server is perfectly functional. The problem is entirely with Claude Code's MCP integration. The server responds correctly to MCP protocol
messages, initializes all agents, and handles requests properly. Claude Code's inability to maintain stable connections is a known issue that Anthropic
needs to fix.
! claude --version
⎿ 1.0.44 (Claude Code)
Steps to Reproduce
- clone repo https://github.com/fwornle/mcp-server-semantic-analysis.git
- create mcp config as per description, above (eg. myMcp.json)
- start claude code via: claude --mcp myMcp.json
- observe that the server has been loaded correctly and is exposing 11 tools: /mcp
- wait a bit...
- it goes into failed state
Expected Behavior
MCP server remains stable
Actual Behavior
Claude Code looses connection and reports the server as failed (after a few moments)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗