How to debug MCP server connection failures in Claude Code

To debug an MCP server that will not connect in Claude Code, run claude mcp list to read each server’s status and failure detail, then claude mcp get <name> for the Issue line. Check approval and config warnings next, then read the debug log that claude --debug=mcp writes. Reconnect from /mcp after you fix the cause.
This guide follows the Claude Code docs as fetched on 2026-11-28. Some behaviour depends on version, and where the docs give a minimum version, the step says so. For the wider review of MCP servers, start with the MCP security guide.
Read the status and the failure detail
claude mcp list prints each configured server with a health status. The statuses that concern a connection failure are ✔ Connected, ! Needs authentication and ✘ Failed to connect. The docs say a failure status means Claude Code could not connect to that server. It does not mean the list command failed. Read the status before you change any config, because it shows which layer to check.
claude mcp list
claude mcp get example
Run the list and get commands
- Run
claude mcp listfrom the project directory. Note each server marked✘ Failed to connect, and copy the detail text after the status. - Run
claude mcp get example, replacingexamplewith the server name. A failed server shows anIssue:line with the HTTP status or error code, plus any error text the server returned. - Compare that text with the server’s own documentation. The docs say Claude Code redacts credential-like text from the detail and never prints the expanded server URL. Check the URL in your config file directly.
Handle a Connection error status
If the status is ✘ Connection error, the list shows no detail. The docs say Claude Code appends nothing to that status, because the exception text could embed the server URL. Use the debug log section below to find the cause. The status line alone does not identify the fault, so do not guess from it.
Rule out statuses that never connect
Some statuses record a configuration decision. Claude Code prints them without contacting the server, so a server with one of these statuses was never tried. The docs list four: ⏸ Pending approval for an unapproved project server from .mcp.json, ✘ Rejected for a server that a disabledMcpjsonServers entry rejects, ⊘ Disabled for this project for a server named in disabledMcpServers, and ✘ Blocked by enterprise managed policy. Clear these first, then debug the connection itself.
Approve project servers
- Start
claudeinteractively in the project and review the approval prompt for each server that comes from.mcp.json. - If you dismissed the prompt, the server stays disabled. Run
claude mcp reset-project-choicesand restart Claude Code to see the prompt for every project server again. - In a folder you have not trusted, the docs say an
enableAllProjectMcpServersorenabledMcpjsonServersentry committed to.claude/settings.jsonis ignored. The server stays at⏸ Pending approvaluntil you accept the workspace trust dialog.
Fix the config warnings
Claude Code warns about several problems that break connections. Check the output of claude mcp list and /mcp for these three:
- Hidden whitespace in
command,url, anargsentry, or anenvorheadersvalue. Claude Code uses the value as written and does not trim it, so remove the whitespace in the file. - The same server name defined in more than one scope with different endpoints. Keep the endpoint you want and remove the other definitions with
claude mcp remove <name> --scope <scope>. - A
${VAR}reference to a variable that is not set and has no:-default. The server still loads with the${VAR}text unexpanded, so set the variable or add a default.
A fourth cause is a url entry with no type. Claude Code reads an entry with no type as a stdio server, so the URL entry fails. Add the type that matches the endpoint.
{
"mcpServers": {
"example": {
"type": "http",
"url": "https://mcp.example.com/mcp"
}
}
}
Find why a stdio server will not start
A stdio server runs as a local process, and its first connection is handled differently from an HTTP or SSE server. The docs say Claude Code retries an HTTP or SSE server’s first connection up to three times after a transient error. Those retries do not apply to a stdio server’s first connection. Check the command path before you retry, because a relative path is a frequent cause.
Check the command path
- Find the
commandandargsentries for the server in.mcp.json, or in the scope where you added it. - Look for a relative path, such as
./servers/db. The docs say a relative path resolves against the directory where you launched Claude Code. - Launch Claude Code from the directory that makes the path correct, or replace the path with an absolute one.
- Run
/mcpand confirm that the server now shows as connected. If it does not, continue with the debug log.
Read the debug log
When the status and detail do not explain the failure, read the debug log. The docs say claude --debug=mcp enables the MCP debug category. If a server connects with zero tools, the log holds that server’s stderr. By default the log is written to ~/.claude/debug/<session-id>.txt. The --debug-file flag enables debug logging and writes to a path you choose, and the docs show /tmp/claude-debug.log as an example.
claude --debug=mcp
claude --debug-file /tmp/claude-debug.log
Use the log in order
- Start Claude Code with
claude --debug=mcp, reproduce the failure, then exit. - Open the newest file in
~/.claude/debug/. Search for the server name and read the lines around the failure. - If you want the log at a fixed path, start with
claude --debug-file /tmp/claude-debug.loginstead. - If a remote server’s
urlorheadersreference a variable that Claude Code does not expand, search the file for the phrasenever expanded toward a remote server.
Isolate a plugin or hook
Sometimes the failing server comes from a plugin, or hook problems appear in the same session. The troubleshooting page says to restart with safe mode to check whether a plugin, MCP server or hook is the source. If the problem goes away in safe mode, you have narrowed the cause to one of those three. Re-enable the plugin or server and repeat the connection test to confirm it.
claude --safe-mode
Know when Claude Code retries
Retries decide whether a failure heals on its own. The table shows what a stdio server’s first-connection failure does in each run mode. The retry rules for HTTP and SSE servers are different, so read the notes after the table.
| How you run Claude Code | Stdio server first connection fails | How to start it again |
|---|---|---|
| Interactive session | Claude Code marks the server as failed | Select Reconnect from the server’s menu in /mcp, or run /mcp reconnect all (v2.1.284 or later) |
claude -p run |
The run continues without the server’s tools | Start the run again. A plugin-provided server skips the connection for 15 minutes after a failure in new runs |
| Agent SDK session | The session continues without the server’s tools | Your code reconnects the server |
For HTTP and SSE servers, the docs describe three rules. A first connection that fails with a transient error, such as a 5xx response, a refused connection or a timeout, is retried up to three times. An authentication or not-found error is not retried, because it needs a configuration change. A server that drops mid-session is retried up to five times with exponential backoff, starting at one second. Claude Code tells Claude about a failed server only when tool search is on, which it is by default.
Reconnect and confirm the fix
Once the cause is fixed, reconnect the server and confirm the result.
- In
/mcp, select the server and choose Reconnect. To retry every server that failed or needs authentication, run/mcp reconnect all. Versions before v2.1.284 print an error that the server “all” was not found. - Run
claude mcp listand confirm the server shows✔ Connected. Then check the tool count for that server in/mcp. - If a slow server still times out at startup, set
MCP_TIMEOUTbefore you launch Claude Code. The docs give 30000 milliseconds as the default for MCP server startup, and the exampleMCP_TIMEOUT=10000 claudesets 10 seconds. For tool-call limits, read the timeouts guide.
For allowlists that stop a server from loading at all, read the restrict MCP servers guide. To record which tool calls ran, read the audit guide.
Enforcing this with AIControls
AIControls supports Claude Code through its gateway, in the CLI and in VS Code. The steps in this post do not depend on that product. They use Claude Code’s own commands, and you can run them on any machine where Claude Code is installed. For the product’s approach to MCP and coding-agent controls, see the AIControls platform page.
Frequently asked questions
Why does claude mcp list show a server as Failed to connect?
The status means Claude Code could not connect to that server. It does not mean the list command failed. The docs say the list appends the failure detail to that line, including the HTTP status or error code and any error text the server returned. Claude Code removes credential-like text from that detail and never prints the expanded server URL, because the URL can carry secrets.
Does Claude Code retry an MCP server whose stdio process fails to start?
Not on the first connection. The docs apply the automatic first-connection retries to HTTP and SSE servers only. In an interactive session the server is marked failed, and you can select Reconnect from its menu in /mcp. In claude -p runs the run continues without that server's tools, so you start the run again. When a plugin provides the server, new runs skip the connection for 15 minutes after a failure.
Why does a connected MCP server show zero tools?
The docs say that status means the server started but did not return a tool list. Select Reconnect for the server in /mcp first. If the tool count stays at zero, run claude --debug=mcp and read the server's stderr in the debug log, which is written to a file named by the session ID under the .claude/debug folder in your home directory.
Why does a relative path in an MCP server config break the connection?
Relative file paths in command or args resolve against the directory where you launched Claude Code, not against the location of the .mcp.json file. The docs call this a frequent cause of a server that fails to start. Launch Claude Code from the directory that makes the path correct, or use an absolute path so the server starts the same way from any folder.