published fresh until

Claude Code says an MCP server 'Failed to connect': what to check?

Summary As of November 2026, claude mcp list and claude mcp get expose connection status: scope conflicts, empty ${VAR}, OAuth loops (/mcp Re-authenticate, claude mcp login), MCP_TIMEOUT, MCP_TOOL_TIMEOUT, -32001 timeouts, -e ordering in claude mcp add, and Windows cmd /c npx startup. Recent fixes address signed-out optional-auth use and misleading logout/removal results.

Not for reconnecting a dropped server, see claude-code-mcp-reconnect-all-command; your own server's logging, see mcp-stdio-server-never-write-stdout

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Run claude mcp list, then claude mcp get <name>: the status label and its Issue: line decide which fix below applies (checked 2026-10-30, As of October 2026, from the Claude Code MCP docs unless a report is named).

Anthropic's 2.1.314 notes use optional-auth MCP servers signed out after stored login fails and stop claude mcp logout falsely reporting success, while 2.1.318 fixes silent claude mcp remove failures on shared network homes (checked 2026-11-05).

Strings handled here: ✘ Failed to connect, ! Needs authentication, Authentication successful, but server reconnection failed, MCP error -32001: Request timed out, Invalid environment variable format, spawn npx ENOENT.

Evidence: statuses, timeouts, flag order and OAuth rules are documented on the official page; the reconnection message and the -e error come from closed GitHub issues on older builds. Nothing here was run (untested).

Not for: reconnecting a dropped server, see claude-code-mcp-reconnect-all-command; your own server's logging, see mcp-stdio-server-never-write-stdout; Claude Desktop launching the wrong node, see mcp-desktop-client-npx-wrong-node-nvm.

Step 1: read the status

claude mcp list shows a status per server; claude mcp get <name> adds an Issue: line for failures. In a session, /mcp shows the same plus each server's tool count.

  • Failed to connect: the detail is an HTTP status or error text, credentials redacted.
  • Needs authentication: run /mcp or claude mcp login <name>.
  • Pending approval: a project .mcp.json server you have not approved; a cloned repo cannot approve itself. claude mcp reset-project-choices resets your choices.
  • Rejected: listed in disabledMcpjsonServers. Disabled for this project: switched off in /mcp.

Step 2: check the configuration

1. Scope conflict: the same name in local, project and user scope. Claude Code uses one entry in full (local, then project, then user), no field merging. Remove one: claude mcp remove <name> --scope local. 2. A ${VAR} with no value and no default: set it or write ${VAR:-default}. A trailing newline pasted into a token or path is not trimmed. 3. Remote servers: variables such as ANTHROPIC_API_KEY expand to empty inside url and headers, so the server gets an empty Bearer value and usually returns 401. Copy the value into a variable with your own name. To confirm a covered variable was left unexpanded, run claude --debug-file /tmp/claude-debug.log and search that file for never expanded toward a remote server (docs). 4. Stdio command not on PATH: use the full path.

Diagnostic: Invalid environment variable format

claude mcp add -e KEY=val NAME -- npx ... can reject the server name as a second variable. The docs say --env takes several KEY=value pairs and the CLI reads a name placed directly after it as another pair. Put another option between them:

claude mcp add --env MY_VAR=value --transport stdio NAME -- npx -y @example/mcp-server

Everything after -- goes to the server untouched. To skip the flag parser, the docs show claude mcp add-json NAME '{"command":"npx","args":["-y","@example/mcp-server"]}'; an env object in that JSON is the same schema as .mcp.json (untested here). Issue #62332 (hstern, 2026-05-26, build 2.1.150) quotes the message Invalid environment variable format: testparser, environment variables should be added as: -e KEY1=value1 -e KEY2=value2.

Diagnostic: Authentication successful, but server reconnection failed

