Claude Code MCP: how to add a server, which scope to use, and examples that work
Add an MCP server to Claude Code with claude mcp add: HTTP and stdio, local, project and user scope, .mcp.json, OAuth, limits, and working examples.
Add an MCP server to Claude Code with claude mcp add: a URL for a remote server, or a command after -- for a local one. It goes into your local scope unless you say otherwise; --scope project writes it to .mcp.json for the whole team, --scope user makes it available in every project. /mcp inside a session shows what connected and signs you in.
Add a remote MCP server (HTTP)
Most hosted servers speak HTTP. Give the transport, a name and the URL:
- 1
Add a remote server
- 2
Sign in to a server that uses OAuth, from inside a session
A server that takes a token instead gets it in a header — GitHub's, for one:
claude mcp add --transport http github \ https://api.githubcopilot.com/mcp/ \ --header "Authorization: Bearer YOUR_GITHUB_PAT"
SSE servers still work — --transport sse — but Anthropic marks SSE deprecated, and since 2.1.265 an http server that only speaks SSE falls back to it on its own. For OAuth, /mcp opens the browser; tokens are stored and refreshed for you, and Clear authentication in the same menu revokes them. Over SSH, claude mcp login <name> --no-browser.
Add a local MCP server (stdio)
A local server is a program Claude Code starts. Everything after -- is the command and its arguments, passed through untouched, so a server's own --port is not read as Claude Code's:
- 1
Playwright, a browser Claude can drive (needs Node 18 or later)
A server that needs an API key in its environment:
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio \ airtable -- npx -y airtable-mcp-server
A read-only Postgres connection through DBHub:
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \ --dsn "postgresql://readonly:pass@prod.db.com:5432/analytics"
--env takes several values, so a name right after it is read as one more variable. Put another option, such as --transport stdio, between the two, as above.
Claude Code MCP scopes: local, project or user
Local scope is the default; local and user scope are stored in ~/.claude.json, project scope in .mcp.json at the project root.
| Scope | Available in | Saved in |
|---|---|---|
| local, the default | this project, only you | ~/.claude.json, under the project |
| project | this project, everyone who clones it | .mcp.json in the repository |
| user | every project, only you | ~/.claude.json, at the top level |
--scope local, --scope project or --scope user. When two scopes define the same name, local wins over project, project over user. Whole entries are used, never merged. On Windows the file is %USERPROFILE%\.claude.json.Claude Code asks before it uses servers from a project's .mcp.json in an interactive session; claude mcp reset-project-choices asks again. Runs with -p and the SDK load them without asking — so read a repository's .mcp.json before you script against it.
.mcp.json and environment variables
A project file is plain JSON, safe to commit as long as the secrets stay in variables. ${VAR} and ${VAR:-default} expand in command, args, env, url and headers:
{ "mcpServers": { "api-server": { "type": "http", "url": "${API_BASE_URL:-https://api.example.com}/mcp", "headers": { "Authorization": "Bearer ${API_KEY}" } } } }
An unset variable with no default stays as written, with a warning. To add an entry without editing a file, claude mcp add-json <name> '<json>' takes the same JSON.
Manage your servers
| Command | What it does |
|---|---|
claude mcp list | every server and its state: connected, needs authentication, failed, pending approval |
claude mcp get <name> | one server's settings |
claude mcp remove <name> | removes it; add --scope for one scope |
claude mcp add-from-claude-desktop | imports Claude Desktop's servers, on macOS and WSL |
claude mcp serve | runs Claude Code itself as an MCP server, over stdio |
/mcp | in a session: status, sign-in, tools |
Limits and context cost
- Output: a tool result over 10,000 tokens shows a warning; the default maximum is 25,000. Raise it with
MAX_MCP_OUTPUT_TOKENS=50000. - Start-up:
MCP_TIMEOUTsets how long a server may take to start, 30 seconds by default;MCP_TIMEOUT=10000 claudesets 10. - Tool search is on by default: only tool names and server instructions load at the start, and full definitions come in when needed, so ten servers do not fill your context.
ENABLE_TOOL_SEARCH=falseloads everything up front;"alwaysLoad": trueexempts one server. - Resources and prompts: reference a resource as
@github:issue://123; a server's prompts appear as commands, such as/mcp__github__pr_review 456.
A company can fix the list in managed-mcp.json or allow and deny servers by URL or command; see Anthropic's managed MCP page.
What your MCP servers actually do
claude mcp list says a server is connected. It does not say whether Claude calls it, how often, or what those calls return. Each call is a tool named mcp__<server>__<tool> in the session's transcript.
On my machine, from 18 July to 4 October 2026, MCP tools made 6,554 of 97,002 tool calls in Claude Code — 7% — and one browser server made most of them. Read from Caprock's export, main threads and subagents together.
Caprock reads those calls from every session's transcript:
- Live: the Home screen describes a session calling one as "<tool> via <server>" while it happens.
- Kind of work: turns spent on MCP tools are a kind of work of their own, beside running commands, editing and reading, with what they cost.
- By tool: each MCP tool is its own row, shown as server·tool; opening one groups its calls by action.
Caprock adds no server to your setup on its own. It ships an optional, read-only one, caprock mcp, that lets Claude ask Caprock about earlier sessions, costs and CI: claude mcp add caprock -- caprock mcp. It records every session on the machine whether or not it started it; free, open source, nothing leaves your machine. Install Caprock.
Questions people ask
- How do I add an MCP server to Claude Code?
- Run claude mcp add --transport http <name> <url> for a remote server, or claude mcp add <name> -- <command> for a local one. Then check it with claude mcp list or /mcp.
- Where does Claude Code store MCP servers?
- Local and user scope go in ~/.claude.json; project scope goes in .mcp.json at the repository root, which you can commit.
- What is the difference between local, project and user scope?
- Local is this project, only you, and the default. Project is shared through .mcp.json. User is every project on your account. Local wins over project, project over user.
- How do I remove an MCP server from Claude Code?
- claude mcp remove <name>. Add --scope local, project or user to remove it from one scope only.
- Why is my MCP server's output cut off?
- Claude Code caps MCP output at 25,000 tokens by default and warns above 10,000. Set MAX_MCP_OUTPUT_TOKENS higher to raise the cap.
Sources
- Claude Code docs — Connect Claude Code to tools via MCP, read 20 October 2026
- Claude Code docs — MCP quickstart, read 20 October 2026
- Claude Code docs — Managed MCP, read 20 October 2026
- Claude Code docs — CLI reference (--mcp-config, MCP_TIMEOUT), read 20 October 2026
- Playwright MCP — README, read 20 October 2026
- Caprock source — MCP calls as their own kind of work (internal/store/workkind.go)
- Caprock source — "<tool> via <server>" in a session's live state (internal/narrate/narrate.go)
- Caprock docs — caprock mcp, the read-only MCP server (0.135.0)
Try it
The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.
Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.
Or run it yourself:
Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app