Claude Code MCP Server Failed to Connect? How to Fix It

You add an MCP server, start Claude Code, and the tools you wanted aren’t there. Run /mcp and the server sits next to a red Failed to connect. When Claude Code MCP failed to connect errors show up, the message itself is vague, but the cause is almost always one of a handful of things: a command that isn’t on your PATH, the wrong scope, a slow start, a server waiting for approval, or missing authentication. Here’s how to find which one.

Step 1: get the real error

Start outside the session, in your terminal:

claude mcp list

Each server gets a status. The ones to know are Connected, Needs authentication, Failed to connect and Pending approval. A failed server usually shows a reason on the same line. For more detail on one server, ask for it by name:

claude mcp get my-server

This shows the server’s scope, its command or URL, and any error. Read it before changing anything, because the fix depends entirely on what it says. If your version of Claude Code only shows a bare status with no reason, update it first with claude update; newer releases give more detail.

Command not found (ENOENT)

For a local stdio server, Claude Code runs the command you gave it, such as npx, uvx, node or python. If that command isn’t on the PATH Claude Code sees, the server can’t start. This is the single most common cause.

  • Check the command works in a fresh terminal: which npx or which uvx
  • If it only works in some shells, it’s probably set up in a file like .zshrc that isn’t loaded everywhere. Use the full path in the server config instead, for example /opt/homebrew/bin/npx
  • If you use a Node version manager, the path can change when you switch versions, so the full path is safer
  • On native Windows (not WSL), servers started with npx are usually wrapped in cmd /c

Remember the -- when adding a stdio server. Everything before it is for Claude Code, everything after it is the server’s own command:

claude mcp add my-server --env API_KEY=abc123 -- npx -y some-mcp-package

If claude itself isn’t found, that’s a different problem: see Claude Code command not found.

The server is in the wrong scope

MCP servers live in one of three scopes, and a server added in one place won’t appear in another:

  • local (the default): only for you, only in this project. Stored in ~/.claude.json under the project’s path
  • project: shared with everyone through a .mcp.json file in the project root
  • user: for you, in every project. Also stored in ~/.claude.json

If a server works in one folder and vanishes in another, you probably added it with the default local scope. Remove it and add it again with --scope user. If the same name exists in several scopes, the most specific one wins in full, so an old local entry can hide a working user-scope one. claude mcp get tells you which scope it’s reading.

It’s waiting for approval

Servers from a project’s .mcp.json need your approval the first time you run Claude Code interactively in that project, because the file could come from anyone who can commit to the repo. Until you approve, the status reads Pending approval. Start claude in the project and accept the prompt. If you declined by mistake, clear your earlier choices and start again:

claude mcp reset-project-choices

It times out on startup

Some servers do a lot of work before they’re ready: downloading a package with npx -y, starting a container, or loading a big index. If startup takes longer than Claude Code waits, it gives up. Raise the limit with MCP_TIMEOUT, in milliseconds:

MCP_TIMEOUT=60000 claude

A better long-term fix is to install the package once, globally or in a virtual environment, and point the config at it, so nothing has to download on every start. Tool calls that run too long are a separate limit, set with MCP_TOOL_TIMEOUT or a per-server timeout in .mcp.json.

Remote servers: URL and authentication

For an HTTP server, the URL has to answer and you have to be allowed in. Claude Code retries the first connection a few times on transient errors, then marks the server as failed. Check the URL in a browser or with curl. If the status says Needs authentication, run /mcp inside Claude Code and choose the server to log in, or run claude mcp login my-server. For servers that take an API key, pass it as a header:

claude mcp add --transport http my-api https://example.com/mcp --header "Authorization: Bearer $MY_TOKEN"

Inside .mcp.json you can use ${VAR} or ${VAR:-default} to read values from your environment instead of committing secrets. If the variable isn’t set, the literal text is used and the server fails, so check it’s exported.

Reconnect without restarting

Once you’ve fixed the cause, you don’t have to quit. A stdio server that failed to start stays failed until you reconnect it, so open /mcp, pick the server and reconnect. If you suspect a plugin or hook is getting in the way rather than the server itself, claude --safe-mode starts Claude Code without them so you can compare, and /doctor checks the rest of your setup.

Quick checklist

  1. Run claude mcp list and claude mcp get <name> and read the error
  2. Make sure the server’s command runs in a fresh terminal, or use its full path
  3. Check the scope: local, project or user
  4. Approve project servers, or run claude mcp reset-project-choices
  5. Raise MCP_TIMEOUT for slow starters
  6. Log in through /mcp for servers that need authentication

Once your servers connect, keep an eye on what you let them do. Is Claude Code safe? covers MCP permissions, and the Claude MCP hub lists servers worth trying.


Leave a Reply