To add an MCP server to Claude Code, run claude mcp add with a transport, a name and the server’s URL or launch command, then check it with claude mcp list (or /mcp inside a session). Remote servers that need a sign-in are authenticated from /mcp or with claude mcp login <name>. There is no mcp.json file in Claude Code: a team’s shared servers go in .mcp.json at the project root, and your own servers go in ~/.claude.json.

claude mcp add --transport http notion https://mcp.notion.com/mcp

Applies to: Claude Code 2.1.325 (changelog), docs as of November 16, 2026. Last checked: November 16, 2026.

On this page

What MCP gives Claude Code

The Model Context Protocol is an open standard that lets Claude Code call tools, databases and APIs in other systems. Anthropic’s MCP reference suggests connecting a server when you keep copying data into the chat from another tool, such as an issue tracker or a monitoring dashboard, so Claude can read and act on that system directly. For a first server, Anthropic also has a step-by-step MCP quickstart.

Warning

Anthropic’s docs say to verify you trust each server before connecting it: servers that fetch external content can expose you to prompt injection. Anthropic reviews connectors for its Directory but doesn’t security-audit or manage any MCP server.

How do I add an MCP server with claude mcp add?

The command shape depends on the transport. The MCP reference documents four.

Transport When the docs recommend it How to add it
http (streamable HTTP) Remote servers; the recommended option and the most widely supported for cloud services claude mcp add --transport http <name> <url>
sse Deprecated. Since v2.1.265, --transport http tries HTTP first and switches to SSE when the server doesn’t accept it --transport http on v2.1.265+, or claude mcp add --transport sse <name> <url>
stdio Local processes that need direct system access or custom scripts claude mcp add [options] <name> -- <command> [args...]
ws (WebSocket) Remote servers that push events unprompted; no OAuth and no --transport flag Only through .mcp.json or claude mcp add-json

Remote HTTP server

# 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"

In JSON configs, type also accepts streamable-http as an alias for http, so configs copied from a server’s own docs work as written. An entry with a url but no type is read as stdio and skipped with the error MCP server "<name>" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry (source).

Remote SSE server

The docs mark SSE as deprecated. On Claude Code v2.1.265 or later, add an SSE-only service with the same --transport http command as above and Claude Code falls back to SSE by itself (source). On an earlier version, or to connect over SSE directly:

# Basic syntax
claude mcp add --transport sse <name> <url>

# Real example: Connect to Asana
claude mcp add --transport sse asana https://mcp.asana.com/sse

# Example with authentication header
claude mcp add --transport sse private-api https://api.company.com/sse \
  --header "X-API-Key: your-key-here"

Local stdio server

# 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

The -- separates Claude Code’s own options (--transport, --env, --scope) from the server command. Everything after it is passed to the server untouched; without it, Claude Code tries to parse the server’s flags such as --port as its own (source). --env accepts several KEY=value pairs, so put at least one other option between --env and the server name or the CLI reads the name as another pair.

Claude Code sets CLAUDE_PROJECT_DIR in the stdio server’s environment to the project root. Because the variable exists only in the server’s environment, a ${CLAUDE_PROJECT_DIR} reference in the command or args of .mcp.json or ~/.claude.json needs a default, such as ${CLAUDE_PROJECT_DIR:-.}. When a session ends, Claude Code sends a stdio server SIGINT, then SIGTERM after 100 ms and SIGKILL after a further 400 ms on macOS and Linux; on Windows it closes stdin and ends the process tree 300 ms later (source).

WebSocket server

claude mcp add-json events-server \
  '{"type":"ws","url":"wss://mcp.example.com/socket","headers":{"Authorization":"Bearer YOUR_TOKEN"}}'

A ws entry takes the same url, headers, headersHelper, timeout and alwaysLoad fields as http; authentication is header-only (source).

Flags you will use most

From the MCP reference:

Flag What it does
--transport, -t http, sse or stdio
--scope, -s local (default), project or user
--env, -e Sets KEY=value environment variables for the server
--header, -H Adds an HTTP header, such as Authorization
--client-id, --client-secret, --callback-port Pre-configured OAuth credentials and a fixed callback port (HTTP and SSE only)

