Skip to main content
Glama

Claude MCP Server Ecosystem

by Coder-RL
REAL_WORLD_TROUBLESHOOTING_2025-05-26.md16.7 kB
# REAL-WORLD TROUBLESHOOTING SCENARIOS **Date**: May 26, 2025 **Purpose**: Actual error messages, root causes, and step-by-step solutions **Based on**: Real debugging session from 2025-05-26 --- ## 🚨 **SCENARIO 1: "MCP Server Shows Failed But Actually Works"** ### **What You See** ```bash $ mcp MCP Server Status • memory-simple-user: connected • sequential-thinking: failed ``` ### **What You Think** "The sequential-thinking server is broken and needs to be fixed." ### **What's Actually Happening** The server is working fine. Claude Code misinterprets stderr output as errors. ### **Proof Test** ```bash # Test the "failed" server directly: echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | /Users/robertlee/.nvm/versions/node/v20.18.3/bin/mcp-server-sequential-thinking # Expected Output: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"sequential-thinking-server","version":"0.2.0"}},"jsonrpc":"2.0","id":1} Sequential Thinking MCP Server running on stdio ``` ### **Root Cause** ```bash # The server outputs this to stderr: stderr: "Sequential Thinking MCP Server running on stdio" # Claude Code sees stderr and reports it as an error: [DEBUG] MCP server error: serverName=sequential-thinking, error=Server stderr: Sequential Thinking MCP Server running on stdio ``` ### **Solution** **Ignore "failed" status when the error message contains startup confirmations.** **Test functionality directly instead of relying on status messages.** --- ## 🚨 **SCENARIO 2: "npx Command Not Found"** ### **What You See** ```bash [DEBUG] MCP server error: serverName=filesystem, error=Connection failed: spawn npx ENOENT ``` ### **What This Means** Claude Code can't find the `npx` command because GUI applications have different PATH than terminal. ### **Real Example from Session** ```json // BEFORE (Broken): "filesystem-standard": { "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "/Users/robertlee"] } // AFTER (Working): "filesystem-standard": { "command": "/Users/robertlee/.nvm/versions/node/v20.18.3/bin/npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/robertlee"] } ``` ### **Step-by-Step Fix** ```bash # 1. Find npx location: which npx # Output: /Users/robertlee/.nvm/versions/node/v20.18.3/bin/npx # 2. Test manually: /Users/robertlee/.nvm/versions/node/v20.18.3/bin/npx @modelcontextprotocol/server-filesystem /Users/robertlee # Should output: "Secure MCP Filesystem Server running on stdio" # 3. Update config with absolute path: # Edit ~/.config/claude-code/config.json # Replace "npx" with full path # 4. Restart Claude Code # 5. Verify fix: mcp__filesystem-standard__list_allowed_directories() # Should work without errors ``` --- ## 🚨 **SCENARIO 3: "TypeScript Server Won't Start"** ### **What You See** ```bash [DEBUG] MCP server error: serverName=data-pipeline, error=Connection failed: Connection to MCP server "data-pipeline" timed out after 30000ms ``` ### **Real Configuration That Fails** ```json "data-pipeline": { "command": "/Users/robertlee/.nvm/versions/node/v20.18.3/bin/tsx", "args": ["/Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts"] } ``` ### **Manual Testing** ```bash # Test the server manually: /Users/robertlee/.nvm/versions/node/v20.18.3/bin/tsx /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts # Likely output (example error): Error: Cannot resolve module '@modelcontextprotocol/sdk' from /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts ``` ### **Root Cause Analysis** 1. **Missing Dependencies**: TypeScript files may import packages not installed 2. **Module Resolution**: tsx may not resolve imports correctly 3. **Compilation Issues**: TypeScript compilation errors at runtime ### **Investigation Steps** ```bash # 1. Check file exists: ls -la /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts # 2. Check imports in file: head -20 /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts # Look for import statements # 3. Check if dependencies are installed: cd /Users/robertlee/GitHubProjects/Claude_MCPServer npm list @modelcontextprotocol/sdk # If not found: npm install @modelcontextprotocol/sdk # 4. Test tsx directly: cd /Users/robertlee/GitHubProjects/Claude_MCPServer tsx servers/data-analytics/src/data-pipeline-fixed.ts # Debug specific error messages # 5. Check package.json: cat package.json | grep -A 10 -B 10 dependencies ``` ### **Temporary Workaround** ```bash # Remove non-working servers from global config: # Edit ~/.config/claude-code/config.json # Comment out or remove problematic servers: { "mcpServers": { "memory-simple-user": { ... }, "filesystem-standard": { ... } // "data-pipeline": { ... } // Commented out until fixed } } ``` --- ## 🚨 **SCENARIO 4: "Memory Server Commands Not Available"** ### **What You See** ```javascript mcp__memory-simple-user__health_check() // Error: mcp__memory-simple-user__health_check is not a function ``` ### **What This Means** The MCP server isn't loaded or global configuration isn't working. ### **Diagnostic Steps** ```bash # 1. Check if global config exists: ls -la ~/.config/claude-code/config.json # If not found, that's the problem # 2. Check config content: cat ~/.config/claude-code/config.json | grep -A 5 memory-simple-user # Should show server configuration # 3. Check if server file exists: ls -la /Users/robertlee/GitHubProjects/Claude_MCPServer/mcp/memory/simple-server.js # Should exist # 4. Test server manually: node /Users/robertlee/GitHubProjects/Claude_MCPServer/mcp/memory/simple-server.js # Should output: "Memory Simple MCP server started" # Press Ctrl+C to stop # 5. Check Claude Code directory: pwd # Claude Code should work from any directory with global config ``` ### **Solution Steps** ```bash # 1. Copy global config (if missing): cp /Users/robertlee/GitHubProjects/Claude_MCPServer/.mcp.json ~/.config/claude-code/config.json # 2. Create config directory (if missing): mkdir -p ~/.config/claude-code # 3. Verify config is correct: cat ~/.config/claude-code/config.json | python -m json.tool # Should parse without errors # 4. Restart Claude Code completely: # Exit all Claude Code sessions and restart # 5. Test from any directory: cd ~ claude # Then test: mcp__memory-simple-user__health_check() ``` --- ## 🚨 **SCENARIO 5: "Module Not Found Errors"** ### **What You See (Example)** ``` Error: Cannot find module '@modelcontextprotocol/sdk' ``` ### **Real Investigation Process** ```bash # 1. Check what's actually installed: cd /Users/robertlee/GitHubProjects/Claude_MCPServer npm list | grep modelcontextprotocol # Shows what MCP packages are available # 2. Check package.json: cat package.json | grep -A 20 dependencies # See what should be installed # 3. Install missing dependencies: npm install @modelcontextprotocol/sdk # Or whatever package is missing # 4. Check for version conflicts: npm ls @modelcontextprotocol/sdk # Look for version mismatches # 5. Clean install if needed: rm -rf node_modules package-lock.json npm install ``` --- ## 🚨 **SCENARIO 6: "PostgreSQL Connection Errors"** ### **What You See** ```bash Error: connect ECONNREFUSED 127.0.0.1:5432 ``` ### **What This Means** Enhanced memory server needs PostgreSQL but it's not running. ### **Quick Check** ```bash # Check if PostgreSQL is running: ps aux | grep postgres # Should show postgres processes if running # Check if port 5432 is open: lsof -i :5432 # Should show postgres if running # Try connecting: psql -h localhost -U postgres -d mcp_enhanced # Will prompt for password or show connection error ``` ### **Solutions** ```bash # Option 1: Start PostgreSQL (if installed): brew services start postgresql # Or: sudo systemctl start postgresql (Linux) # Option 2: Use simple memory server instead: # Remove memory-enhanced from config, use memory-simple-user # Option 3: Set up PostgreSQL properly: # Follow database setup guide (beyond scope of quick troubleshooting) ``` --- ## 🛠️ **GENERAL DEBUGGING METHODOLOGY** ### **Step 1: Isolate the Problem** ```bash # Test server manually before blaming configuration: node /path/to/server.js # or tsx /path/to/server.ts ``` ### **Step 2: Check Logs** ```bash # Check MCP logs: ls /Users/robertlee/Library/Caches/claude-cli-nodejs/-Users-robertlee/ # Look for recent error logs # Check latest log: cat /Users/robertlee/Library/Caches/claude-cli-nodejs/-Users-robertlee/mcp-logs-*/$(ls -t /Users/robertlee/Library/Caches/claude-cli-nodejs/-Users-robertlee/mcp-logs-*/ | head -1) ``` ### **Step 3: Verify Configuration** ```bash # Check global config syntax: cat ~/.config/claude-code/config.json | python -m json.tool # Should parse without errors # Check all paths exist: ls -la /Users/robertlee/GitHubProjects/Claude_MCPServer/mcp/memory/simple-server.js which npx ``` ### **Step 4: Test Incrementally** ```bash # Start with minimal config: { "mcpServers": { "memory-simple-user": { "command": "node", "args": ["/Users/robertlee/GitHubProjects/Claude_MCPServer/mcp/memory/simple-server.js"] } } } # Test one server at a time # Add more servers only after each one works ``` --- ## 🎯 **PREVENTION STRATEGIES** ### **1. Always Use Absolute Paths** ```json // GOOD: "command": "/Users/robertlee/.nvm/versions/node/v20.18.3/bin/node" // BAD: "command": "node" ``` ### **2. Test Servers Manually First** ```bash # Before adding to config, test manually: node /path/to/server.js # Ensure it starts and responds to MCP protocol ``` ### **3. Validate JSON Configuration** ```bash # Always validate JSON syntax: cat ~/.config/claude-code/config.json | python -m json.tool ``` ### **4. Document Working Configurations** ```bash # Keep a backup of working config: cp ~/.config/claude-code/config.json ~/.config/claude-code/config.json.working ``` ### **5. Understand False Positives** ```bash # Remember: stderr output ≠ error # Test functionality, not status messages ``` --- ## 🚨 **SCENARIO 7: "Only 2 of 12 Configured MCP Servers Connect" (CRITICAL DISCOVERY)** ### **What You See** ```bash $ mcp MCP Server Status • filesystem-standard: connected • memory-simple-user: connected • sequential-thinking: failed # But your global config has 12 servers configured ``` ### **What You Think** "10 servers are broken and need to be fixed." ### **What's Actually Happening** **CRITICAL DISCOVERY**: The servers are NOT broken. Claude Code has connection management issues. ### **Proof Test - All Servers Actually Work** ```bash # Test sequential-thinking (shows as "failed"): echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | /Users/robertlee/.nvm/versions/node/v20.18.3/bin/mcp-server-sequential-thinking # Expected: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"sequential-thinking-server","version":"0.2.0"}},"jsonrpc":"2.0","id":1} # Test data-pipeline (not showing in status): echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | /Users/robertlee/.nvm/versions/node/v20.18.3/bin/tsx /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts # Expected: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"data-pipeline-fixed","version":"1.0.0"}},"jsonrpc":"2.0","id":1} # Test data-governance (not showing in status): echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | /Users/robertlee/.nvm/versions/node/v20.18.3/bin/tsx /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-governance-fixed.ts # Expected: {"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"data-governance-fixed","version":"1.0.0"}},"jsonrpc":"2.0","id":1} ``` ### **All Servers Start Successfully** ```bash # Sequential-thinking: timeout 3s /Users/robertlee/.nvm/versions/node/v20.18.3/bin/mcp-server-sequential-thinking # Output: "Sequential Thinking MCP Server running on stdio" # Data-pipeline: timeout 3s /Users/robertlee/.nvm/versions/node/v20.18.3/bin/tsx /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-pipeline-fixed.ts # Output: "Data Pipeline MCP Server (Fixed) running on stdio" # Data-governance: timeout 3s /Users/robertlee/.nvm/versions/node/v20.18.3/bin/tsx /Users/robertlee/GitHubProjects/Claude_MCPServer/servers/data-analytics/src/data-governance-fixed.ts # Output: "uLudata ugovernance MCP Server (Fixed) running on stdio" ``` ### **Root Cause Analysis** **Primary Issue**: Claude Code connection management limitations, NOT server failures **Evidence**: 1. **All servers start successfully** when tested manually 2. **All servers respond to MCP protocol** correctly 3. **Configuration is valid** (12 servers properly configured) 4. **Only 2-3 servers connect** despite all being functional **Possible Claude Code Issues**: - **Connection limit**: May only support 2-3 concurrent MCP servers - **Timeout during connection**: May fail to establish connections within timeout - **Tool discovery failures**: May fail during tool registration phase - **STDIO communication issues**: May lose connections after establishment - **Configuration processing bug**: May not process full config file - **Resource constraints**: May limit servers due to memory/CPU usage ### **Investigation Commands** ```bash # 1. Verify all 12 servers are in config: node -e "const config = JSON.parse(require('fs').readFileSync('/Users/robertlee/.config/claude-code/config.json', 'utf8')); console.log('Total servers:', Object.keys(config.mcpServers).length); Object.keys(config.mcpServers).forEach(name => console.log('-', name));" # 2. Check MCP server processes: ps aux | grep -E "(mcp|tsx|sequential)" | grep -v grep # 3. Test each server individually: for server in sequential-thinking data-pipeline data-governance; do echo "Testing $server..." # Add appropriate test command for each done # 4. Monitor Claude Code logs during startup: # Check /Users/robertlee/Library/Caches/claude-cli-nodejs/-Users-robertlee/ ``` ### **Systematic Testing Strategy** ```bash # Test incremental server addition: # Step 1: Start with working 2 servers { "mcpServers": { "memory-simple-user": {...}, "filesystem-standard": {...} } } # Step 2: Add sequential-thinking (we know it works) { "mcpServers": { "memory-simple-user": {...}, "filesystem-standard": {...}, "sequential-thinking": {...} } } # Step 3: If successful, add data-pipeline # Continue adding one server at a time until we find the limit ``` ### **Workaround Solutions** ```bash # Option 1: Test with fewer servers to find Claude Code's limit # Start with 3 servers, gradually increase # Option 2: Use multiple Claude Code configurations # Split 12 servers across multiple .mcp.json files # Use different configurations in different directories # Option 3: Focus on most important servers first # Prioritize servers by functionality and configure only essential ones ``` ### **Known Working Servers (Verified Functional)** 1. **memory-simple-user**: ✅ Connects and works 2. **filesystem-standard**: ✅ Connects and works 3. **sequential-thinking**: ✅ Protocol works, connection issues 4. **data-pipeline**: ✅ Protocol works, connection issues 5. **data-governance**: ✅ Protocol works, connection issues 6. **memory-enhanced**: ⚠️ Uses HTTP protocol, needs STDIO conversion ### **Critical Understanding** **This is NOT a server configuration problem. This is a Claude Code connection management limitation.** The debugging focus should be: 1. **Claude Code's connection process**, not server startup 2. **Connection limits**, not server functionality 3. **Tool discovery phase**, not MCP protocol compliance 4. **STDIO communication stability**, not server implementation --- **This troubleshooting guide provides real examples and solutions from actual debugging sessions. Use it to quickly identify and resolve similar issues.**

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Coder-RL/Claude_MCPServer_Dev1'

If you have feedback or need assistance with the MCP directory API, please join our Discord server