Claude Code MCP server failed to connect: how to fix it
Claude Code shows Failed to connect when an MCP server never started or never answered. Run claude mcp get with the server's name to read the error, then fix the cause; common ones are a relative path, a missing variable, bare npx on native Windows and a rejected credential.
Contents
When Claude Code says an MCP server failed to connect, the server either never started or started and never completed the MCP handshake. Run claude mcp get <name> first: it prints an Issue: line with the error the server gave. Common causes are a relative path, a missing variable, bare npx on native Windows and a rejected credential. A server that never shows up at all is a different problem, usually a .mcp.json in the wrong place.
What follows comes from Anthropic's Debug your configuration and MCP pages, both read on 24 October 2026, when the newest version in Anthropic's changelog was v2.1.310.
What "Failed to connect" means in claude mcp list#
claude mcp list checks each server and prints one of three health states: ✔ Connected, ! Needs authentication or ✘ Failed to connect. A failure is about that server, not the list command. Three other states never come from a connection attempt, because they record a decision: ⏸ Pending approval (a .mcp.json server you haven't approved), ⊘ Disabled for this project (turned off for the project; /mcp turns it back on) and ✘ Rejected, which only claude mcp get shows (a disabledMcpjsonServers entry blocks it).
Since v2.1.219, a failed server's line carries the detail: the HTTP status or error code, plus any text the server sent back. claude mcp get <name> puts the same text on an Issue: line, and the server's page in /mcp shows it too. That one line usually names the cause.
How it retries depends on the transport. A remote HTTP or SSE server whose first connection fails with a 5xx, a refused connection or a timeout is retried up to three times. A stdio server, the kind started with a command such as npx or uvx, is not retried in an interactive session: it stays failed until you choose Reconnect in /mcp. How Claude Code reconnects a server that drops mid-session, and how to give a slow server longer to start, is in the MCP timeout guide.
Claude Code MCP server failed to connect: causes and fixes#
| What you see | Cause | Fix |
|---|---|---|
| Fails from some folders, works from others | A relative path in command or args. It resolves against the folder you launched Claude Code from, not the folder .mcp.json sits in |
Use absolute paths for local scripts. npx and uvx on your PATH are fine as they are (native Windows aside, below) |
A server in .mcp.json never appears |
The file is inside .claude/, or its servers sit under servers (VS Code's shape) instead of mcpServers |
Put .mcp.json at the repository root, with the servers under mcpServers |
A server added to settings.json never appears |
settings.json doesn't read an mcpServers key |
Use .mcp.json for the project, or claude mcp add --scope user for yourself |
Project server shows ⏸ Pending approval |
The one-time approval prompt was dismissed | Run claude in the folder and approve it in /mcp. claude mcp reset-project-choices resets earlier choices |
| Server starts without its API key | The key isn't in the server's entry, and not in the environment Claude Code passes to stdio servers | Set it in the server's own env block in .mcp.json |
! Needs authentication |
A remote server answered 401 or 403 and wants an OAuth sign-in | Open /mcp, pick the server and sign in, or run claude mcp login <name> in a shell |
| A remote server copied from another app never loads | Its entry has a url but no type. Claude Code reads an entry with no type as stdio, so it skips the server and says it has a "url" but no "type" |
Add "type": "http", "sse" or "ws" to match the endpoint |
Connected, but zero tools |
The server started and isn't returning a tool list | Reconnect in /mcp, then debug logging (below) |
| A long pause, then failed | The server took longer than the startup timeout | See the timeout guide |
A 401 on a server whose Authorization header you set yourself shows as a failure, not as "needs authentication", because the credential to fix is the one in your config. And a ${VAR} in the config that nothing sets gets a warning in claude mcp list and /mcp naming the variable, while the server still loads with the text ${VAR} left in.
Find the real error#
- Run
claude mcp get <name>and read theIssue:line. - For a stdio server, copy its
commandandargsand run them yourself in a terminal, in the same folder. A missing package, a wrong Node version or a crash on start shows up right there. - Start
claude --debug=mcp, reproduce the failure and open~/.claude/debug/<session-id>.txt. The server's stderr lands there. - Fix the cause, then choose Reconnect in
/mcp. From v2.1.284,/mcp reconnect allretries every server that failed or needs a sign-in.
A stdio server can also fail because it prints its own messages to stdout. The MCP specification says a stdio server must not write anything to stdout that is not an MCP message; logs belong on stderr. A banner or a console.log there breaks the stream Claude Code reads.
If nothing stands out, claude --safe-mode starts a session with MCP servers, hooks, skills and CLAUDE.md all switched off. If the problem goes away, it lives in your own configuration.
Why is .mcp.json not loading?#
Claude Code reads project servers from one place: .mcp.json at the root of the repository. Each server sits under mcpServers, with its command, its arguments and any variables it needs:
{
"mcpServers": {
"docs": {
"command": "node",
"args": ["/Users/you/tools/docs-server/index.js"],
"env": { "DOCS_TOKEN": "${DOCS_TOKEN}" }
}
}
}
Servers you add with claude mcp add don't go in that file at all: local and user scope live in ~/.claude.json. That's a different file from ~/.claude/settings.json, which holds settings, permissions and hooks but no servers. Setting up MCP servers for every project walks through the three scopes and which one wins when a name appears twice.
A cloned repository can't approve its own servers. enableAllProjectMcpServers committed in the project's .claude/settings.json is ignored in a folder you haven't trusted, and the server stays at ⏸ Pending approval. Run claude in the folder and accept the trust dialog first.
npx MCP servers on native Windows#
Older Claude Code versions warned that Windows needs a cmd /c wrapper to run npx. Version 2.1.119 (23 April 2026) removed that warning as a false positive, and the current MCP page doesn't mention a wrapper. Bug reports filed later on native Windows still show bare npx servers at Failed to connect, with spawn npx ENOENT or EINVAL. The reporters trace it to npx being a npx.cmd file, which Node refuses to start without a shell (issue 58510, issue 68221). Both were closed without a fix named in the changelog.
The workaround those reports give is to start cmd and pass npx as an argument:
{
"mcpServers": {
"context7": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@upstash/context7-mcp"]
}
}
}
Write it into .mcp.json by hand: a January 2026 report (issue 20061) found claude mcp add saving /c as C:/. Under WSL none of this applies: Claude Code runs as a Linux program there (Windows or WSL compares the two). Codex reads its servers from a different file and fails in its own ways; that is in Codex MCP server failed to start.
How Shuriken does it#
Shuriken keeps one list of MCP servers instead of a config per folder and per computer. In Global MCPs you add a server once, pick the projects it belongs to, and sign in to it once. Every chat in those projects is handed the server when it starts, in Claude Code, Codex or another agent, on any of your accounts, and the sign-in follows you, sealed, to your other computers. The sign-in belongs to the server, so switching accounts doesn't ask for it again. The list reaches chats you run in Shuriken; a claude you start in a terminal still reads its own config files, as it would without Shuriken.
The list also says, per server, whether it can run on the project's computer: Ready, Not starting with the error the server gave, Needs sign-in, Waiting for approval, Missing on that device when npx or another command isn't installed (with an Install button for the ones Shuriken knows how to install, such as Node and uv), or Needs a secret when a ${VAR} in its config is set nowhere on that device. Those readings come from the same claude mcp list health check and a test start of the server, never from a model call. If you want to try it, download Shuriken.
Sources
- Debug your configuration: Check MCP servers and common causes (Claude Code docs) (accessed 24 October 2026)
- Connect Claude Code to tools via MCP: server status, scopes, reconnection (Claude Code docs) (accessed 24 October 2026)
- CLI reference: --debug (Claude Code docs) (accessed 24 October 2026)
- Claude Code changelog: v2.1.119 and v2.1.284 (accessed 24 October 2026)
- GitHub issue 58510: Windows MCP servers using bare npx fail with spawn ENOENT (accessed 24 October 2026)
- GitHub issue 68221: Windows npx-based MCP servers fail to connect (spawn EINVAL) (accessed 24 October 2026)
- GitHub issue 20061: claude mcp add mangles the /c flag on Windows (accessed 24 October 2026)
- Model Context Protocol specification 2025-11-25: Transports (stdio) (accessed 24 October 2026)
Frequently asked questions
Why does claude mcp list say Failed to connect?
Claude Code started or called the server and got no working MCP connection back. Run claude mcp get with the server's name: since v2.1.219 it prints an Issue line with the status code or error text the server returned.
Why is my .mcp.json not loading in Claude Code?
It has to sit at the repository root, not inside .claude/, and list servers under mcpServers, not servers. A project server also waits for a one-time approval; if you dismissed the prompt, approve it from /mcp.
Can I put MCP servers in settings.json?
No. settings.json does not read an mcpServers key. Put project servers in .mcp.json at the repository root, or add your own with claude mcp add --scope user, which stores them in ~/.claude.json.
The MCP server is connected but Claude Code shows no tools. What now?
The server started but sent no tool list. Choose Reconnect in /mcp; if the count stays at zero, start claude --debug=mcp and read the server's stderr in ~/.claude/debug/<session-id>.txt.
Do npx MCP servers need cmd /c on Windows?
Anthropic's MCP page no longer says so, and v2.1.119 removed the warning that asked for it. Bug reports from May and June 2026 still show bare npx servers failing on native Windows, and wrapping the command in cmd /c is the fix those reports give.