GuidesHosting choices

Claude Code MCP servers: claude mcp add, scopes and /mcp

Add MCP servers to Claude Code with claude mcp add: which file each scope writes, approving .mcp.json, OAuth over SSH, env variables, timeouts and fixes.

November 23, 2026The Everpod team
The short answer

Add servers from your shell with claude mcp add: claude mcp add --transport http <name> <url> for a remote server, and claude mcp add <name> -- <command> for a local one that Claude Code starts itself, with everything after -- passed to the server untouched. With no --scope the server is saved at local scope, in ~/.claude.json under the current project and for you alone; --scope user saves it in the same file for all your projects, and --scope project writes .mcp.json at the project root, which you commit and each person approves once. claude mcp list connects to each server and prints ✔ Connected, ! Needs authentication or ✘ Failed to connect with the server’s error. Inside a session, /mcp shows each server’s tools, signs in to servers that use OAuth, and turns servers off or reconnects them; claude mcp login <name> does the sign-in from the shell, over SSH too. This is Claude Code 2.1.330, the npm release of 20 November 2026.

Adding a server from a URL, a command or a JSON block

A server’s setup instructions are often written for Claude Desktop, Cursor or another client and give no claude mcp add line. Anthropic’s MCP reference says to look in them for a URL, a launch command or an mcpServers block, and each has its command. Run them in your shell, not inside a claude session.

# a URL: a remote server over HTTP (this one needs no sign-in)
claude mcp add --transport http claude-code-docs https://code.claude.com/docs/mcp

# a launch command: a local server, started by Claude Code over stdio
claude mcp add airtable --env AIRTABLE_API_KEY=YOUR_KEY -- npx -y airtable-mcp-server

# an mcpServers block from another client: the object inside it, not the wrapper
claude mcp add-json example '{"command":"npx","args":["-y","@example/mcp-server"]}'
Copied

Success prints Added HTTP MCP server claude-code-docs with URL: https://code.claude.com/docs/mcp to local config and a File modified: line naming the file. That means the entry was saved, not that the server works: add doesn’t check credentials, so a placeholder key is accepted and fails at the first connection.

Which file each scope writes

ScopeHow to pick itSaved inLoads
local, the default
no flag, or --scope local~/.claude.json, under projects and this project’s pathIn this project, for you
user
--scope user (-s user)~/.claude.json, in the top-level mcpServersIn every project, for you
project
--scope project.mcp.json at the project rootFor everyone with the repository, once each approves it

Of the two files, .mcp.json is the one worth writing by hand, since it is committed. Every scope uses the same entry shape:

{
  "mcpServers": {
    "claude-code-docs": {
      "type": "http",
      "url": "https://code.claude.com/docs/mcp"
    },
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@playwright/mcp@latest"]
    }
  }
}
Copied

Claude Code reads it when a session starts, so restart after editing it. Before 2.1.327, claude mcp add and remove at project scope deleted other top-level keys from the file, such as $schema.

Checking that it connected

claude mcp list connects to each server and prints one of these beside it; the last three are read from your settings without connecting:

StatusWhat it means
✔ Connected
Ready to use
! Connected · tools fetch failed
It connected but couldn’t list its tools; claude mcp get name gives the error
! Needs authentication
It answered and wants a sign-in, or a token you haven’t given it
✘ Failed to connect
Followed by the HTTP status or error code and whatever text the server sent back
✘ Connection error
The attempt threw an error; no detail is shown
⏸ Pending approval (run `claude` to approve)
A .mcp.json server you haven’t approved yet
⊘ Disabled for this project (re-enable via /mcp)
Turned off for this project
✘ Blocked by enterprise managed policy
Your organization’s policy refuses it

A failure there is the server’s, not the command’s. The first check of an npx server can fail while the package downloads, so run it again before digging. Inside a session, /mcp lists the same servers with a tool count beside each connected one; select a server to see its tools and to authenticate, reconnect or disable it. /mcp reconnect name, or /mcp reconnect all since 2.1.284, retries without opening the panel. An interactive session doesn’t restart a stdio server whose process died; it marks it failed until you reconnect it there.

