Connect MCP Servers to Claude Code
- MCP (Model Context Protocol) is an open standard that lets Claude Code read and act on outside tools such as issue trackers, databases and design tools, so you stop copying data into chat.
- Add a server with
claude mcp add. For a remote server use--transport http <name> <url>(recommended). For a local program useclaude mcp add <name> -- <command> [args](stdio). The--separates Claude’s options from the server’s command. - Scope decides who gets the server:
local(default, only you, only this project, stored in~/.claude.json),project(shared via.mcp.jsonin the project root),user(only you, all projects). - Check with
claude mcp listor/mcpinside a session. A server that needs sign-in shows! Needs authentication; run/mcporclaude mcp login <name>to complete OAuth. - Safety: the docs say to verify you trust each server, because servers that fetch outside content can expose you to prompt injection. Project servers from
.mcp.jsonask for your approval first. Use a read-only database user, and keep tokens out of committed files. - We read the official pages on 2026-11-02. We did not run
claude mcpcommands or connect any server, so every command and output below comes from the docs.
What you’ll be able to do after this tutorial
Section titled “What you’ll be able to do after this tutorial”- Add a hosted (HTTP) server and a local (stdio) server to Claude Code.
- Pick the right scope and know which file holds the server.
- Sign in to a server that needs OAuth, and check or remove servers.
- List the safety checks to do before connecting a server you did not write.
Concepts to know first
Section titled “Concepts to know first”Automation 5 explains MCP in plain words: a shared plug that lets AI use your tools. Dev 5 shows how to build your own server. This tutorial is the Claude Code side: the commands and files for connecting servers. Permission rules for MCP tools follow the same system as Coding 13.
Three ways to connect (official docs, 2026-11-02)
Section titled “Three ways to connect (official docs, 2026-11-02)”| Kind | When | Command shape |
|---|---|---|
| Remote HTTP | A hosted service with a URL. The docs call HTTP the recommended option | claude mcp add --transport http <name> <url> |
| Local stdio | A program that runs on your machine (needs local access) | claude mcp add [options] <name> -- <command> [args...] |
| Remote SSE | Deprecated. Use HTTP where available | claude mcp add --transport sse <name> <url> |
The docs also describe WebSocket servers ("type": "ws"), which you configure in .mcp.json or with claude mcp add-json; the --transport flag does not accept ws. This tutorial does not go further into it.
Scopes
Section titled “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 |
Note that “local scope” for MCP is stored in ~/.claude.json, not in .claude/settings.local.json (the general local settings file from Coding 13). If the same server name exists in several scopes, Claude Code connects once, using the highest-precedence definition: local, then project, then user, then plugin servers, then claude.ai connectors. Fields are not merged across scopes.
Step-by-step guide
Section titled “Step-by-step guide”-
Check that the server is worth trusting
Before you add anything, decide whether you trust it. The official docs say: “Verify you trust each server before connecting it. Servers that fetch external content can expose you to prompt injection risk.” Prefer servers from the provider’s own docs or from reviewed connectors in the Anthropic Directory, and read what tools the server offers.
-
Add a hosted (HTTP) server
The official quickstart connects Anthropic’s own docs server, which needs no sign-in. Run this in your terminal, not inside a Claude session:
Terminal window claude mcp add --transport http claude-code-docs https://code.claude.com/docs/mcpThe command prints an
Added ...line, which means the configuration was written, not that the server connects. By default it uses local scope. -
Check the connection
Terminal window claude mcp listEach server shows a status. The docs list these:
Status Meaning ✔ ConnectedReady to use ! Needs authenticationReachable, but needs a browser sign-in or a token passed with --header✘ Failed to connectThe server did not respond ⏸ Pending approvalA project-scoped server you have not approved yet ✘ Blocked by enterprise managed policyYour organization blocks it. Ask your administrator Inside a session,
/mcpshows the same panel.claude mcp get <name>shows details and which scope holds the server. -
Use it
Start
claudeand ask for something that needs the server. Naming the server makes sure the answer comes from it and not from another tool.Copy and paste this promptUse the claude-code-docs server to look up what MCP_TIMEOUT does
If Claude Code asks for permission the first time Claude calls the server, read the prompt and approve it. Tool calls in Claude’s output are labeled with the server name, which is how you confirm the answer came from the server.
-
Add a server that needs sign-in (OAuth)
Hosted services such as Sentry, Linear and Notion put their MCP servers behind OAuth. The docs example uses Sentry:
Terminal window claude mcp add --transport http sentry https://mcp.sentry.dev/mcpAfter adding,
claude mcp listshows! Needs authentication, which the docs say is expected. Then open/mcpin a session, select the server, choose Authenticate, and approve in the browser. You can also runclaude mcp login sentryfrom your shell, andclaude mcp logout sentryclears stored credentials. The docs say tokens are stored securely and refreshed automatically.For a server that uses a static token instead of OAuth, pass it at add time:
Terminal window claude mcp add --transport http secure-api https://api.example.com/mcp \--header "Authorization: Bearer your-token" -
Add a local (stdio) server
The official quickstart uses the Playwright server, which gives Claude a browser. It runs through
npx, so it needs Node.js 18 or later:Terminal window claude mcp add playwright -- npx -y @playwright/mcp@latestEverything after
--is the command Claude Code runs to start the server. There is no--transportflag because stdio is the default. The firstclaude mcp listcan show✘ Failed to connectwhile npx downloads the package; the docs say to wait and run it again.If you add environment variables, the docs warn that the server name must not come right after
--env; put another option such as--transport stdiobetween them:Terminal window claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \-- npx -y airtable-mcp-server -
Share a server with your team (project scope)
Terminal window claude mcp add --transport http shared-server --scope project https://example.com/mcpThis writes
.mcp.jsonin the project root, which you commit:{"mcpServers": {"shared-server": {"type": "http","url": "https://example.com/mcp"}}}In interactive sessions, Claude Code asks each person to approve a project-scoped server before using it, so a cloned repository cannot launch processes without your consent. To reset those approvals, run
claude mcp reset-project-choices. A JSON entry that has aurlbut notypeis an error, because an entry with no type is read as stdio. -
Remove a server
Terminal window claude mcp remove claude-code-docsFor a remote server, Claude Code also deletes the OAuth tokens and client registration it stored. It does not revoke the tokens at the service that issued them. If the service supports revocation, run
claude mcp logout <name>first. The docs also note that each connected server takes some space in Claude’s context window, so remove servers you no longer use.When a server will not connect - TerminalRun claude mcp list→ Read the status next to the server
- TerminalRun claude mcp get <name>→ See the Issue line with the HTTP status or error code, and the scope
- Claude Code promptType /mcp→ Authenticate or re-authenticate if it says Needs authentication
- Your configCheck the URL, the type field and any ${VAR} values→ Fix a missing type, a hidden space or an unset variable
This is a simplified flow. See the official help page for the actual screens.
Quick reference
Section titled “Quick reference”Commands from the official docs
Section titled “Commands from the official docs”| Command | What it does |
|---|---|
claude mcp add --transport http <name> <url> |
Add a remote HTTP server |
claude mcp add <name> -- <command> [args] |
Add a local stdio server |
claude mcp add-json <name> '<json>' |
Add from a JSON block (escape it for your shell) |
claude mcp add-from-claude-desktop |
Import from Claude Desktop (macOS and WSL only) |
claude mcp list / get <name> |
List servers with status / show details |
claude mcp login <name> / logout <name> |
Run or clear the OAuth sign-in |
claude mcp remove <name> |
Remove a server (add --scope <scope> if needed) |
/mcp |
Status and sign-in panel inside a session |
Output size
Section titled “Output size”The docs say Claude Code warns when a tool’s output exceeds 10,000 tokens and limits it to 25,000 tokens by default. You can change the limit with the MAX_MCP_OUTPUT_TOKENS environment variable before starting Claude Code. A very large result is saved to a file instead of the conversation.
Organization control
Section titled “Organization control”Administrators can deploy or restrict servers with managed MCP configuration (managed-mcp.json, allowedMcpServers, deniedMcpServers). A blocked server can show Blocked by enterprise managed policy. This tutorial does not cover that setup; see the official managed MCP page.
Common sticking points
Section titled “Common sticking points”claude mcp add printed “Added” but the server does not work
Section titled “claude mcp add printed “Added” but the server does not work”- Cause: The command saves the configuration without checking credentials or whether the command runs.
- Fix: Run
claude mcp listor/mcp. Wait and retry if a stdio package is still downloading.
Status shows “Needs authentication”
Section titled “Status shows “Needs authentication””- Cause: The server answered with 401 or 403 and wants you to sign in.
- Fix: Run
/mcpand choose Authenticate, orclaude mcp login <name>. Note thatclaude -phas no/mcppanel, so sign in from an interactive session first.
I added the server but a project folder does not see it
Section titled “I added the server but a project folder does not see it”- Cause: Local scope is the default, so the server loads only in the project where you added it.
- Fix: Re-add it with
--scope userfor all projects, or--scope projectto share it. A server’s scope is fixed when you add it, so remove and re-add it.
Status shows “Pending approval”
Section titled “Status shows “Pending approval””- Cause: A
.mcp.jsonserver you have not approved yet. - Fix: Run
claudeinteractively in the folder and approve it. In an untrusted folder, approvals committed to the repository are ignored.
The add command fails with “already exists”
Section titled “The add command fails with “already exists””- Cause: Same name at the same scope.
- Fix: Remove the old entry first, or pick another name. Names can contain only letters, numbers, hyphens and underscores.
Practical tips
Section titled “Practical tips”- Add servers you actually use. Every connected server adds tool names and instructions to Claude’s context.
- Use
--scope projectonly for servers the whole team needs and that need no personal secrets. - Prefer OAuth over pasting a long-lived token, and use the narrowest access the server offers (for example a fine-grained token limited to chosen repositories, as in the docs’ GitHub example).
- Start with read-only access. Give database servers a read-only user.
- Treat text that a server returns as untrusted input. If Claude suddenly proposes an odd action after reading outside content, stop and check.
- MCP tools go through the permission system, so you can allow or deny them with rules; see Coding 13.
- Version details in the docs change (for example the automatic HTTP-to-SSE fallback needs v2.1.265 or later). If a flag is missing, check
claude --versionagainst the docs.
Next tutorials
Section titled “Next tutorials”- Automation 5. Connecting with connectors (MCP) — the idea behind MCP
- Dev 5. Build your own MCP server — write a server and connect it
- 13. Tune settings and permissions — allow and deny rules
- C14. Claude Code key features
- Developer guide
Sources
Last verified: Nov 16, 2026
- Connect Claude Code to tools via MCP code.claude.com
- Connect to MCP servers (quickstart) code.claude.com
Prices, limits, and menu names change often. Before making an important decision, check the official pages above for the latest details.
Finished this tutorial?
Progress is saved only in this browser and never sent anywhere.