协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
troubleshoot-mcp-connection【开发与工程】Diagnose and fix MCP server connection issues between Claude Code, Claude Desktop, and MCP servers. Covers Windows argument parsing, authentication failures, transport issues, and platform-specific debugging. Use when Claude Code or Claude Desktop fails to connect to an MCP server, when MCP tools don't appear in sessions, on "cannot attach the server…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Diag + 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, MCP server entries w/ command, args, env.
If err: Config doesn't exist|empty → never configured. Follow configure-mcp-server 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()"
Fails:
ls "/mnt/c/Program Files/R/"Rscript -e "library(mcptools)"Rscript -e "library(ellmer)"HF 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 proc starts + init out (JSON-RPC handshake or "listening") no errs.
If err: R mcptools fails → check R ver path correct + mcptools in R lib. mcp-remote fails → reinstall global npm install -g mcp-remote + verify on PATH.
"Cannot attach the server" (Claude Desktop)
Root: Windows cmd arg parsing.
Fix: env vars instead of --header:
{
"hf-mcp-server": {
"command": "mcp-remote",
"args": ["https://huggingface.co/mcp"],
"env": { "HF_TOKEN": "your_token" }
}
}
Also ensure mcp-remote global (npm install -g mcp-remote), not relying on npx.
"Connection refused"
"Command not found"
C:\\PROGRA~1\\... for paths w/ spacesMCP tools missing, no err
Got: Err pattern matched to documented category (cannot attach, conn refused, cmd not found, silent fail).
If err: No match → capture full err out + check server logs. Search exact err 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 returns 200, whoami returns HF username → confirms net + auth.
If err: curl conn err → DNS|proxy. Token rejected (401) → regen 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 errs → valid syntax.
If err: Common: trailing commas after last entry, missing quotes around strings, mismatched braces. Fix syntax err per parser + re-validate.
Windows (Claude Desktop):
C:\PROGRA~1\R\R-45~1.0\bin\x64\Rscript.exeWSL (Claude Code):
Got: Platform-specific issue ID'd (Windows arg parsing, WSL path resolve, NVM ctx).
If err: Windows-specific → switch cmd-line args → env vars for auth. WSL-specific → verify Windows exec path accessible from WSL via full /mnt/c/....
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 + re-add, claude mcp list shows correct config + fresh conn succeeds.
If err: Re-add fails → check exec path correct + cmd works direct in terminal. Claude Desktop → ensure fully closed (system tray) before restart.
Claude Code: MCP errs in terminal out at sess start.
Claude Desktop: App logs (location varies by OS).
Server-side: Add logging → capture incoming reqs + errs.
Got: Logs reveal specific point of fail (server start, handshake, auth, tool reg).
If err: No logs → add stderr capture to server cmd (redirect to log file) + reproduce. Claude Desktop → %APPDATA%\Claude\logs\ for app logs.
~/.claude.json) vs Desktop (%APPDATA%\Claude\claude_desktop_config.json)configure-mcp-server — initial MCP setupbuild-custom-mcp-server — custom server debug ctxsetup-wsl-dev-environment — WSL prereq setup