Adding MCP Servers to Claude Code: Local, Remote, and Project-Scoped
The complete claude mcp add reference — stdio vs HTTP transports, local/project/user scopes, .mcp.json with env expansion, OAuth via /mcp, and the gotchas.
Connect an MCP server to Claude Code with one command: claude mcp add <name> -- <command> for local stdio servers, or claude mcp add --transport http <name> <url> for hosted ones. Pick a scope (--scope local, project, or user), authenticate remotes with OAuth via /mcp, and commit .mcp.json so your whole team gets the same servers.
Steps at a glance
- Pick the transport. Use stdio for a server that runs on your machine as a child process (most npx/uvx servers), and Streamable HTTP for a hosted remote server the vendor operates (a URL like https://mcp.linear.app/mcp).
- Choose the scope. Default local keeps the server personal to this project. Use --scope project to write it to a committed .mcp.json the whole team shares, or --scope user to have it in every project you open.
- Add the server. Local: claude mcp add <name> --env KEY=value -- <command and args>. Remote: claude mcp add --transport http <name> <url>, with --header for token auth if the server doesn't use OAuth.
- Authenticate if it's remote. Inside a session, run /mcp, select the server, and choose Authenticate to complete the browser OAuth flow. Tokens are stored securely and refreshed automatically.
- Verify it connected. claude mcp list shows every configured server with connection status; /mcp shows status and tool counts in-session. A server that's added but not connected has given you nothing yet.
- Scope what it may do. MCP tools participate in permissions as mcp__<server>__<tool>. Allow the specific tools you want friction-free, and deny write-capable tools on servers you only need to read from.
Key takeaways
- Two transports cover everything: stdio for local child-process servers (claude mcp add name -- npx -y some-server) and Streamable HTTP for hosted ones (--transport http + URL). SSE is deprecated.
- Three scopes: local (just you, this project — the default), project (committed to .mcp.json, whole team), user (just you, every project).
- Remote servers authenticate with OAuth: add the server, run /mcp, pick it, and complete the browser flow — tokens are stored and refreshed automatically.
- .mcp.json supports ${VAR} and ${VAR:-default} expansion in commands, URLs, env, and headers, so secrets stay out of the committed file.
- MCP tools obey the permission system as mcp__server__tool, and server output is capped (~25k tokens by default) — an MCP server is code you're trusting, so vet it like a dependency.
MCP servers are how Claude Code reaches beyond your filesystem — into GitHub, your database, your issue tracker, a headless browser, your docs. The protocol is open, the ecosystem is in the thousands of servers, and wiring one up is a single command. The decisions that actually matter are the transport, the scope, and how much you trust the thing — this guide covers all three.
One command, two transports
Local (stdio) servers run on your machine as a child process Claude Code launches. This is most open-source servers — anything you'd run with npx, uvx, or docker run:
# the -- separator is critical: everything after it is the server's own command
claude mcp add postgres --env DATABASE_URI="postgresql://localhost:5432/mydb" \
-- uvx postgres-mcp --access-mode=restrictedRemote (HTTP) servers are hosted by the vendor — nothing runs on your machine, and auth is usually OAuth:
claude mcp add --transport http linear https://mcp.linear.app/mcp
claude mcp add --transport http notion https://mcp.notion.com/mcpIf a remote server takes a token instead of OAuth, pass it as a header: claude mcp add --transport http --header "Authorization: Bearer <token>" name url. You'll also see --transport sse in older docs — SSE is deprecated; prefer HTTP wherever the vendor offers it.
Manage what you've added with claude mcp list (with connection status), claude mcp get <name>, and claude mcp remove <name>.
Scopes: who gets the server
| Scope | Stored in | Who sees it |
|---|---|---|
local (default) | ~/.claude.json (this project's entry) | You, this project only |
project | .mcp.json at the repo root — committed | Everyone who clones the repo |
user | ~/.claude.json (global) | You, every project |
The team play is project scope. A committed .mcp.json means "these are this repo's integrations" — new teammates get them on clone, and Claude Code asks each person to approve the file's servers before their tools activate (you'll see them as pending in /mcp until then).
Secrets stay out of the committed file via environment expansion — .mcp.json supports ${VAR} and ${VAR:-default} in command, args, env, url, and headers:
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp",
"headers": { "Authorization": "Bearer ${GITHUB_PAT}" }
}
}
}Each teammate exports GITHUB_PAT their own way; the repo never holds a token.
Authentication: the /mcp flow
Hosted servers that return a 401 want OAuth. The flow is built in: run /mcp inside a session, select the server, choose Authenticate, and finish in the browser. Claude Code stores the token securely and refreshes it automatically. /mcp is also your status panel — per-server connection state, tool counts, and reconnects live there.
What a connected server actually gives you
Three things, not one:
- Tools — the headline feature. They appear to the model as
mcp__<server>__<tool>and participate in the permission system under exactly that name, so you can allowmcp__github__get_issuewhile denyingmcp__github__*writes. - Resources — reference server data inline with
@server:resourcementions (e.g.@github:issue://123), fetched and attached to your prompt. - Prompts — servers can ship reusable prompts that surface as slash commands:
/mcp__github__list_prs.
Two operational limits worth knowing: server startup has a timeout (raise with MCP_TIMEOUT=60000 claude for slow Docker-based servers), and tool output is capped — about 25k tokens by default, configurable via MAX_MCP_OUTPUT_TOKENS — so a tool that dumps a whole database will get truncated, by design.
Trust is the real configuration
An MCP server is code that runs with the credentials you hand it, feeding text straight into your agent's context. That has two failure modes: a malicious or compromised server (supply chain), and a legitimate server returning attacker-controlled content (prompt injection — a web-fetching tool reading a hostile page). So:
- Vet provenance before adding — prefer official vendor servers and well-known projects; read the source of small community ones. The Add MCP Server command walks this checklist, and MCP Inspector lets you poke a server's tools directly before trusting it in a session.
- Scope credentials down — read-only tokens and modes where offered; many servers ship them precisely for this.
- Don't hoard servers — every connected server's tool definitions ride along in context. Keep the per-project set tight, and disable ones you're not using (the
enableAllProjectMcpServerssetting auto-approves a repo's full set — convenient, but understand what you're signing).
TIP
Not sure which servers are worth connecting? Start with the best MCP servers in 2026 — the short list that covers docs, GitHub, browsers, and databases for most developers.
Building your own server instead of consuming one? Start with Building an MCP Server, then deploy it remotely when the team needs it — and once you're running more than a handful, governance becomes the next problem.
Frequently asked questions
- How do I add an MCP server to Claude Code?
- Run claude mcp add. For a local stdio server: claude mcp add my-server --env API_KEY=... -- npx -y some-mcp-server. For a hosted remote server: claude mcp add --transport http linear https://mcp.linear.app/mcp, then authenticate with /mcp inside a session. The -- separator matters: everything after it is the server's own launch command.
- Where does Claude Code store MCP server configuration?
- Local- and user-scoped servers live in ~/.claude.json (per-project entries for local scope, a top-level mcpServers key for user scope). Project-scoped servers live in a .mcp.json file at the repo root, designed to be committed so teammates get the same servers.
- What's the difference between local, project, and user scope?
- Local (default): only you, only in this project — right for experiments and personal credentials. Project: written to .mcp.json, checked in, shared with everyone who clones the repo; each teammate approves it before its tools activate. User: only you, but in every project — right for personal utilities like a notes or search server.
- How do I authenticate a remote MCP server?
- Most hosted servers use OAuth: add the server, run /mcp, select it, and choose Authenticate — a browser window completes the flow, and Claude Code stores and auto-refreshes the token. For servers that take API keys instead, pass a header at add time: claude mcp add --transport http --header "Authorization: Bearer <token>" name url.
- Why isn't my MCP server connecting?
- Run claude mcp list to see status. The usual causes: the launch command isn't on PATH (test it standalone first), a required env var is missing (--env KEY=value), a slow server tripping the startup timeout (raise it with MCP_TIMEOUT=60000 claude), or a project-scoped server still pending approval — check /mcp.
Related
- The Best MCP Servers in 2026The MCP servers actually worth connecting in 2026 — Context7, GitHub, Chrome DevTools, Playwright, Serena, Exa, Firecrawl, and the best official vendor servers, by use case.
- Building an MCP ServerAn accurate introduction to the Model Context Protocol: server anatomy, transports, and connecting a tool to Claude Code.
- Deploying a Remote MCP Server: Stateless, Streamable HTTP, and Horizontal ScalingTake an MCP server from local stdio to a remote, multi-user HTTP service — Streamable HTTP, stateless vs. stateful sessions, OAuth, and horizontal scaling.
- Connecting and Governing MCP Servers: Registries, Gateways, and Tool SprawlAs MCP servers multiply, discovery, trust, and tool sprawl become the problem. How registries, gateways, and curation keep a growing fleet secure and usable.
- Add MCP ServerAdd an MCP server to the current project the safe way — pick the transport and scope, wire secrets through env vars, vet provenance, and verify the connection before trusting it.
- MCP InspectorThe official open-source visual tool for testing and debugging Model Context Protocol servers — connect, list, and call tools, resources, and prompts.
- Claude Code Troubleshooting: Fixes for the Most Common ProblemsPractical fixes for the Claude Code issues people actually hit — install and auth failures, context-limit errors, MCP servers that won't connect, permission loops, and CI quirks.
- Claude Code Settings & Permissions: settings.json ExplainedEvery Claude Code settings file and which one wins, the permission-rule syntax with its Bash matching gotchas, permission modes, and a safe starter settings.json.
- Context7Upstash's MCP server that pulls up-to-date, version-specific library documentation into your agent's context — the cure for hallucinated APIs.
- Github MCP ServerGitHub's official MCP server — repos, issues, PRs, Actions, and security data for your agent, as a free hosted remote or a local Docker server.
- Claude Settings AuditorAudit every Claude Code settings layer — user, project, local, and managed — and report the effective merged configuration with its risks: over-broad Bash allows, missing deny rules for secrets, bypassPermissions defaults, unvetted MCP servers and hooks, and rules that never match. Use before trusting a new repo's checked-in settings, or to harden your own before handing the agent more autonomy.
- Plugin ScaffolderScaffold a complete, valid Claude Code plugin from a description — the .claude-plugin/plugin.json manifest, component directories (skills, agents, commands, hooks, MCP config), portable ${CLAUDE_PLUGIN_ROOT} wiring, a local test loop with --plugin-dir, and a marketplace.json for distribution. Use when turning scattered .claude/ customizations into one installable, versioned package.
- Running Claude Code in CI: Headless Mode & GitHub ActionsClaude Code without the terminal — claude -p flags, JSON and structured output, safe permission scoping, and the official GitHub Action responding to @claude.
- Claude Code Plugins: Install, Use, and Build Your OwnHow Claude Code plugins work — what they can bundle, the /plugin and marketplace commands, the plugin.json manifest, and building and testing your own.
- 25 Claude Code Tips, Shortcuts, and Power FeaturesThe 25 highest-leverage Claude Code tips — keyboard shortcuts, bash and memory shortcuts, session commands, model tricks, and the power features most people miss.
- MCP Ecosystem Statistics 2026The Model Context Protocol by the numbers — SDK downloads, server counts across registries, governance facts, and growth since the Linux Foundation donation.
- MCP vs A2A: AI Agent Protocols ExplainedWhat MCP and A2A each standardize, how Agent Cards and Tasks work, why the protocols are complementary — and who governs them now (spoiler: both are Linux Foundation).
- MCP Troubleshooting: Server Won't Connect & Other FixesFixes for the MCP problems people actually hit — servers failing to connect, missing tools, OAuth loops, timeouts, truncated output, and Windows quirks.
- Chrome DevTools MCPGoogle's official MCP server that gives coding agents a live Chrome — Puppeteer automation plus DevTools network, console, and performance insights.
- Cloudflare MCPCloudflare's official MCP servers — a Code Mode server covering 2,500 API endpoints in ~1k tokens, plus hosted servers for docs, Workers, and observability.
- ExaThe search engine built for AIs — semantic web search, page contents, Websets, and research APIs, plus the ecosystem's most-used search MCP server.
- Figma MCPFigma's official MCP server — structured design context, variables, screenshots, and Code Connect mappings for agents, plus write-back to the canvas.
- FirecrawlThe API to search, scrape, and crawl the web for AI — clean Markdown out of any site, LLM-powered extraction, and a first-class MCP server.
- Linear MCPLinear's hosted MCP server — find, create, and update issues, projects, and comments from your AI agent, with OAuth and one-command setup.
- Notion MCPNotion's hosted MCP server — search the workspace, fetch and create pages and databases, and manage comments through Markdown-optimized agent tools.
- Postgres MCP ProThe maintained Postgres MCP server — safe SQL execution, EXPLAIN with hypothetical indexes, workload-driven index tuning, and database health checks.
- Sentry MCPSentry's hosted MCP service for debugging — pull issues, events, traces, and releases into your agent, and trigger Seer root-cause analysis.
- Sequential Thinking MCPThe official MCP reference server for structured reasoning — a sequential_thinking tool that lets agents decompose, revise, and branch their thinking.
- SerenaAn MCP toolkit that gives coding agents IDE-grade powers — symbol-level retrieval and editing via language servers, across 40+ languages.
- Slack MCP ServerThe community-canonical Slack MCP server — smart history fetch, message search, channels, reactions, and opt-in posting, after the official server was archived.
- Stripe MCPStripe's official MCP server — customers, invoices, payment links, subscriptions, refunds, and docs search for agents, hosted at mcp.stripe.com.
- Supabase MCPSupabase's official MCP server — run SQL and migrations, read logs and advisors, generate types, and deploy Edge Functions, with read-only and project scoping.
- TavilyThe web-access layer for agents — Search, Extract, Crawl, Map, and Research APIs purpose-built for LLMs, behind one key, with a hosted MCP server.
- MCP (Model Context Protocol)MCP is the open standard for connecting AI models to external tools and data: write one server, and any MCP client — Claude Code, IDEs, agents — can use it.