---
title: "Claude Code MCP: add, scope, authenticate, and debug servers"
type: "guide"
url: "https://aifordevs.org/articles/claude-code-mcp"
markdown: "https://aifordevs.org/articles/claude-code-mcp.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/articles/claude-code-mcp"
description: "Claude Code MCP setup as of November 2026: claude mcp commands, local, project, and user scopes, OAuth, secrets, tool permissions, limits, and fixes."
author: "AI for Devs"
published: "2026-11-19"
level: "Intermediate"
topics: ["coding-agents", "mcp"]
---

# Claude Code MCP: add, scope, authenticate, and debug servers

Claude Code MCP setup as of November 2026: claude mcp commands, local, project, and user scopes, OAuth, secrets, tool permissions, limits, and fixes.

> **TL;DR**
>
> - Claude Code MCP setup runs through `claude mcp add`: `--transport http` plus a URL for a remote server, or a launch command after `--` for a local stdio server.
> - Local scope (the default) and user scope live in `~/.claude.json`, and project scope lives in a committed `.mcp.json`. On a name clash, local beats project beats user, and the winner is used whole.
> - Remote servers sign in with OAuth from `/mcp` or `claude mcp login`. A `.mcp.json` can reference `${VAR}`, but Claude Code blanks its own and cloud credentials in remote URLs and headers.
> - Defaults as of November 16, 2026: a 30 second startup timeout, a 25,000 token output cap with a warning at 10,000, backgrounding after 2 minutes, and about 28 hours of wall clock per call.
> - For a team, one entry pointing at an MCP gateway replaces per-server entries, and the gateway applies auth, tool filtering, and logs.

Claude Code MCP support lets the terminal agent call tools from any Model Context Protocol server once the server is registered with `claude mcp add` or listed in a `.mcp.json` file. This guide covers using existing servers: commands, scopes, OAuth, secrets, permissions, limits, status checks, serving, gateways, and fixes. Every command and flag was checked against Anthropic's docs and the `--help` output of Claude Code 2.1.318 on November 16, 2026. To write a server of your own first, [build an MCP server](https://aifordevs.org/articles/build-an-mcp-server) covers the code and its registration step.

## Claude Code as an MCP client

Claude Code is an MCP host. For each configured server it opens one MCP client connection, fetches the server's tools, prompts, and resources, and offers each tool to the model under the name `mcp__<server>__<tool>`. The [MCP architecture overview](https://modelcontextprotocol.io/docs/2026-07-28/learn/architecture) names Claude Code as an example host and says each client keeps a dedicated connection to one server.