Server names added through claude mcp can contain only letters, numbers, hyphens and underscores. The names workspace, claude-in-chrome, computer-use, Claude Preview and Claude Browser are reserved for built-in servers: claude mcp add rejects them, and a config entry with one is skipped at load time with a warning (source).

The server’s docs only show setup for another client

Many servers document Claude Desktop or Cursor setup and give no claude mcp add line. The MCP reference says to look for one of three things in those instructions and turn it into a Claude Code command (source):

What the instructions give you What it means Claude Code command
A URL such as https://mcp.example.com/mcp Remote server claude mcp add --transport http example https://mcp.example.com/mcp (for a wss:// URL, use add-json with "type":"ws")
A launch command such as npx -y @example/mcp-server Local stdio server claude mcp add example --env API_KEY=your-key -- npx -y @example/mcp-server
An mcpServers JSON block Config for another client’s settings file claude mcp add-json with the object inside mcpServers, not the wrapper

This block written for another client:

{
  "mcpServers": {
    "example": {
      "command": "npx",
      "args": ["-y", "@example/mcp-server"]
    }
  }
}

becomes this command:

claude mcp add-json example '{"command":"npx","args":["-y","@example/mcp-server"]}'

Two repairs are sometimes needed first: add "type": "http", "sse" or "ws" to an entry that has a url but no type, and rename a key that has characters other than letters, numbers, hyphens and underscores. Each command writes to local scope unless you add --scope project or --scope user, prints an Added ... line on success, and claude mcp get <name> then shows whether it connected.

Which scope should I use: local, project or user?

The --scope flag decides where the config is written and who gets it (MCP installation scopes).

Scope Loads in Shared with team Stored in
Local (default) Current project only No ~/.claude.json, under the project’s path
Project Current project only Yes, via version control .mcp.json in the project root
User All your projects No ~/.claude.json
# Add a project-scoped server
claude mcp add --transport http shared-server --scope project https://example.com/mcp

That command writes this .mcp.json, which you commit so the team gets the same servers:

{
  "mcpServers": {
    "shared-server": {
      "type": "http",
      "url": "https://example.com/mcp"
    }
  }
}

When one server is defined in several places, Claude Code connects once, using the whole entry from the highest-precedence source without merging fields: local, then project, then user, then plugin-provided servers, then claude.ai connectors. The three scopes are matched by name; plugins and connectors are matched by endpoint, so a plugin pointing at the same URL as one of your servers counts as a duplicate. A server your organization provides through the managedMcpServers managed setting ranks above all of them (v2.1.259 or later) (source).

In interactive sessions, Claude Code asks for approval before using project-scoped servers from .mcp.json; claude mcp reset-project-choices resets those choices. claude -p runs, Agent SDK sessions and cloud sessions outside a project’s threads can’t show that prompt and load project servers without asking. To keep a server out anyway, add it to disabledMcpjsonServers, exclude project settings with --setting-sources, or start with --strict-mcp-config so only the servers passed with --mcp-config load (source). A cloned repository can’t approve its own servers: enableAllProjectMcpServers or enabledMcpjsonServers committed to .claude/settings.json is ignored until you accept the workspace trust dialog (source).

Environment variables in .mcp.json

.mcp.json expands ${VAR} and ${VAR:-default} in command, args, env, url and headers, so a shared file can keep secrets out of version control (source):

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

If a variable is unset and has no default, the config still loads, claude mcp list and /mcp show a warning naming the variable, and the literal ${VAR} text is used.

How do I list, inspect and remove servers?

# List all configured servers
claude mcp list

# Get details for a specific server
claude mcp get notion

# Remove a server
claude mcp remove notion

# (within Claude Code) Check server status
/mcp

claude mcp list shows a status per server, such as ✔ Connected, ! Needs authentication or ✘ Failed to connect; a failure there means Claude Code couldn’t reach that server, not that the command failed. For a failed server, claude mcp list appends the HTTP status or error code and any error text the server returned, and claude mcp get <name> shows it on an Issue: line. Some statuses report a configuration decision instead of a connection attempt (server status):

