# How to Add an MCP Server to Claude Code

> Canonical: https://skillalmanac.com/learn/add-an-mcp-server-to-claude-code | Updated: 2026-11-21 | Index status: not offered to search engines

Add a remote or local MCP server to Claude Code with claude mcp add, pick a scope, and confirm the connection with claude mcp list and /mcp.

## Facts

- 2026-11-21: claude mcp add --transport http <name> <url> adds a remote HTTP server (https://code.claude.com/docs/en/mcp)
- 2026-11-21: The default scope is local, which stores the server in ~/.claude.json under the current project; project scope writes .mcp.json and user scope applies across projects (https://code.claude.com/docs/en/mcp)
- 2026-11-21: claude mcp list reports Connected, Needs authentication, Failed to connect, or Pending approval for each server (https://code.claude.com/docs/en/mcp)
- 2026-11-21: Interactive sessions ask for approval before using project-scoped servers from .mcp.json; claude mcp reset-project-choices clears those choices (https://code.claude.com/docs/en/mcp)
- 2026-11-21: claude -p and Agent SDK runs cannot complete the OAuth flow, so remote servers must be signed in from an interactive session first (https://code.claude.com/docs/en/mcp)

You add an MCP server to Claude Code with the `claude mcp add` command, choosing a transport and a scope that controls who can use it. After adding it, `claude mcp list` and the `/mcp` view show whether the connection worked. The steps below follow the official MCP page as of 2026-11-21; check [the current docs](https://code.claude.com/docs/en/mcp) if a flag has changed.

## Choose a transport and a scope

Two decisions shape the command. The transport is `http` for a remote server that has a URL, or `stdio` for a local process that Claude Code starts itself. The scope decides where the configuration lives and who gets it.

| Scope | Where it is stored | Who gets the server |
|---|---|---|
| `local` (default) | `~/.claude.json`, under the current project path | You, in this project only |
| `project` | `.mcp.json` in the project root | Everyone who clones the repository |
| `user` | `~/.claude.json` | You, in every project |

Pick `project` only when the server configuration is safe to commit, because the file goes into version control. Secrets such as API keys belong in environment variables, not in the file.

## Steps

1. Add a remote server. For example, `claude mcp add --transport http notion https://mcp.notion.com/mcp` registers a server named `notion`.
2. Add a local stdio server. Pass environment variables with `--env` and place the server command after `--`, as in `claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable -- npx -y airtable-mcp-server`.
3. Set the scope if the default does not fit. Append `--scope project` (or `--scope user`) to the command.
4. For a remote server that needs sign-in, start Claude Code in the project, run `/mcp`, and follow the browser login. From a shell, `claude mcp login <name>` does the same job.
5. Check the result with `claude mcp list` or `claude mcp get <name>`. A healthy server shows `Connected`.

## Check that it worked

Run `claude mcp list` and look for `Connected` next to your server name. If the status is `Needs authentication`, finish the OAuth step in step 4. If it is `Failed to connect`, run `claude mcp get <name>` to read the stored URL or command and fix that value before adding again.

## Pitfalls

- **Server flags land in the wrong place.** Without the `--` separator, flags such as `--port` that belong to the server are parsed as Claude Code options. Put `--` directly before the server command.
- **`--env` is out of position.** Put another option, such as `--transport stdio`, between `--env` and the server name. Notice this when the server starts without its key.
- **Project servers stay pending.** A project-scoped server from `.mcp.json` shows `Pending approval` until you approve it in an interactive session. Run `claude mcp reset-project-choices` if an earlier choice needs to be undone.
- **Scripted runs cannot finish OAuth.** `claude -p` and Agent SDK runs cannot complete the browser flow. Sign in from an interactive session first, then run the script.
- **Removing a server keeps its tokens at the provider.** `claude mcp remove` deletes the local OAuth tokens but does not revoke them. Run `claude mcp logout <name>` before removing if you want the access revoked.

## When to use a skill instead

Adding a server is a configuration task, and the command above covers it. The harder work starts when you write the server yourself and need to decide its tools, input schemas and error shapes before connecting it. [mcp-server-builder](/skills/skill-almanac/mcp-server-builder) is a related skill on this site that reviews a server design for those choices, including the transport decision between stdio and HTTP. Use it before the steps above when the server does not exist yet. For a server someone else already maintains, the command-line steps are enough and no skill is needed.

## FAQ

**How do I remove an MCP server from Claude Code?**
Run `claude mcp remove <name>`. For a remote server with OAuth, run `claude mcp logout <name>` first so the tokens are revoked at the provider.

**Why does Claude Code ask me to approve a server?**
Servers defined in a project's `.mcp.json` need your approval in an interactive session before Claude Code uses them. The approval protects you from running a server a teammate committed without your review.

**What does "Needs authentication" mean in the list output?**
The server answered with a 401 or 403 response, so Claude Code treats it as requiring sign-in. Open `/mcp` in an interactive session and complete the login, or use `claude mcp login <name>`.

## Related skills

- [mcp-server-builder](https://skillalmanac.com/skills/skill-almanac/mcp-server-builder.md): Platform Score 56/100 (provisional)

## Related guides

- [Claude skills vs MCP vs plugins: what each one is for](https://skillalmanac.com/learn/skills-vs-mcp-vs-plugins.md)
- [What Is Claude Code and What It Can Touch on Your Machine](https://skillalmanac.com/learn/what-is-claude-code.md)
- [Claude Code Desktop App: What the Code Tab Adds](https://skillalmanac.com/learn/claude-code-desktop-app-guide.md)
- [Claude Code Subagents: When to Delegate and How to Scope Tools](https://skillalmanac.com/learn/claude-code-subagents-guide.md)
- [Codex vs Claude Code: Config Files and Sandbox](https://skillalmanac.com/learn/codex-vs-claude-code.md)
- [Cursor vs Claude Code: Editor or Terminal Workflow](https://skillalmanac.com/learn/cursor-vs-claude-code.md)

## Sources

- https://code.claude.com/docs/en/mcp

Platform Scores report our assessment under a published method. They are not a safety guarantee.
