协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
troubleshoot-mcp-connection【开发与工程】Diagnose, fix MCP server connection issues between Claude Code, Claude Desktop, MCP servers. Covers Windows arg parsing, auth fails, transport issues, platform-specific debugging. Use when Claude Code or Claude Desktop fail connect to MCP server, when MCP tools don't appear, on "cannot attach server" errors, when working connection stopped, or when s…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Diagnose, resolve MCP server connection failures.
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"
Got: Config file located, readable. Shows MCP server entries with command, args, env fields.
If fail: Config file missing or empty? Server never configured. Use configure-mcp-server skill — set up from scratch.
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 fail:
ls "/mnt/c/Program Files/R/"Rscript -e "library(mcptools)"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
Got: Server process starts. Produces init output (JSON-RPC handshake or "listening" msg). No errors.
If fail: R mcptools fails? Check R version path correct, mcptools installed in R library. mcp-remote fails? Reinstall global with npm install -g mcp-remote. Verify on PATH.
"Cannot attach server" (Claude Desktop)
Root cause: Windows command argument parsing.
Fix: Use env vars instead of --header args:
{
"hf-mcp-server": {
"command": "mcp-remote",
"args": ["https://huggingface.co/mcp"],
"env": { "HF_TOKEN": "your_token" }
}
}
Also ensure mcp-remote global installed (npm install -g mcp-remote) — no rely on npx.
"Connection refused"
"Command not found"
C:\\PROGRA~1\\... for paths with spacesMCP tools don't appear, no error
Got: Error pattern matched to one documented category (cannot attach, connection refused, command not found, silent failure).
If fail: Error matches no known pattern? Capture full error output. Check server-side logs. Search exact error in MCP server's GitHub issues.
# 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
Got: HTTP endpoint returns 200. whoami returns Hugging Face username. Network and auth OK.
If fail: curl returns connection error? Check DNS, proxy. Token rejected (401)? Regenerate at huggingface.co/settings/tokens. Update config.
# Validate JSON (common issue: trailing commas, missing quotes)
python3 -m json.tool /path/to/config.json
Got: JSON parses, no errors. Config syntax valid.
If fail: Common JSON issues — trailing commas after last entry, missing quotes around strings, mismatched braces. Fix syntax error from parser. Re-validate.
Windows (Claude Desktop):
C:\PROGRA~1\R\R-45~1.0\bin\x64\Rscript.exeWSL (Claude Code):
Got: Platform-specific issue identified (Windows arg parsing, WSL path resolution, NVM context loading).
If fail: Windows-specific? Switch from command-line args to env vars for auth. WSL-specific? Verify Windows executable path accessible from WSL via /mnt/c/....
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)
Got: After remove and re-add, claude mcp list shows server with correct config. Fresh connection succeeds.
If fail: Re-add fails? Check executable path correct. Run command directly in terminal — works? For Claude Desktop, ensure app fully closed (check system tray) before restart.
Claude Code: Look for MCP errors in terminal output when start session.
Claude Desktop: Check application logs (location varies by OS).
Server-side: Add logging to MCP server. Capture incoming requests, errors.
Got: Log entries reveal specific failure point (server startup, handshake, auth, tool registration).
If fail: No logs? Add stderr capture to server command (redirect to log file). Reproduce failure. For Claude Desktop, check %APPDATA%\Claude\logs\ for app-level logs.
~/.claude.json) vs Claude Desktop (%APPDATA%\Claude\claude_desktop_config.json)configure-mcp-server - initial MCP setupbuild-custom-mcp-server - custom server debugging contextsetup-wsl-dev-environment - WSL prerequisite setup