Status Meaning What to do
⏸ Pending approval (run `claude` to approve) A .mcp.json server you haven’t approved Run claude interactively and approve it
✘ Rejected (see disabledMcpjsonServers in settings) A disabledMcpjsonServers entry blocks it (shown only by claude mcp get) Remove the entry if you want the server
⊘ Disabled for this project (re-enable via /mcp) You switched it off in /mcp Turn it back on in /mcp
✘ Blocked by enterprise managed policy An organization policy refuses it Ask your administrator

claude mcp remove also deletes the OAuth tokens and client registration Claude Code stored for a remote server, but it doesn’t revoke the tokens at the authorization server. To revoke them where the server supports it, run claude mcp logout <name> before claude mcp remove <name> (source).

To switch a server off without deleting its config, toggle it in the /mcp panel. Claude Code records that per project in ~/.claude.json under disabledMcpServers; built-in servers that are off by default, such as computer-use, are switched on through a separate enabledMcpServers list (source).

How do I authenticate a remote MCP server?

Many remote servers use OAuth 2.0. Add the server without a credential, then sign in (authentication):

  1. Add the server:

    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
    
  2. In a Claude Code session, run /mcp and follow the browser sign-in.

  3. Check that the server shows as connected in the /mcp menu.

Tokens are stored and refreshed automatically; “Clear authentication” in /mcp revokes access. If the browser redirect fails with a connection error after you sign in, paste the full callback URL from the address bar into the prompt Claude Code shows. To sign in from the shell instead of /mcp, run claude mcp login (source):

claude mcp login sentry

It prints the authorization URL instead of opening a browser when none is available, such as over SSH (connect with ssh -t, since the paste step needs an interactive terminal). --no-browser forces the URL prompt:

claude mcp login sentry --no-browser

claude mcp logout <name> clears stored credentials. claude -p and Agent SDK runs have no /mcp panel and can’t run the OAuth flow, so sign in from an interactive session or with claude mcp login first. If you configured an Authorization header and the server rejects it, Claude Code reports the connection as failed rather than falling back to OAuth; remove the header to use the sign-in flow.

Servers without dynamic client registration

