Skip to main content
RapidDev - Software Development Agency
mcp-tutorial

How to debug MCP server connection issues

Debug MCP server connection issues systematically: first test the server manually in your terminal, then use MCP Inspector to verify the protocol layer, check your host configuration for JSON syntax errors, and finally review server logs for startup failures. Most connection problems come from incorrect paths, missing environment variables, or JSON config typos.

What you'll learn

  • A systematic checklist for debugging MCP connection failures
  • How to test MCP servers manually in the terminal
  • How to use MCP Inspector for protocol-level debugging
  • Where to find and interpret MCP server logs
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate7 min read15-20 minAll MCP hosts and serversMarch 2026RapidDev Engineering Team
TL;DR

Debug MCP server connection issues systematically: first test the server manually in your terminal, then use MCP Inspector to verify the protocol layer, check your host configuration for JSON syntax errors, and finally review server logs for startup failures. Most connection problems come from incorrect paths, missing environment variables, or JSON config typos.

Systematic Debugging of MCP Server Connections

When an MCP server fails to connect, the host typically shows a generic error or simply does not list the server's tools. Without a systematic approach, debugging can feel like guessing. This tutorial provides a step-by-step checklist that isolates the problem layer by layer: is the server binary accessible, does it start correctly, does the protocol handshake succeed, and is the host configuration valid?

Prerequisites

  • An MCP server that is failing to connect to your host
  • Terminal access on your machine
  • Node.js 18+ installed (for MCP Inspector)
  • Access to your MCP host's configuration file

Step-by-step guide

1

Test the server command manually in your terminal

The first step is to verify that the server binary can actually run. Open your terminal and execute the exact command from your MCP host config. If the server uses npx, run the full npx command. If it uses node or uvx, run that. A working server will output JSON-RPC messages to stdout and wait for input. If you see an error instead, the problem is in the server itself — not the host connection. Common failures include command not found, missing dependencies, or missing environment variables.

typescript
1# Copy the exact command from your config and run it
2# For npx-based servers:
3npx -y @modelcontextprotocol/server-github
4
5# For node-based servers:
6node ./dist/index.js
7
8# For Python servers:
9uvx mcp-server-git --repository /path/to/repo
10
11# Set environment variables first if needed:
12export API_KEY="your-key"
13node ./dist/index.js

Expected result: The server starts and waits for input (you may see a JSON-RPC initialization message), or you see a clear error that points to the cause.

2

Validate your host configuration JSON

