EveryMCP
Developer GuideMarch 29, 2026

How to Debug MCP Servers: A Complete Troubleshooting Guide

MCP servers are powerful — until something breaks. This guide walks you through diagnosing and fixing the most common Model Context Protocol issues, from connection failures to silent tool call errors.

1. Understanding the MCP Connection Lifecycle

Before you can debug MCP servers effectively, you need a mental model of how connections work. Every MCP session follows three phases:

  1. 1. Initialization — The client (Claude Desktop, Cursor, etc.) spawns the server process or connects via HTTP/SSE. The server sends its capabilities (tools, resources, prompts).
  2. 2. Tool Discovery — The client lists available tools. If this fails, no tools appear in the AI interface.
  3. 3. Tool Execution — The AI calls a specific tool. The server executes it and returns results as structured content.

Most bugs live in one of these three phases. Pinpointing which phase fails first narrows your debugging surface dramatically.

2. Connection Errors & Server Not Found

The most common MCP complaint: "The server doesn't appear in my client." Here's how to systematically diagnose it.

Check your config file

For Claude Desktop, your MCP config lives at:

# macOS
~/Library/Application Support/Claude/claude_desktop_config.json

# Windows
%APPDATA%\Claude\claude_desktop_config.json

Validate your JSON is syntactically correct. A single misplaced comma silently breaks the entire config. Use jq . claude_desktop_config.json or an online JSON validator.

Verify the server binary exists

# If using npx:
npx -y @your-mcp-server/package --help

# If using a local path:
node /path/to/your/server.js --help

If the binary doesn't start cleanly from the terminal, it won't start from the client either. Always test server startup in isolation first.

Check for port conflicts (HTTP/SSE servers)

# Find what's using port 3000
lsof -i :3000
# or
netstat -tlnp | grep 3000

3. Tool Call Failures & Silent Errors

The server connects but tool calls return empty results, errors, or the AI says it "couldn't complete the action." These are often the trickiest bugs.

Return value shape matters

MCP tools must return content in the correct format. A common mistake is returning a raw string instead of the required content array:

// ❌ Wrong — raw string
return "success";

// ✅ Correct — content array
return {
  content: [{ type: "text", text: "success" }]
};

Schema validation failures

If the AI passes arguments that don't match your tool's JSON Schema, the call fails before reaching your handler. Make your schemas explicit:

{
  "name": "search_records",
  "description": "Search database records",
  "inputSchema": {
    "type": "object",
    "properties": {
      "query": { "type": "string", "description": "Search query" },
      "limit": { "type": "number", "default": 10 }
    },
    "required": ["query"]
  }
}

Unhandled promise rejections

In Node.js MCP servers, unhandled promise rejections often swallow errors silently. Always wrap async tool handlers in try/catch and return structured error content rather than throwing:

async function handleToolCall(name, args) {
  try {
    const result = await doSomething(args);
    return { content: [{ type: "text", text: JSON.stringify(result) }] };
  } catch (err) {
    return {
      content: [{ type: "text", text: `Error: ${err.message}` }],
      isError: true
    };
  }
}

4. Authentication & Permission Issues

API keys, OAuth tokens, and file permissions cause a large share of MCP failures in production. Here's what to check.

Environment variables not reaching the server

When Claude Desktop spawns your server, it may not inherit your shell's environment. Pass secrets explicitly in the config:

{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["server.js"],
      "env": {
        "API_KEY": "sk-your-key-here"
      }
    }
  }
}

File system permission errors

MCP servers that access the file system may fail if Claude Desktop runs as a different user or in a sandboxed context. Verify the server process can read/write the target directories: ls -la /path/to/directory

Token expiry mid-session

OAuth tokens expire. If your MCP server works initially but fails after a period of time, implement token refresh logic. Store refresh tokens securely and renew access tokens before they expire.

5. Slow Responses & Timeouts

MCP clients typically have a 30–60 second timeout for tool calls. If your server makes heavy API calls or database queries, you may hit this limit.

Common causes

  • →N+1 queries — fetching records one at a time instead of in bulk
  • →Missing database indexes on fields used in tool queries
  • →External API calls with no timeout set (can hang indefinitely)
  • →Returning too much data — the AI doesn't need entire database dumps

Set explicit timeouts on external calls

// Always set a timeout for external HTTP calls
const response = await fetch(url, {
  signal: AbortSignal.timeout(10000) // 10 seconds
});

6. Enabling Debug Logging

Structured logging is your best friend when debugging MCP servers. The key constraint: MCP uses stdio for communication, so your server must write logs to stderr, never stdout.

// ❌ Never — this corrupts the MCP protocol
console.log("debug info");

// ✅ Correct — write to stderr
console.error("[MCP Debug] Tool called:", toolName, args);

Claude Desktop logs location

# macOS
~/Library/Logs/Claude/mcp*.log
# or
~/Library/Logs/Claude/mcp-server-YOUR_SERVER_NAME.log

# Windows
%APPDATA%\Claude\logs\

Tail these logs in real time while reproducing your issue:tail -f ~/Library/Logs/Claude/mcp*.log

7. Using the MCP Inspector

The official MCP Inspector is the fastest way to test your server without a full client setup. It gives you a UI to connect to any MCP server and invoke tools directly.

# Install and run the inspector
npx @modelcontextprotocol/inspector

# Or point it at a specific server
npx @modelcontextprotocol/inspector node server.js

The Inspector opens a web UI (usually at localhost:5173) where you can:

  • ✓Browse all tools, resources, and prompts your server exposes
  • ✓Call tools with custom arguments and see raw responses
  • ✓View the full JSON-RPC message exchange in real time
  • ✓Test error handling without spinning up a full AI client

8. Common Error Reference

Error / SymptomLikely Cause
Server doesn't appear in clientBad JSON config, server crashes on start, wrong command path
Tool list is emptyServer fails during initialization, capability declaration missing
Tool call returns nothingWrong return format — wrap in content array
'Method not found' errorServer doesn't implement the called JSON-RPC method
Timeout on every callExternal API hanging, no timeout set, N+1 database queries
Works locally, fails in CIMissing env vars, different Node version, missing npm install
Partial results onlyResponse truncated — reduce data returned per call
Auth error after 1 hourOAuth token expired — implement refresh flow

Debugging Checklist

  1. 1.Validate your config JSON is syntactically valid
  2. 2.Test server startup in the terminal independently
  3. 3.Check Claude Desktop logs at ~/Library/Logs/Claude/
  4. 4.Use MCP Inspector to call tools without a full AI client
  5. 5.Verify all logs go to stderr, never stdout
  6. 6.Wrap async handlers in try/catch and return structured errors
  7. 7.Set explicit timeouts on all external HTTP calls
  8. 8.Check env vars are explicitly passed in the MCP server config

Find the Right MCP Server for Your Stack

Browse 400+ MCP servers organized by category, tool, and use case. Stop searching — start building.

Browse the MCP Directory →