Using a connected server needs nothing more: Claude picks its tools when a task calls for them, and may ask your permission the first time it calls one. A server’s resources are mentioned like files, as @server:protocol://resource/path, and its prompts appear in the / menu as /servername:promptname (MCP).

Signing in to a server that uses OAuth

Services such as Sentry, Linear and Notion put their MCP servers behind OAuth. Add the URL with no header, and claude mcp list shows ! Needs authentication; then, in a session, open /mcp, select the server, choose Authenticate, and approve in the browser that opens. If the browser’s redirect fails after you sign in, paste the full callback URL from its address bar into the prompt Claude Code shows.

From the shell, claude mcp login name runs the same flow, and on a server it is the easier route. Per the command-line sign-in docs, it notices when there is no local browser, over SSH or on Linux with no display, and prints the authorization URL instead. Open it on your own computer, sign in, and paste the full redirect URL from the address bar back at the prompt. The paste needs an interactive terminal, so connect with ssh -t; --no-browser forces the printed URL even where a browser is found.

A key in a header and OAuth don’t mix: when a server rejects an Authorization header you configured, Claude Code reports the connection as failed, not as needing authentication, and doesn’t fall back to OAuth. Remove the header to sign in with OAuth instead.

What a local server sees, and variables in the config

A stdio server inherits the environment Claude Code was started from. The environment variables reference describes CLAUDE_CODE_MCP_ALLOWLIST_ENV=1 as the switch that gives it “only a safe baseline environment plus the server’s configured env, instead of inheriting your shell environment,” and CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 strips credentials from it, from Bash commands and from hooks. So by default a key exported in your shell, or in the tmux session you run Claude Code in on a server, reaches every local server you add, and a key a server can’t find has to be in the environment that started claude, or in the entry’s env. Codex works the other way round and passes a local server only a short list, as the Codex MCP guide shows. Claude Code also sets CLAUDE_PROJECT_DIR to the project root in the server’s environment.

An entry can read variables in its command, args, env, url and headers, as ${VAR} or ${VAR:-default}, which is how a committed .mcp.json carries no secrets:

{
  "mcpServers": {
    "api-server": {
      "type": "http",
      "url": "${API_BASE_URL:-https://api.example.com}/mcp",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    }
  }
}
Copied

claude mcp list, get and the /mcp detail view print a reference by its name, never its value.

Approving a project’s .mcp.json servers

A .mcp.json in a repository asks every clone to run its servers, so an interactive session asks before using them. Your answer is written to .claude/settings.local.json as one of three settings: enabledMcpjsonServers lists the servers you approved, enableAllProjectMcpServers: true approves every one, and disabledMcpjsonServers lists the ones you rejected. A rejection wins over both approvals, in any settings file, a committed .claude/settings.json included. To be asked again, run claude mcp reset-project-choices and restart.

Approvals committed to the repository count only once you trust the folder. Until you have run claude there and accepted the trust dialog, an approval committed to the project’s .claude/settings.json is ignored, and the server stays at ⏸ Pending approval: “A cloned repository can’t approve its own servers.” Approvals in your own ~/.claude/settings.json, in managed settings or in a --settings file still apply there.

Some sessions never ask. claude -p runs, Agent SDK sessions and cloud sessions (other than the threads of a Project on Claude Code on the web) load project servers without asking, and so does a session started in bypassPermissions with skipDangerousModePermissionPrompt in your user or managed settings. To keep a server out of those, the project scope docs give three ways: name it in disabledMcpjsonServers, leave project settings out with --setting-sources, or start with --strict-mcp-config, which loads only what --mcp-config names.

Turning servers and tools off

Time, output and context limits

Values from the time limits and output limits sections. Times are in milliseconds, and the variables go in the shell that starts Claude Code.

LimitDefaultTo change it
A server’s startup
30 secondsMCP_TIMEOUT=60000 claude
One tool call, start to finish
About 28 hoursMCP_TOOL_TIMEOUT, or "timeout" in milliseconds on the server’s entry (below 1000 is ignored)
Each request to an HTTP or SSE server, until its first byte
60 secondsRaised by a per-server timeout, MCP_TOOL_TIMEOUT or MCP_TIMEOUT above 60000; never lowered
A call with no response and no progress
5 minutes remote, 30 minutes stdioCLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT (0 turns it off); a per-server timeout also sets a floor
A long call moved to the background
After 2 minutes, main conversation onlyCLAUDE_CODE_MCP_AUTO_BACKGROUND_MS (0 turns it off)
A result kept in the conversation
25,000 tokens, with a warning past 10,000MAX_MCP_OUTPUT_TOKENS
A text result kept in the conversation
50,000 charactersOnly the server, per tool, up to 500,000
One HTTP or SSE response
16 MiB, then the request failsOnly the server, by returning less

