---
title: "Claude Code MCP config: commands, scopes and managed settings"
type: guide
url: https://agentsfordevs.com/guides/claude-code-mcp
markdown: https://agentsfordevs.com/guides/claude-code-mcp.md
publisher: Agents for Devs
author: Agents for Devs desk
reviewed_by: Agents for Devs desk
published: 2026-12-06
updated: 2026-12-06
license: https://agentsfordevs.com/reuse
citation: 'Agents for Devs. "Claude Code MCP config: commands, scopes and managed settings." Published Dec 6, 2026. https://agentsfordevs.com/guides/claude-code-mcp'
attribution: Credit Agents for Devs and link to https://agentsfordevs.com/guides/claude-code-mcp
format: Guide
topics:
  - coding-agents
description: "Configure MCP servers in Claude Code: claude mcp add for HTTP and stdio, local/project/user scopes, .mcp.json, OAuth sign-in and admin allowlists."
---

# Claude Code MCP config: commands, scopes and managed settings

How Claude Code registers, stores, authenticates and restricts MCP servers, with each command taken from Anthropic's docs.

## Short answer

Claude Code connects to MCP servers you register with `claude mcp add`: `claude mcp add --transport http <name> <url>` for a remote server, or `claude mcp add <name> -- <command>` for a local stdio server. The `--scope` flag decides where the entry is saved: local (the default) and user scopes go in `~/.claude.json`, project scope goes in a shared `.mcp.json`. Admins restrict servers with `managed-mcp.json` or the `allowedMcpServers` and `deniedMcpServers` managed settings.

**Checked against:** Anthropic's [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp), [Control MCP server access for your organization](https://code.claude.com/docs/en/managed-mcp), [Deploy managed settings](https://code.claude.com/docs/en/managed-settings) and [Configure permissions](https://code.claude.com/docs/en/permissions), December 6, 2026.

**Run by us:** no. Commands are copied from Anthropic's docs.

## How do I add a remote MCP server to Claude Code?

Run `claude mcp add --transport http <name> <url>`, which registers a server that Claude Code reaches over [Streamable HTTP](/glossary/streamable-http).

```bash
# Basic syntax
claude mcp add --transport http <name> <url>

# Real example: Connect to Notion
claude mcp add --transport http notion https://mcp.notion.com/mcp

# Example with Bearer token
claude mcp add --transport http secure-api https://api.example.com/mcp \
  --header "Authorization: Bearer your-token"
```

Anthropic's docs mark the SSE transport as deprecated. A service that only exposes an SSE endpoint can still be added with the same `--transport http` command: Claude Code tries HTTP first and switches to SSE if the server rejects it. As of December 6, 2026, that automatic switch requires Claude Code v2.1.265 or later; on older versions, pass `--transport sse`.

The `--transport` flag doesn't accept `ws`; add WebSocket servers with `claude mcp add-json` and `"type":"ws"`. In JSON config, `type` also accepts `streamable-http` as an alias for `http`. For transport trade-offs, see [stdio vs Streamable HTTP](/guides/mcp-transports).

## How do I add a local stdio server?

Put Claude Code's own options first, then `--`, then the command that starts the server.

```bash
# Basic syntax
claude mcp add [options] <name> -- <command> [args...]

# Real example: Add Airtable server
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \
  -- npx -y airtable-mcp-server
```

Everything after `--` goes to the server untouched, so a server flag such as `--port` is never parsed as a Claude Code option. `--env` accepts several `KEY=value` pairs, which means a server name placed straight after it gets read as another pair and rejected. Keep another option, such as `--transport stdio`, between them. The short forms `-e`, `-t`, `-H` and `-s` stand for `--env`, `--transport`, `--header` and `--scope`.

If a server's docs give you a JSON block, pass the server object to `add-json`:

```bash
claude mcp add-json example '{"command":"npx","args":["-y","<MCP_SERVER_PACKAGE>"]}'
```

## Which scope should I pick, and where is each one saved?

Use local scope for a server only you need in one repo, project scope to share it through version control, and user scope to load it in every project.

| Scope | How to set it | Loads in | Saved in |
|---|---|---|---|
| Local | Default when you omit `--scope` | Current project only | `~/.claude.json` |
| Project | `--scope project` | Current project only, for everyone who has the repo | `.mcp.json` in the project root |
| User | `--scope user` | All your projects | `~/.claude.json` |

