troubleshoot-mcp-connection
Über
Diese Fähigkeit diagnostiziert und behebt MCP-Server-Verbindungsprobleme zwischen Claude Code/Desktop und MCP-Servern. Sie behandelt häufige Probleme wie Argument-Parsing, Authentifizierungsfehler und Transportprobleme auf verschiedenen Plattformen. Nutzen Sie sie, wenn MCP-Tools nicht erscheinen, Verbindungen scheitern oder wenn Sie MCP auf einem neuen Rechner einrichten.
Schnellinstallation
Claude Code
Empfohlennpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/troubleshoot-mcp-connectionKopieren Sie diesen Befehl und fügen Sie ihn in Claude Code ein, um diese Fähigkeit zu installieren
Dokumentation
MCP接続のトラブルシューティング
Diagnose and resolve MCP server connection failures.
使用タイミング
- Claude Code or Claude Desktop fails to connect to an MCP server
- MCP tools don't appear in sessions
- "Cannot attach the server" errors
- Connection was working but stopped
- Setting up MCP on a new machine
入力
- 必須: Error message or symptom description
- 必須: Which client (Claude Code, Claude Desktop, or both)
- 必須: Which MCP server (mcptools, Hugging Face, custom)
- 任意: Recent changes to configuration or environment
手順
ステップ1: Identify the Client and Configuration
Claude Code (WSL):
# View MCP configuration
claude mcp list
claude mcp get server-name
# Configuration stored in
cat ~/.claude.json | python3 -m json.tool
Claude Desktop (Windows):
# Configuration file location
cat "/mnt/c/Users/$USER/AppData/Roaming/Claude/claude_desktop_config.json"
期待結果: Configuration file is located and readable, showing the MCP server entries with command, args, and env fields.
失敗時: If the config file does not exist or is empty, the server was never configured. Follow the configure-mcp-server skill to set it up from scratch.
ステップ2: Test Server Independently
R mcptools:
# Test if R can start the server
"/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe" -e "mcptools::mcp_server()"
If this fails:
- Check R path exists:
ls "/mnt/c/Program Files/R/" - Check mcptools is installed:
Rscript -e "library(mcptools)" - Check ellmer dependency:
Rscript -e "library(ellmer)"
Hugging Face MCP:
# Test mcp-remote directly
mcp-remote https://huggingface.co/mcp
# Check if mcp-remote is installed
which mcp-remote
npm list -g mcp-remote
期待結果: The server process starts and produces initialization output (JSON-RPC handshake or "listening" message) without errors.
失敗時: If R mcptools fails, check that the R version path is correct and that mcptools is installed in the R library. If mcp-remote fails, reinstall globally with npm install -g mcp-remote and verify it is on the PATH.
ステップ3: Diagnose Common Error Patterns
"Cannot attach the server" (Claude Desktop)
Root cause: Windows command argument parsing.
Fix: Use environment variables instead of --header arguments:
{
"hf-mcp-server": {
"command": "mcp-remote",
"args": ["https://huggingface.co/mcp"],
"env": { "HF_TOKEN": "your_token" }
}
}
Also ensure mcp-remote is globally installed (npm install -g mcp-remote), not relying on npx.
"Connection refused"
- Server isn't running or port is wrong
- Firewall blocking the connection
- Wrong transport type (stdio vs HTTP)
"Command not found"
- Missing full path to executable
- PATH not configured in the execution context
- On Windows: use
C:\\PROGRA~1\\...for paths with spaces
MCP tools don't appear but no error
- Server starts but tools aren't registered
- Check server stdout for initialization messages
- Verify the server uses the correct MCP protocol version
期待結果: Error pattern matched to one of the documented categories (cannot attach, connection refused, command not found, or silent failure).
失敗時: If the error does not match any known pattern, capture the full error output and check server-side logs. Search for the exact error message in the MCP server's GitHub issues.
ステップ4: Check Network and Authentication
# Test Hugging Face API connectivity
curl -I "https://huggingface.co/mcp"
# Verify token validity
curl -H "Authorization: Bearer $HF_TOKEN" https://huggingface.co/api/whoami
期待結果: HTTP endpoint returns 200 status and the whoami call returns your Hugging Face username, confirming network connectivity and valid authentication.
失敗時: If curl returns a connection error, check DNS resolution and proxy settings. If the token is rejected (401), regenerate the token at huggingface.co/settings/tokens and update the configuration.
ステップ5: Verify JSON Configuration Syntax
# Validate JSON (common issue: trailing commas, missing quotes)
python3 -m json.tool /path/to/config.json
期待結果: JSON parses without errors, confirming the configuration file has valid syntax.
失敗時: The most common JSON issues are trailing commas after the last entry in an object or array, missing quotes around string values, and mismatched braces. Fix the syntax error reported by the parser and re-validate.
ステップ6: Platform-Specific Debugging
Windows (Claude Desktop):
- Argument parsing differs from Unix
- Spaces in paths break command execution
- Use 8.3 short paths:
C:\PROGRA~1\R\R-45~1.0\bin\x64\Rscript.exe - Environment variables work more reliably than command-line headers
WSL (Claude Code):
- Unix-style quoting works correctly
- Can use full paths with spaces (quoted)
- npm/npx via NVM: ensure NVM is loaded in the execution context
期待結果: Platform-specific issue identified (e.g., Windows argument parsing, WSL path resolution, or NVM context loading).
失敗時: If the issue is Windows-specific, switch from command-line arguments to environment variables for authentication. If WSL-specific, verify that the Windows executable path is accessible from WSL using the full /mnt/c/... path.
ステップ7: Reset and Reconfigure
If all else fails:
# Remove and re-add the server (Claude Code)
claude mcp remove server-name
claude mcp add server-name stdio "/full/path/to/executable" -- args
# Restart Claude Desktop after config changes
# (close and reopen the application)
期待結果: After removing and re-adding the server, claude mcp list shows the server with the correct configuration and a fresh connection attempt succeeds.
失敗時: If re-adding fails, check that the executable path is correct and the command works when run directly in the terminal. For Claude Desktop, ensure the application is fully closed (check system tray) before restarting.
ステップ8: Check Logs
Claude Code: Look for MCP errors in the terminal output when starting a session.
Claude Desktop: Check application logs (location varies by OS).
Server-side: Add logging to the MCP server to capture incoming requests and errors.
期待結果: Log entries reveal the specific point of failure (server startup, handshake, authentication, or tool registration).
失敗時: If no logs are available, add stderr capture to the server command (e.g., redirect to a log file) and reproduce the failure. For Claude Desktop, check %APPDATA%\Claude\logs\ for application-level logs.
バリデーション
- Server starts independently without errors
- Configuration JSON is valid
- Client connects successfully
- MCP tools appear in the session
- Tools execute correctly when called
- Connection persists across multiple requests
よくある落とし穴
- Editing the wrong config file: Claude Code (
~/.claude.json) vs Claude Desktop (%APPDATA%\Claude\claude_desktop_config.json) - Not restarting after config changes: Claude Desktop requires restart; Claude Code picks up changes on new session
- npx in restricted environments: npx downloads packages at runtime. If network or permissions are restricted, install globally.
- Token expiration: Hugging Face tokens can expire. Regenerate if auth failures appear suddenly.
- Version mismatches: MCP protocol versions must be compatible between client and server
関連スキル
configure-mcp-server- initial MCP setupbuild-custom-mcp-server- custom server debugging contextsetup-wsl-dev-environment- WSL prerequisite setup
GitHub Repository
Verwandte Skills
evaluating-llms-harness
TestenDiese Claude Skill führt den lm-evaluation-harness aus, um LLMs über 60+ standardisierte akademische Aufgaben wie MMLU und GSM8K zu benchmarken. Sie wurde für Entwickler entwickelt, um Modellqualität zu vergleichen, Trainingsfortschritt zu verfolgen oder akademische Ergebnisse zu berichten. Das Tool unterstützt verschiedene Backends, einschließlich HuggingFace- und vLLM-Modelle.
cloudflare-cron-triggers
TestenDiese Fähigkeit bietet umfassendes Wissen zur Implementierung von Cloudflare Cron Triggers, um Workers mithilfe von Cron-Ausdrücken zu planen. Sie behandelt das Einrichten periodischer Aufgaben, Wartungsjobs und automatisierter Workflows, während häufige Probleme wie ungültige Cron-Ausdrücke und Zeitzonenprobleme behandelt werden. Entwickler können sie zum Konfigurieren geplanter Handler, zum Testen von Cron-Triggers und zur Integration mit Workflows und Green Compute verwenden.
webapp-testing
TestenDiese Claude Skill bietet ein Playwright-basiertes Toolkit zum Testen lokaler Webanwendungen durch Python-Skripte. Es ermöglicht Frontend-Verifizierung, UI-Debugging, Screenshot-Aufnahme und Log-Einblick bei gleichzeitiger Verwaltung von Server-Lebenszyklen. Nutzen Sie es für Browser-Automatisierungsaufgaben, führen Sie Skripte jedoch direkt aus, anstatt deren Quellcode zu lesen, um Kontextverschmutzung zu vermeiden.
finishing-a-development-branch
TestenDiese Fähigkeit unterstützt Entwickler dabei, abgeschlossene Arbeiten zu finalisieren, indem sie testet, ob Tests bestehen, und dann strukturierte Integrationsoptionen präsentiert. Sie leitet den Workflow für das Zusammenführen von Code, das Erstellen von PRs oder das Bereinigen von Branches nach Abschluss der Implementierung. Nutzen Sie sie, wenn Ihr Code bereit und getestet ist, um den Entwicklungsprozess systematisch abzuschließen.