Claude Code discovers servers that use Dynamic Client Registration or a Client ID Metadata Document (CIMD) automatically. If you see “Incompatible auth server: does not support dynamic client registration”, register an OAuth app in the server’s developer portal (with a redirect URI of the form http://localhost:PORT/callback if it asks for one) and pass its credentials. --client-secret prompts with masked input, and the secret goes to the system keychain (macOS) or a credentials file, not your config (source):

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

The secret can only be set when you add the server; to change it, remove the server and add it again with --client-secret and the same --scope. The same part of the docs covers oauth.scopes to pin requested scopes, oauth.authServerMetadataUrl to override metadata discovery, and headersHelper for non-OAuth schemes such as Kerberos or short-lived tokens. Our MCP OAuth guide explains how remote server authorization works at the protocol level.

Warning

The docs state that Claude Code executes a headersHelper as an arbitrary shell command. For a server in a project .mcp.json or at local scope, it runs only after you accept the trust dialog for that project directory; a parent folder’s trust doesn’t count.

Can I add a server from JSON or import from Claude Desktop?

Yes. claude mcp add-json takes a full JSON entry:

# Basic syntax
claude mcp add-json <name> '<json>'

# Example: Adding an HTTP server with JSON configuration
claude mcp add-json weather-api '{"type":"http","url":"https://api.weather.com/mcp","headers":{"Authorization":"Bearer token"}}'

To copy servers you set up in Claude Desktop, run:

claude mcp add-from-claude-desktop

An interactive dialog lets you pick which servers to import. The docs say this works only on macOS and WSL, reads the Claude Desktop config from its standard location and accepts --scope user. A server whose name contains characters other than letters, numbers, hyphens and underscores is reported and skipped, and a name that already exists gets a numeric suffix such as server_1 (source).

If you log in to Claude Code with a claude.ai account, connectors you added at claude.ai appear automatically in /mcp. Set "disableClaudeAiConnectors": true in any settings file, or ENABLE_CLAUDEAI_MCP_SERVERS=false, to turn off the connectors Claude Code fetches itself; a project-level false can’t re-enable connectors a user or policy setting turned off (source).

How do I use MCP resources and prompts?

Resources. Type @ in a prompt to see resources from connected servers next to files, and reference one as @server:protocol://resource/path:

Can you analyze @github:issue://123 and suggest a fix?

Prompts. Servers can expose prompts as commands. Type / to see them: Claude Code lists each one as /servername:promptname (MCP), and typing /mcp__servername__promptname also runs it, with arguments space-separated:

/mcp__github__pr_review 456

Both are described in the MCP reference.

Setting Default and effect
MAX_MCP_OUTPUT_TOKENS Warning above 10,000 tokens of tool output; default limit 25,000 tokens. A successful text result over the limit is saved to a file in the session’s tool-results folder and Claude gets the path
Text results over 50,000 characters Saved to a file whatever their token count, unless the tool declares anthropic/maxResultSizeChars (up to 500,000)
MCP_TIMEOUT Server startup timeout in ms, e.g. MCP_TIMEOUT=10000 claude
timeout in a server entry Hard per-call limit in ms for that server; overrides MCP_TOOL_TIMEOUT (about 28 hours when unset). Values below 1000 are ignored
CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT Idle window before a silent tool call aborts: five minutes for HTTP, SSE, WebSocket and connector servers, 30 for stdio; 0 disables it
ENABLE_TOOL_SEARCH Tool search is on by default and defers tool definitions until needed; auto loads tools upfront while they stay under 10% of the context window, auto:N sets your own percentage, false loads everything upfront
alwaysLoad: true Loads all of one server’s tools at session start, bypassing deferral
export MAX_MCP_OUTPUT_TOKENS=50000
claude

A tool call in the main conversation that is still running after two minutes moves to a background task, shown in /tasks, instead of blocking the session; the timeouts above still apply to it. HTTP and SSE responses over 16 MiB fail. Sources: output limits, time limits, backgrounding, tool search.

How do organizations control MCP servers?

Control MCP server access for your organization documents three mechanisms:

Mechanism What it does Users keep their own servers?
managed-mcp.json A fixed server set with exclusive control; an empty "mcpServers": {} disables MCP No, including plugin servers and --mcp-config
managedMcpServers in managed settings (v2.1.259+) Gives every user the remote http or sse servers you list, https:// URLs only, no ${VAR} expansion Yes
allowedMcpServers / deniedMcpServers Filter user-configured servers by serverUrl, serverCommand or serverName; add allowManagedMcpServersOnly: true so users can’t broaden the allowlist. The denylist always wins Yes, within the lists
Platform managed-mcp.json path
macOS /Library/Application Support/ClaudeCode/managed-mcp.json
Linux and WSL /etc/claude-code/managed-mcp.json
Windows C:\Program Files\ClaudeCode\managed-mcp.json
{
  "allowManagedMcpServersOnly": true,
  "allowedMcpServers": [
    { "serverUrl": "https://api.githubcopilot.com/*" },
    { "serverUrl": "https://*.internal.example.com/*" }
  ]
}

The docs warn that a serverName entry is not a security control, since users choose the name; use serverUrl or serverCommand for enforcement. managed-mcp.json is a standalone file and can’t be delivered through server-managed settings, and anyone who can read the managed settings on a machine can read a header value set in managedMcpServers, so use a credential issued for that whole audience or leave headers out and let each user sign in with OAuth.

Servers the docs use as examples

Anthropic’s reference walks through Notion, Sentry (OAuth), GitHub (personal access token in a header) and Stripe. Our directory has the install commands and client support for each: GitHub MCP Server, Sentry MCP, Notion MCP and Stripe MCP. The full list is in the MCP server directory, and best MCP servers for Claude Code groups them by job.

claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
  --header "Authorization: Bearer YOUR_GITHUB_PAT"

The docs note that claude mcp add saves the config without validating credentials, so a placeholder is accepted but the server fails later with an HTTP 401 shown in /mcp.