```bash
# Add a project-scoped server
claude mcp add --transport http shared-server --scope project https://example.com/mcp

# Add a user server
claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
```

When one name is defined in several places, Claude Code uses the whole entry from the highest-ranked source, without merging fields: local, then project, user, plugin-provided servers and claude.ai connectors. A server supplied through the managed `managedMcpServers` setting (v2.1.259 or later) outranks all of them.

## What goes in a shared .mcp.json?

A `.mcp.json` file holds an `mcpServers` object keyed by server name, and it should reference secrets through environment variables instead of containing them.

```json
{
  "mcpServers": {
    "api-server": {
      "type": "http",
      "url": "${API_BASE_URL:-https://api.example.com}/mcp",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    }
  }
}
```

Claude Code expands `${VAR}` and `${VAR:-default}` in a server's `command`, `args`, `env`, `url` and `headers`. In a remote server's `url` and `headers`, though, credential variables read as empty: Claude Code's own (`ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`), cloud credentials such as `AWS_BEARER_TOKEN_BEDROCK`, and others such as `NPM_TOKEN`. The server gets no credential and usually answers `401`. A name like `API_KEY` expands normally.

Always set `type` on a remote entry. An entry with a `url` and no `type` produces `MCP server "<name>" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry`.

## Does Claude Code ask before using a project's servers?

In interactive sessions, yes: Claude Code asks for approval before it uses servers from a project's `.mcp.json`. In `claude -p` runs, Agent SDK sessions and some cloud sessions, it can't show that prompt and loads them without asking.

```bash
claude mcp reset-project-choices
```

That command resets your approval choices. Because headless runs skip the prompt, a repo's `.mcp.json` can add servers to them, which matters for [prompt injection against coding agents](/guides/prompt-injection-coding-agents). To keep a project server out:

- Add it to `disabledMcpjsonServers`, which blocks it in every permission mode.
- Exclude project settings with `--setting-sources` (or the SDK's `settingSources` option).
- Start the session with `--strict-mcp-config`.

`enableAllProjectMcpServers` or `enabledMcpjsonServers` committed to a repo's `.claude/settings.json` is ignored while the folder is untrusted, and the server stays at `⏸ Pending approval`.

## How do I sign in to an OAuth server?

Add the server, then run `/mcp` inside a session or `claude mcp login <name>` from your shell.

```bash
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
claude mcp login sentry
claude mcp login sentry --no-browser
```

Without a local browser, such as over SSH, `claude mcp login` prints the authorization URL; open it locally and paste the full redirect URL back (connect with `ssh -t`). `--no-browser` forces that flow. To revoke tokens where the authorization server supports it, run `claude mcp logout <name>` before `claude mcp remove <name>`.

Claude Code registers itself automatically through [dynamic client registration](/glossary/dynamic-client-registration), or through a Client ID Metadata Document where the server uses one. If you see "Incompatible auth server: does not support dynamic client registration," the server needs pre-configured credentials, so register an OAuth app in its developer portal and pass the client ID:

```bash
claude mcp add --transport http \
  --client-id your-client-id --client-secret --callback-port 8080 \
  my-server https://mcp.example.com/mcp
```

`--client-secret` prompts with masked input, or reads `MCP_CLIENT_SECRET` in CI. The secret is kept in the system keychain on macOS, or a credentials file, not in your config. Register `http://localhost:PORT/callback` with the same port. To cap what a sign-in grants, set `oauth.scopes` to a space-separated string in the server's JSON entry. The protocol side is covered in [MCP authorization step by step](/guides/mcp-oauth-flow).

## How do I allow or deny individual MCP tools?

Write permission rules that name the tool as `mcp__<server>__<tool>`.

| Rule | Matches |
|---|---|
| `mcp__puppeteer` | Any tool from the `puppeteer` server |
| `mcp__puppeteer__*` | Every tool from the `puppeteer` server |
| `mcp__puppeteer__puppeteer_navigate` | One tool |
| `mcp__*` | Every MCP tool; works in deny and ask rules only |

Allow rules accept a glob only after a literal `mcp__<server>__` prefix; an unanchored allow glob such as `"mcp__*"` is skipped and approves nothing.

## How do admins restrict which servers run?

Deploy `managed-mcp.json` for a fixed set, or put `allowedMcpServers` and `allowManagedMcpServersOnly` in managed settings for an approved catalog.

| Goal | Configure |
|---|---|
| Only the servers you list | `managed-mcp.json` with those servers |
| No MCP | `managed-mcp.json` containing `{"mcpServers": {}}` |
| Your servers plus users' own | `managedMcpServers` in managed settings |
| Users pick from an approved list | `allowedMcpServers` plus `allowManagedMcpServersOnly: true` |
| Block specific servers | `deniedMcpServers` |

`managed-mcp.json` goes in `/Library/Application Support/ClaudeCode/` on macOS, `/etc/claude-code/` on Linux and WSL, or `C:\Program Files\ClaudeCode\` on Windows, next to `managed-settings.json`. It can't be delivered through server-managed settings.

```json
{
  "allowManagedMcpServersOnly": true,
  "allowedMcpServers": [
    { "serverUrl": "https://api.githubcopilot.com/*" },
    { "serverUrl": "https://*.internal.example.com/*" }
  ]
}
```

Match remote servers with `serverUrl` (wildcards allowed) and stdio servers with `serverCommand`, an array that must equal the command and every argument. Anthropic warns that a `serverName` entry "is not a security control," because users choose the name. Without `allowManagedMcpServersOnly`, allowlists from user settings merge in and can widen yours; denylists merge from every scope, and nothing overrides a denylist match.

A user adding an unlisted server sees `Cannot add MCP server "<name>": not allowed by enterprise policy`. A server that becomes blocked simply disappears from `/mcp`, so announce changes. To confirm a machine picked up the policy, run `/status` and look for `Enterprise managed settings (file)` on the `Setting sources` line. For finding servers nobody approved, see [shadow MCP servers](/guides/shadow-mcp-servers).

## What breaks, and how do I fix it?

Start with `claude mcp list`, which prints a health status next to each server, then `claude mcp get <name>` for one server's details.

| You see | What it means | Fix |
|---|---|---|
| `✘ Failed to connect` | Claude Code couldn't reach the server; `claude mcp get` shows the detail on an `Issue:` line | Read the HTTP status or error code there |
| `! Needs authentication` | No valid token | `/mcp` or `claude mcp login <name>` |
| ``⏸ Pending approval (run `claude` to approve)`` | Unapproved `.mcp.json` server | Run `claude` interactively and approve |
| `✘ Blocked by enterprise managed policy` | Managed policy | Ask your admin |
| `MCP server sentry already exists in local config` | Name taken at that scope | `claude mcp remove` it or choose another name |

`MCP_TIMEOUT` sets the startup timeout (`MCP_TIMEOUT=10000 claude` allows 10 seconds). A per-server `timeout` field in milliseconds overrides `MCP_TOOL_TIMEOUT` for that server's tool calls. MCP output is capped at 25,000 tokens by default; raise it with `export MAX_MCP_OUTPUT_TOKENS=50000` before starting `claude`.

## What to read next

- [Codex CLI MCP config](/guides/codex-cli-mcp)
- [Gemini CLI MCP config](/guides/gemini-cli-mcp)
- [How coding agents ask permission](/guides/coding-agent-permissions)
- [MCP host](/glossary/mcp-host)

## Sources

1. [Connect Claude Code to tools via MCP, Anthropic](https://code.claude.com/docs/en/mcp)
2. [Control MCP server access for your organization, Anthropic](https://code.claude.com/docs/en/managed-mcp)
3. [Deploy managed settings, Anthropic](https://code.claude.com/docs/en/managed-settings)
4. [Configure permissions, Anthropic](https://code.claude.com/docs/en/permissions)

## Changelog

- 2026-12-06: First published.

## Cite this page

Agents for Devs. "Claude Code MCP config: commands, scopes and managed settings." Published Dec 6, 2026. https://agentsfordevs.com/guides/claude-code-mcp

- Page: https://agentsfordevs.com/guides/claude-code-mcp
- Markdown: https://agentsfordevs.com/guides/claude-code-mcp.md
- Reuse: quote or summarize with a link to the page. Terms: https://agentsfordevs.com/reuse