A result over the token or character limit isn’t lost: it is saved to a file in the session’s tool-results folder under ~/.claude/projects/, and Claude is given the path to read it. Error text from a tool is cut differently: past about 11,000 characters, Claude gets the first 5,000 and the last 5,000. For a slow tool on a remote server, the per-server timeout is the one setting that lifts the 60-second request timer and the idle window together; it is also that server’s hard limit per call.

Many servers cost little context. Tool search is on by default, so a session starts with only each tool’s name and each server’s instructions, and a tool’s full definition loads when Claude looks for it; Anthropic says there is no fixed cap on tools per server. A server whose tools Claude needs on every turn can skip the search with "alwaysLoad": true on its entry, which loads all its tools up front and also makes startup wait for that server for up to five seconds. ENABLE_TOOL_SEARCH=false loads every tool up front instead, and ENABLE_TOOL_SEARCH=auto does so until the definitions reach 10% of the context window.

In claude -p, on a server and in scheduled jobs

The rest of running Claude Code on a timer, including what a -p run trusts without asking, is in Claude Code headless on a schedule.

When a server won’t work

What you seeUsual cause, and the fix
/mcp lists no servers
Added from another project at local scope, written to a file Claude Code doesn’t read, or a malformed entry, which is skipped: claude mcp list names the field in a parse warning
✘ Failed to connect with 401 or 403
The key in your header is wrong or isn’t valid for that endpoint, or the header reads a variable Claude Code empties, such as ANTHROPIC_API_KEY
MCP endpoint not found at <origin>. Check the URL in your MCP config.
A 404: the path is wrong. claude mcp get name shows the full URL; remove the server and add it with the documented path
✘ Connection error, or no detail
For a remote server, curl -I <url>: a 404 or 405 means it is up (many endpoints accept only POST), 401 or 403 means it wants a sign-in, nothing means the URL or the network
A stdio server fails
Run its command yourself. If it starts and waits, compare it with claude mcp get name; a different command means the -- was left out
Connection timed out at startup
Often npx downloading on first run: MCP_TIMEOUT=60000 claude
Connected, but no tools
Usually a missing variable such as an API key; add it with --env or the entry’s env
MCP server sentry already exists in local config
Remove it first, or pick another name; with exists in multiple scopes, add --scope to the remove
Edits to .mcp.json don’t show
Restart the session; if you rejected the server before, claude mcp reset-project-choices
A tool in /mcp that Claude never calls
Its full name, mcp__<server>__<tool>, is over 128 characters and is left out; give the server a shorter name
"workspace" is a reserved MCP server name and was not loaded
Rename it; Claude Code reserves its built-in servers’ names, among them claude-in-chrome, computer-use, Claude Preview and Claude Browser
MCP server "example" was not saved to /home/user/.claude.json
Another Claude Code process may have kept the file locked past the 10 to 20 seconds the command waits: run the add again with CLAUDE_CODE_CONFIG_LOCK_WAIT_MS=60000 (2.1.318 or later). Or the file is read-only or inside a sandbox: make it writable, or run the command outside the sandbox
MCP server "<name>" needs you to sign in again (run /mcp to re-authenticate)
The sign-in expired or was revoked: Authenticate again from /mcp

Claude Code as an MCP server

The other direction exists too. claude mcp serve runs Claude Code as a stdio MCP server that another client, such as Claude Desktop, connects to with "command": "claude" and "args": ["mcp", "serve"]. It prints nothing when it starts, because it is waiting on standard input. If claude isn’t on the client’s PATH, give the full path from which claude or the client fails with spawn claude ENOENT. It exposes only Claude Code’s tools, and asking you to confirm each tool call is left to your client. What a server is on either side of the protocol, and what to check before trusting one, is in what an MCP server is.

Run Claude Code on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.