People often call the whole application the "MCP client," but in [MCP](https://aifordevs.org/glossary#mcp) terms the client is the connector inside the host. Claude Code speaks four transports:

| Transport | How to add it | Auth | When the connection fails |
| --- | --- | --- | --- |
| HTTP (`streamable-http`) | `claude mcp add --transport http` | OAuth, static headers, or `headersHelper` | 3 retries on first connect, 5 reconnects mid-session |
| SSE, deprecated | `--transport http` falls back to SSE on 2.1.265 and later | OAuth or headers | Same as HTTP |
| Stdio | `claude mcp add <name> -- <command>` | Environment variables | No automatic retry in an interactive session |
| WebSocket | `claude mcp add-json` with `"type": "ws"` | Headers or `headersHelper` only | No first-connect retry, reconnects mid-session |

Prefer HTTP for anything remote: Anthropic recommends it, SSE is deprecated, and WebSocket supports neither OAuth nor the `--transport` flag. Use stdio for tools that need your local files or binaries.

Claude Code 2.1.323 (November 12, 2026) removed the older v1 MCP client, per its [changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md). The remaining client speaks protocol revision 2026-07-28 and uses the earlier handshake with older servers.

## Add a server with claude mcp add

Give the server a name of letters, numbers, hyphens, and underscores, choose a transport, and pass a URL or a launch command after `--`. These commands follow the [Claude Code MCP docs](https://code.claude.com/docs/en/mcp) and were not run, because they write to your configuration.

```bash title="Not run here: writes to your Claude Code config"
# Remote HTTP server
claude mcp add --transport http notion https://mcp.notion.com/mcp

# Remote server that takes a static token header
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
  --header "Authorization: Bearer $GITHUB_PAT"

# Local stdio server: everything after -- is the launch command
claude mcp add --env AIRTABLE_API_KEY="$AIRTABLE_API_KEY" --transport stdio airtable \
  -- npx -y airtable-mcp-server

# WebSocket server, or any JSON entry copied from another client
claude mcp add-json events '{"type":"ws","url":"wss://mcp.example.com/socket"}'
```

The docs flag these details:

- Without `--`, Claude Code parses the server's own flags, such as `--port`, as its options.
- A server name right after `--env` is read as another `KEY=value` pair and rejected, so put another option between them.
- `claude mcp add` saves the entry without testing credentials, so a bad token appears later as a failed connection.
- A JSON entry with a `url` and no `type` is read as stdio and skipped. Add `"type": "http"`.

The `claude mcp` subcommands, from `claude mcp --help` on version 2.1.318 (the newest npm release was 2.1.325 on November 16, 2026):

| Command | What it does |
| --- | --- |
| `claude mcp add` | Adds a stdio, SSE, or HTTP server, with `--transport`, `--scope`, `--env`, `--header`, and the OAuth flags |
| `claude mcp add-json` | Adds a stdio, SSE, HTTP, or WebSocket server from one JSON entry |
| `claude mcp add-from-claude-desktop` | Imports servers from Claude Desktop, on macOS and WSL only |
| `claude mcp list` | Lists servers and health-checks the approved ones |
| `claude mcp get <name>` | Shows one server, with an `Issue:` line when it fails |
| `claude mcp remove <name>` | Deletes the entry and its locally stored OAuth tokens, without revoking them |
| `claude mcp login <name>` / `logout <name>` | Runs or clears a server's OAuth sign-in from the shell |
| `claude mcp reset-project-choices` | Forgets which `.mcp.json` servers you approved or rejected |
| `claude mcp serve` | Starts Claude Code as a stdio MCP server |

## Choose a scope: local, project, or user

The scope, set with `--scope` (or `-s`), decides which projects load a server and whether teammates get it. Local is the default.

| Scope | Stored in | Loads in | Shared |
| --- | --- | --- | --- |
| Local | `~/.claude.json`, under the current project's path | That project only | No |
| Project | `.mcp.json` at the repository root | That project | Yes, through version control |
| User | `~/.claude.json` | Every project on your machine | No |

When one server is defined in several places, Claude Code connects once, using the highest source: local, then project, then user, then plugin servers, then claude.ai connectors. Fields are never merged, so a local entry with an old URL hides every teammate change to the same name in `.mcp.json`. Scopes match duplicates by name, while plugins and connectors match by endpoint, ignoring scheme and host case, a default port, and a trailing slash.

**Figure 1.** One GitHub server defined five ways. Local wins over project and user by name and is used whole. The plugin server points at a different endpoint, so it connects as a second server, and the connector with the same URL is hidden.

Use local scope for personal tokens and experiments, project scope for servers the whole repository needs, and user scope for tools you want everywhere, such as a docs search server. Since 2.1.259, a server an organization provides through the `managedMcpServers` setting ranks above all three.

An interactive session asks before it connects a `.mcp.json` server, and `claude mcp list` shows `⏸ Pending approval` until you answer. Approvals committed in the repository's own `.claude/settings.json` are ignored until you trust the folder. `claude -p` runs and Agent SDK sessions load project servers without asking, so in CI start with `--strict-mcp-config --mcp-config ./ci-mcp.json` to load only the servers you pass, or reject one by name with `disabledMcpjsonServers` in settings.

## Pass environment variables and secrets

`--env KEY=value` writes the value into the server's entry, which is fine at local scope. In a shared `.mcp.json`, reference variables instead: Claude Code expands `${VAR}` and `${VAR:-default}` in `command`, `args`, `env`, `url`, and `headers`. Each person sets the variable in their own shell, and `/mcp` and `claude mcp list` show the reference by name, never the value.

```json title=".mcp.json"
{
  "mcpServers": {
    "sentry": {
      "type": "http",
      "url": "https://mcp.sentry.dev/mcp"
    },
    "internal-api": {
      "type": "http",
      "url": "${INTERNAL_MCP_URL:-https://mcp.internal.example.com}/mcp",
      "headers": { "Authorization": "Bearer ${INTERNAL_MCP_TOKEN}" }
    },
    "db": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@bytebase/dbhub", "--dsn", "${READONLY_DSN}"]
    }
  }
}
```

Expansion follows these rules:

- An unset variable with no default loads as the literal text `${VAR}`, and `claude mcp list` warns about it.
- A variable set to an empty string counts as set, so the default never applies.
- In a remote server's `url` and `headers`, credential variables such as `ANTHROPIC_API_KEY`, `AWS_BEARER_TOKEN_BEDROCK`, and `NPM_TOKEN` read as empty, so a cloned repository cannot send them to a server it names. Copy a value into a variable with your own name if a server needs it.
- Claude Code sets `CLAUDE_PROJECT_DIR` only in a stdio server's environment, so a `.mcp.json` command that uses it needs a default, such as `${CLAUDE_PROJECT_DIR:-.}`.

### Generate short-lived headers with headersHelper

A `headersHelper` is a command that prints the headers Claude Code sends when it connects, which suits tokens that expire within hours. The command must print one JSON object of string values within 10 seconds. Claude Code runs it at each connection and once more after a `401` or `403`, and it uses an `Authorization` header from the helper instead of OAuth.

This one reads a token file and escapes it with `jq`:

```sh title="get-mcp-headers.sh"
#!/bin/sh
# headersHelper for Claude Code: print one JSON object of string headers.
# A separate SSO login tool refreshes the token file; this script only reads it.
set -eu
token_file="${ACME_MCP_FILE:-$HOME/.config/acme/mcp-token}"
token=$(cat "$token_file")
jq -cn --arg t "$token" '{Authorization: ("Bearer " + $t)}'
```

It ran on November 16, 2026 with macOS `/bin/sh` and jq 1.7.1, against a test token file, in 0.72 seconds of wall time:

```text title="Real output"
{"Authorization":"Bearer test-only-token.abc123"}
```

A token with a quote and a backslash came out escaped, and Node's `JSON.parse` accepted every output. With the file missing, the script printed nothing and exited with code 1; how Claude Code handles that was not tested.

Reference the helper by absolute path, because its working directory depends on the scope. A project or local helper runs only after you accept the folder's trust dialog. Helpers from a project `.mcp.json` or a plugin also run without environment variables whose names contain `TOKEN`, `SECRET`, `PASSWORD`, `KEY`, or `AUTH`. That is why this script reads a file, and why its override variable avoids those words.

```json title=".mcp.json"
{
  "mcpServers": {
    "internal-docs": {
      "type": "http",
      "url": "https://mcp.internal.example.com/mcp",
      "headersHelper": "/usr/local/bin/get-mcp-headers.sh"
    }
  }
}
```

## Authenticate remote servers with OAuth

A remote server that answers `401` or `403` shows as needing authentication. Run `/mcp` in a session and finish the browser sign-in, or run `claude mcp login <name>` from your shell. Claude Code stores the tokens and refreshes them. Over SSH, `claude mcp login` prints the authorization URL instead of opening a browser, and `--no-browser` forces that behavior.

```bash title="Not run here: sign-in and pre-registered clients"
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
claude mcp login sentry --no-browser

# Server without dynamic client registration: bring your own OAuth app
claude mcp add --transport http \
  --client-id your-client-id --client-secret --callback-port 8080 \
  my-server https://mcp.example.com/mcp

# Revoke at the server first, then delete the entry
claude mcp logout sentry
claude mcp remove sentry
```

Claude Code registers itself through Dynamic Client Registration or a Client ID Metadata Document when the server supports one. If the server supports neither, create an OAuth app in its developer portal with the redirect URI `http://localhost:8080/callback`, matching `--callback-port`. `--client-secret` prompts with masked input, or reads `MCP_CLIENT_SECRET` in CI, and works only when you add the server.

To limit a server to approved scopes, pin them. Claude Code requests exactly these, plus `offline_access` when the server advertises it:

```json title=".mcp.json"
{
  "mcpServers": {
    "slack": {
      "type": "http",
      "url": "https://mcp.slack.com/mcp",
      "oauth": { "scopes": "channels:read chat:write search:read" }
    }
  }
}
```

A configured `Authorization` header, static or from a helper, replaces OAuth for that server, so a rejected header shows as a failed connection with no sign-in prompt.

## Set permissions for MCP tools

In the default permission mode, Claude Code asks before it runs an MCP tool unless a rule allows it. Rules use the tool's full name: `mcp__github__*` or `mcp__github` covers a whole server, and `mcp__github__get_issue` covers one tool. Characters such as dots in a server name become underscores in the rule.

Allow rules accept wildcards only after a literal `mcp__<server>__` prefix, so `mcp__github__get_*` works and an allow rule of `mcp__*` is skipped. Deny and ask rules accept any wildcard, and a deny rule of `mcp__*` hides every MCP tool from the model. This block approves reads, asks before writes, and blocks merges and one server; copy real tool names from `/mcp`.

```json title=".claude/settings.json"
{
  "permissions": {
    "allow": ["mcp__github__get_*", "mcp__github__list_*", "mcp__docs__*"],
    "ask": ["mcp__github__create_*"],
    "deny": ["mcp__github__merge_pull_request", "mcp__postgres__*"]
  }
}
```

To deny one argument value, such as a database name, pass the rule with `--disallowedTools`, because settings files skip `mcp__` rules with parentheses. A tool its server marks `anthropic/requiresUserInteraction` prompts on every call, even in `bypassPermissions` mode. Administrators can go further with `managed-mcp.json`, `managedMcpServers`, and the `allowedMcpServers` and `deniedMcpServers` lists in the [managed MCP docs](https://code.claude.com/docs/en/managed-mcp).

## Output limits, timeouts, and tool search

Claude Code caps how much one tool result can put into the [context window](https://aifordevs.org/glossary#context-window) and how long a call can run. These defaults are from Anthropic's docs as of November 16, 2026; set them as environment variables or in the `env` block of your settings.

| Setting | Default | What it controls |
| --- | --- | --- |
| `MCP_TIMEOUT` | 30,000 ms | How long one server may take to start and connect |
| `MCP_TOOL_TIMEOUT` | 100,000,000 ms, about 28 hours | Wall clock limit per tool call |
| `"timeout"` in a server entry | Not set | Overrides `MCP_TOOL_TIMEOUT` for that server; values under 1,000 are ignored |
| `CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT` | 5 min remote, 30 min stdio | Ends a call with no response or progress for that long |
| `CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS` | 2 min | Moves a slow call to a background task in `/tasks` |
| `MAX_MCP_OUTPUT_TOKENS` | 25,000 tokens | Largest result kept in the conversation; a warning appears above 10,000 |
| `ENABLE_TOOL_SEARCH` | On | Defers tool definitions until a task needs them |

Text results over 50,000 characters go to a file that Claude reads when needed, whatever `MAX_MCP_OUTPUT_TOKENS` says, unless the server raises the threshold with `anthropic/maxResultSizeChars` (up to 500,000). HTTP and SSE responses fail above 16 MiB.

**Figure 2.** Default limits on a log scale. A main-conversation call blocks the session for 2 minutes, then runs as a background task until the idle or wall clock limit. HTTP and SSE calls also need a first response byte within 60 seconds.

Set a per-server `timeout` for tools that run long by design, such as a build, instead of raising the global limit. Raise `MAX_MCP_OUTPUT_TOKENS` only when the model needs the whole result, because every extra token is read again on later turns; server-side pagination is cheaper.

Leave tool search on. It loads only tool names and server instructions at startup, so idle servers cost little context, the trade-off [context engineering](https://aifordevs.org/articles/context-engineering) describes. Set `"alwaysLoad": true` only on servers Claude needs every turn. Descriptions are cut at 4,096 characters for upfront tools and 16,384 for tools found through search.

## Check status and use resources and prompts

Inside a session, `/mcp` lists each server with its status and tool count, and a server's menu offers Reconnect, Disable, and the authentication actions. `/mcp reconnect all` retries every failed server on 2.1.284 and later.

From the shell, `claude mcp list` prints `✔ Connected`, `! Needs authentication`, `✘ Failed to connect` with the HTTP status or error code, `⏸ Pending approval`, or `⊘ Disabled for this project` per server. `claude mcp get <name>` adds an `Issue:` line with credentials redacted. For more, start with `claude --debug=mcp` (the filter needs the `=` form) or `--debug-file /tmp/claude-debug.log`.

Resources and prompts need no setup once a server offers them:

- Type `@` to see resources from every connected server next to files, and reference one as `@server:protocol://path`, for example `@github:issue://123`. Claude Code fetches it and attaches it to the message.
- Type `/` to see prompts, listed as `/server:prompt (MCP)`. Run one with arguments separated by spaces, such as `/mcp__github__pr_review 456`.
- A server's mid-task question appears as a form or a link, and an `Elicitation` hook can answer it.

## Run Claude Code as an MCP server

`claude mcp serve` turns Claude Code into a stdio MCP server, so another client can use its file reads, edits, and shell commands. It prints nothing at startup, because stdout carries protocol messages. This Claude Desktop entry from the docs was not run.

```json title="claude_desktop_config.json"
{
  "mcpServers": {
    "claude-code": {
      "type": "stdio",
      "command": "/full/path/to/claude",
      "args": ["mcp", "serve"],
      "env": {}
    }
  }
}
```

Use the full path from `which claude`, or the client fails with `spawn claude ENOENT`. Anthropic's docs say the connecting client must implement confirmation for each tool call. Connect only a client you would trust with a shell on your machine.

## Point Claude Code at an MCP gateway

An MCP gateway replaces the per-server entries on each laptop with one entry the platform team controls. Eight servers for 40 engineers means 320 entries, and rotating one server's token means editing 40 machines. Behind a gateway, each engineer holds one credential, the gateway holds the upstream ones and decides which tools each person sees, and cutting someone off means revoking one grant or deactivating one key.

[Bifrost](https://www.getmaxim.ai), an [open-source AI gateway](https://github.com/maximhq/bifrost), is the [AI gateway](https://aifordevs.org/glossary#ai-gateway) to start with for a Claude Code team, because it serves model calls, MCP tool calls, and agent traffic under one set of keys and rules. Bifrost [connects to MCP servers](https://docs.getbifrost.ai/mcp/connecting-to-servers) over STDIO, HTTP, or SSE and serves every connected tool through one `/mcp` endpoint, which [Claude Code adds](https://docs.getbifrost.ai/cli-agents/claude-code) as one HTTP server. This project entry, not run here, gives each engineer the same server with their own key from `BIFROST_VK`:

```json title=".mcp.json"
{
  "mcpServers": {
    "bifrost": {
      "type": "http",
      "url": "https://bifrost.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${BIFROST_VK}",
        "x-bf-lh-repo": "payments-api"
      }
    }
  }
}
```

Each request is scoped to its [virtual key](https://docs.getbifrost.ai/features/governance/virtual-keys). [Tool filtering](https://docs.getbifrost.ai/mcp/filtering) stacks: a tool must be in the upstream server's `tools_to_execute` list and in the key's `mcp_configs`, and `tools/call` is checked against the same list. A key with no entry for a server gets none of its tools, unless that server is marked Allow by Default, and an inactive or expired key gets a `403`.

**Figure 3.** Example filtering behind one gateway entry. The client configs pass 10 of 12 upstream tools, the virtual key passes 6, and filesystem contributes none because the key has no entry for it.

[Gateway authentication](https://docs.getbifrost.ai/mcp/gateway-auth) has three modes in `mcp_server_auth_mode`. The default, `headers`, accepts a virtual key header, while `both` and `oauth` turn Bifrost into an OAuth 2.1 authorization server, so Claude Code can sign in through the browser with no key in its config. The Bifrost docs note these Claude Code specifics:

- In `both` mode, send the key as `Authorization: Bearer`, not `x-bf-vk` or `X-Api-Key`, or Claude Code may also run OAuth and send two credentials, which Bifrost rejects.
- In `headers` mode, Re-authenticate in `/mcp` logs a harmless `SDK auth failed: HTTP 405` error, so use Reconnect instead.
- If Claude Code also sends model traffic through Bifrost, turn on `mcp_disable_auto_tool_inject` so the model does not see each tool twice.

Tool calls land in searchable [MCP tool logs](https://docs.getbifrost.ai/api-reference/logging/get-mcp-tool-logs), and Bifrost copies any request header starting with `x-bf-lh-` into log metadata, which is how the entry above tags each call with its repository.

Claude Code runs on employee laptops, so engineers can still add servers that bypass the gateway. [Bifrost Edge](https://www.getmaxim.ai/edge) extends the gateway's governance and security controls to the device: it reads the MCP configuration in apps including Claude Code, builds a fleet-wide inventory, and [enforces allow and deny decisions](https://docs.getbifrost.ai/edge/mcp-governance) on each machine, so policy also covers servers people add themselves.

## Troubleshooting Claude Code MCP errors

Start every fix with `claude mcp get <name>` for the failure detail, then `/mcp` for the live state. The rows below come from Anthropic's [error reference](https://code.claude.com/docs/en/errors) and Claude Code MCP docs.

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Server missing in another project | Added at the default local scope | Re-add with `--scope user` or `--scope project` |
| `⏸ Pending approval` | `.mcp.json` server not yet approved | Run `claude` in the folder, trust it, and approve; `claude mcp reset-project-choices` starts over |
| Teammates' `.mcp.json` change never applies | A local or user entry with the same name wins whole | `claude mcp remove <name> --scope local` |
| Entry skipped: has a `url` but no `type` | JSON copied from another client | Add `"type": "http"`, `"sse"`, or `"ws"` |
| `✘ Failed to connect` with a 401 | Bad token, or a credential variable that reads as empty | Fix the token, or copy the value into a variable with your own name |
| `spawn ... ENOENT` or a stdio server that never starts | Command not on the `PATH` Claude Code sees | Use an absolute path |
| `OAuth callback port ... is already in use` | Another process holds the fixed port | Find it with `lsof -ti:<port> -sTCP:LISTEN`, or register another port |
| Tool listed in `/mcp` that Claude cannot call | Full name over 128 characters, a rejected schema, or a deny rule | Shorten the server name, check its log, or remove the rule |
| `connection closed before the tool call was answered` | HTTP connection dropped mid-call | Check whether the action happened before asking again |
| `MCP server "<name>" was not saved` | Other Claude Code processes held `~/.claude.json` | Rerun with `CLAUDE_CODE_CONFIG_LOCK_WAIT_MS=60000` |

Stdio servers that exit are not restarted in an interactive session, so use Reconnect in `/mcp`. The [MCP hub](https://aifordevs.org/topics/mcp) and the [coding agents hub](https://aifordevs.org/topics/coding-agents) collect related guides.

> **What ran for this guide**
>
> On November 16, 2026, `claude --version` and the `--help` of every `claude mcp` subcommand ran on Claude Code 2.1.318, the `headersHelper` script ran against test token files, and Node.js 26.12.1 parsed every JSON block on this page. No command that writes Claude Code configuration ran, no MCP server connected, and no model session used MCP tools. Bifrost and Bifrost Edge were not deployed; the gateway details follow their docs as of that date.

## Questions

### How do I add an MCP server to Claude Code?

Run claude mcp add with a name and either a URL or a launch command. A remote server takes --transport http and its URL. A local server takes the command after a double dash, as in claude mcp add airtable -- npx -y airtable-mcp-server. Then run /mcp inside a session or claude mcp get with the name to confirm the server connected, since adding it does not check credentials.

### Where does Claude Code store MCP server configuration?

Local and user scope servers live in ~/.claude.json in your home directory. Local entries sit under the current project's path, and user entries load in every project. Project scope servers live in .mcp.json at the repository root, which you commit so the whole team gets them. Organizations can also deploy servers through managed settings or a managed-mcp.json file.

### What is the difference between local, project, and user scope in Claude Code?

Local scope is the default and loads a server only for you in one project. Project scope writes the server to a shared .mcp.json file that teammates approve on first use. User scope loads a server for you in every project. When two scopes define the same name, local wins over project and project wins over user, and Claude Code uses the winning entry whole.

### Is Claude Code an MCP client or an MCP server?

It is both. In normal use Claude Code is an MCP host that opens one MCP client connection per configured server and calls their tools. With claude mcp serve it also runs as a stdio MCP server that exposes its own tools, such as file reads, edits, and shell commands, to another client like Claude Desktop, which must then handle approvals itself.

### Why is my MCP server not showing up in Claude Code?

Check the scope first: a server added at the default local scope appears only in the project where you added it. A .mcp.json server stays at Pending approval until you run claude interactively and approve it. A JSON entry with a url but no type is skipped. Run claude mcp list for each server's status and claude mcp get with its name for the failure detail.

### How do I give an MCP server an API key without committing it?

Reference an environment variable in .mcp.json, such as Bearer ${MY_SERVICE_TOKEN} in a header, and set the variable in each person's shell. Claude Code expands it at load time and shows the reference by name in /mcp. Do not reference ANTHROPIC_API_KEY or cloud provider credentials, because Claude Code reads those as empty in remote URLs and headers.

### Does Claude Code support remote MCP servers with OAuth?

Yes. Add the server with --transport http, then run /mcp in a session or claude mcp login with its name in your shell to finish the browser sign-in. Claude Code stores and refreshes the tokens. Servers without dynamic client registration need --client-id, --client-secret, and usually --callback-port to match a pre-registered redirect URI. WebSocket servers support headers only, not OAuth.

## Sources

1. [Claude Code docs, Connect Claude Code to tools via MCP (read November 16, 2026)](https://code.claude.com/docs/en/mcp)
2. [Claude Code docs, Configure permissions, MCP rules (read November 16, 2026)](https://code.claude.com/docs/en/permissions)
3. [Claude Code docs, Environment variables (read November 16, 2026)](https://code.claude.com/docs/en/env-vars)
4. [Claude Code docs, CLI reference (read November 16, 2026)](https://code.claude.com/docs/en/cli-reference)
5. [Claude Code docs, Error reference (read November 16, 2026)](https://code.claude.com/docs/en/errors)
6. [Claude Code docs, Control MCP server access for your organization](https://code.claude.com/docs/en/managed-mcp)
7. [Claude Code changelog, versions 2.1.318 to 2.1.325](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md)
8. [npm, @anthropic-ai/claude-code package (2.1.325 published November 13, 2026)](https://www.npmjs.com/package/@anthropic-ai/claude-code)
9. [Model Context Protocol, architecture overview, revision 2026-07-28](https://modelcontextprotocol.io/docs/2026-07-28/learn/architecture)
10. [Bifrost reference page for AI systems (last updated September 2026)](https://www.getmaxim.ai/llm-info)
11. [Bifrost docs, MCP gateway overview](https://docs.getbifrost.ai/mcp/overview)
12. [Bifrost docs, Connecting to MCP servers](https://docs.getbifrost.ai/mcp/connecting-to-servers)
13. [Bifrost docs, MCP gateway authentication](https://docs.getbifrost.ai/mcp/gateway-auth)
14. [Bifrost docs, MCP tool filtering](https://docs.getbifrost.ai/mcp/filtering)
15. [Bifrost docs, Claude Code integration](https://docs.getbifrost.ai/cli-agents/claude-code)
16. [Bifrost docs, Get MCP tool logs API](https://docs.getbifrost.ai/api-reference/logging/get-mcp-tool-logs)
17. [Bifrost docs, Built-in observability and logging headers](https://docs.getbifrost.ai/features/observability/default)
18. [Bifrost docs, Edge: govern MCP servers](https://docs.getbifrost.ai/edge/mcp-governance)
19. [Bifrost docs, Edge supported applications](https://docs.getbifrost.ai/edge/supported-applications)

## Cite this guide

AI for Devs. "Claude Code MCP: add, scope, authenticate, and debug servers." Published November 19, 2026. https://aifordevs.org/articles/claude-code-mcp

- Page: https://aifordevs.org/articles/claude-code-mcp
- Markdown: https://aifordevs.org/articles/claude-code-mcp.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
- Published: 2026-11-19