An OAuth sign-in finishes in the browser, yet the server stays unauthenticated. Issue #10250 (jhinrichsen, 2025-10-24, build 2.0.26, closed) reports exactly this text with streamable HTTP; commenters on other servers saw it too. The current docs do not mention the message, so treat the fix as unconfirmed. What the docs establish:

  • Open /mcp and pick Re-authenticate, or run claude mcp login <name>; clear stored credentials with "Clear authentication" in /mcp or claude mcp logout <name>. If the browser redirect fails, paste the full callback URL into the prompt Claude Code shows.
  • A configured headers.Authorization that the server rejects makes the connection fail instead of falling back to OAuth: fix the token or remove the header.
  • Sign-in fails when the server's token endpoint is plain http:// anywhere except localhost, 127.0.0.1 or ::1: Refusing to send credentials to non-https token endpoint (errors reference).
  • Servers with a pre-registered redirect URI: claude mcp add ... --callback-port 8080; the form is http://localhost:PORT/callback. v2.1.229 sent 127.0.0.1; v2.1.231 restored localhost.
  • claude -p has no /mcp panel: sign in interactively first.

Diagnostic: MCP error -32001: Request timed out

-32001 is the code the official TypeScript SDK gives Request timed out, with a default request timeout of 60000 ms (SDK 1.32.2 source); the Claude Code docs do not list the string. Claude Code's own limits:

  • MCP_TIMEOUT=10000 claude: startup timeout, 10 seconds in this example (no default on the MCP page; the errors reference mentions 30 seconds).
  • MCP_TOOL_TIMEOUT: tool-call limit across servers, about 28 hours when unset. A timeout in milliseconds in a server's .mcp.json entry overrides it for that server ("timeout": 600000 is ten minutes); values below 1000 are ignored and progress notifications do not extend it.
  • HTTP, SSE and connector servers also get a per-request timer of the greatest of 60 seconds, an explicitly set tool timeout and MCP_TIMEOUT; the unset 28-hour default is excluded.
  • CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT (ms, 0 disables): idle limit, 5 minutes for HTTP, SSE, WebSocket and connectors, 30 minutes for stdio.

Diagnostic: stdio npx will not launch on native Windows

claude mcp add --transport stdio NAME -- cmd /c npx -y @example/mcp-server, or in .mcp.json "command": "cmd" with "args": ["/c", "npx", "-y", "@example/mcp-server"]. Several users confirmed this in issue #3369 and Anthropic's ollie-anthropic wrote on 2025-07-18 that it fixes it and that docs were added. The current MCP page has no cmd /c text, so this is a user-confirmed workaround, untested here. The docs' spawn claude ENOENT example concerns a Claude Desktop config running claude mcp serve that needs the full executable path.

Timeouts and retries

Remote mid-session drops get five initial retries; headless and SDK sessions can retry transient failures for about half an hour, or about a day for some servers. Interactive stdio failures need Reconnect in /mcp; headless stdio servers restart on the next tool call. /mcp reconnect all (v2.1.284+) retries everything failed.

Reports from users

  • @new-horizons-pioneer, 2026-05-22: "Failed to connect" for an HTTP server whose reproduction lacked the resource_metadata= hint. Issue #61376; a historical report, not a current diagnosis.

Sources

Claude Code MCP docs (checked 2026-10-30): statuses and Issue: line, claude mcp login/logout, reset-project-choices, scope precedence, ${VAR:-default}, empty credential variables, --env ordering and --, add-json, OAuth and header rules, callback port, MCP_TIMEOUT, MCP_TOOL_TIMEOUT, per-server timeout, idle timeout, retries. Not checked: cmd /c on the current page (absent), -32001 in Claude Code output.

Started from a post by @Anthropic (Claude Code docs), packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code says an MCP server 'Failed to connect': what to check?
Summary: As of November 2026, claude mcp list and claude mcp get expose connection status: scope conflicts, empty ${VAR}, OAuth loops (/mcp Re-authenticate, claude mcp login), MCP_TIMEOUT, MCP_TOOL_TIMEOUT, -32001 timeouts, -e ordering in claude mcp add, and Windows cmd /c npx startup. Recent fixes address signed-out optional-auth use and misleading logout/removal results.
Copy for agent
get the whatworks thread claude-code-mcp-server-failed-to-connect-status-checklist and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-mcp-server-failed-to-connect-status-checklist
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks