Operations & Gateways
Add MCP Servers to Claude Code: The claude mcp add Guide
By MCP Beast·
claude mcp add is the command that registers an MCP server with Claude Code. One command writes one entry into a configuration file, and the flags you choose decide how Claude Code reaches the server, where the entry is stored and who else sees it. This guide covers the command as Claude Code's MCP documentation describes it, then looks at when adding a single router endpoint is a better fit than adding many servers one by one.
Everything below about Claude Code comes from that documentation. Flags and version requirements change between releases, so check claude mcp add --help on your installed version. Example names and URLs are placeholders, not recommendations.
Choose the transport first
Every claude mcp add command answers one question: how does Claude Code talk to this server? The documentation gives four options.
| Transport | How you add it | When it fits |
|---|---|---|
| HTTP | claude mcp add --transport http <name> <url> | A remote server. The documentation calls HTTP the recommended option for remote servers |
| SSE | claude mcp add --transport sse <name> <url> | A remote server that only exposes an SSE endpoint. The documentation marks SSE as deprecated |
| stdio | claude mcp add [options] <name> -- <command> [args...] | A process that runs on your machine |
| WebSocket | claude mcp add-json or .mcp.json | A remote server that pushes events. --transport does not accept ws |
For the protocol-level differences, see MCP stdio vs SSE vs HTTP.
Add a remote HTTP server
claude mcp add --transport http <name> <url>
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
The --header flag attaches a static header to every request. The documentation notes that a server whose Authorization header you configured is not sent through OAuth: if that header is rejected, Claude Code reports the connection as failed rather than falling back to sign-in. For an endpoint that supports OAuth, leave the header off.
For a server that only speaks SSE, the documentation says the same --transport http command first tries HTTP and then switches to SSE when the server does not accept it, from Claude Code v2.1.265. On an earlier version, or to force it, pass --transport sse.
Add a local stdio server
claude mcp add --env API_KEY=your-key --transport stdio example \
-- npx -y @example/mcp-server
The -- separates Claude's own options (--transport, --env, --scope) from the command that starts the server. Everything after it is passed to the server untouched. Without it, Claude Code would try to read the server's flags as its own. The documentation adds one trap: --env accepts several KEY=value pairs, so if the server name comes directly after --env the CLI reads the name as another pair. Put another option, such as --transport stdio, between them.
Add a server from JSON
When setup instructions give you a JSON block instead of a command, use claude mcp add-json:
claude mcp add-json <name> '<json>'
The documentation says to pass the object inside mcpServers, not the wrapper, and that an entry with a url but no type is an error, because Claude Code reads an entry with no type as stdio. Add "type": "http", "sse" or "ws" to match the endpoint.
Pick a scope deliberately
The --scope flag decides which projects load the server and whether teammates share it. The documentation defines three scopes.
| Scope | Loads in | Shared with team | Stored in |
|---|---|---|---|
| Local (default) | Current project only | No | ~/.claude.json |
| Project | Current project only | Yes, via version control | .mcp.json in the project root |
| User | All your projects | No | ~/.claude.json |
claude mcp add --transport http shared-server --scope project https://example.com/mcp
claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
Local scope is the default, so a command without --scope is private to you and the current project. Use project scope when the whole team should get the same server: Claude Code creates or updates .mcp.json at the project root, and you commit it. The resulting file has this shape:
{
"mcpServers": {
"shared-server": {
"type": "http",
"url": "https://example.com/mcp"
}
}
}
Two behaviors in the documentation matter for teams. First, Claude Code prompts for approval in interactive sessions before using project-scoped servers from .mcp.json; claude mcp reset-project-choices resets those choices. Second, .mcp.json supports environment variable expansion, either ${VAR} or ${VAR:-default}, in command, args, env, url and headers. That lets a team commit one file while each person supplies their own secret, instead of pasting a key into version control. For how credentials should and should not travel, see MCP credential injection.
When the same server name exists in several places, the documentation says Claude Code uses the highest-precedence definition and does not merge fields: local first, then project, then user, then plugin-provided servers, then claude.ai connectors.
List, inspect and remove servers
claude mcp list
claude mcp get notion
claude mcp remove notion
Inside a session, /mcp shows server status. claude mcp list prints a health status beside each server, such as connected, needs authentication or failed to connect. A failure status means Claude Code could not reach that server, not that the list command failed. A successful claude mcp add prints an Added ... line, which the documentation says means the configuration was written. Use claude mcp get <name> to confirm the connection.
If you add a name twice at the same scope, the command fails with an error that the server already exists. Removing a remote server also deletes the OAuth tokens and client registration Claude Code stored for it. It does not revoke them at the authorization server; run claude mcp logout <name> first if you want revocation where the server supports it.
Authenticate remote servers
Claude Code supports OAuth 2.0 for remote servers. It flags a server as needing authentication when the server answers 401 Unauthorized or 403 Forbidden. The documented flow:
- Add the server with
claude mcp add --transport http <name> <url>. - Run
/mcpinside Claude Code and follow the browser steps, or runclaude mcp login <name>from your shell. - To clear stored credentials, run
claude mcp logout <name>.
claude mcp login prints the authorization URL when no local browser is available, such as over SSH, and accepts --no-browser to force that behavior. Two limits are worth knowing in advance. A claude -p or Agent SDK run has no /mcp panel and cannot run the OAuth flow, so sign in from an interactive session first. And for servers behind an authenticating proxy, the documentation describes a separate header-plus-login setup that needs Claude Code v2.1.299 or later.
What adding many servers costs
Each claude mcp add is cheap. The cost appears when the list grows: more entries to approve, endpoints that can fail, credentials to issue and sign-ins to repeat.
- Configuration. One entry per server, per scope, per machine, unless you commit them to
.mcp.json. - Sign-in. Each OAuth server needs its own browser step, and the documentation notes that tokens are stored per endpoint. A name defined with different endpoints in two scopes needs a separate sign-in in each.
- Context. The documentation says tool search is on by default for supported models and defers tool definitions, so only tool names and server instructions load at session start. That limits the context cost of extra servers. It is a client feature: it depends on model, version and settings, and
ENABLE_TOOL_SEARCHcan change it. Measure your own setup, as described in how to cut MCP token usage. - Policy. Local, project and user entries sit in files on individual machines. Managed MCP configuration for administrators is a separate mechanism from
claude mcp add.
When one router endpoint is the better add
A router is a single MCP endpoint that fronts many upstream servers. In Claude Code it is one HTTP entry:
claude mcp add --transport http mcp-beast <router-url> --scope user
<router-url> is a placeholder for the endpoint your router publishes. After that one command, the upstream catalog lives behind the endpoint instead of in your configuration files.
MCP Beast's router is an example of this pattern. Its guide describes a task-driven sequence of discover_tools, then get_schema for the chosen tool, then invoke, plus a roster of connectors with their sign-in state. That is MCP Beast's product workflow, not behavior every router or MCP server shares.
Choose the router when these conditions hold:
| Situation | Many claude mcp add entries | One router endpoint |
|---|---|---|
| Catalog changes weekly | Edit config on every machine | Change the catalog behind one entry |
| Several people need the same servers | Each person signs in to each server | Sign-in state is managed where the router runs |
| Calls need policy or an audit trail | Depends on each server and each client | One place to apply and record decisions |
| Tool context is a concern | Relies on the client's tool search | Smaller visible surface, but verify it |
The honest limits matter. A router adds a hop and a component to operate, so it is not free. It does not remove the need to authorize each upstream. And context savings depend on your client, model and catalog, so test them rather than assume them. The proxy guide walks through the setup choices, and the gateway, proxy and router comparison explains where a router differs from a pure forwarder.
If you run two or three stable servers for one project, plain claude mcp add with project scope is simple and sufficient. The router earns its place when the list is long, shared, changing or needs central control.
Frequently Asked Questions
What does claude mcp add do?
It registers an MCP server with Claude Code by writing a configuration entry. The flags set the transport, the scope and any headers or environment variables the server needs.
What is the default scope for claude mcp add?
Local. The server loads only in the current project and stays private to you. Add `--scope project` to write a shared `.mcp.json`, or `--scope user` to make it available in all your projects.
Why does a stdio server need a double dash?
The `--` separates Claude Code's options from the server's own command and arguments. Without it, Claude Code would read the server's flags as its own.
When should I add one router instead of many servers?
When the server list is long, shared across people or changing often, and you want one sign-in point and central policy. For a few stable servers, direct entries are simpler.
Try MCP Beast as the single endpoint in your Claude Code setup. Add it once with claude mcp add, connect your upstream servers behind it, and compare sign-in effort and visible tool context against your current list.