A single misplaced comma or missing quote in your config file will prevent all MCP servers from loading. Copy your entire configuration file content and paste it into a JSON validator (like jsonlint.com or your IDE's built-in JSON validation). Common JSON syntax errors include trailing commas after the last item in an object, missing closing braces, and unescaped backslashes in Windows file paths.

typescript
1# Validate JSON from the command line
2# macOS/Linux:
3cat ~/Library/Application\ Support/Claude/claude_desktop_config.json | python3 -m json.tool
4
5# If it outputs formatted JSON valid
6# If it outputs an error fix the syntax
7
8# Common issues:
9# WRONG: trailing comma
10{ "env": { "KEY": "value", } }
11
12# RIGHT: no trailing comma
13{ "env": { "KEY": "value" } }
14
15# WRONG: unescaped backslash (Windows paths)
16{ "args": ["C:\Users\name\server"] }
17
18# RIGHT: escaped backslash
19{ "args": ["C:\\Users\\name\\server"] }

Expected result: The JSON validator confirms your config file is valid JSON, or shows you the exact line with the syntax error.

3

Use MCP Inspector to test the protocol layer

MCP Inspector is an official debugging tool that acts as an MCP client and connects to your server. It shows you the initialization handshake, lists available tools and resources, and lets you execute tool calls interactively. If the Inspector can connect but your host cannot, the problem is in the host configuration. If the Inspector also fails, the problem is in the server itself.

typescript
1# Install and run MCP Inspector
2npx -y @modelcontextprotocol/inspector
3
4# For stdio servers, it will prompt you for the command
5# For HTTP servers, specify the URL:
6npx -y @modelcontextprotocol/inspector --transport http --url http://localhost:3000/mcp

Expected result: MCP Inspector connects to your server and displays available tools and resources, confirming the server is working at the protocol level.

4

Check MCP server logs for startup errors

MCP hosts capture server stderr output in log files. Claude Desktop on macOS writes logs to ~/Library/Logs/Claude/mcp*.log. On Windows, check %APPDATA%\Claude\logs\. Cursor shows MCP errors in the Output panel (select MCP from the dropdown). These logs often contain the exact error message that explains why the server failed to start.

typescript
1# Claude Desktop logs (macOS)
2tail -n 50 -F ~/Library/Logs/Claude/mcp*.log
3
4# Claude Desktop logs (Windows in PowerShell)
5Get-Content -Tail 50 -Wait "$env:APPDATA\Claude\logs\mcp.log"
6
7# Cursor check Output panel
8# View Output select 'MCP' from dropdown

Expected result: You see the server's stderr output including any error messages, stack traces, or configuration warnings.

5

Verify environment variables are reaching the server

If your server starts but fails because of missing API keys, the env block in your config may not be reaching the server process. Add a startup check to your server that logs which environment variables are set (without logging the actual values). This confirms whether the host is injecting the variables correctly. If you have exhausted these debugging steps and still cannot resolve the issue, the RapidDev team has experience debugging complex MCP configurations and can help identify the root cause.

typescript
1// Add to your server's entry point for debugging
2const requiredVars = ["API_KEY", "DATABASE_URL"];
3for (const varName of requiredVars) {
4 const isSet = !!process.env[varName];
5 console.error(` ${varName}: ${isSet ? "SET" : "MISSING"}`);
6}
7
8# Python equivalent
9import os, sys
10required_vars = ["API_KEY", "DATABASE_URL"]
11for var in required_vars:
12 is_set = var in os.environ
13 print(f" {var}: {'SET' if is_set else 'MISSING'}", file=sys.stderr)

Expected result: The server logs show which environment variables are set and which are missing, helping you identify configuration gaps.

Complete working example

debug-mcp-checklist.sh
1#!/bin/bash
2# MCP Server Connection Debugging Checklist
3# Run each step to isolate the problem
4
5echo "=== Step 1: Check if server command exists ==="
6which node
7which npx
8which uvx
9
10echo ""
11echo "=== Step 2: Validate config JSON ==="
12CONFIG="$HOME/Library/Application Support/Claude/claude_desktop_config.json"
13if [ -f "$CONFIG" ]; then
14 python3 -m json.tool "$CONFIG" > /dev/null 2>&1
15 if [ $? -eq 0 ]; then
16 echo "Config JSON: VALID"
17 else
18 echo "Config JSON: INVALID — fix syntax errors"
19 python3 -m json.tool "$CONFIG"
20 fi
21else
22 echo "Config file not found at: $CONFIG"
23fi
24
25echo ""
26echo "=== Step 3: Test server manually ==="
27echo "Run your server command here, e.g.:"
28echo " npx -y @modelcontextprotocol/server-github"
29echo " node ./dist/index.js"
30echo " uvx mcp-server-git --repository /path"
31
32echo ""
33echo "=== Step 4: Check recent logs ==="
34if ls ~/Library/Logs/Claude/mcp*.log 1> /dev/null 2>&1; then
35 echo "Recent MCP log entries:"
36 tail -n 20 ~/Library/Logs/Claude/mcp*.log
37else
38 echo "No MCP log files found"
39fi
40
41echo ""
42echo "=== Step 5: Run MCP Inspector ==="
43echo "npx -y @modelcontextprotocol/inspector"

Common mistakes when debugging MCP server connection issues

Why it's a problem: Skipping the manual terminal test and jumping straight to config changes

How to avoid: Always test the server command in your terminal first. If it does not work there, no host configuration will fix it.

Why it's a problem: Editing the config file while the MCP host is running and expecting changes to apply

How to avoid: After editing the config, restart Claude Desktop completely or reload Cursor's window.

Why it's a problem: Not checking for JSON syntax errors in the config file

How to avoid: Use python3 -m json.tool or an online validator to check the config before restarting.

Why it's a problem: Ignoring the MCP server logs

How to avoid: Server logs contain the actual error messages. Check ~/Library/Logs/Claude/mcp*.log on macOS before making random changes.

Best practices

  • Follow the debugging checklist in order: command → config → protocol → logs
  • Test server commands in terminal before adding them to host configs
  • Validate JSON config files after every edit
  • Use MCP Inspector as the definitive protocol-level test
  • Add startup validation in your servers that logs which env vars are present
  • Keep a tail -f on the log file while restarting the host to catch errors in real time
  • Document working configurations so you can revert if something breaks

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

My MCP server is not connecting in [Claude Desktop / Cursor]. The server is [description]. Here is my config: [paste config]. I see this error in the logs: [paste error]. Help me debug the connection issue step by step.

MCP Prompt

Help me debug my MCP server connection issue. When I run [command] in my terminal, I see [error]. My config file is at [path]. Walk me through the debugging checklist.

Frequently asked questions

My server works in the terminal but not in Claude Desktop. Why?

GUI applications like Claude Desktop do not inherit your shell's PATH or environment variables. Use absolute paths for commands (e.g., /opt/homebrew/bin/npx instead of npx) and set all required environment variables in the config's env block.

How do I know if the problem is the server or the host?

Use MCP Inspector to test independently of the host. If Inspector connects and lists tools, the server is fine and the problem is in the host configuration. If Inspector also fails, the server itself has an issue.

Can I debug MCP servers with a regular debugger?

Yes, for Node.js servers use --inspect flag: node --inspect ./dist/index.js, then connect Chrome DevTools. For Python, use debugpy. Note that breakpoints will pause the MCP protocol, so the host may time out.

Why do all my MCP servers fail at once?

This almost always indicates a JSON syntax error in your config file. A single invalid character breaks the entire config, preventing all servers from loading. Validate the JSON first.

The server connects but no tools appear. What is wrong?

The server is running but either has no tools registered, or the tool registration happens after the initialization handshake. Check your server code to ensure tools are registered before the server starts listening. Also check if there is a tool limit in your host (Cursor has a ~40 tool limit).

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.