Successfully implemented the fix for MCP connection issues with Claude Code CLI. The problem was caused by using an incorrect entry point that didn't properly handle stdio transport for MCP connections.
- File:
src/mcp_server/stdio_full_mcp.py - Action: Copied from
stdio_full_mcp.py.backupto make it a proper Python module - Purpose: Provides correct stdio transport implementation using FastMCP's
run()method
Updated three documentation files to reference the correct entry point:
-
docs/CLAUDE_CLI_SETUP.md- Lines 43 & 60: Changed from
src.mcp_server.mcp_apptosrc.mcp_server.stdio_full_mcp
- Lines 43 & 60: Changed from
-
docs/FINALIZATION_SUMMARY.md- Line 51: Changed from
src.mcp_server.mcp_apptosrc.mcp_server.stdio_full_mcp
- Line 51: Changed from
-
docs/MCP_SERVER_TESTING_GUIDE.md- Line 117: Changed from
src.mcp_server.mcp_apptosrc.mcp_server.stdio_full_mcp - Added
PYTHONPATHenvironment variable
- Line 117: Changed from
- File:
docs/MCP_CONNECTION_FIX.md - Purpose: Detailed explanation of the problem, solution, and migration guide
- File:
deployment/docker/.env - Status: Confirmed
MCP_ENABLED=trueis set correctly
{
"context": {
"command": "docker",
"args": ["exec", "-i", "context-server", "python", "-m", "src.mcp_server.mcp_app"],
"env": {
"MCP_ENABLED": "true",
"PYTHONPATH": "/app"
}
}
}{
"context": {
"command": "docker",
"args": ["exec", "-i", "context-server", "python", "-m", "src.mcp_server.stdio_full_mcp"],
"env": {
"MCP_ENABLED": "true",
"PYTHONPATH": "/app"
}
}
}Key Change: mcp_app → stdio_full_mcp
cd deployment/docker
docker-compose psExpected output should show all services as "Up (healthy)":
- context-server
- postgres
- redis
- qdrant
- ollama
If not running:
docker-compose up -dLinux/Mac:
nano ~/.config/claude/mcp_servers.jsonWindows:
notepad %APPDATA%\Claude\mcp_servers.jsonUpdate the configuration to use stdio_full_mcp as shown above.
- Close Claude Code CLI completely
- Wait 5 seconds
- Reopen Claude Code CLI
In Claude Code CLI, ask:
Can you check the health of the Context MCP server?
Expected Response:
Claude should successfully call the health_check tool and return server status information including:
- Server name: "Context"
- Version: "0.1.0"
- Status: "running"
- Connection state: "connected"
Try these commands to verify MCP tools are working:
-
List available tools:
What MCP tools are available from the Context server? -
Test semantic search:
Search for authentication functions in the codebase using the Context server. -
Check indexing status:
What's the current indexing status of the Context server?
-
Check Docker logs:
docker logs context-server | tail -50Look for:
- "Starting FULL STDIO MCP server (all tools)..."
- "FastMCP server instance created successfully"
- "Starting FastMCP stdio transport..."
-
Verify the module exists:
docker exec context-server ls -la /app/src/mcp_server/stdio_full_mcp.py -
Test the entry point directly:
docker exec -i context-server python -m src.mcp_server.stdio_full_mcpPress Ctrl+C to exit after verifying it starts without errors.
-
Check MCP_ENABLED setting:
docker exec context-server env | grep MCP_ENABLED
Should return:
MCP_ENABLED=true
Issue: "ModuleNotFoundError: No module named 'src.mcp_server.stdio_full_mcp'" Solution: The file wasn't copied correctly. Run:
docker exec context-server ls -la /app/src/mcp_server/stdio_full_mcp.pyIssue: Claude CLI shows "Connection timeout" Solution:
- Restart Docker services:
docker-compose restart context-server - Check logs:
docker logs context-server - Verify Claude CLI config file syntax is valid JSON
Issue: "MCP server is disabled"
Solution: Edit deployment/docker/.env and set MCP_ENABLED=true, then restart:
docker-compose restart context-serverAfter successful connection:
- ✅ Index your codebase
- ✅ Test semantic search functionality
- ✅ Try context-aware prompt enhancement
- ✅ Explore cross-language analysis tools
- ✅
src/mcp_server/stdio_full_mcp.py(created from backup) - ✅
docs/CLAUDE_CLI_SETUP.md(updated entry point) - ✅
docs/FINALIZATION_SUMMARY.md(updated entry point) - ✅
docs/MCP_SERVER_TESTING_GUIDE.md(updated entry point) - ✅
docs/MCP_CONNECTION_FIX.md(new documentation) - ✅
MCP_FIX_IMPLEMENTATION_SUMMARY.md(this file)