MCP HubMCP Hub
스킬 목록으로 돌아가기

troubleshoot-mcp-connection

pjt222
업데이트됨 2 days ago
8 조회
17
2
17
GitHub에서 보기
테스팅aimcp

정보

이 기술은 Claude Code/Desktop과 MCP 서버 간의 연결 문제를 진단하고 수정합니다. 도구가 표시되지 않거나 연결이 실패하거나 "서버를 연결할 수 없습니다" 오류가 발생할 때 도움이 됩니다. Windows 인수 구문 분석, 인증 및 전송 문제에 대한 플랫폼별 디버깅을 다룹니다.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/troubleshoot-mcp-connection

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Troubleshoot MCP Connection

Diagnose and resolve MCP server connection failures.

When to Use

  • 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

Inputs

  • Required: Error message or symptom description
  • Required: Which client (Claude Code, Claude Desktop, or both)
  • Required: Which MCP server (mcptools, Hugging Face, custom)
  • Optional: Recent changes to configuration or environment

Procedure

Step 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"

Got: Configuration file is located and readable, showing the MCP server entries with command, args, and env fields.

If fail: 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.

Step 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

Got: The server process starts and produces initialization output (JSON-RPC handshake or "listening" message) without errors.

If fail: If R mcptools fails, check that the R version path is correct and 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.

Step 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

Got: Error pattern matched to one of the documented categories (cannot attach, connection refused, command not found, or silent failure).

If fail: 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.

Step 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

Got: HTTP endpoint returns 200 status and the whoami call returns your Hugging Face username, confirming network connectivity and valid authentication.

If fail: 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.

Step 5: Verify JSON Configuration Syntax

# Validate JSON (common issue: trailing commas, missing quotes)
python3 -m json.tool /path/to/config.json

Got: JSON parses without errors, confirming the configuration file has valid syntax.

If fail: 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.

Step 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

Got: Platform-specific issue identified (e.g., Windows argument parsing, WSL path resolution, or NVM context loading).

If fail: 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.

Step 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)

Got: After removing and re-adding the server, claude mcp list shows the server with the correct configuration and a fresh connection attempt succeeds.

If fail: 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.

Step 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.

Got: Log entries reveal the specific point of failure (server startup, handshake, authentication, or tool registration).

If fail: 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.

Validation

  • 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

Pitfalls

  • 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

Related Skills

  • configure-mcp-server - initial MCP setup
  • build-custom-mcp-server - custom server debugging context
  • setup-wsl-dev-environment - WSL prerequisite setup

GitHub 저장소

pjt222/agent-almanac
경로: i18n/caveman-lite/skills/troubleshoot-mcp-connection
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

연관 스킬

evaluating-llms-harness

테스팅

이 Claude Skill은 MMLU, GSM8K를 포함한 60개 이상의 표준화된 학술 과제에서 LLM 성능을 벤치마크하기 위해 lm-evaluation-harness를 실행합니다. 개발자들이 모델 품질을 비교하고, 학습 진행 상황을 추적하거나 학술 결과를 보고할 수 있도록 설계되었습니다. 이 도구는 HuggingFace와 vLLM 모델을 포함한 다양한 백엔드를 지원합니다.

스킬 보기

cloudflare-cron-triggers

테스팅

이 스킬은 cron 표현식을 사용하여 Worker를 스케줄링하기 위한 Cloudflare Cron Triggers 구현에 관한 포괄적인 지식을 제공합니다. 주기적 작업, 유지보수 작업, 자동화된 워크플로우 설정 방법을 다루며, 잘못된 cron 표현식이나 시간대 문제 같은 일반적인 이슈들을 해결하는 방법을 포함합니다. 개발자들은 이를 통해 스케줄된 핸들러 구성, cron 트리거 테스트, Workflows 및 Green Compute와의 연동 작업을 수행할 수 있습니다.

스킬 보기

webapp-testing

테스팅

이 Claude Skill은 Python 스크립트를 통해 로컬 웹 애플리케이션을 테스트하기 위한 Playwright 기반 툴킷을 제공합니다. 프론트엔드 검증, UI 디버깅, 스크린샷 캡처, 로그 확인 기능을 지원하며 서버 라이프사이클을 관리합니다. 브라우저 자동화 작업에 사용하되 컨텍스트 오염을 방지하기 위해 소스 코드를 읽지 않고 스크립트를 직접 실행하세요.

스킬 보기

finishing-a-development-branch

테스팅

이 스킬은 테스트 통과를 확인한 후 체계적인 통합 옵션을 제시하여 개발자가 완성된 작업을 마무리하도록 돕습니다. 구현이 완료된 후 머지, PR 생성, 브랜치 정리와 같은 워크플로우를 안내합니다. 코드가 준비되고 테스트가 완료되었을 때 개발 프로세스를 체계적으로 마무리하기 위해 사용하세요.

스킬 보기