How to add MCP servers to Claude Code with claude mcp add, pick the right scope (local, project, user), and wire .mcp.json so your whole team shares the config.
Manager, Architect Technology at Cognizant
If you've typed claude mcp add for the first time and gotten a wall of flags, here's the short version: pick a transport (http for a hosted server, nothing extra for a local one), name the server, point it at a URL or a command, and decide who else should see it with --scope. That last part, scope, is the one people get wrong, because the default (local) is private to you and tied to the exact folder you ran the command from.
This walks through claude mcp add, the three scopes, and the .mcp.json file that ties a server config to your repo, based on Anthropic's current MCP docs.
claude mcp add actually do?It writes a server entry into a config file. That's it. The command doesn't install anything or start a process on the spot, it just registers how to reach the server next time Claude Code starts a session. For a hosted server you give it a transport and URL:
claude mcp add --transport http claude-code-docs https://code.claude.com/docs/mcp
Run claude mcp list right after and you might still see ✘ Failed to connect for a second. That's normal, Claude Code hasn't tried connecting yet when the "Added" message prints, it only confirms the entry got saved. Give it a moment and check again.
Local servers run as a subprocess on your machine, which is what you want for anything touching your filesystem, a local database socket, or a browser. The syntax uses a -- separator to split Claude Code's own flags from the command the server actually runs:
claude mcp add playwright -- npx -y @playwright/mcp@latest
Forget the -- and flag parsing breaks, because Claude Code can't tell where its options end and the server's command begins. We covered a full working example of this with Playwright MCP for browser testing if you want to see it end to end, including the test output it produces.
Stdio servers also default to a 30-second startup timeout, which the Playwright example can blow past on its first run while npx downloads the package. Bump it with MCP_TIMEOUT=60000 claude if that happens, then try claude mcp list again once the download finishes.
Scope decides two things: who else can see the server, and which file stores the config. Per Anthropic's docs, there are three:
| Scope | Flag | File | Who sees it |
|---|---|---|---|
| Local | default, or --scope local | ~/.claude.json, under this project's entry | Only you, only in this exact project folder |
| Project | --scope project | .mcp.json in the repo root | Anyone who clones the repo, after they approve it |
| User | --scope user | ~/.claude.json, top-level mcpServers key | Only you, in every project you open |
Local is the default for a reason, it's the safest place to drop something with a personal API key or a half-working config you're still testing. Project scope is the one worth thinking about before you use it, since it's version-controlled: commit .mcp.json and the next person who clones the repo gets prompted to approve each server the first time they run claude. That approval step matters. Don't skip it just because the prompt is annoying, it's the thing stopping a malicious .mcp.json from silently running a command on a teammate's machine.
Scope is fixed once you add the server. Want to move it? Remove and re-add at the new scope:
claude mcp remove claude-code-docs --scope local
claude mcp add --scope user --transport http claude-code-docs https://code.claude.com/docs/mcp
.mcp.json actually look like?It's a flat JSON object keyed by server name, under a top-level mcpServers key. Anthropic's docs give this example covering both an HTTP server and a stdio one in the same file:
{
"mcpServers": {
"claude-code-docs": {
"type": "http",
"url": "https://code.claude.com/docs/mcp"
},
"playwright": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"]
}
}
}
The type field isn't optional for a URL-based entry. Skip it on a hand-written server and Claude Code just quietly skips the whole entry at load time rather than erroring loudly, which is a fun way to lose an hour wondering why a server you swear you added isn't showing up in /mcp.
A few names are off-limits no matter which scope you use: workspace, claude-in-chrome, computer-use, Claude Preview, and Claude Browser are reserved for Claude Code's own built-ins. claude mcp add rejects those outright, and if you've hand-written one into .mcp.json, Claude Code skips it and warns you to rename it.
One thing worth flagging if you're setting this up for a team: .mcp.json only takes effect when Claude Code starts. Edit it mid-session and nothing happens until you exit and start a new one.
.mcp.json?Don't paste a raw API key into a file you're about to commit. Claude Code supports ${VAR} and ${VAR:-default} expansion inside command, args, env, url, and headers, so the committed file references an environment variable instead of the value itself:
{
"mcpServers": {
"api": {
"type": "http",
"url": "${API_BASE_URL:-https://dev.example.com}/mcp",
"headers": {
"X-API-Key": "${API_KEY}"
}
}
}
}
There's a gotcha here that catches people out: Claude Code reads certain variable names, like ANTHROPIC_API_KEY or AWS_BEARER_TOKEN_BEDROCK, as empty on purpose when they appear in a URL or header, because those are Claude Code's own credentials and letting an MCP server config read them would leak them straight to whatever that server logs. Copy the value into a differently named variable first if you need it for an MCP header.
For OAuth-backed servers like Sentry, Notion, or Linear, skip static tokens entirely. Add the server, then run /mcp inside a session, pick it from the list, and choose Authenticate, which opens a browser sign-in. A quick setup walkthrough for the mail side of this, connecting Gmail over MCP, is in our Gmail MCP setup guide if you want a worked example of the sign-in flow against a real service.
claude mcp list is the command you'll run constantly. It shows every registered server with a status: ✔ Connected, ! Needs authentication, ✘ Failed to connect, or ⏸ Pending approval for a project-scoped server you haven't signed off on yet. Run claude mcp get <name> for the full config and error detail behind any of those.
Rejected a project server by mistake and want the prompt back? claude mcp reset-project-choices clears your prior approvals and shows it again next launch. And if you want a server off without deleting its config, there's a lighter touch than removing it: toggle it from the /mcp panel, or add its name to a disabledMcpServers list in ~/.claude.json.
Removing is the same shape as adding:
claude mcp remove playwright
If the name exists at more than one scope, remove tells you so and asks for --scope to pick which copy goes.
Nine times out of ten it's one of three things. For an HTTP server, curl the URL directly (curl -I https://your-server-url) and read the response code: a 404 or 405 usually means the server's up but only answers POST, a 401 or 403 means you need to authenticate or your token's wrong, and no response at all means a network or URL problem. For stdio, run the exact command from your .mcp.json entry in your own terminal. If it starts and sits there waiting for input, the server itself is fine and the issue is in how Claude Code is calling it; if it errors, the error names what's missing.
The third cause is just scope. If /mcp says no servers at all, check you're in the same project folder where you ran claude mcp add, since local-scoped servers are tied to that exact directory. This is the single most common support question for MCP in Claude Code, by a wide margin.
One more thing worth knowing if you're troubleshooting against an older install: Anthropic has shipped several patches specifically to make these errors more readable. Before version 2.1.219, a failed HTTP connection only showed the bare "Failed to connect" with no status code attached. Before 2.1.299, some working HTTP servers still timed out at startup no matter how high you set MCP_TIMEOUT. If you're hitting either of those exact symptoms, update Claude Code before you spend an hour debugging a server that's actually fine.
.mcp.json, and make sure secrets are env-var references, not literalsFor more on wiring up specific servers once you've got the scope question sorted, our Claude Code skills guide covers the adjacent feature that lets a server ship its own usage instructions alongside its tools, so Claude doesn't have to guess how to call them.
Start with one server. The hosted docs server from the quickstart costs nothing to try, since it needs no auth and no local process. Get a feel for the add, list, remove loop with that before you wire in anything that touches real credentials or a production database.
New AI tools, automation workflows, and course drops — straight to your inbox. Join 2,400+ builders.
Google's Gmail and Drive MCP servers went GA on Nov 24, 2026. Here's how to wire Gmail MCP into Claude Code before the Feb 1, 2027 REST API throttling deadline.
Pinky is a free open-source MCP gateway from DIYgod that lets Claude Code or Codex control your real iPhone or Android phone with a human approval gate for risky actions.
Earshot is an open-source, CPU-only MCP server that gives Claude Code and other coding agents the ability to hear, score, and synthesize sound effects.
Comments