How to Add an MCP Server to Claude Code
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.
Updated · Markdown version
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 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
- Add a remote server. For example,
claude mcp add --transport http notion https://mcp.notion.com/mcpregisters a server namednotion. - Add a local stdio server. Pass environment variables with
--envand place the server command after--, as inclaude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable -- npx -y airtable-mcp-server. - Set the scope if the default does not fit. Append
--scope project(or--scope user) to the command. - 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. - Check the result with
claude mcp listorclaude mcp get <name>. A healthy server showsConnected.
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--portthat 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--envand the server name. Notice this when the server starts without its key. - Project servers stay pending. A project-scoped server from
.mcp.jsonshowsPending approvaluntil you approve it in an interactive session. Runclaude mcp reset-project-choicesif an earlier choice needs to be undone. - Scripted runs cannot finish OAuth.
claude -pand 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 removedeletes the local OAuth tokens but does not revoke them. Runclaude 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 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 in this catalog
Platform Score is our assessment under a published method. It is not a safety guarantee.
Related guides
- Claude skills vs MCP vs plugins: what each one is for
- What Is Claude Code and What It Can Touch on Your Machine
- Claude Code Desktop App: What the Code Tab Adds
- Claude Code Subagents: When to Delegate and How to Scope Tools
- Codex vs Claude Code: Config Files and Sandbox
- Cursor vs Claude Code: Editor or Terminal Workflow
Terms this guide uses
This item is a worked example in the AI glossary for:
Sources
- https://code.claude.com/docs/en/mcp (accessed 2026-11-21)
This page is not offered to search engines yet: The content file does not mark this page indexable yet.