Connect to external tools with MCP
--- a/mcp.md
+++ b/mcp.md
@@ -828,7 +828,7 @@
## Related resources
* **[Custom tools guide](</docs/en/agent-sdk/custom-tools>)** : Build your own MCP server that runs in-process with your SDK application
- * **[Permissions](</docs/en/agent-sdk/permissions>)** : Control which MCP tools your agent can use with `allowedTools` and `disallowedTools`
+ * **[Permissions](</docs/en/agent-sdk/permissions>)** : Pre-approve MCP tools with `allowedTools` and deny them with `disallowedTools`
* **[TypeScript SDK reference](</docs/en/agent-sdk/typescript>)** : Full API reference including MCP configuration options
* **[Python SDK reference](</docs/en/agent-sdk/python>)** : Full API reference including MCP configuration options
* **[MCP server directory](<https://github.com/modelcontextprotocol/servers>)** : Browse available MCP servers for databases, APIs, and more
--- a/mcp.md
+++ b/mcp.md
@@ -361,7 +361,7 @@
mcpServers: {
"api-server": {
command: "npx",
- args: ["-y", "@your-org/api-mcp-server"],
+ args: ["-y", "<MCP_SERVER_PACKAGE>"],
env: {
API_KEY: process.env.API_KEY
}
@@ -375,7 +375,7 @@
mcp_servers={
"api-server": {
"command": "npx",
- "args": ["-y", "@your-org/api-mcp-server"],
+ "args": ["-y", "<MCP_SERVER_PACKAGE>"],
"env": {"API_KEY": os.environ["API_KEY"]},
}
},
@@ -386,7 +386,7 @@
"mcpServers": {
"api-server": {
"command": "npx",
- "args": ["-y", "@your-org/api-mcp-server"],
+ "args": ["-y", "<MCP_SERVER_PACKAGE>"],
"env": {
"API_KEY": "${API_KEY}"
}
--- a/mcp.md
+++ b/mcp.md
@@ -747,7 +747,7 @@
asyncio.run(main())
-A remote server’s status can also change after it reports `"connected"`. When the connection to it drops mid-session, Claude Code moves the server back to `"pending"` while [reconnecting](</docs/en/mcp#automatic-reconnection>). A later `mcpServerStatus()` call in TypeScript, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python, can then report `"pending"` for a server you saw connected earlier, with no configuration change on your side. After five reconnection attempts fail, the server reports `"failed"`, or `"needs-auth"` when it needs authorizing again. A `"failed"` HTTP or SSE server can still return to `"connected"` without a call from you, because Claude Code keeps [retrying in the background](</docs/en/mcp#mid-session-drops-of-a-remote-server>) after a transient error. To retry manually, call [`reconnectMcpServer()`](</docs/en/agent-sdk/typescript#methods>) in TypeScript or [`ClaudeSDKClient.reconnect_mcp_server()`](</docs/en/agent-sdk/python#methods>) in Python.
+A remote server’s status can also change after it reports `"connected"`. Claude Code moves the server back to `"pending"` while [reconnecting](</docs/en/mcp#automatic-reconnection>). A later `mcpServerStatus()` call in TypeScript, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python, can then report `"pending"` for a server you saw connected earlier, with no configuration change on your side. After five reconnection attempts fail, the server reports `"failed"`, or `"needs-auth"` when it needs authorizing again. A `"failed"` HTTP or SSE server can still return to `"connected"` without a call from you, because Claude Code keeps [retrying in the background](</docs/en/mcp#mid-session-drops-of-a-remote-server>) after a transient error. To retry manually, call [`reconnectMcpServer()`](</docs/en/agent-sdk/typescript#methods>) in TypeScript or [`ClaudeSDKClient.reconnect_mcp_server()`](</docs/en/agent-sdk/python#methods>) in Python.
## Troubleshooting
Show diff (380 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -2,11 +2,7 @@
This page covers MCP configuration for the Agent SDK. To add MCP servers to the Claude Code CLI so they load in every project, see [MCP installation scopes](</docs/en/mcp#mcp-installation-scopes>).
-##
-
-
-
-Quickstart
+## Quickstart
This example connects to the [Claude Code documentation](<https://code.claude.com/docs>) MCP server using HTTP transport and uses `allowedTools` with a wildcard to permit all tools from the server.
@@ -58,19 +54,11 @@
The agent connects to the documentation server, searches for information about hooks, and returns the results.
-##
-
-
-
-Add an MCP server
+## Add an MCP server
You can configure MCP servers in code when calling `query()`, or in a `.mcp.json` file loaded via `settingSources`.
-###
-
-
-
-Add a server in code
+### Add a server in code
Pass MCP servers directly in the `mcpServers` option. This example starts a local filesystem MCP server for `/Users/me/projects`. Replace that path with a directory on your machine:
@@ -121,11 +109,7 @@
asyncio.run(main())
-###
-
-
-
-Add a server from a config file
+### Add a server from a config file
Create a `.mcp.json` file at your project root. The file is picked up when the `project` setting source is enabled, which it is for default `query()` options. If you set `settingSources` explicitly, include `"project"` for this file to load. Replace `/Users/me/projects` with a directory on your machine:
@@ -138,11 +122,7 @@
}
}
-##
-
-
-
-Connection timing
+## Connection timing
Claude Code starts connecting your MCP servers when the session starts, and sends the init message once the first-turn wait, if any, ends. How long the first turn waits for a server depends on where you configured it. If you set `permissionPromptToolName`, the first turn always waits for that tool’s server, up to `MCP_TIMEOUT`, wherever you configured it. For a server in `options.mcpServers`, find its type in the first column to see how long the first turn waits for it.
@@ -159,19 +139,11 @@
* **Otherwise, with[tool search](</docs/en/agent-sdk/tool-search>) on, which is the default**: the first turn waits up to 2 seconds, and only for pending servers that set [`alwaysLoad: true`](</docs/en/mcp#exempt-a-server-from-deferral>) or that you named. The rest keep connecting in the background, and Claude [reaches their tools](</docs/en/mcp#tool-availability>) once they connect.
* **Otherwise, with tool search off** : the first turn waits up to 2 seconds for every pending settings-file and plugin server. Tool search is off when your [`ENABLE_TOOL_SEARCH` value or model](</docs/en/agent-sdk/tool-search#configure-tool-search>) turns it off, or when you exclude the `ToolSearch` tool, for example through `disallowedTools`.
-###
-
-
-
-Named servers
+### Named servers
You name a server by listing any of its tools, such as `mcp__github__list_issues` or `mcp__github__*`, in `allowedTools` or in a `permissions.allow` rule in the `settings` option. An [`mcp_tool` hook](</docs/en/hooks#mcp-tool-hook-fields>) also names the server it calls when you configure it on a prompt-submission, tool-use, permission, subagent, task, elicitation, or worktree event. Before v2.1.284, naming a server had no effect on the first-turn wait.
-###
-
-
-
-Set the first-turn wait yourself
+### Set the first-turn wait yourself
To choose the first-turn wait yourself, set `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` in the [`env` option](</docs/en/agent-sdk/configuration#set-environment-variables>), for example `CLAUDE_CODE_MCP_STARTUP_WAIT_MS: "5000"`. The first turn then waits up to that many milliseconds for pending settings-file and plugin servers, whether or not tool search is on. The same limit replaces the `MCP_TIMEOUT` wait for the stdio, HTTP, and SSE servers in `options.mcpServers`. Three waits apply whatever value you set, including `0`:
@@ -181,11 +153,7 @@
Set the variable to `0` to skip the wait for every other server. Servers still pending when the wait ends keep connecting in the background. `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` requires Claude Code v2.1.274 or later.
-###
-
-
-
-Make startup wait for servers
+### Make startup wait for servers
Two settings make startup itself wait, before Claude Code sends the init message:
@@ -194,19 +162,11 @@
The init message reports each server’s status as of the moment Claude Code sends it.
-##
-
-
-
-Allow MCP tools
+## Allow MCP tools
MCP tools require explicit permission before Claude can use them. Without permission, Claude will see that tools are available but won’t be able to call them.
-###
-
-
-
-Tool naming convention
+### Tool naming convention
MCP tools are named `mcp__<server-name>__<tool-name>`, where `<server-name>` is the name you register the server under, such as its key in `mcpServers`. Characters in the server name such as `.` and spaces are replaced by `_`. This table shows the full name of a `list_issues` tool for two server keys:
@@ -217,11 +177,7 @@
Use the full tool names in `allowedTools` and in [MCP permission rules](</docs/en/permissions#mcp>). For a server that a [plugin](</docs/en/agent-sdk/plugins>) provides, `<server-name>` takes the [plugin-scoped form](</docs/en/mcp#plugin-provided-mcp-servers>) and starts with `plugin_`.
-###
-
-
-
-Auto-approve with allowedTools
+### Auto-approve with allowedTools
Use `allowedTools` to auto-approve specific MCP tools:
@@ -257,11 +213,7 @@
**Prefer`allowedTools` over permission modes for MCP access.** `permissionMode: "acceptEdits"` does not auto-approve MCP tools (only file edits and filesystem Bash commands). `permissionMode: "bypassPermissions"` does auto-approve MCP tools but also disables most other safety prompts, which is broader than necessary; see [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) for the prompts that remain. A wildcard in `allowedTools` grants exactly the MCP server you want and nothing more. See [Permission modes](</docs/en/agent-sdk/permissions#permission-modes>) for a full comparison.
-###
-
-
-
-Discover available tools
+### Discover available tools
To see what tools an MCP server provides, check the server’s documentation or inspect the `tools` array in the `system` init message. MCP tool names start with `mcp__`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so the `tools` array lists the `mcp__` tools of each server that has connected by then, plus those of servers with a cached tool list, which connect on first use. Tools of any other server that hasn’t connected are absent; see Error handling for reading each server’s status. This filter prints the MCP tool names:
@@ -302,11 +254,7 @@
You can also ask Claude to list the tools available from a server.
-##
-
-
-
-Transport types
+## Transport types
MCP servers communicate with your agent using different transport protocols. Check the server’s documentation to see which transport it supports:
@@ -314,11 +262,7 @@
* If the docs give you a **URL** , use HTTP or SSE
* If you’re building your own tools in code, use an SDK MCP server
-###
-
-
-
-stdio servers
+### stdio servers
Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine. For the `.mcp.json` form, use the same fields shown at Add a server from a config file. In code, pass the command and its arguments. Replace `/Users/me/projects` with a directory on your machine:
@@ -352,11 +296,7 @@
allowed_tools=["mcp__filesystem__read_file", "mcp__filesystem__list_directory"],
)
-###
-
-
-
-HTTP/SSE servers
+### HTTP/SSE servers
Use HTTP or SSE for cloud-hosted MCP servers and remote APIs. For the `.mcp.json` form, use the same fields as the example at HTTP headers for remote servers, with `"type": "sse"` for an SSE server. In code, pass the server’s URL:
@@ -392,35 +332,19 @@
For the streamable HTTP transport, use `"type": "http"` instead. In `.mcp.json` and other JSON config files, `"streamable-http"` is accepted as an alias for `"http"`. The SDKs’ `McpHttpServerConfig` type declares only `"http"`, so use `"http"` for servers you pass in code.
-###
-
-
-
-SDK MCP servers
+### SDK MCP servers
Define custom tools directly in your application code instead of running a separate server process. See the [custom tools guide](</docs/en/agent-sdk/custom-tools>) for implementation details. An SDK MCP server registered by an [`initialize` control request](</docs/en/agent-sdk/typescript#sdkcontrolinitializeresponse>) begins connecting as soon as Claude Code processes the request.
-##
-
-
-
-MCP tool search
+## MCP tool search
When you have many MCP tools configured, tool definitions can consume a significant portion of your context window. Tool search solves this by withholding tool definitions from context and loading only the ones Claude needs for each turn. Tool search is enabled by default. See [Tool search](</docs/en/agent-sdk/tool-search>) for configuration options, best practices, and using tool search with custom SDK tools.
-##
-
-
-
-Authentication
+## Authentication
Most MCP servers require authentication to access external services. Pass credentials through environment variables in the server configuration.
-###
-
-
-
-Pass credentials via environment variables
+### Pass credentials via environment variables
Use the `env` field to pass API keys, tokens, and other credentials to the MCP server:
@@ -472,11 +396,7 @@
The `${API_KEY}` syntax expands environment variables at runtime.
-###
-
-
-
-HTTP headers for remote servers
+### HTTP headers for remote servers
For HTTP and SSE servers, pass authentication headers directly in the server configuration:
@@ -530,11 +450,7 @@
For a complete working example of a remote server authenticated with headers, see List issues from a repository.
-###
-
-
-
-OAuth2 authentication
+### OAuth2 authentication
The [MCP specification supports OAuth 2.1](<https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization>) for authorization. The SDK doesn’t open a browser or run an interactive OAuth flow. When a configured server returns an authorization challenge and Claude Code has no token to send, the SDK reports the server as `needs-auth` or `failed`:
@@ -579,17 +495,9 @@
allowed_tools=["mcp__oauth-api__*"],
)
-##
-
-
-
-Examples
-
-###
-
-
-
-List issues from a repository
+## Examples
+
+### List issues from a repository
This example connects to the remote [GitHub MCP server](<https://github.com/github/github-mcp-server>) to list recent issues. The example includes debug logging to verify the MCP connection and tool calls. Before running, create a [GitHub personal access token](<https://github.com/settings/personal-access-tokens>) with read access to the repositories you want to query and set it as an environment variable:
@@ -680,11 +588,7 @@
In the `MCP servers:` line, a `status` of `connected` for `github` confirms the token works. If Claude Code has a cached tool list for the server, the status can read `pending` instead and the server connects on its first tool call. If the status is `failed` or `needs-auth`, see Error handling before trusting the result, since Claude can fall back to built-in tools when the server is unavailable.
-###
-
-
-
-Query a database
+### Query a database
This example uses [DBHub](<https://github.com/bytebase/dbhub>) to query a Postgres database. The agent automatically discovers the database schema, writes the SQL query, and returns the results. DBHub’s `execute_sql` tool runs whatever SQL the agent emits, including writes, unless you restrict it. Setting `readonly = true` in the [DBHub configuration file](<https://dbhub.ai/config/toml>) makes DBHub reject `INSERT`, `UPDATE`, `DELETE`, and DDL statements, so the example cannot modify your data even if the agent emits a write. DBHub resolves `${DATABASE_URL}` from the process environment when it loads the config, so the connection string stays out of the file. Create this `dbhub.toml` next to your script:
@@ -758,11 +662,7 @@
asyncio.run(main())
-##
-
-
-
-Error handling
+## Error handling
MCP servers can fail to connect for various reasons: the server process might not be installed, credentials might be invalid, or a remote server might be unreachable. Claude Code emits a `system` message with subtype `init` at the start of each query. This message includes the connection status for each MCP server. The `status` field can be `"pending"`, `"connected"`, `"failed"`, `"needs-auth"`, or `"disabled"`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so such a server that connected within the wait shows `"connected"`. In the init message, don’t treat `"pending"` as a failure on its own. It can mean any of these:
@@ -849,17 +749,9 @@
A remote server’s status can also change after it reports `"connected"`. When the connection to it drops mid-session, Claude Code moves the server back to `"pending"` while [reconnecting](</docs/en/mcp#automatic-reconnection>). A later `mcpServerStatus()` call in TypeScript, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python, can then report `"pending"` for a server you saw connected earlier, with no configuration change on your side. After five reconnection attempts fail, the server reports `"failed"`, or `"needs-auth"` when it needs authorizing again. A `"failed"` HTTP or SSE server can still return to `"connected"` without a call from you, because Claude Code keeps [retrying in the background](</docs/en/mcp#mid-session-drops-of-a-remote-server>) after a transient error. To retry manually, call [`reconnectMcpServer()`](</docs/en/agent-sdk/typescript#methods>) in TypeScript or [`ClaudeSDKClient.reconnect_mcp_server()`](</docs/en/agent-sdk/python#methods>) in Python.
-##
-
-
-
-Troubleshooting
-
-###
-
-
-
-Server shows “failed” status
+## Troubleshooting
+
+### Server shows “failed” status
Check the `init` message to see which servers failed to connect:
@@ -887,11 +779,7 @@
* **Invalid connection string** : For database servers, verify the connection string format and that the database is accessible.
* **Network issues** : For remote HTTP/SSE servers, check the URL is reachable and any firewalls allow the connection.
-###
-
-
-
-Tools not being called
+### Tools not being called
If Claude sees tools but doesn’t use them, check that you’ve granted permission with `allowedTools`:
@@ -915,11 +803,7 @@
allowed_tools=["mcp__servername__*"], # Auto-approve calls from this server
)
-###
-
-
-
-A tool is missing from an SDK MCP server
+### A tool is missing from an SDK MCP server
In the TypeScript SDK, when a tool’s input schema can’t be converted to JSON Schema, the server you created with [`createSdkMcpServer()`](</docs/en/agent-sdk/typescript#createsdkmcpserver>) leaves that tool out when it lists its tools. The SDK emits a warning at that point. Under Node.js the warning is a process warning with code `CLAUDE_SDK_MCP_TOOL_SCHEMA_UNCONVERTIBLE`, and it starts with this text:
@@ -927,11 +811,7 @@
The rest of the warning gives the conversion error’s message when it has one, then says what to check and change. Before TypeScript Agent SDK v0.3.286, one unconvertible schema made the server’s whole tool listing fail without this warning, so none of that server’s tools reached Claude.
-###
-
-
-
-Connection timeouts
+### Connection timeouts
MCP server connections time out after 30 seconds by default. To change how long a running tool call may take, set [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>). If your server takes longer to start, the connection fails. Raise the connection limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
@@ -941,19 +821,11 @@
In TypeScript, you can set the tool-call limit for a single SDK MCP server by passing [`timeout` to `createSdkMcpServer()`](</docs/en/agent-sdk/typescript#createsdkmcpserver>).
-###
-
-
-
-Tool output exceeds maximum allowed tokens
+### Tool output exceeds maximum allowed tokens
The SDK applies the same MCP output limits as Claude Code. When a successful tool result with no image content is larger than 25,000 tokens, Claude Code saves the output to a file and replaces the tool result with an error message that names the file path, so the agent can read the output back in portions. To change the token limit, set the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. Unless the tool declares `anthropic/maxResultSizeChars`, a successful text result longer than 50,000 characters is saved to a file regardless of the token limit. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server declares that annotation.
-##
-
-
-
-Related resources
+## Related resources
* **[Custom tools guide](</docs/en/agent-sdk/custom-tools>)** : Build your own MCP server that runs in-process with your SDK application
* **[Permissions](</docs/en/agent-sdk/permissions>)** : Control which MCP tools your agent can use with `allowedTools` and `disallowedTools`
--- a/mcp.md
+++ b/mcp.md
@@ -223,7 +223,7 @@
Auto-approve with allowedTools
-Use `allowedTools` to auto-approve specific MCP tools so Claude can use them without a permission prompt:
+Use `allowedTools` to auto-approve specific MCP tools:
TypeScript
--- a/mcp.md
+++ b/mcp.md
@@ -536,7 +536,12 @@
OAuth2 authentication
-The [MCP specification supports OAuth 2.1](<https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization>) for authorization. The SDK doesn’t open a browser or run an interactive OAuth flow. When a configured server returns an authorization challenge and no stored token is available, the agent run continues without that server’s tools, and the server reports status `needs-auth`. The `mcp_servers` array of the [system init message](</docs/en/agent-sdk/typescript#sdksystemmessage>) may still show `pending` for that server when it’s emitted. To confirm whether a server needs credentials, poll `mcpServerStatus()` in the TypeScript SDK or [`get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python. To supply credentials, complete the OAuth flow in your own application and pass the resulting access token in the server’s `headers`:
+The [MCP specification supports OAuth 2.1](<https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization>) for authorization. The SDK doesn’t open a browser or run an interactive OAuth flow. When a configured server returns an authorization challenge and Claude Code has no token to send, the SDK reports the server as `needs-auth` or `failed`:
+
+ * **`needs-auth`** : Claude Code found no sign-in it can use for the server. Pass a token in `headers`, or [sign in from an interactive Claude Code session](</docs/en/mcp#authenticate-with-remote-mcp-servers>) on the same machine before the run.
+ * **`failed`** , with an `error` in its [`McpServerStatus`](</docs/en/agent-sdk/typescript#mcpserverstatus>) entry that starts with `Couldn't read the stored credentials` or `A request to MCP server`: Claude Code couldn’t read its credential store. For what to do, see [Couldn’t read the stored credentials for MCP server](</docs/en/errors#couldnt-read-the-stored-credentials-for-mcp-server>). Before Claude Code v2.1.307, the status was `needs-auth` instead when a Mac’s login keychain was locked.
+
+In either case, the agent run continues without that server’s tools. The `mcp_servers` array of the [system init message](</docs/en/agent-sdk/typescript#sdksystemmessage>) may still show `pending` for that server when it’s emitted. To confirm whether a server needs credentials, poll `mcpServerStatus()` in the TypeScript SDK or [`get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python. To supply credentials, complete the OAuth flow in your own application and pass the resulting access token in the server’s `headers`:
TypeScript
--- a/mcp.md
+++ b/mcp.md
@@ -144,7 +144,7 @@
Connection timing
-Claude Code registers the servers you pass in `options.mcpServers` at startup and emits the init message once the first-turn wait, if any, resolves. Whether each `options.mcpServers` server delays the first turn, and when it connects, depends on its type:
+Claude Code starts connecting your MCP servers when the session starts, and sends the init message once the first-turn wait, if any, ends. How long the first turn waits for a server depends on where you configured it. If you set `permissionPromptToolName`, the first turn always waits for that tool’s server, up to `MCP_TIMEOUT`, wherever you configured it. For a server in `options.mcpServers`, find its type in the first column to see how long the first turn waits for it.
Server type| Delays the first turn?| First-turn wait timeout
---|---|---
@@ -152,17 +152,47 @@
Remote server with a cached tool list, saved by Claude Code from a previous connection| No; the cached tools are available from the first turn| None; connects on its first tool call, and that deferred connect has its own timeout
In-process SDK server| Yes, until it connects and lists its tools| [`MCP_TIMEOUT`](</docs/en/env-vars>), 30 seconds by default, per connect attempt; the connection fails at that deadline
-Servers loaded from settings files such as `.mcp.json` or from plugins commonly show `pending` in the init message. When `options.mcpServers` holds a stdio, HTTP, or SSE server, the first turn waits for these pending servers too, up to `MCP_TIMEOUT`. When `options.mcpServers` is empty or holds only SDK servers, the first turn waits up to 2 seconds instead:
-
- * **With[tool search](</docs/en/agent-sdk/tool-search>), the default**: the wait covers still-pending servers configured with [`alwaysLoad: true`](</docs/en/mcp#exempt-a-server-from-deferral>) and not the rest. The rest keep connecting in the background. [Tool availability](</docs/en/mcp#tool-availability>) describes how Claude reaches their tools once they connect.
- * **Without tool search** : the wait covers every pending server. [Configure tool search](</docs/en/agent-sdk/tool-search#configure-tool-search>) covers what turns tool search off. If you exclude the `ToolSearch` tool from the session, for example through `disallowedTools`, the session also runs without tool search.
-
-If you set `permissionPromptToolName`, the first turn also waits for that tool’s server in every case, up to `MCP_TIMEOUT`. To set the first-turn wait yourself, add `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` to the [`env` option](</docs/en/agent-sdk/configuration#set-environment-variables>), for example `CLAUDE_CODE_MCP_STARTUP_WAIT_MS: "5000"`. The first turn then waits up to that many milliseconds for every pending server, whether or not tool search is available. This deadline also replaces the `MCP_TIMEOUT` first-turn wait for stdio, HTTP, and SSE servers in `options.mcpServers`. `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` requires Claude Code v2.1.274 or later. Servers still pending when the wait ends keep connecting in the background. Set the variable to `0` to skip the wait. A `permissionPromptToolName` server keeps its own `MCP_TIMEOUT` wait regardless of the value. To block startup itself at a separate, earlier phase than the first-turn wait, before the init message is sent:
-
- * Set [`MCP_CONNECTION_NONBLOCKING`](</docs/en/env-vars>) to `0` to block on the whole connection batch. Claude Code caps that wait at 5 seconds by default. Adjust the cap with the [`MCP_CONNECT_TIMEOUT_MS`](</docs/en/env-vars>) environment variable, in milliseconds. Servers still pending at that deadline keep connecting in the background.
- * Set `alwaysLoad: true` on a server’s config to make its tools available at their full schemas on the first turn, [exempt from tool search deferral](</docs/en/mcp#exempt-a-server-from-deferral>). Claude Code waits at startup for that server’s tools, capped at the same deadline, while other servers keep connecting in the background; a remote server with a cached tool list supplies them without connecting, per the table above.
-
-The `system` message with subtype `init` reports each server’s status at the moment it’s emitted; see Error handling for reading those statuses.
+A server has a cached tool list only when the [MCP discovery cache](</docs/en/mcp#server-status-detail>) is on. Servers from settings files such as `.mcp.json`, or from plugins, often still show `pending` in the init message. How long the first turn waits for them depends on `options.mcpServers` and tool search:
+
+ * **`options.mcpServers` includes a stdio, HTTP, or SSE server**: the first turn waits for the pending settings-file and plugin servers too, up to `MCP_TIMEOUT`.
+ * **Otherwise, when`ANTHROPIC_BASE_URL` points to a [gateway](</docs/en/mcp#tool-search-through-a-gateway>) and [`ENABLE_TOOL_SEARCH`](</docs/en/mcp#configure-tool-search>) is unset**: the first turn waits up to 2 seconds for every pending settings-file and plugin server.
+ * **Otherwise, with[tool search](</docs/en/agent-sdk/tool-search>) on, which is the default**: the first turn waits up to 2 seconds, and only for pending servers that set [`alwaysLoad: true`](</docs/en/mcp#exempt-a-server-from-deferral>) or that you named. The rest keep connecting in the background, and Claude [reaches their tools](</docs/en/mcp#tool-availability>) once they connect.
+ * **Otherwise, with tool search off** : the first turn waits up to 2 seconds for every pending settings-file and plugin server. Tool search is off when your [`ENABLE_TOOL_SEARCH` value or model](</docs/en/agent-sdk/tool-search#configure-tool-search>) turns it off, or when you exclude the `ToolSearch` tool, for example through `disallowedTools`.
+
+###
+
+
+
+Named servers
+
+You name a server by listing any of its tools, such as `mcp__github__list_issues` or `mcp__github__*`, in `allowedTools` or in a `permissions.allow` rule in the `settings` option. An [`mcp_tool` hook](</docs/en/hooks#mcp-tool-hook-fields>) also names the server it calls when you configure it on a prompt-submission, tool-use, permission, subagent, task, elicitation, or worktree event. Before v2.1.284, naming a server had no effect on the first-turn wait.
+
+###
+
+
+
+Set the first-turn wait yourself
+
+To choose the first-turn wait yourself, set `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` in the [`env` option](</docs/en/agent-sdk/configuration#set-environment-variables>), for example `CLAUDE_CODE_MCP_STARTUP_WAIT_MS: "5000"`. The first turn then waits up to that many milliseconds for pending settings-file and plugin servers, whether or not tool search is on. The same limit replaces the `MCP_TIMEOUT` wait for the stdio, HTTP, and SSE servers in `options.mcpServers`. Three waits apply whatever value you set, including `0`:
+
+ * **A`permissionPromptToolName` server**: up to `MCP_TIMEOUT`.
+ * **An in-processSDK server**: up to `MCP_TIMEOUT` per connect attempt.
+ * **A still-connectingnamed server**: at least up to 2 seconds, so a value below `2000` doesn’t shorten its wait.
+
+Set the variable to `0` to skip the wait for every other server. Servers still pending when the wait ends keep connecting in the background. `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` requires Claude Code v2.1.274 or later.
+
+###
+
+
+
+Make startup wait for servers
+
+Two settings make startup itself wait, before Claude Code sends the init message:
+
+ * **[`MCP_CONNECTION_NONBLOCKING`](</docs/en/env-vars>) set to `0`**: startup waits for the whole connection batch, up to 5 seconds by default. Set [`MCP_CONNECT_TIMEOUT_MS`](</docs/en/env-vars>), in milliseconds, to change that cap. Servers still pending at the cap keep connecting in the background.
+ * **`alwaysLoad: true` on a server’s config**: startup waits up to the same cap for that server’s tools, so the first turn has them at full schema, [exempt from tool search deferral](</docs/en/mcp#exempt-a-server-from-deferral>). A remote server with a cached tool list supplies them without connecting or holding startup.
+
+The init message reports each server’s status as of the moment Claude Code sends it.
##
--- a/mcp.md
+++ b/mcp.md
@@ -178,7 +178,14 @@
Tool naming convention
-MCP tools follow the naming pattern `mcp__<server-name>__<tool-name>`. For example, a GitHub server named `"github"` with a `list_issues` tool becomes `mcp__github__list_issues`.
+MCP tools are named `mcp__<server-name>__<tool-name>`, where `<server-name>` is the name you register the server under, such as its key in `mcpServers`. Characters in the server name such as `.` and spaces are replaced by `_`. This table shows the full name of a `list_issues` tool for two server keys:
+
+Key in `mcpServers`| Full tool name
+---|---
+`github`| `mcp__github__list_issues`
+`my.server`| `mcp__my_server__list_issues`
+
+Use the full tool names in `allowedTools` and in [MCP permission rules](</docs/en/permissions#mcp>). For a server that a [plugin](</docs/en/agent-sdk/plugins>) provides, `<server-name>` takes the [plugin-scoped form](</docs/en/mcp#plugin-provided-mcp-servers>) and starts with `plugin_`.
###
--- a/mcp.md
+++ b/mcp.md
@@ -805,7 +805,7 @@
asyncio.run(main())
-A remote server’s status can also change after it reports `"connected"`. When the connection to it drops mid-session, Claude Code moves the server back to `"pending"` while [reconnecting](</docs/en/mcp#automatic-reconnection>). A later `mcpServerStatus()` call in TypeScript, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python, can then report `"pending"` for a server you saw connected earlier, with no configuration change on your side. After five reconnection attempts fail, the server reports `"failed"`, or `"needs-auth"` when it needs authorizing again. To retry manually, call [`reconnectMcpServer()`](</docs/en/agent-sdk/typescript#methods>) in TypeScript or [`ClaudeSDKClient.reconnect_mcp_server()`](</docs/en/agent-sdk/python#methods>) in Python.
+A remote server’s status can also change after it reports `"connected"`. When the connection to it drops mid-session, Claude Code moves the server back to `"pending"` while [reconnecting](</docs/en/mcp#automatic-reconnection>). A later `mcpServerStatus()` call in TypeScript, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python, can then report `"pending"` for a server you saw connected earlier, with no configuration change on your side. After five reconnection attempts fail, the server reports `"failed"`, or `"needs-auth"` when it needs authorizing again. A `"failed"` HTTP or SSE server can still return to `"connected"` without a call from you, because Claude Code keeps [retrying in the background](</docs/en/mcp#mid-session-drops-of-a-remote-server>) after a transient error. To retry manually, call [`reconnectMcpServer()`](</docs/en/agent-sdk/typescript#methods>) in TypeScript or [`ClaudeSDKClient.reconnect_mcp_server()`](</docs/en/agent-sdk/python#methods>) in Python.
##
--- a/mcp.md
+++ b/mcp.md
@@ -70,7 +70,7 @@
-In code
+Add a server in code
Pass MCP servers directly in the `mcpServers` option. This example starts a local filesystem MCP server for `/Users/me/projects`. Replace that path with a directory on your machine:
@@ -125,7 +125,7 @@
-From a config file
+Add a server from a config file
Create a `.mcp.json` file at your project root. The file is picked up when the `project` setting source is enabled, which it is for default `query()` options. If you set `settingSources` explicitly, include `"project"` for this file to load. Replace `/Users/me/projects` with a directory on your machine:
@@ -283,7 +283,7 @@
stdio servers
-Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine. For the `.mcp.json` form, use the same fields shown at From a config file. In code, pass the command and its arguments. Replace `/Users/me/projects` with a directory on your machine:
+Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine. For the `.mcp.json` form, use the same fields shown at Add a server from a config file. In code, pass the command and its arguments. Replace `/Users/me/projects` with a directory on your machine:
TypeScript
--- a/mcp.md
+++ b/mcp.md
@@ -905,7 +905,7 @@
Tool output exceeds maximum allowed tokens
-The SDK applies the same MCP output limit as Claude Code. When a tool result with no image content is larger than 25,000 tokens, Claude Code saves the output to a file and replaces the tool result with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server can declare a higher per-tool limit with the `anthropic/maxResultSizeChars` annotation.
+The SDK applies the same MCP output limits as Claude Code. When a successful tool result with no image content is larger than 25,000 tokens, Claude Code saves the output to a file and replaces the tool result with an error message that names the file path, so the agent can read the output back in portions. To change the token limit, set the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. Unless the tool declares `anthropic/maxResultSizeChars`, a successful text result longer than 50,000 characters is saved to a file regardless of the token limit. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server declares that annotation.
##
--- a/mcp.md
+++ b/mcp.md
@@ -877,6 +877,18 @@
+A tool is missing from an SDK MCP server
+
+In the TypeScript SDK, when a tool’s input schema can’t be converted to JSON Schema, the server you created with [`createSdkMcpServer()`](</docs/en/agent-sdk/typescript#createsdkmcpserver>) leaves that tool out when it lists its tools. The SDK emits a warning at that point. Under Node.js the warning is a process warning with code `CLAUDE_SDK_MCP_TOOL_SCHEMA_UNCONVERTIBLE`, and it starts with this text:
+
+ Tool "<name>" on SDK MCP server "<server>" was left out of the server's tool list, because its input schema cannot be converted to JSON Schema
+
+The rest of the warning gives the conversion error’s message when it has one, then says what to check and change. Before TypeScript Agent SDK v0.3.286, one unconvertible schema made the server’s whole tool listing fail without this warning, so none of that server’s tools reached Claude.
+
+###
+
+
+
Connection timeouts
MCP server connections time out after 30 seconds by default. To change how long a running tool call may take, set [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>). If your server takes longer to start, the connection fails. Raise the connection limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
--- a/mcp.md
+++ b/mcp.md
@@ -150,7 +150,7 @@
---|---|---
stdio server, or HTTP/SSE server without a cached tool list| Yes, until it connects| [`MCP_TIMEOUT`](</docs/en/env-vars>), 30 seconds by default; the connection fails at that deadline
Remote server with a cached tool list, saved by Claude Code from a previous connection| No; the cached tools are available from the first turn| None; connects on its first tool call, and that deferred connect has its own timeout
-In-process SDK server| Yes, until it connects and lists its tools| None; the connect and tool listing requests each have their own timeout
+In-process SDK server| Yes, until it connects and lists its tools| [`MCP_TIMEOUT`](</docs/en/env-vars>), 30 seconds by default, per connect attempt; the connection fails at that deadline
Servers loaded from settings files such as `.mcp.json` or from plugins commonly show `pending` in the init message. When `options.mcpServers` holds a stdio, HTTP, or SSE server, the first turn waits for these pending servers too, up to `MCP_TIMEOUT`. When `options.mcpServers` is empty or holds only SDK servers, the first turn waits up to 2 seconds instead:
--- a/mcp.md
+++ b/mcp.md
@@ -144,7 +144,7 @@
Connection timing
-Claude Code registers the servers you pass in `options.mcpServers` at startup and emits the init message once the first-turn wait, if any, resolves. Without `options.mcpServers`, Claude Code waits 2 seconds for pending servers before the first turn, so servers loaded from settings files such as `.mcp.json` commonly show `pending` at init. When each `options.mcpServers` server connects, and whether it delays the first turn, depends on its type:
+Claude Code registers the servers you pass in `options.mcpServers` at startup and emits the init message once the first-turn wait, if any, resolves. Whether each `options.mcpServers` server delays the first turn, and when it connects, depends on its type:
Server type| Delays the first turn?| First-turn wait timeout
---|---|---
@@ -152,7 +152,12 @@
Remote server with a cached tool list, saved by Claude Code from a previous connection| No; the cached tools are available from the first turn| None; connects on its first tool call, and that deferred connect has its own timeout
In-process SDK server| Yes, until it connects and lists its tools| None; the connect and tool listing requests each have their own timeout
-To block startup itself at a separate, earlier phase than the first-turn wait, before the init message is sent:
+Servers loaded from settings files such as `.mcp.json` or from plugins commonly show `pending` in the init message. When `options.mcpServers` holds a stdio, HTTP, or SSE server, the first turn waits for these pending servers too, up to `MCP_TIMEOUT`. When `options.mcpServers` is empty or holds only SDK servers, the first turn waits up to 2 seconds instead:
+
+ * **With[tool search](</docs/en/agent-sdk/tool-search>), the default**: the wait covers still-pending servers configured with [`alwaysLoad: true`](</docs/en/mcp#exempt-a-server-from-deferral>) and not the rest. The rest keep connecting in the background. [Tool availability](</docs/en/mcp#tool-availability>) describes how Claude reaches their tools once they connect.
+ * **Without tool search** : the wait covers every pending server. [Configure tool search](</docs/en/agent-sdk/tool-search#configure-tool-search>) covers what turns tool search off. If you exclude the `ToolSearch` tool from the session, for example through `disallowedTools`, the session also runs without tool search.
+
+If you set `permissionPromptToolName`, the first turn also waits for that tool’s server in every case, up to `MCP_TIMEOUT`. To set the first-turn wait yourself, add `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` to the [`env` option](</docs/en/agent-sdk/configuration#set-environment-variables>), for example `CLAUDE_CODE_MCP_STARTUP_WAIT_MS: "5000"`. The first turn then waits up to that many milliseconds for every pending server, whether or not tool search is available. This deadline also replaces the `MCP_TIMEOUT` first-turn wait for stdio, HTTP, and SSE servers in `options.mcpServers`. `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` requires Claude Code v2.1.274 or later. Servers still pending when the wait ends keep connecting in the background. Set the variable to `0` to skip the wait. A `permissionPromptToolName` server keeps its own `MCP_TIMEOUT` wait regardless of the value. To block startup itself at a separate, earlier phase than the first-turn wait, before the init message is sent:
* Set [`MCP_CONNECTION_NONBLOCKING`](</docs/en/env-vars>) to `0` to block on the whole connection batch. Claude Code caps that wait at 5 seconds by default. Adjust the cap with the [`MCP_CONNECT_TIMEOUT_MS`](</docs/en/env-vars>) environment variable, in milliseconds. Servers still pending at that deadline keep connecting in the background.
* Set `alwaysLoad: true` on a server’s config to make its tools available at their full schemas on the first turn, [exempt from tool search deferral](</docs/en/mcp#exempt-a-server-from-deferral>). Claude Code waits at startup for that server’s tools, capped at the same deadline, while other servers keep connecting in the background; a remote server with a cached tool list supplies them without connecting, per the table above.
--- a/mcp.md
+++ b/mcp.md
@@ -150,7 +150,7 @@
---|---|---
stdio server, or HTTP/SSE server without a cached tool list| Yes, until it connects| [`MCP_TIMEOUT`](</docs/en/env-vars>), 30 seconds by default; the connection fails at that deadline
Remote server with a cached tool list, saved by Claude Code from a previous connection| No; the cached tools are available from the first turn| None; connects on its first tool call, and that deferred connect has its own timeout
-In-process SDK server| No; never delays the first turn| None
+In-process SDK server| Yes, until it connects and lists its tools| None; the connect and tool listing requests each have their own timeout
To block startup itself at a separate, earlier phase than the first-turn wait, before the init message is sent:
--- a/mcp.md
+++ b/mcp.md
@@ -888,7 +888,7 @@
Tool output exceeds maximum allowed tokens
-The SDK applies the same MCP output limit as Claude Code. When a tool result is larger than 25,000 tokens, the full output is saved to a file and the tool result is replaced with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server can declare a higher per-tool limit with the `anthropic/maxResultSizeChars` annotation.
+The SDK applies the same MCP output limit as Claude Code. When a tool result with no image content is larger than 25,000 tokens, Claude Code saves the output to a file and replaces the tool result with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server can declare a higher per-tool limit with the `anthropic/maxResultSizeChars` annotation.
##
--- a/mcp.md
+++ b/mcp.md
@@ -72,7 +72,7 @@
In code
-Pass MCP servers directly in the `mcpServers` option:
+Pass MCP servers directly in the `mcpServers` option. This example starts a local filesystem MCP server for `/Users/me/projects`. Replace that path with a directory on your machine:
TypeScript
@@ -127,7 +127,7 @@
From a config file
-Create a `.mcp.json` file at your project root. The file is picked up when the `project` setting source is enabled, which it is for default `query()` options. If you set `settingSources` explicitly, include `"project"` for this file to load:
+Create a `.mcp.json` file at your project root. The file is picked up when the `project` setting source is enabled, which it is for default `query()` options. If you set `settingSources` explicitly, include `"project"` for this file to load. Replace `/Users/me/projects` with a directory on your machine:
{
"mcpServers": {
@@ -278,7 +278,7 @@
stdio servers
-Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine. For the `.mcp.json` form, use the same fields shown at From a config file. In code, pass the command and its arguments:
+Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine. For the `.mcp.json` form, use the same fields shown at From a config file. In code, pass the command and its arguments. Replace `/Users/me/projects` with a directory on your machine:
TypeScript
@@ -348,7 +348,7 @@
allowed_tools=["mcp__remote-api__*"],
)
-For the streamable HTTP transport, use `"type": "http"` instead. In `.mcp.json` and other JSON config files, `"streamable-http"` is accepted as an alias for `"http"`. The programmatic `mcpServers` option accepts only `"http"`.
+For the streamable HTTP transport, use `"type": "http"` instead. In `.mcp.json` and other JSON config files, `"streamable-http"` is accepted as an alias for `"http"`. The SDKs’ `McpHttpServerConfig` type declares only `"http"`, so use `"http"` for servers you pass in code.
###
@@ -630,6 +630,8 @@
print(message.result)
asyncio.run(main())
+
+In the `MCP servers:` line, a `status` of `connected` for `github` confirms the token works. If Claude Code has a cached tool list for the server, the status can read `pending` instead and the server connects on its first tool call. If the status is `failed` or `needs-auth`, see Error handling before trusting the result, since Claude can fall back to built-in tools when the server is unavailable.
###
--- a/mcp.md
+++ b/mcp.md
@@ -872,11 +872,13 @@
Connection timeouts
-MCP server connections time out after 30 seconds by default. Claude Code applies that limit to the connection attempt only; to change how long a running tool call may take, set [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>). If your server takes longer to start, the connection fails. Raise the connection limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
+MCP server connections time out after 30 seconds by default. To change how long a running tool call may take, set [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>). If your server takes longer to start, the connection fails. Raise the connection limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
* Using a lighter-weight server if available
* Pre-warming the server before starting your agent
* Checking server logs for slow initialization causes
+
+In TypeScript, you can set the tool-call limit for a single SDK MCP server by passing [`timeout` to `createSdkMcpServer()`](</docs/en/agent-sdk/typescript#createsdkmcpserver>).
###
--- a/mcp.md
+++ b/mcp.md
@@ -144,7 +144,7 @@
Connection timing
-Claude Code registers the servers you pass in `options.mcpServers` at startup and emits the init message once the first-turn wait, if any, resolves. Servers loaded from settings files such as `.mcp.json` don’t get the full wait and commonly show `pending` at init. When each `options.mcpServers` server connects, and whether it delays the first turn, depends on its type:
+Claude Code registers the servers you pass in `options.mcpServers` at startup and emits the init message once the first-turn wait, if any, resolves. Without `options.mcpServers`, Claude Code waits 2 seconds for pending servers before the first turn, so servers loaded from settings files such as `.mcp.json` commonly show `pending` at init. When each `options.mcpServers` server connects, and whether it delays the first turn, depends on its type:
Server type| Delays the first turn?| First-turn wait timeout
---|---|---
@@ -715,7 +715,13 @@
Error handling
-MCP servers can fail to connect for various reasons: the server process might not be installed, credentials might be invalid, or a remote server might be unreachable. Claude Code emits a `system` message with subtype `init` at the start of each query. This message includes the connection status for each MCP server. The `status` field can be `"pending"`, `"connected"`, `"failed"`, `"needs-auth"`, or `"disabled"`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so such a server that connected within the wait shows `"connected"`. A `"pending"` status means the server hasn’t connected yet, which is common for settings-file servers that don’t get the full wait, or that its tool list was served from the cache with a connection made on first use; the reported status for a deadline-expired server can be `"pending"` or `"failed"` depending on timing. Don’t treat `"pending"` as a failure. Check for `"failed"` or `"needs-auth"` to detect servers that won’t be usable:
+MCP servers can fail to connect for various reasons: the server process might not be installed, credentials might be invalid, or a remote server might be unreachable. Claude Code emits a `system` message with subtype `init` at the start of each query. This message includes the connection status for each MCP server. The `status` field can be `"pending"`, `"connected"`, `"failed"`, `"needs-auth"`, or `"disabled"`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so such a server that connected within the wait shows `"connected"`. In the init message, don’t treat `"pending"` as a failure on its own. It can mean any of these:
+
+ * The server hasn’t connected yet. See how long Claude Code waits for it before the first turn
+ * The server’s tool list was served from the cache, with a connection made on first use
+ * The connection deadline expired. Such a server reports `"pending"` or `"failed"` depending on timing
+
+Check for `"failed"` or `"needs-auth"` to detect servers that won’t be usable:
TypeScript
@@ -792,6 +798,8 @@
asyncio.run(main())
+A remote server’s status can also change after it reports `"connected"`. When the connection to it drops mid-session, Claude Code moves the server back to `"pending"` while [reconnecting](</docs/en/mcp#automatic-reconnection>). A later `mcpServerStatus()` call in TypeScript, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python, can then report `"pending"` for a server you saw connected earlier, with no configuration change on your side. After five reconnection attempts fail, the server reports `"failed"`, or `"needs-auth"` when it needs authorizing again. To retry manually, call [`reconnectMcpServer()`](</docs/en/agent-sdk/typescript#methods>) in TypeScript or [`ClaudeSDKClient.reconnect_mcp_server()`](</docs/en/agent-sdk/python#methods>) in Python.
+
##
@@ -823,7 +831,7 @@
if server.get("status") == "failed":
print(f"Server {server['name']} failed to connect")
-A `"pending"` status doesn’t mean the server failed; see Error handling for the two cases it covers at init. To get updated statuses later in the session, call the query’s `mcpServerStatus()` method in the TypeScript SDK, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python. Common causes:
+A `"pending"` status doesn’t mean the server failed. See Error handling for the cases it covers at init. To get updated statuses later in the session, call the query’s `mcpServerStatus()` method in the TypeScript SDK, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python. Common causes:
* **Missing environment variables** : Ensure required tokens and credentials are set. For stdio servers, check the `env` field matches what the server expects.
* **Server not installed** : For `npx` commands, verify the package exists and Node.js is in your PATH.
--- a/mcp.md
+++ b/mcp.md
@@ -316,11 +316,7 @@
HTTP/SSE servers
-Use HTTP or SSE for cloud-hosted MCP servers and remote APIs:
-
- * In code
-
- * .mcp.json
+Use HTTP or SSE for cloud-hosted MCP servers and remote APIs. For the `.mcp.json` form, use the same fields as the example at HTTP headers for remote servers, with `"type": "sse"` for an SSE server. In code, pass the server’s URL:
TypeScript
@@ -351,18 +347,6 @@
},
allowed_tools=["mcp__remote-api__*"],
)
-
- {
- "mcpServers": {
- "remote-api": {
- "type": "sse",
- "url": "https://api.example.com/mcp/sse",
- "headers": {
- "Authorization": "Bearer ${API_TOKEN}"
- }
- }
- }
- }
For the streamable HTTP transport, use `"type": "http"` instead. In `.mcp.json` and other JSON config files, `"streamable-http"` is accepted as an alias for `"http"`. The programmatic `mcpServers` option accepts only `"http"`.
@@ -892,7 +876,7 @@
Tool output exceeds maximum allowed tokens
-The SDK applies the same MCP output limit as Claude Code. When a tool result is larger than 25,000 tokens, the full output is saved to a file and the tool result is replaced with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server can declare a higher per-tool limit.
+The SDK applies the same MCP output limit as Claude Code. When a tool result is larger than 25,000 tokens, the full output is saved to a file and the tool result is replaced with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server can declare a higher per-tool limit with the `anthropic/maxResultSizeChars` annotation.
##
@@ -902,7 +886,6 @@
* **[Custom tools guide](</docs/en/agent-sdk/custom-tools>)** : Build your own MCP server that runs in-process with your SDK application
* **[Permissions](</docs/en/agent-sdk/permissions>)** : Control which MCP tools your agent can use with `allowedTools` and `disallowedTools`
- * **[MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>)** : How the SDK handles tool results that exceed `MAX_MCP_OUTPUT_TOKENS`, including the persist-to-disk fallback and the `anthropic/maxResultSizeChars` per-tool annotation
* **[TypeScript SDK reference](</docs/en/agent-sdk/typescript>)** : Full API reference including MCP configuration options
* **[Python SDK reference](</docs/en/agent-sdk/python>)** : Full API reference including MCP configuration options
* **[MCP server directory](<https://github.com/modelcontextprotocol/servers>)** : Browse available MCP servers for databases, APIs, and more
--- a/mcp.md
+++ b/mcp.md
@@ -157,7 +157,7 @@
* Set [`MCP_CONNECTION_NONBLOCKING`](</docs/en/env-vars>) to `0` to block on the whole connection batch. Claude Code caps that wait at 5 seconds by default. Adjust the cap with the [`MCP_CONNECT_TIMEOUT_MS`](</docs/en/env-vars>) environment variable, in milliseconds. Servers still pending at that deadline keep connecting in the background.
* Set `alwaysLoad: true` on a server’s config to make its tools available at their full schemas on the first turn, [exempt from tool search deferral](</docs/en/mcp#exempt-a-server-from-deferral>). Claude Code waits at startup for that server’s tools, capped at the same deadline, while other servers keep connecting in the background; a remote server with a cached tool list supplies them without connecting, per the table above.
-The `system` message with subtype `init` reports each server’s status at the moment it’s emitted. Check for status `failed` or `needs-auth` when you want to detect servers that won’t be usable, rather than treating every status other than `connected` as a failure; see Error handling for the full status check.
+The `system` message with subtype `init` reports each server’s status at the moment it’s emitted; see Error handling for reading those statuses.
##
@@ -221,7 +221,7 @@
Discover available tools
-To see what tools an MCP server provides, check the server’s documentation or inspect the `tools` array in the `system` init message. MCP tool names start with `mcp__`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so the `tools` array lists the `mcp__` tools of each such server that connected within the wait. A server with a cached tool list shows `pending` with its `mcp__` tools already listed and a connection made on first use. Any other server that hasn’t connected when the message is emitted, including settings-file servers that don’t get the full wait, shows its current status, such as `pending`, `failed`, or `needs-auth`, with its tools absent; see Error handling for the full status set. This filter prints the MCP tool names:
+To see what tools an MCP server provides, check the server’s documentation or inspect the `tools` array in the `system` init message. MCP tool names start with `mcp__`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so the `tools` array lists the `mcp__` tools of each server that has connected by then, plus those of servers with a cached tool list, which connect on first use. Tools of any other server that hasn’t connected are absent; see Error handling for reading each server’s status. This filter prints the MCP tool names:
TypeScript
@@ -278,11 +278,7 @@
stdio servers
-Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine:
-
- * In code
-
- * .mcp.json
+Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine. For the `.mcp.json` form, use the same fields shown at From a config file. In code, pass the command and its arguments:
TypeScript
@@ -313,15 +309,6 @@
},
allowed_tools=["mcp__filesystem__read_file", "mcp__filesystem__list_directory"],
)
-
- {
- "mcpServers": {
- "filesystem": {
- "command": "npx",
- "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
- }
- }
- }
###
@@ -893,7 +880,7 @@
Connection timeouts
-MCP server connections time out after 30 seconds by default. If your server takes longer to start, the connection fails. Raise the limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
+MCP server connections time out after 30 seconds by default. Claude Code applies that limit to the connection attempt only; to change how long a running tool call may take, set [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>). If your server takes longer to start, the connection fails. Raise the connection limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
* Using a lighter-weight server if available
* Pre-warming the server before starting your agent
Show diff (2118 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -1,1209 +1,921 @@
-Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs. Connect a server when you find yourself copying data into chat from another tool, like an issue tracker or a monitoring dashboard. Once connected, Claude can read and act on that system directly instead of working from what you paste. If you’re connecting your first server, start with the [MCP quickstart](</docs/en/mcp-quickstart>) for a step-by-step walkthrough. This page is the full reference.
-
-##
-
-
-
-What you can do with MCP
-
-With MCP servers connected, you can ask Claude Code to:
-
- * **Implement features from issue trackers** : “Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.”
- * **Analyze monitoring data** : “Check Sentry and Statsig to check the usage of the feature described in ENG-4521.”
- * **Query databases** : “Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.”
- * **Integrate designs** : “Update our standard email template based on the new Figma designs that were posted in Slack”
- * **Automate workflows** : “Create Gmail drafts inviting these 10 users to a feedback session about the new feature.”
- * **React to external events** : an MCP server can also act as a [channel](</docs/en/channels>) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you’re away.
-
-##
-
-
-
-Find and build MCP servers
-
-Browse reviewed connectors in the [Anthropic Directory](<https://claude.ai/directory>). Directory connectors use the same MCP infrastructure as Claude Code, so you can add any remote server listed there with `claude mcp add`.
-
-Verify you trust each server before connecting it. Servers that fetch external content can expose you to [prompt injection risk](</docs/en/security#protect-against-prompt-injection>).
-
-To build your own server, see the [MCP server guide](<https://modelcontextprotocol.io/docs/develop/build-server>) for protocol fundamentals and the [Claude connector building docs](<https://claude.com/docs/connectors/building>) for authentication, testing, and Directory submission. You can also have Claude scaffold a server for you with the official [`mcp-server-dev` plugin](<https://github.com/anthropics/claude-plugins-official/tree/main/plugins/mcp-server-dev>).
-
-1
-
-Install the plugin
-
-In a Claude Code session, run:
-
- /plugin install mcp-server-dev@claude-plugins-official
-
-If the install fails, match the message Claude Code reports:
-
- * `Marketplace "claude-plugins-official" not found`: add the marketplace with `/plugin marketplace add anthropics/claude-plugins-official`, then retry the install.
- * The plugin is not found in the marketplace: check the plugin name. Claude Code [refreshes a stale marketplace catalog and retries](</docs/en/discover-plugins#install-plugins>) before reporting this, so if you turned off [marketplace auto-update](</docs/en/discover-plugins#configure-auto-updates>), refresh manually with `/plugin marketplace update claude-plugins-official` and retry the install.
-
-Check the install summary: if it reports `Run /reload-plugins to activate.`, run that command.
-
-2
-
-Run the build skill
-
- /mcp-server-dev:build-mcp-server
-
-Claude asks about your use case and scaffolds a remote HTTP or local stdio server.
-
-##
-
-
-
-Installing MCP servers
-
-MCP servers can be configured in several ways depending on your needs:
-
-###
-
-
-
-Option 1: Add a remote HTTP server
-
-HTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.
-
- # 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"
-
-When configuring MCP servers via JSON in `.mcp.json`, `~/.claude.json`, or `claude mcp add-json`, the `type` field accepts `streamable-http` as an alias for `http`. The MCP specification uses the name `streamable-http` for this transport, so configurations copied from server documentation work without modification. A JSON entry that has a `url` but no `type` is a configuration error, because Claude Code reads an entry with no `type` as a stdio server. Claude Code skips that server and reports `MCP server "<name>" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry`. Before v2.1.202, Claude Code reported this misconfiguration as `command: expected string, received undefined`. In `--output-format stream-json` runs, Claude Code also reports a skipped `--mcp-config` entry in the `system/init` event’s [`mcp_server_errors` field](</docs/en/headless#stream-responses>), so scripts can detect that the server never loaded. This requires Claude Code v2.1.219 or later.
-
-###
-
-
-
-Option 2: Add a remote SSE server
-
-The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.
-
-Some services still expose only an SSE endpoint. Use the same command as the HTTP transport, with `--transport sse`:
-
- # 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"
-
-###
-
-
-
-Option 3: Add a local stdio server
-
-Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. `CLAUDE_PROJECT_DIR` is the stable project root and doesn’t change when you add or remove working directories mid-session. A server that limits its own filesystem access to a set of allowed directories should implement the MCP `roots/list` request instead. Claude Code answers `roots/list` with the session’s launch directory plus every [additional working directory](</docs/en/permissions#working-directories>) you’ve granted with `--add-dir`, `/add-dir`, or the `additionalDirectories` setting. Claude Code sends `notifications/roots/list_changed` when that set changes. Before v2.1.203, `roots/list` returned only the launch directory and Claude Code didn’t send `notifications/roots/list_changed`. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in the `command` or `args` of a project-scoped `.mcp.json` entry or a local- or user-scoped server entry in `~/.claude.json` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default.
-
- # 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
-
-**Important: Separate server arguments with`--`**For stdio servers, the `--` (double dash) separates Claude’s own options, such as `--transport`, `--env`, and `--scope`, from the command and arguments that run the server. Everything after `--` is passed to the server untouched.For example:
-
- * `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`
- * `claude mcp add --env KEY=value --transport stdio myserver -- python server.py --port 8080` → runs `python server.py --port 8080` with `KEY=value` in environment
-
-Without `--`, Claude Code would try to parse the server’s flags, like `--port` above, as its own options.`--env` accepts multiple `KEY=value` pairs. If the server name comes directly after `--env`, the CLI reads the name as another pair and rejects it, so place at least one other option between `--env` and the server name, as in the examples above.
-
-###
-
-
-
-Option 4: Add a remote WebSocket server
-
-WebSocket servers hold a persistent bidirectional connection, which suits remote MCP servers that push events to Claude unprompted. Use HTTP instead when your server only responds to requests, since HTTP supports OAuth and the `claude mcp add --transport` flag, while WebSocket supports neither. Configure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:
-
- claude mcp add-json events-server \
- '{"type":"ws","url":"wss://mcp.example.com/socket","headers":{"Authorization":"Bearer YOUR_TOKEN"}}'
-
-The `type: "ws"` entry accepts the same `url`, `headers`, `headersHelper`, `timeout`, and `alwaysLoad` fields as `http`. Authentication is header-only, so pass a static token in `headers` or generate one at connect time with `headersHelper`. The `claude mcp add --transport` flag doesn’t accept `ws`.
-
-###
-
-
-
-Managing your servers
-
-Once configured, you can manage your MCP servers with these commands:
-
- # 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
-
-####
-
-
-
-Server status
-
-`claude mcp add` confirms a successful add by printing an `Added ...` line, which means the configuration was written. `claude mcp list` then shows a health status next to each server it lists, such as `✔ Connected`, `! Needs authentication`, or `✘ Failed to connect`. A failure status means Claude Code couldn’t connect to that server, not that the list command failed. Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` and `claude mcp get <name>` as `⏸ Pending approval (run `claude` to approve)`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows rejected servers as `✘ Rejected (see disabledMcpjsonServers in settings)`. WebSocket servers don’t appear in `claude mcp list` output. Use `claude mcp get <name>` or the `/mcp` panel to check them.
-
-####
-
-
-
-Project server approvals and workspace trust
-
-As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
-
- * your user `~/.claude/settings.json`
- * managed settings
- * settings passed with `--settings`
-
-Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server.
-
-####
-
-
-
-Server status detail
-
-In `/mcp`, a server’s menu, and the [`/plugin`](</docs/en/plugins>) manager, a remote (HTTP or SSE) server you’ve used before can show a `cached` status such as `cached 2h ago · connects on first use · 5 tools`. Claude Code loaded the server’s tool list from a previous session instead of connecting at startup, and it connects the server the first time Claude calls one of its tools. The tools are available from your first message, so you don’t need to do anything. To make every server connect at startup instead, set [`MCP_DISCOVERY_CACHE=0`](</docs/en/env-vars>). The discovery cache and its `cached` status require Claude Code v2.1.221 or later. When a server’s status is `✘ Failed to connect`, `claude mcp list` appends the failure detail to that status line, and `claude mcp get <name>` shows it on an `Issue:` line: the HTTP status or error code, plus any error text the server returned. The server’s detail view in `/mcp` includes the same server-reported text in its `Issue:` row. Claude Code redacts credential-like text from this detail and never includes the expanded server URL, which can carry secrets. Claude Code appends no detail to a `✘ Connection error` status, because the exception text it would print there can embed that URL. Before v2.1.219, both commands showed only the bare failure status, without the status code or the server’s error text. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect.
-
-####
-
-
-
-Configuration warnings
-
-Claude Code also warns when an MCP config value carries hidden leading or trailing whitespace, which often comes from pasting a token with a trailing newline. Claude Code checks `command`, `url`, each `args` entry, and the values and key names under `env` and `headers`. Claude Code shows the warning in `claude mcp list` output and in `/mcp`, naming the affected fields without echoing their values, for example `Leading or trailing whitespace in: headers.Authorization`. Claude Code doesn’t trim the whitespace and uses the values exactly as written, so edit the configuration to remove it. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
-
-####
-
-
-
-Tool availability
-
-The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. How the wait happens depends on your configuration:
-
- * **Withtool search, the default**: the wait happens inside the `ToolSearch` call.
- * **Without tool search** : Claude uses the `WaitForMcpServers` tool instead. Configurations without tool search include a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, and a model earlier than the Claude 4.5 generation on Google Cloud’s Agent Platform.
- * **On a Microsoft Foundry[deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>)**: Claude starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API. After Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request.
-
-With tool search enabled, when a server finishes connecting while Claude is working, Claude Code lists the server’s tool names to Claude on its next request in the same turn. Claude can then search for and call those tools without waiting for your next message.
-
-###
-
-
-
-Disable a server without removing it
-
-Toggle a server off in the `/mcp` panel to stop Claude Code from connecting to it without losing its configuration. Claude Code still lists the server in `/mcp`, marked as disabled. When you toggle a server, Claude Code records your choice per project in `~/.claude.json`, in one of two lists that cover disjoint sets of servers:
-
- * `disabledMcpServers`: an opt-out list for user-configured servers, plugin servers, claude.ai connectors, and built-in servers that default to on. Claude Code doesn’t connect to a server you list here. When you disable a claude.ai connector with the per-project `/mcp` toggle described in Disable claude.ai connectors, Claude Code writes it to this list under its display name, for example `claude.ai Slack`.
- * `enabledMcpServers`: an opt-in list for built-in servers that default to off, such as `computer-use`. Claude Code connects to a default-off server only when you list it here.
-
-Claude Code consults exactly one of the two lists for each server, so neither list overrides the other. If you add a regular server to `enabledMcpServers`, or a default-off built-in server to `disabledMcpServers`, Claude Code ignores the entry. `disabledMcpServers` and `enabledMcpServers` are unrelated to [`enabledMcpjsonServers` and `disabledMcpjsonServers`](</docs/en/settings#available-settings>), which control approval of servers defined in a project’s `.mcp.json` file.
-
-###
-
-
-
-Dynamic tool updates
-
-Claude Code supports MCP `list_changed` notifications, allowing MCP servers to dynamically update their available tools, prompts, and resources without requiring you to disconnect and reconnect. When an MCP server sends a `list_changed` notification, Claude Code automatically refreshes the available capabilities from that server. If a refresh request fails, Claude Code keeps the server’s previously discovered tools, prompts, and resources until a later refresh succeeds. Before v2.1.214, a transient error during the refresh replaced the server’s tools, prompts, and resources with an empty list.
-
-###
-
-
-
-Automatic reconnection
-
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. When a configured server fails to connect, Claude Code tells Claude which server failed and its connection error, including in `ToolSearch` results that find no matching tool, so Claude reports the connection failure in its response. Requires tool search, which is enabled by default. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model that doesn’t support tool search, and on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code doesn’t report failed server connections to Claude. Before v2.1.205, Claude Code didn’t pass connection errors to Claude, and Claude could respond as if the failed server’s tools were never configured. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
-
-###
-
-
-
-Push messages with channels
-
-An MCP server can also push messages directly into your session so Claude can react to external events like CI results, monitoring alerts, or chat messages. To enable this, your server declares the `claude/channel` capability and you opt it in with the `--channels` flag at startup. See [Channels](</docs/en/channels>) to use an officially supported channel, or [Channels reference](</docs/en/channels-reference>) to build your own.
-
-Tips:
-
- * Use the `-s` or `--scope` flag to specify where the configuration is stored:
- * `local` (default): available only to you in the current project
- * `project`: shared with everyone in the project via the `.mcp.json` file
- * `user`: available to you across all projects
- * Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)
- * The `--transport` and `--header` flags also accept `-t` and `-H` short forms
- * Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
- * Set a per-server tool execution timeout by adding a `timeout` field in milliseconds to that server’s `.mcp.json` entry, for example `"timeout": 600000` for ten minutes. This overrides the `MCP_TOOL_TIMEOUT` environment variable for that server only
- * Claude Code displays a warning when MCP tool output exceeds 10,000 tokens and limits output to 25,000 tokens by default. To raise the limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`); the warning threshold is fixed. See MCP output limits and warnings
- * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. For an HTTP, SSE, or [claude.ai connector](</docs/en/mcp#use-mcp-servers-from-claude-ai>) server there is also a second, per-request timer that covers each request through to the server’s first response byte. That timer is 60 seconds unless you set the per-server `timeout` or `MCP_TOOL_TIMEOUT`; setting either to 60 seconds or higher raises the per-request timer to that value, a lower value doesn’t shorten it, and the 28-hour default of an unset `MCP_TOOL_TIMEOUT` never feeds it. Stdio and WebSocket servers have no per-request timer. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. These timeouts bound how long a call can run, not always how long it blocks the session: on Claude Code v2.1.212 or later, a main-conversation call that runs past two minutes moves to a background task first. See Automatic backgrounding of long tool calls.
-
-###
-
-
-
-Automatic backgrounding of long tool calls
-
-An MCP tool call in the main conversation that is still running after two minutes moves to a background task instead of blocking the session. Claude receives the task ID immediately and keeps working, and the result arrives as a task notification when the call settles. Automatic backgrounding requires Claude Code v2.1.212 or later. The task appears in [`/tasks`](</docs/en/commands#all-commands>), where you can also stop it, and it doesn’t survive exiting the session. The per-call limits still apply while the call runs in the background: the wall-clock limit set by the per-server `timeout` or [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>), and the idle timeout set by [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>). Set the [`CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS`](</docs/en/env-vars>) environment variable in milliseconds to change the threshold, or set it to `0` to turn automatic backgrounding off. Setting `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` to `1` also turns it off, along with all other background task features. Some calls never move to the background:
-
- * Calls from [subagents](</docs/en/sub-agents>); Claude Code backgrounds only main-conversation calls
- * Calls to IDE servers
- * Calls in [non-interactive mode](</docs/en/headless>), unless `CLAUDE_AUTO_BACKGROUND_TASKS` is set to `1`, since a one-shot run can end before the result arrives
-
-A call waiting on an open elicitation dialog isn’t backgrounded while the dialog is open; the server is blocked on your input, not slow, so Claude Code defers the move until the dialog closes.
-
-###
-
-
-
-Plugin-provided MCP servers
-
-[Plugins](</docs/en/plugins>) can bundle MCP servers that provide tools and integrations when you enable the plugin. Plugin MCP servers work identically to user-configured servers. **How plugin MCP servers work** :
-
- * Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`
- * When you enable a plugin, Claude Code starts its MCP servers automatically
- * Claude Code offers plugin MCP tools alongside manually configured MCP tools
- * You add and remove plugin servers by installing or uninstalling the plugin, not with `/mcp` commands. You can still toggle an installed plugin server off in `/mcp`, which stops Claude Code from connecting to it without removing the plugin
-
-**Example plugin MCP configuration** : In `.mcp.json` at plugin root:
+The [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/docs/getting-started/intro>) is an open standard for connecting AI agents to external tools and data sources. With MCP, your agent can query databases, integrate with APIs like Slack and GitHub, and connect to other services without writing custom tool implementations. MCP servers can run as local processes, connect over HTTP, or execute directly within your SDK application.
+
+This page covers MCP configuration for the Agent SDK. To add MCP servers to the Claude Code CLI so they load in every project, see [MCP installation scopes](</docs/en/mcp#mcp-installation-scopes>).
+
+##
+
+
+
+Quickstart
+
+This example connects to the [Claude Code documentation](<https://code.claude.com/docs>) MCP server using HTTP transport and uses `allowedTools` with a wildcard to permit all tools from the server.
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ for await (const message of query({
+ prompt: "Use the docs MCP server to explain what hooks are in Claude Code",
+ options: {
+ mcpServers: {
+ "claude-code-docs": {
+ type: "http",
+ url: "https://code.claude.com/docs/mcp"
+ }
+ },
+ allowedTools: ["mcp__claude-code-docs__*"]
+ }
+ })) {
+ if (message.type === "result" && message.subtype === "success") {
+ console.log(message.result);
+ }
+ }
+
+ import asyncio
+ from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage
+
+ async def main():
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "claude-code-docs": {
+ "type": "http",
+ "url": "https://code.claude.com/docs/mcp",
+ }
+ },
+ allowed_tools=["mcp__claude-code-docs__*"],
+ )
+
+ async for message in query(
+ prompt="Use the docs MCP server to explain what hooks are in Claude Code",
+ options=options,
+ ):
+ if isinstance(message, ResultMessage) and message.subtype == "success":
+ print(message.result)
+
+ asyncio.run(main())
+
+The agent connects to the documentation server, searches for information about hooks, and returns the results.
+
+##
+
+
+
+Add an MCP server
+
+You can configure MCP servers in code when calling `query()`, or in a `.mcp.json` file loaded via `settingSources`.
+
+###
+
+
+
+In code
+
+Pass MCP servers directly in the `mcpServers` option:
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ for await (const message of query({
+ prompt: "List files in my project",
+ options: {
+ mcpServers: {
+ filesystem: {
+ command: "npx",
+ args: ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
+ }
+ },
+ allowedTools: ["mcp__filesystem__*"]
+ }
+ })) {
+ if (message.type === "result" && message.subtype === "success") {
+ console.log(message.result);
+ }
+ }
+
+ import asyncio
+ from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage
+
+ async def main():
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "filesystem": {
+ "command": "npx",
+ "args": [
+ "-y",
+ "@modelcontextprotocol/server-filesystem",
+ "/Users/me/projects",
+ ],
+ }
+ },
+ allowed_tools=["mcp__filesystem__*"],
+ )
+
+ async for message in query(prompt="List files in my project", options=options):
+ if isinstance(message, ResultMessage) and message.subtype == "success":
+ print(message.result)
+
+ asyncio.run(main())
+
+###
+
+
+
+From a config file
+
+Create a `.mcp.json` file at your project root. The file is picked up when the `project` setting source is enabled, which it is for default `query()` options. If you set `settingSources` explicitly, include `"project"` for this file to load:
{
"mcpServers": {
- "database-tools": {
- "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
- "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
- "env": {
- "DB_URL": "${DB_URL}"
- }
- }
- }
- }
-
-Or inline in `plugin.json`:
-
- {
- "name": "my-plugin",
- "mcpServers": {
- "plugin-api": {
- "command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
- "args": ["--port", "8080"]
- }
- }
- }
-
-**Plugin MCP features** :
-
- * **Automatic lifecycle** : servers connect and disconnect at these points:
- * At session startup, Claude Code connects the servers for enabled plugins automatically. In `/mcp`, a remote (HTTP or SSE) plugin server you’ve used before can show the `cached` status instead; Claude Code connects it when Claude first calls one of its tools
- * If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers. When you reload, Claude Code keeps the live connections of plugin servers whose configuration is unchanged, and does the same when you [replace the session’s MCP server list](</docs/en/agent-sdk/typescript#mcpsetserversresult>) from the Agent SDK without naming them. Before v2.1.210, Claude Code disconnected plugin-provided MCP servers that the new SDK server list didn’t name
- * In [web sessions](</docs/en/claude-code-on-the-web>), an MCP call to a plugin server that isn’t connected yet, such as right after an idle session wakes, starts the server on demand and waits for it to connect. Before v2.1.211, plugin servers in a web session reconnected only when the next message started a turn, so MCP calls after an idle session woke failed until then
- * **Path placeholders** : `${CLAUDE_PLUGIN_ROOT}` resolves to the plugin’s installation directory, `${CLAUDE_PLUGIN_DATA}` to its [persistent state](</docs/en/plugins-reference#persistent-data-directory>) directory, and `${CLAUDE_PROJECT_DIR}` to the stable project root. Substitution applies to:
- * `stdio` servers: `command`, `args`, `env`
- * `http`, `sse`, and `ws` servers: `url`, `headers`, and `headersHelper`. Before v2.1.195, `headersHelper` passed the placeholder through as a literal string
- * **User environment access** : access to the same environment variables as manually configured servers
- * **Multiple transport types** : support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server
-
-Plugin servers appear in `/mcp` with indicators showing they come from plugins. **Plugin MCP tool names** : Tools from a plugin-bundled MCP server include both the plugin name and the server key in their callable name. The full form is `mcp__plugin_<plugin-name>_<server-name>__<tool-name>`, where any character outside `A-Z`, `a-z`, `0-9`, `_`, and `-` is replaced with `_`. For the `database-tools` server bundled in a plugin named `my-plugin`, a `query` tool is callable as:
-
- mcp__plugin_my-plugin_database-tools__query
-
-Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>), or a [hook matcher](</docs/en/hooks#match-mcp-tools>). A hook matcher written against the bare server key, such as `mcp__database-tools__.*`, never fires for a plugin-bundled server. The server itself registers under the scoped name `plugin:<plugin-name>:<server-name>`, such as `plugin:my-plugin:database-tools`. Use that name where a configured server name is expected, such as an [`mcp_tool` hook’s `server` field](</docs/en/hooks#mcp-tool-hook-fields>). See the [plugin components reference](</docs/en/plugins-reference#mcp-servers>) for details on bundling MCP servers with plugins.
-
-##
-
-
-
-MCP installation scopes
-
-MCP servers can be configured at three scopes. The scope you choose controls which projects the server loads in and whether the configuration is shared with your team. Administrators can also deploy servers at the enterprise level via managed configuration.
-
-Scope| Loads in| Shared with team| Stored in
----|---|---|---
-Local| Current project only| No| `~/.claude.json`
-Project| Current project only| Yes, via version control| `.mcp.json` in project root
-User| All your projects| No| `~/.claude.json`
-
-###
-
-
-
-Local scope
-
-Local scope is the default. A local-scoped server loads only in the project where you added it and stays private to you. Claude Code stores it in `~/.claude.json` under that project’s path, so the same server won’t appear in your other projects. Use local scope for personal development servers, experimental configurations, or servers with credentials you don’t want in version control.
-
-The term “local scope” for MCP servers differs from general local settings. MCP local-scoped servers are stored in `~/.claude.json` (your home directory), while general local settings use `.claude/settings.local.json` (in the project directory). See [Settings](</docs/en/settings#settings-files>) for details on settings file locations.
-
- # Add a local-scoped server (default)
- claude mcp add --transport http stripe https://mcp.stripe.com
-
- # Explicitly specify local scope
- claude mcp add --transport http stripe --scope local https://mcp.stripe.com
-
-The command writes the server into the entry for your current project inside `~/.claude.json`. The example below shows the result when you run it from `/path/to/your/project`:
-
- {
- "projects": {
- "/path/to/your/project": {
- "mcpServers": {
- "stripe": {
- "type": "http",
- "url": "https://mcp.stripe.com"
+ "filesystem": {
+ "command": "npx",
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
+ }
+ }
+ }
+
+##
+
+
+
+Connection timing
+
+Claude Code registers the servers you pass in `options.mcpServers` at startup and emits the init message once the first-turn wait, if any, resolves. Servers loaded from settings files such as `.mcp.json` don’t get the full wait and commonly show `pending` at init. When each `options.mcpServers` server connects, and whether it delays the first turn, depends on its type:
+
+Server type| Delays the first turn?| First-turn wait timeout
+---|---|---
+stdio server, or HTTP/SSE server without a cached tool list| Yes, until it connects| [`MCP_TIMEOUT`](</docs/en/env-vars>), 30 seconds by default; the connection fails at that deadline
+Remote server with a cached tool list, saved by Claude Code from a previous connection| No; the cached tools are available from the first turn| None; connects on its first tool call, and that deferred connect has its own timeout
+In-process SDK server| No; never delays the first turn| None
+
+To block startup itself at a separate, earlier phase than the first-turn wait, before the init message is sent:
+
+ * Set [`MCP_CONNECTION_NONBLOCKING`](</docs/en/env-vars>) to `0` to block on the whole connection batch. Claude Code caps that wait at 5 seconds by default. Adjust the cap with the [`MCP_CONNECT_TIMEOUT_MS`](</docs/en/env-vars>) environment variable, in milliseconds. Servers still pending at that deadline keep connecting in the background.
+ * Set `alwaysLoad: true` on a server’s config to make its tools available at their full schemas on the first turn, [exempt from tool search deferral](</docs/en/mcp#exempt-a-server-from-deferral>). Claude Code waits at startup for that server’s tools, capped at the same deadline, while other servers keep connecting in the background; a remote server with a cached tool list supplies them without connecting, per the table above.
+
+The `system` message with subtype `init` reports each server’s status at the moment it’s emitted. Check for status `failed` or `needs-auth` when you want to detect servers that won’t be usable, rather than treating every status other than `connected` as a failure; see Error handling for the full status check.
+
+##
+
+
+
+Allow MCP tools
+
+MCP tools require explicit permission before Claude can use them. Without permission, Claude will see that tools are available but won’t be able to call them.
+
+###
+
+
+
+Tool naming convention
+
+MCP tools follow the naming pattern `mcp__<server-name>__<tool-name>`. For example, a GitHub server named `"github"` with a `list_issues` tool becomes `mcp__github__list_issues`.
+
+###
+
+
+
+Auto-approve with allowedTools
+
+Use `allowedTools` to auto-approve specific MCP tools so Claude can use them without a permission prompt:
+
+TypeScript
+
+Python
+
+ const _ = {
+ options: {
+ mcpServers: {
+ // your servers
+ },
+ allowedTools: [
+ "mcp__github__*", // All tools from the github server
+ "mcp__db__query", // Only the query tool from db server
+ "mcp__slack__send_message" // Only send_message from slack server
+ ]
+ }
+ };
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ # your servers
+ },
+ allowed_tools=[
+ "mcp__github__*", # All tools from the github server
+ "mcp__db__query", # Only the query tool from db server
+ "mcp__slack__send_message", # Only send_message from slack server
+ ],
+ )
+
+Wildcards (`*`) let you allow all tools from a server without listing each one individually.
+
+**Prefer`allowedTools` over permission modes for MCP access.** `permissionMode: "acceptEdits"` does not auto-approve MCP tools (only file edits and filesystem Bash commands). `permissionMode: "bypassPermissions"` does auto-approve MCP tools but also disables most other safety prompts, which is broader than necessary; see [How permissions are evaluated](</docs/en/agent-sdk/permissions#how-permissions-are-evaluated>) for the prompts that remain. A wildcard in `allowedTools` grants exactly the MCP server you want and nothing more. See [Permission modes](</docs/en/agent-sdk/permissions#permission-modes>) for a full comparison.
+
+###
+
+
+
+Discover available tools
+
+To see what tools an MCP server provides, check the server’s documentation or inspect the `tools` array in the `system` init message. MCP tool names start with `mcp__`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so the `tools` array lists the `mcp__` tools of each such server that connected within the wait. A server with a cached tool list shows `pending` with its `mcp__` tools already listed and a connection made on first use. Any other server that hasn’t connected when the message is emitted, including settings-file servers that don’t get the full wait, shows its current status, such as `pending`, `failed`, or `needs-auth`, with its tools absent; see Error handling for the full status set. This filter prints the MCP tool names:
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ const options = {
+ mcpServers: {
+ // your servers
+ },
+ };
+
+ for await (const message of query({ prompt: "...", options })) {
+ if (message.type === "system" && message.subtype === "init") {
+ const mcpTools = message.tools.filter((name) => name.startsWith("mcp__"));
+ console.log("Available MCP tools:", mcpTools);
+ }
+ }
+
+ import asyncio
+ from claude_agent_sdk import query, ClaudeAgentOptions, SystemMessage
+
+ async def main():
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ # your servers
+ },
+ )
+ async for message in query(prompt="...", options=options):
+ if isinstance(message, SystemMessage) and message.subtype == "init":
+ mcp_tools = [t for t in message.data.get("tools", []) if t.startswith("mcp__")]
+ print("Available MCP tools:", mcp_tools)
+
+ asyncio.run(main())
+
+You can also ask Claude to list the tools available from a server.
+
+##
+
+
+
+Transport types
+
+MCP servers communicate with your agent using different transport protocols. Check the server’s documentation to see which transport it supports:
+
+ * If the docs give you a **command to run** (like `npx @modelcontextprotocol/server-filesystem`), use stdio
+ * If the docs give you a **URL** , use HTTP or SSE
+ * If you’re building your own tools in code, use an SDK MCP server
+
+###
+
+
+
+stdio servers
+
+Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine:
+
+ * In code
+
+ * .mcp.json
+
+TypeScript
+
+Python
+
+ const _ = {
+ options: {
+ mcpServers: {
+ filesystem: {
+ command: "npx",
+ args: ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
+ }
+ },
+ allowedTools: ["mcp__filesystem__read_file", "mcp__filesystem__list_directory"]
+ }
+ };
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "filesystem": {
+ "command": "npx",
+ "args": [
+ "-y",
+ "@modelcontextprotocol/server-filesystem",
+ "/Users/me/projects",
+ ],
}
- }
- }
- }
- }
-
-###
-
-
-
-Project scope
-
-Project-scoped servers enable team collaboration by storing configurations in a `.mcp.json` file at your project’s root directory. When you add a project-scoped server, Claude Code automatically creates or updates this file with the appropriate configuration structure. Check `.mcp.json` into version control so everyone on your team gets the same MCP tools and services.
-
- # Add a project-scoped server
- claude mcp add --transport http shared-server --scope project https://example.com/mcp
-
-The resulting `.mcp.json` file follows a standardized format:
+ },
+ allowed_tools=["mcp__filesystem__read_file", "mcp__filesystem__list_directory"],
+ )
{
"mcpServers": {
- "shared-server": {
- "type": "http",
- "url": "https://example.com/mcp"
- }
- }
- }
-
-For security reasons, Claude Code prompts for approval in interactive sessions before using project-scoped servers from `.mcp.json` files. To reset those approval choices, run `claude mcp reset-project-choices`. `claude -p` runs, [Agent SDK](</docs/en/headless>) sessions, and [cloud sessions](</docs/en/claude-code-on-the-web>) can’t show that prompt: Claude Code loads project-scoped servers there without asking. To keep a server out anyway, add it to [`disabledMcpjsonServers`](</docs/en/settings#available-settings>), which blocks it in every mode, or exclude project settings entirely with [`--setting-sources`](</docs/en/cli-reference>) or the SDK’s `settingSources` option.
-
-###
-
-
-
-User scope
-
-User-scoped servers are stored in `~/.claude.json` and provide cross-project accessibility, making them available across all projects on your machine while remaining private to your user account. This scope works well for personal utility servers, development tools, or services you frequently use across different projects.
-
- # Add a user server
- claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
-
-###
-
-
-
-Scope hierarchy and precedence
-
-When the same server is defined in more than one place, Claude Code connects to it once, using the definition from the highest-precedence source. The entire server entry from that source is used; fields are not merged across scopes.
-
- 1. Local scope
- 2. Project scope
- 3. User scope
- 4. [Plugin-provided servers](</docs/en/plugins>)
- 5. claude.ai connectors
-
-The three scopes match duplicates by name. Plugins and connectors match by endpoint, so one that points at the same URL or command as a server above is treated as a duplicate. If you open a local session in the [Desktop app’s Code tab](</docs/en/desktop#mcp-servers-from-the-claude-desktop-chat-app>) with the same stdio server name at the top level of `~/.claude.json` (user scope) and in `.mcp.json`, the Code tab uses the `~/.claude.json` definition.
-
-###
-
-
-
-Environment variable expansion in `.mcp.json`
-
-Claude Code supports environment variable expansion in `.mcp.json` files, allowing teams to share configurations while maintaining flexibility for machine-specific paths and sensitive values like API keys. **Supported syntax:**
-
- * `${VAR}`: expands to the value of environment variable `VAR`
- * `${VAR:-default}`: expands to `VAR` if set, otherwise uses `default`
-
-**Expansion locations:** Environment variables can be expanded in:
-
- * `command`: the server executable path
- * `args`: command-line arguments
- * `env`: environment variables passed to the server
- * `url`: for HTTP server types
- * `headers`: for HTTP server authentication
-
-**Example with variable expansion:**
+ "filesystem": {
+ "command": "npx",
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
+ }
+ }
+ }
+
+###
+
+
+
+HTTP/SSE servers
+
+Use HTTP or SSE for cloud-hosted MCP servers and remote APIs:
+
+ * In code
+
+ * .mcp.json
+
+TypeScript
+
+Python
+
+ const _ = {
+ options: {
+ mcpServers: {
+ "remote-api": {
+ type: "sse",
+ url: "https://api.example.com/mcp/sse",
+ headers: {
+ Authorization: `Bearer ${process.env.API_TOKEN}`
+ }
+ }
+ },
+ allowedTools: ["mcp__remote-api__*"]
+ }
+ };
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "remote-api": {
+ "type": "sse",
+ "url": "https://api.example.com/mcp/sse",
+ "headers": {"Authorization": f"Bearer {os.environ['API_TOKEN']}"},
+ }
+ },
+ allowed_tools=["mcp__remote-api__*"],
+ )
+
+ {
+ "mcpServers": {
+ "remote-api": {
+ "type": "sse",
+ "url": "https://api.example.com/mcp/sse",
+ "headers": {
+ "Authorization": "Bearer ${API_TOKEN}"
+ }
+ }
+ }
+ }
+
+For the streamable HTTP transport, use `"type": "http"` instead. In `.mcp.json` and other JSON config files, `"streamable-http"` is accepted as an alias for `"http"`. The programmatic `mcpServers` option accepts only `"http"`.
+
+###
+
+
+
+SDK MCP servers
+
+Define custom tools directly in your application code instead of running a separate server process. See the [custom tools guide](</docs/en/agent-sdk/custom-tools>) for implementation details. An SDK MCP server registered by an [`initialize` control request](</docs/en/agent-sdk/typescript#sdkcontrolinitializeresponse>) begins connecting as soon as Claude Code processes the request.
+
+##
+
+
+
+MCP tool search
+
+When you have many MCP tools configured, tool definitions can consume a significant portion of your context window. Tool search solves this by withholding tool definitions from context and loading only the ones Claude needs for each turn. Tool search is enabled by default. See [Tool search](</docs/en/agent-sdk/tool-search>) for configuration options, best practices, and using tool search with custom SDK tools.
+
+##
+
+
+
+Authentication
+
+Most MCP servers require authentication to access external services. Pass credentials through environment variables in the server configuration.
+
+###
+
+
+
+Pass credentials via environment variables
+
+Use the `env` field to pass API keys, tokens, and other credentials to the MCP server:
+
+ * In code
+
+ * .mcp.json
+
+TypeScript
+
+Python
+
+ const _ = {
+ options: {
+ mcpServers: {
+ "api-server": {
+ command: "npx",
+ args: ["-y", "@your-org/api-mcp-server"],
+ env: {
+ API_KEY: process.env.API_KEY
+ }
+ }
+ },
+ allowedTools: ["mcp__api-server__*"]
+ }
+ };
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "api-server": {
+ "command": "npx",
+ "args": ["-y", "@your-org/api-mcp-server"],
+ "env": {"API_KEY": os.environ["API_KEY"]},
+ }
+ },
+ allowed_tools=["mcp__api-server__*"],
+ )
{
"mcpServers": {
"api-server": {
- "type": "http",
- "url": "${API_BASE_URL:-https://api.example.com}/mcp",
- "headers": {
- "Authorization": "Bearer ${API_KEY}"
- }
- }
- }
- }
-
-If a referenced environment variable isn’t set and has no default value, the config still loads: Claude Code reports a missing-variable warning for that server in `claude mcp list` output and uses the unexpanded `${VAR}` text as-is. Set the variable or add a `:-default` fallback so the server starts with the value you intend.
-
-##
-
-
-
-Practical examples
-
-###
-
-
-
-Example: Monitor errors with Sentry
-
-Sentry’s remote MCP server gives Claude access to the errors your applications report to Sentry. It authenticates through OAuth rather than an API key, so you don’t pass a credential when you add it. If you already added the `sentry` server in the [MCP quickstart](</docs/en/mcp-quickstart>), skip this command: running `claude mcp add` again with the same server name at the same scope fails with `MCP server sentry already exists in local config`.
-
- claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
-
-Authenticate with your Sentry account:
-
- /mcp
-
-Follow the sign-in steps in your browser. Once you’re signed in, the `sentry` server shows `connected` in the `/mcp` menu. Then debug production issues:
-
- What are the most common errors in the last 24 hours?
-
- Show me the stack trace for error ID abc123
-
- Which deployment introduced these new errors?
-
-###
-
-
-
-Example: Connect to GitHub for code reviews
-
-GitHub’s remote MCP server authenticates with a GitHub personal access token passed as a header. To get one, open your [GitHub token settings](<https://github.com/settings/personal-access-tokens>), generate a new fine-grained token with access to the repositories you want Claude to work with, then add the server:
-
- claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
- --header "Authorization: Bearer YOUR_GITHUB_PAT"
-
-Replace `YOUR_GITHUB_PAT` with your personal access token. The `claude mcp add` command saves the configuration without validating credentials, so a placeholder value is accepted here but the server fails to connect later. To verify the connection, run `/mcp` and check that the server shows `connected`. A server with bad credentials shows `failed`, and the failure detail includes the HTTP status the server returned, such as a 401. Then work with GitHub:
-
- Review PR #456 and suggest improvements
-
- Create a new issue for the bug we just found
-
- Show me all open PRs assigned to me
-
-###
-
-
-
-Example: Query your PostgreSQL database
-
-[DBHub](<https://github.com/bytebase/dbhub>), the `@bytebase/dbhub` package, is an MCP server that connects Claude to a relational database through the connection string you pass in `--dsn`. Use a read-only database user in the connection string so the queries Claude runs can’t modify data:
-
- claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
- --dsn "postgresql://readonly:pass@prod.db.com:5432/analytics"
-
-To confirm the server starts, run `/mcp` and check that `db` shows `connected`. Then query your database naturally:
-
- What's our total revenue this month?
-
- Show me the schema for the orders table
-
- Find customers who haven't made a purchase in 90 days
-
-##
-
-
-
-Authenticate with remote MCP servers
-
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. What Claude Code shows depends on the server:
-
- * For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow.
- * For a claude.ai connector, a `401` caused by claude.ai rejecting your session token doesn’t flag the connector, because re-authorizing the connector can’t fix your login. Claude Code shows the [session-token-rejected state](</docs/en/errors#claude-ai-rejected-the-session-token>) instead.
-
-When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. The notice requires Claude Code v2.1.193 or later. It counts only servers you can sign in to from Claude Code. Before v2.1.218, it also counted claude.ai connectors that weren’t connected in claude.ai, which you can connect only from claude.ai settings. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
-
-1
-
-Add the server that requires authentication
-
-If you already added this server in the Sentry example or the [MCP quickstart](</docs/en/mcp-quickstart>), skip this step: running `claude mcp add` again with the same server name at the same scope fails with `MCP server sentry already exists in local config`. Otherwise, run:
-
- claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
-
-2
-
-Use the /mcp command within Claude Code
-
-In Claude Code, use the command:
-
- /mcp
-
-Then follow the steps in your browser to log in.
-
-Tips:
-
- * Authentication tokens are stored securely and refreshed automatically
- * Use “Clear authentication” in the `/mcp` menu to revoke access
- * If your browser doesn’t open automatically, copy the provided URL and open it manually
- * If the browser redirect fails with a connection error after authenticating, paste the full callback URL from your browser’s address bar into the URL prompt that appears in Claude Code
- * OAuth authentication works with HTTP servers
-
-###
-
-
-
-Authenticate from the command line
-
-From v2.1.186, `claude mcp login <name>` runs a configured server’s OAuth flow directly from your shell, so you don’t need to open the `/mcp` panel inside a session.
-
- claude mcp login sentry
-
-To clear stored credentials later, run `claude mcp logout <name>`. As of v2.1.191, the command detects when no local browser is available, such as during an SSH session or on Linux without a display server, and prints the authorization URL instead of trying to open a browser. Open the URL on your local machine, then paste the full redirect URL from your browser’s address bar back at the prompt. The command needs an interactive terminal for the paste step, so connect with `ssh -t`. Pass `--no-browser` to force the URL prompt even when a local browser is detected.
-
- claude mcp login sentry --no-browser
-
-###
-
-
-
-Use a fixed OAuth callback port
-
-Some MCP servers require a specific redirect URI registered in advance. By default, Claude Code picks a random available port for the OAuth callback. Use `--callback-port` to fix the port so it matches a pre-registered redirect URI of the form `http://localhost:PORT/callback`. You can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).
-
- # Fixed callback port with dynamic client registration
- claude mcp add --transport http \
- --callback-port 8080 \
- my-server https://mcp.example.com/mcp
-
-###
-
-
-
-Use pre-configured OAuth credentials
-
-Some MCP servers don’t support automatic OAuth setup via Dynamic Client Registration. If you see an error like “Incompatible auth server: does not support dynamic client registration,” the server requires pre-configured credentials. Claude Code also supports servers that use a Client ID Metadata Document (CIMD) instead of Dynamic Client Registration, and discovers these automatically. If automatic discovery fails, register an OAuth app through the server’s developer portal first, then provide the credentials when adding the server.
-
-1
-
-Register an OAuth app with the server
-
-Create an app through the server’s developer portal and note your client ID and client secret.Many servers also require a redirect URI. If so, choose a port and register a redirect URI in the format `http://localhost:PORT/callback`. Use that same port with `--callback-port` in the next step.
-
-2
-
-Add the server with your credentials
-
-Choose one of the following methods. The port used for `--callback-port` can be any available port. It needs to match the redirect URI you registered in the previous step.
-
- * claude mcp add
-
- * claude mcp add-json
-
- * claude mcp add-json (callback port only)
-
- * CI / env var
-
-Use `--client-id` to pass your app’s client ID. The `--client-secret` flag prompts for the secret with masked input:
-
- claude mcp add --transport http \
- --client-id your-client-id --client-secret --callback-port 8080 \
- my-server https://mcp.example.com/mcp
-
-Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:
-
- claude mcp add-json my-server \
- '{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"clientId":"your-client-id","callbackPort":8080}}' \
- --client-secret
-
-Use `--callback-port` without a client ID to fix the port while using dynamic client registration:
-
- claude mcp add-json my-server \
- '{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"callbackPort":8080}}'
-
-Set the secret via environment variable to skip the interactive prompt:
-
- MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \
- --client-id your-client-id --client-secret --callback-port 8080 \
- my-server https://mcp.example.com/mcp
-
-3
-
-Authenticate in Claude Code
-
-Run `/mcp` in Claude Code and follow the browser login flow.
-
-Tips:
-
- * The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config
- * If the server uses a public OAuth client with no secret, use only `--client-id` without `--client-secret`
- * `--callback-port` can be used with or without `--client-id`
- * These flags only apply to HTTP and SSE transports. They have no effect on stdio servers
- * Use `claude mcp get <name>` to verify that OAuth credentials are configured for a server
-
-###
-
-
-
-Override OAuth metadata discovery
-
-Point Claude Code at a specific OAuth authorization server metadata URL to bypass the default discovery chain. Set `authServerMetadataUrl` when the MCP server’s standard endpoints error, or when you want to route discovery through an internal proxy. By default, Claude Code first checks RFC 9728 Protected Resource Metadata at `/.well-known/oauth-protected-resource`, then falls back to RFC 8414 authorization server metadata at `/.well-known/oauth-authorization-server`. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
+ "command": "npx",
+ "args": ["-y", "@your-org/api-mcp-server"],
+ "env": {
+ "API_KEY": "${API_KEY}"
+ }
+ }
+ }
+ }
+
+The `${API_KEY}` syntax expands environment variables at runtime.
+
+###
+
+
+
+HTTP headers for remote servers
+
+For HTTP and SSE servers, pass authentication headers directly in the server configuration:
+
+ * In code
+
+ * .mcp.json
+
+TypeScript
+
+Python
+
+ const _ = {
+ options: {
+ mcpServers: {
+ "secure-api": {
+ type: "http",
+ url: "https://api.example.com/mcp",
+ headers: {
+ Authorization: `Bearer ${process.env.API_TOKEN}`
+ }
+ }
+ },
+ allowedTools: ["mcp__secure-api__*"]
+ }
+ };
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "secure-api": {
+ "type": "http",
+ "url": "https://api.example.com/mcp",
+ "headers": {"Authorization": f"Bearer {os.environ['API_TOKEN']}"},
+ }
+ },
+ allowed_tools=["mcp__secure-api__*"],
+ )
{
"mcpServers": {
- "my-server": {
+ "secure-api": {
"type": "http",
- "url": "https://mcp.example.com/mcp",
- "oauth": {
- "authServerMetadataUrl": "https://auth.example.com/.well-known/openid-configuration"
- }
- }
- }
- }
-
-The URL must use `https://`. The metadata URL’s `scopes_supported` overrides the scopes the upstream server advertises.
-
-###
-
-
-
-Restrict OAuth scopes
-
-Set `oauth.scopes` to pin the scopes Claude Code requests during the authorization flow. This is the supported way to restrict an MCP server to a security-team-approved subset when the upstream authorization server advertises more scopes than you want to grant. The value is a single space-separated string, matching the `scope` parameter format in RFC 6749 §3.3.
-
- {
- "mcpServers": {
- "slack": {
- "type": "http",
- "url": "https://mcp.slack.com/mcp",
- "oauth": {
- "scopes": "channels:read chat:write search:read"
- }
- }
- }
- }
-
-`oauth.scopes` takes precedence over both `authServerMetadataUrl` and the scopes the server discovers at `/.well-known`. Leave it unset to let the MCP server determine the requested scope set. As of v2.1.196, when `oauth.scopes` isn’t set, Claude Code requests the scope provided by the server’s `WWW-Authenticate` header or its protected resource metadata, and sends no `scope` parameter when neither provides one. It no longer requests the full `scopes_supported` catalog from automatically discovered authorization server metadata. Requesting that catalog made identity providers that advertise admin-only or template scopes reject the authorization request with an `invalid_scope` error. Metadata fetched from a configured `authServerMetadataUrl` still supplies its `scopes_supported` as the requested scopes. If the authorization server advertises `offline_access` in `scopes_supported`, Claude Code appends it to the pinned scopes so the access token can be refreshed without a new browser sign-in. If the server later returns a 403 `insufficient_scope` for a tool call, Claude Code re-authenticates with the same pinned scopes. Widen `oauth.scopes` when a tool you need requires a scope outside the pinned set.
-
-###
-
-
-
-Use dynamic headers for custom authentication
-
-If your MCP server uses an authentication scheme other than OAuth, such as Kerberos, short-lived tokens, or an internal SSO, use `headersHelper` to generate request headers at connection time. Claude Code runs the command and merges its output into the connection headers.
-
- {
- "mcpServers": {
- "internal-api": {
- "type": "http",
- "url": "https://mcp.internal.example.com",
- "headersHelper": "/opt/bin/get-mcp-auth-headers.sh"
- }
- }
- }
-
-The command can also be inline:
-
- {
- "mcpServers": {
- "internal-api": {
- "type": "http",
- "url": "https://mcp.internal.example.com",
- "headersHelper": "echo '{\"Authorization\": \"Bearer '\"$(get-token)\"'\"}'"
- }
- }
- }
-
-**Requirements:**
-
- * The command must write a JSON object of string key-value pairs to stdout
- * The command runs in a shell with a 10-second timeout, from the session’s current working directory. Use an absolute path or a command on `PATH` for the script
- * Dynamic headers override any static `headers` with the same name
-
-The helper runs fresh on each connection, at session start and on reconnect. There is no caching, so your script is responsible for any token reuse. As of v2.1.193, if a tool call returns `401 Unauthorized` or `403 Forbidden`, Claude Code automatically re-runs the helper, reconnects with the fresh headers, and retries the call once. Claude Code marks the server as needing authentication in `/mcp` only if that retry also fails. Claude Code sets these environment variables when executing the helper:
-
-Variable| Value
----|---
-`CLAUDE_CODE_MCP_SERVER_NAME`| the name of the MCP server
-`CLAUDE_CODE_MCP_SERVER_URL`| the URL of the MCP server
-`CLAUDE_PLUGIN_ROOT`| the plugin’s root directory. Set only when a [plugin](</docs/en/plugins-reference#mcp-servers>) provides the server
-
-Use these to write a single helper script that serves multiple MCP servers. For a plugin-provided server, the helper also runs with its working directory set to the plugin root, so a relative `headersHelper` path resolves inside the plugin directory rather than against the session’s working directory. Requires Claude Code v2.1.195 or later. A plugin-provided `headersHelper` can’t reference the plugin’s [`${user_config.*}`](</docs/en/plugins-reference#user-configuration>) values, because the command runs through a shell. Claude Code reports the server as misconfigured with an [error](</docs/en/errors#plugin-command-references-user-config>) and doesn’t substitute the value. Put `${user_config.KEY}` in the server’s `headers` field instead, which isn’t shell-parsed, or have the helper script read the value from its own environment or a config file. Before v2.1.207, `headersHelper` substituted `${user_config.*}` values.
-
-`headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.
-
-##
-
-
-
-Add MCP servers from JSON configuration
-
-If you have a JSON configuration for an MCP server, you can add it directly:
-
-1
-
-Add an MCP server from JSON
-
- # 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"}}'
-
- # Example: Adding a stdio server with JSON configuration
- claude mcp add-json local-weather '{"type":"stdio","command":"/path/to/weather-cli","args":["--api-key","abc123"],"env":{"CACHE_DIR":"/tmp"}}'
-
- # Example: Adding an HTTP server with pre-configured OAuth credentials
- claude mcp add-json my-server '{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"clientId":"your-client-id","callbackPort":8080}}' --client-secret
-
-2
-
-Verify the server was added
-
- claude mcp get weather-api
-
-Tips:
-
- * Make sure the JSON is properly escaped in your shell
- * The JSON must conform to the MCP server configuration schema
- * You can use `--scope user` to add the server to your user configuration instead of the project-specific one
-
-##
-
-
-
-Import MCP servers from Claude Desktop
-
-If you’ve already configured MCP servers in Claude Desktop, you can import them:
-
-1
-
-Import servers from Claude Desktop
-
- # Basic syntax
- claude mcp add-from-claude-desktop
-
-2
-
-Select which servers to import
-
-After running the command, you’ll see an interactive dialog that allows you to select which servers you want to import.
-
-3
-
-Verify the servers were imported
-
- claude mcp list
-
-Server names added through `claude mcp` commands can contain only letters, numbers, hyphens, and underscores. Claude Desktop doesn’t apply that restriction, so a Claude Desktop server whose name contains any other character, such as a space, can’t be imported. The import reports each name it rejects and still imports the other servers you selected. Before v2.1.205, the first invalid name stopped the import and none of the selected servers were added.
-
-Tips:
-
- * This feature only works on macOS and Windows Subsystem for Linux (WSL)
- * It reads the Claude Desktop configuration file from its standard location on those platforms
- * Use the `--scope user` flag to add servers to your user configuration
- * Imported servers keep the same names as in Claude Desktop when the name contains only letters, numbers, hyphens, and underscores. Claude Code reports a server whose name contains any other character and skips it
- * If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)
-
-##
-
-
-
-Use MCP servers from claude.ai
-
-If you’ve logged into Claude Code with a [claude.ai](<https://claude.ai>) account, MCP servers you’ve added in claude.ai, known as [connectors](<https://claude.com/docs/connectors>), are automatically available in Claude Code:
-
-1
-
-Configure MCP servers in claude.ai
-
-Add servers at [claude.ai/customize/connectors](<https://claude.ai/customize/connectors>). On Team and Enterprise plans, only admins can add servers.
-
-2
-
-Authenticate the MCP server
-
-Complete any required authentication steps in claude.ai.
-
-3
-
-View and manage servers in Claude Code
-
-In Claude Code, use the command:
-
- /mcp
-
-Servers from claude.ai appear in the list with indicators showing they come from claude.ai.
-
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is a claude.ai subscription login. They aren’t loaded, even if you previously ran `/login`, when:
-
- * `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper` is active
- * A third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active
- * `CLAUDE_CODE_OAUTH_TOKEN` holds a token from [`claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>), which can only make model requests
-
-If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. If `/mcp` shows a connector as `connected · session token rejected`, or its detail view shows [`claude.ai rejected the session token`](</docs/en/errors#claude-ai-rejected-the-session-token>), claude.ai rejected the token from your Claude Code login, usually because the login expired and couldn’t be refreshed. Authorizing the connector again doesn’t clear this state, because the connector’s own authorization in claude.ai isn’t what was rejected. To clear it:
-
- 1. Run `/login` to sign in again.
- 2. Reconnect the connector from `/mcp`.
-
-Before v2.1.222, Claude Code marked connectors as needing authentication instead, and authorizing them didn’t resolve it. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
-
-###
-
-
-
-Organization controls on connector tools
-
-Your organization can set per-tool controls on [claude.ai connectors](<https://claude.com/docs/connectors>). Claude Code reads these settings at startup and enforces them locally. Run `/mcp` to see which setting applies to each tool on a connector.
-
- * **Tool set to`ask`**: Claude Code prompts on every call with the reason `Your organization requires approval for this tool`. The prompt appears even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and never offers an option to remember your choice. [Allow rules](</docs/en/permissions>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead.
- * **Tool set to`blocked`**: Claude Code filters the tool out before Claude sees it, so it never appears in the tool list.
-
-###
-
-
-
-Disable claude.ai connectors
-
-To disable claude.ai MCP servers in Claude Code, set [`disableClaudeAiConnectors`](</docs/en/settings#available-settings>) to `true` in any settings scope:
-
- {
- "disableClaudeAiConnectors": true
- }
-
-This setting uses any-source-true semantics: `true` in any settings source takes precedence. A checked-in project `.claude/settings.json` can opt a repository out of cloud connectors, but a project-level `false` can’t re-enable connectors that a user- or policy-level `true` has disabled. Servers passed explicitly via `--mcp-config` are unaffected. You can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:
-
- ENABLE_CLAUDEAI_MCP_SERVERS=false claude
-
-To block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](</docs/en/managed-mcp>) by name or by URL pattern. For example, a `serverName` entry of `"claude.ai Slack"` blocks the Slack connector. To toggle a connector on or off for the current project only, use the `/mcp` panel.
-
-These client-side settings govern local Claude Code sessions. In [Claude Code on the web](</docs/en/claude-code-on-the-web>) sessions, claude.ai connectors are provisioned by the remote host and arrive as explicit `--mcp-config` entries, so `disableClaudeAiConnectors` doesn’t apply there. Connector URLs are also rewritten through the session proxy, so a `deniedMcpServers` `serverUrl` pattern targeting the vendor URL won’t match. Manage which connectors a cloud session can use from your claude.ai organization settings.
-
-##
-
-
-
-Use Claude Code as an MCP server
-
-You can use Claude Code itself as an MCP server that other applications can connect to:
-
- # Start Claude as a stdio MCP server
- claude mcp serve
-
-The command prints nothing when it starts. A stdio MCP server communicates over stdin and stdout, so a silent, blocked terminal means the server is running and waiting for a client to connect. You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:
-
- {
- "mcpServers": {
- "claude-code": {
- "type": "stdio",
- "command": "claude",
- "args": ["mcp", "serve"],
- "env": {}
- }
- }
- }
-
-**Configuring the executable path** : the `command` field must reference the Claude Code executable. If the `claude` command is not in your system’s PATH, you’ll need to specify the full path to the executable.To find the full path:
-
- which claude
-
-Then use the full path in your configuration:
-
- {
- "mcpServers": {
- "claude-code": {
- "type": "stdio",
- "command": "/full/path/to/claude",
- "args": ["mcp", "serve"],
- "env": {}
- }
- }
- }
-
-Without the correct executable path, you’ll encounter errors like `spawn claude ENOENT`.
-
-Tips:
-
- * In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.
- * This MCP server only exposes Claude Code’s tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
-
-##
-
-
-
-MCP output limits and warnings
-
-When MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:
-
- * **Output warning threshold** : Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens
- * **Configurable limit** : you can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable
- * **Default limit** : the default maximum is 25,000 tokens
- * **Scope** : the environment variable applies to tools that don’t declare their own limit. Tools that set `anthropic/maxResultSizeChars` use that value instead for text content, regardless of what `MAX_MCP_OUTPUT_TOKENS` is set to. Tools that return image data are still subject to `MAX_MCP_OUTPUT_TOKENS`
-
-To increase the limit for tools that produce large outputs:
-
- export MAX_MCP_OUTPUT_TOKENS=50000
- claude
-
-###
-
-
-
-Raise the limit for a specific tool
-
-If you’re building an MCP server, you can allow individual tools to return results larger than the default persist-to-disk threshold by setting `_meta["anthropic/maxResultSizeChars"]` in the tool’s `tools/list` response entry. Claude Code raises that tool’s threshold to the annotated value, up to a hard ceiling of 500,000 characters. This is useful for tools that return inherently large but necessary outputs, such as database schemas or full file trees. Without the annotation, results that exceed the default threshold are persisted to disk and replaced with a file reference in the conversation.
-
- {
- "name": "get_schema",
- "description": "Returns the full database schema",
- "_meta": {
- "anthropic/maxResultSizeChars": 200000
- }
- }
-
-The annotation applies independently of `MAX_MCP_OUTPUT_TOKENS` for text content, so users don’t need to raise the environment variable for tools that declare it. Tools that return image data are still subject to the token limit.
-
-If you frequently encounter output warnings with specific MCP servers you don’t control, consider increasing the `MAX_MCP_OUTPUT_TOKENS` limit. You can also ask the server author to add the `anthropic/maxResultSizeChars` annotation or to paginate their responses. The annotation has no effect on tools that return image content; for those, raising `MAX_MCP_OUTPUT_TOKENS` is the only option.
-
-##
-
-
-
-Tool input schemas with a root-level combinator
-
-Some MCP servers declare a tool’s input schema as a JSON Schema union, with `anyOf`, `oneOf`, or `allOf` at the top level of the schema. The Claude API doesn’t accept those keywords at the schema root. It does accept combinators nested inside `properties`, which Claude Code sends unchanged. As of Claude Code v2.1.195, tools with a root-level combinator stay available. Before sending the tool to the API, Claude Code flattens the schema into a single object and prepends a sentence to the tool’s description that tells Claude which parameter groups belong together:
-
- * `allOf`: properties from every branch are merged, and each branch’s `required` list still applies
- * `anyOf` and `oneOf`: properties from every branch are merged, and each branch’s `required` list is described in the tool description instead of enforced by the schema
-
-Your server receives whichever arguments Claude chose, so keep validating the combination server-side. When Claude Code can’t produce a schema the API accepts, or on a deployment that doesn’t receive the remote configuration that enables the rewrite, such as an offline machine, it skips that one tool, records the reason in the server’s log, and leaves the server’s other tools available. Versions earlier than v2.1.195 skip every tool whose input schema has a root-level `anyOf`, `oneOf`, or `allOf`.
-
-##
-
-
-
-Require approval for a specific tool
-
-If you’re building an MCP server, you can mark a tool as requiring explicit approval on every call by setting `_meta["anthropic/requiresUserInteraction"]` to `true` in the tool’s `tools/list` response entry. The value must be the JSON boolean `true`; any other value is ignored. Claude Code shows that tool’s permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and doesn’t offer a “don’t ask again” option for it. [Allow rules](</docs/en/permissions#permission-rule-syntax>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead. The prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>), an `allow` result from the prompt tool for a flagged tool is converted to a deny with the message `MCP tool requires user interaction; not supported via --permission-prompt-tool`. The Agent SDK’s [`canUseTool` callback](</docs/en/agent-sdk/permissions>) does receive these calls and can approve them, because your SDK application is expected to show them to a user. Use this for tools whose permission prompt is itself the point, such as a consent or access-grant step where auto-approval would mean no human ever agreed. Other tools from the same server keep their normal permission behavior. The following `tools/list` entry marks one tool as always requiring approval.
-
- {
- "name": "grant_access",
- "description": "Requests access to a protected resource",
- "_meta": {
- "anthropic/requiresUserInteraction": true
- }
- }
-
-The `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow. Some surfaces, such as [Remote Control](</docs/en/remote-control>) and applications built on the [Agent SDK](</docs/en/agent-sdk/overview>), normally let you approve tool calls with one tap. For a tool marked with this annotation, Claude Code withholds the one-tap action and shows the tool’s full permission prompt instead, so approval still comes from a person answering the prompt rather than a tap. Claude Code withholds one-tap approval the same way for any permission request that only the terminal dialog can render in full, such as one that carries a safety warning or an always-allow option the remote surface can’t show. You answer that request in the terminal dialog rather than from Remote Control. Requires Claude Code v2.1.214 or later.
-
-##
-
-
-
-Respond to MCP elicitation requests
-
-MCP servers can request structured input from you mid-task using elicitation. When a server needs information it can’t get on its own, Claude Code displays an interactive dialog and passes your response back to the server. No configuration is required on your side: elicitation dialogs appear automatically when a server requests them. Servers can request input in two ways:
-
- * **Form mode** : Claude Code shows a dialog with form fields defined by the server (for example, a username and password prompt). Fill in the fields and submit.
- * **URL mode** : Claude Code opens a browser URL for authentication or approval. Complete the flow in the browser, then confirm in the CLI.
-
-To auto-respond to elicitation requests without showing a dialog, use the [`Elicitation` hook](</docs/en/hooks#elicitation>). If you’re building an MCP server that uses elicitation, see the [MCP elicitation specification](<https://modelcontextprotocol.io/docs/learn/client-concepts#elicitation>) for protocol details and schema examples.
-
-##
-
-
-
-Use MCP resources
-
-MCP servers can expose resources that you can reference using @ mentions, similar to how you reference files.
-
-###
-
-
-
-Reference MCP resources
-
-1
-
-List available resources
-
-Type `@` in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu.
-
-2
-
-Reference a specific resource
-
-Use the format `@server:protocol://resource/path` to reference a resource:
-
- Can you analyze @github:issue://123 and suggest a fix?
-
- Please review the API documentation at @docs:file://api/authentication
-
-3
-
-Multiple resource references
-
-You can reference multiple resources in a single prompt:
-
- Compare @postgres:schema://users with @docs:file://database/user-model
-
-Tips:
-
- * Resources are automatically fetched and included as attachments when referenced
- * Resource paths are fuzzy-searchable in the @ mention autocomplete
- * Claude Code automatically provides tools to list and read MCP resources when servers support them
- * Resources can contain any type of content that the MCP server provides (text, JSON, structured data, etc.)
-
-##
-
-
-
-Scale with MCP tool search
-
-Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window. Claude Code doesn’t impose a fixed per-server tool cap; the practical limit is your context window budget.
-
-Tool search isn’t supported on Microsoft Foundry [deployments hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>), which reject it server-side: Claude Code detects the rejection and loads MCP tools upfront for that deployment instead. `ENABLE_TOOL_SEARCH` can’t override this, since the rejection comes from the deployment itself.
-
-###
-
-
-
-How it works
-
-Tool search is enabled by default. MCP tools are deferred rather than loaded into context upfront, and Claude uses a search tool to discover relevant ones when a task needs them. Only the tools Claude actually uses enter context. From your perspective, MCP tools work exactly as before. If you prefer threshold-based loading, set `ENABLE_TOOL_SEARCH=auto` to load schemas upfront when they fit within 10% of the context window and defer only the overflow. See Configure tool search for all options.
-
-###
-
-
-
-For MCP server authors
-
-If you’re building an MCP server, the server instructions field becomes more useful with tool search enabled. Server instructions help Claude understand when to search for your tools, similar to how [skills](</docs/en/skills>) work. Add clear, descriptive server instructions that explain:
-
- * What category of tasks your tools handle
- * When Claude should search for your tools
- * Key capabilities your server provides
-
-Claude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.
-
-###
-
-
-
-Configure tool search
-
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override that fallback. Setting [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`](</docs/en/env-vars>) keeps tool search off, and `ENABLE_TOOL_SEARCH` can’t override it. The variable strips the beta header that `defer_loading` tool definitions and `tool_reference` content blocks require. Tool search requires a model that supports `tool_reference` blocks: Claude Sonnet 4.5, Claude Haiku 4.5, Claude Opus 4.5, and later models. See [model compatibility in the API docs](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool#model-compatibility>) for the current list. On Google Cloud’s Agent Platform, Claude Code decides by model generation:
-
- * **Claude Opus 4.5, Sonnet 4.5, Haiku 4.5, and later** : tool search is on by default, the same as on the Anthropic API.
- * **Earlier Agent Platform models** : Claude Code loads all MCP tools upfront, because their serving stacks reject the required beta header. `ENABLE_TOOL_SEARCH=true` doesn’t override this.
-
-Before v2.1.221, Claude Code disabled tool search for all models on Google Cloud’s Agent Platform unless you set `ENABLE_TOOL_SEARCH=true`. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
-
-Value| Behavior
----|---
-(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Google Cloud’s Agent Platform models earlier than the Claude 4.5 generation, when `ANTHROPIC_BASE_URL` is a non-first-party host, or on a Microsoft Foundry deployment hosted on Azure
-`true`| All MCP tools deferred, except on a Microsoft Foundry deployment hosted on Azure, where the server-side rejection still forces upfront loading, and on Google Cloud’s Agent Platform models earlier than the Claude 4.5 generation, where Claude Code keeps loading tools upfront. Claude Code sends the beta header through proxies, and requests fail on proxies that don’t support `tool_reference` blocks
-`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
-`auto:N`| Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%
-`false`| All MCP tools loaded upfront, no deferral
-
- # Use a custom 5% threshold
- ENABLE_TOOL_SEARCH=auto:5 claude
-
- # Disable tool search entirely
- ENABLE_TOOL_SEARCH=false claude
-
-Or set the value in your [settings.json `env` field](</docs/en/settings#available-settings>). You can also disable the `ToolSearch` tool specifically:
-
- {
- "permissions": {
- "deny": ["ToolSearch"]
- }
- }
-
-###
-
-
-
-Exempt a server from deferral
-
-If a server’s tools should always be visible to Claude without a search step, set `alwaysLoad` to `true` in that server’s configuration. Every tool from that server then loads into context at session start regardless of the `ENABLE_TOOL_SEARCH` setting. Use this for a small number of tools that Claude needs on every turn, since each upfront tool consumes context that would otherwise be available for your conversation. The following `.mcp.json` entry exempts one HTTP server while leaving other servers deferred:
-
- {
- "mcpServers": {
- "core-tools": {
- "type": "http",
- "url": "https://mcp.example.com/mcp",
- "alwaysLoad": true
- }
- }
- }
-
-The `alwaysLoad` field is available on all server types. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also makes startup wait for the server’s tools, capped at the standard 5-second connect timeout, since they must be present when the first prompt is built. A remote server with a valid `cached` entry supplies its tools from the cache without connecting, so it doesn’t hold startup. Other servers connect in the background by default; set [`MCP_CONNECTION_NONBLOCKING=0`](</docs/en/env-vars>) to make startup wait for them too.
-
-##
-
-
-
-Use MCP prompts as commands
-
-MCP servers can expose prompts that become available as commands in Claude Code.
-
-###
-
-
-
-Execute MCP prompts
-
-1
-
-Discover available prompts
-
-Type `/` to see all available commands, including those from MCP servers. MCP prompts appear with the format `/mcp__servername__promptname`.
-
-2
-
-Execute a prompt without arguments
-
- /mcp__github__list_prs
-
-3
-
-Execute a prompt with arguments
-
-Many prompts accept arguments. Pass them space-separated after the command:
-
- /mcp__github__pr_review 456
-
- /mcp__jira__create_issue "Bug in login flow" high
-
-Tips:
-
- * MCP prompts are dynamically discovered from connected servers
- * Arguments are parsed based on the prompt’s defined parameters
- * Prompt results are injected directly into the conversation
- * Server and prompt names are normalized, with spaces converted to underscores
-
-##
-
-
-
-Managed MCP configuration
-
-For organizations that need centralized control over which MCP servers users can connect to, see [Managed MCP configuration](</docs/en/managed-mcp>). It covers deploying a fixed server set with `managed-mcp.json`, restricting servers with `allowedMcpServers` and `deniedMcpServers`, and what users see when a server is blocked.
+ "url": "https://api.example.com/mcp",
+ "headers": {
+ "Authorization": "Bearer ${API_TOKEN}"
+ }
+ }
+ }
+ }
+
+The `${API_TOKEN}` syntax expands environment variables at runtime.
+
+For a complete working example of a remote server authenticated with headers, see List issues from a repository.
+
+###
+
+
+
+OAuth2 authentication
+
+The [MCP specification supports OAuth 2.1](<https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization>) for authorization. The SDK doesn’t open a browser or run an interactive OAuth flow. When a configured server returns an authorization challenge and no stored token is available, the agent run continues without that server’s tools, and the server reports status `needs-auth`. The `mcp_servers` array of the [system init message](</docs/en/agent-sdk/typescript#sdksystemmessage>) may still show `pending` for that server when it’s emitted. To confirm whether a server needs credentials, poll `mcpServerStatus()` in the TypeScript SDK or [`get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python. To supply credentials, complete the OAuth flow in your own application and pass the resulting access token in the server’s `headers`:
+
+TypeScript
+
+Python
+
+ // After completing OAuth flow in your app.
+ // Implement getAccessTokenFromOAuthFlow for your OAuth provider.
+ const accessToken = await getAccessTokenFromOAuthFlow();
+
+ const options = {
+ mcpServers: {
+ "oauth-api": {
+ type: "http",
+ url: "https://api.example.com/mcp",
+ headers: {
+ Authorization: `Bearer ${accessToken}`
+ }
+ }
+ },
+ allowedTools: ["mcp__oauth-api__*"]
+ };
+
+ # After completing OAuth flow in your app.
+ # Implement get_access_token_from_oauth_flow for your OAuth provider.
+ access_token = await get_access_token_from_oauth_flow()
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "oauth-api": {
+ "type": "http",
+ "url": "https://api.example.com/mcp",
+ "headers": {"Authorization": f"Bearer {access_token}"},
+ }
+ },
+ allowed_tools=["mcp__oauth-api__*"],
+ )
+
+##
+
+
+
+Examples
+
+###
+
+
+
+List issues from a repository
+
+This example connects to the remote [GitHub MCP server](<https://github.com/github/github-mcp-server>) to list recent issues. The example includes debug logging to verify the MCP connection and tool calls. Before running, create a [GitHub personal access token](<https://github.com/settings/personal-access-tokens>) with read access to the repositories you want to query and set it as an environment variable:
+
+ export GITHUB_TOKEN=YOUR_GITHUB_PAT
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ for await (const message of query({
+ prompt: "List the 3 most recent issues in anthropics/claude-code",
+ options: {
+ mcpServers: {
+ github: {
+ type: "http",
+ url: "https://api.githubcopilot.com/mcp/",
+ headers: {
+ Authorization: `Bearer ${process.env.GITHUB_TOKEN}`
+ }
+ }
+ },
+ allowedTools: ["mcp__github__list_issues"]
+ }
+ })) {
+ // Verify MCP server connected successfully
+ if (message.type === "system" && message.subtype === "init") {
+ console.log("MCP servers:", message.mcp_servers);
+ }
+
+ // Log when Claude calls an MCP tool
+ if (message.type === "assistant") {
+ for (const block of message.message.content) {
+ if (block.type === "tool_use" && block.name.startsWith("mcp__")) {
+ console.log("MCP tool called:", block.name);
+ }
+ }
+ }
+
+ // Print the final result
+ if (message.type === "result" && message.subtype === "success") {
+ console.log(message.result);
+ }
+ }
+
+ import asyncio
+ import os
+ from claude_agent_sdk import (
+ query,
+ ClaudeAgentOptions,
+ ResultMessage,
+ SystemMessage,
+ AssistantMessage,
+ )
+
+ async def main():
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "github": {
+ "type": "http",
+ "url": "https://api.githubcopilot.com/mcp/",
+ "headers": {"Authorization": f"Bearer {os.environ['GITHUB_TOKEN']}"},
+ }
+ },
+ allowed_tools=["mcp__github__list_issues"],
+ )
+
+ async for message in query(
+ prompt="List the 3 most recent issues in anthropics/claude-code",
+ options=options,
+ ):
+ # Verify MCP server connected successfully
+ if isinstance(message, SystemMessage) and message.subtype == "init":
+ print("MCP servers:", message.data.get("mcp_servers"))
+
+ # Log when Claude calls an MCP tool
+ if isinstance(message, AssistantMessage):
+ for block in message.content:
+ if hasattr(block, "name") and block.name.startswith("mcp__"):
+ print("MCP tool called:", block.name)
+
+ # Print the final result
+ if isinstance(message, ResultMessage) and message.subtype == "success":
+ print(message.result)
+
+ asyncio.run(main())
+
+###
+
+
+
+Query a database
+
+This example uses [DBHub](<https://github.com/bytebase/dbhub>) to query a Postgres database. The agent automatically discovers the database schema, writes the SQL query, and returns the results. DBHub’s `execute_sql` tool runs whatever SQL the agent emits, including writes, unless you restrict it. Setting `readonly = true` in the [DBHub configuration file](<https://dbhub.ai/config/toml>) makes DBHub reject `INSERT`, `UPDATE`, `DELETE`, and DDL statements, so the example cannot modify your data even if the agent emits a write. DBHub resolves `${DATABASE_URL}` from the process environment when it loads the config, so the connection string stays out of the file. Create this `dbhub.toml` next to your script:
+
+dbhub.toml
+
+ [[sources]]
+ id = "production"
+ dsn = "${DATABASE_URL}"
+
+ [[tools]]
+ name = "execute_sql"
+ source = "production"
+ readonly = true
+
+The script then points DBHub at the config file instead of passing a connection string directly. Before running, set the `DATABASE_URL` environment variable to your connection string. Replace the placeholder values with your own database details:
+
+ export DATABASE_URL=postgresql://user:password@localhost:5432/mydb
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ for await (const message of query({
+ // Natural language query - Claude writes the SQL
+ prompt: "How many users signed up last week? Break it down by day.",
+ options: {
+ mcpServers: {
+ postgres: {
+ command: "npx",
+ // dbhub.toml sets readonly = true, so execute_sql rejects writes
+ args: ["-y", "@bytebase/dbhub", "--config", "dbhub.toml"]
+ }
+ },
+ allowedTools: ["mcp__postgres__execute_sql"]
+ }
+ })) {
+ if (message.type === "result" && message.subtype === "success") {
+ console.log(message.result);
+ }
+ }
+
+ import asyncio
+ from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage
+
+ async def main():
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ "postgres": {
+ "command": "npx",
+ # dbhub.toml sets readonly = true, so execute_sql rejects writes
+ "args": [
+ "-y",
+ "@bytebase/dbhub",
+ "--config",
+ "dbhub.toml",
+ ],
+ }
+ },
+ allowed_tools=["mcp__postgres__execute_sql"],
+ )
+
+ # Natural language query - Claude writes the SQL
+ async for message in query(
+ prompt="How many users signed up last week? Break it down by day.",
+ options=options,
+ ):
+ if isinstance(message, ResultMessage) and message.subtype == "success":
+ print(message.result)
+
+ asyncio.run(main())
+
+##
+
+
+
+Error handling
+
+MCP servers can fail to connect for various reasons: the server process might not be installed, credentials might be invalid, or a remote server might be unreachable. Claude Code emits a `system` message with subtype `init` at the start of each query. This message includes the connection status for each MCP server. The `status` field can be `"pending"`, `"connected"`, `"failed"`, `"needs-auth"`, or `"disabled"`. Claude Code emits the init message after the first-turn connection wait for servers passed in `options.mcpServers`, so such a server that connected within the wait shows `"connected"`. A `"pending"` status means the server hasn’t connected yet, which is common for settings-file servers that don’t get the full wait, or that its tool list was served from the cache with a connection made on first use; the reported status for a deadline-expired server can be `"pending"` or `"failed"` depending on timing. Don’t treat `"pending"` as a failure. Check for `"failed"` or `"needs-auth"` to detect servers that won’t be usable:
+
+TypeScript
+
+Python
+
+ import { query } from "@anthropic-ai/claude-agent-sdk";
+
+ try {
+ for await (const message of query({
+ prompt: "Process data",
+ options: {
+ mcpServers: {
+ // Replace dataServer with your server configuration
+ "data-processor": dataServer
+ }
+ }
+ })) {
+ if (message.type === "system" && message.subtype === "init") {
+ const unavailableServers = message.mcp_servers.filter(
+ (s) => s.status === "failed" || s.status === "needs-auth"
+ );
+
+ if (unavailableServers.length > 0) {
+ console.warn("Unavailable MCP servers:", unavailableServers);
+ }
+ }
+
+ if (message.type === "result" && message.subtype === "error_during_execution") {
+ console.error("Execution failed");
+ }
+ }
+ } catch (error) {
+ // A single-shot query() throws after yielding an error result. If the
+ // failure was an error result, the error subtype branch above has
+ // already run; a failure to start or reach the Claude Code process
+ // yields no result message. MCP servers that fail to connect don't
+ // throw: use the status check above, and note that servers still
+ // "pending" at init need a later status check.
+ console.log(`Session ended with an error: ${error}`);
+ }
+
+ import asyncio
+ from claude_agent_sdk import query, ClaudeAgentOptions, SystemMessage, ResultMessage
+
+ async def main():
+ # Replace data_server with your server configuration
+ options = ClaudeAgentOptions(mcp_servers={"data-processor": data_server})
+
+ try:
+ async for message in query(prompt="Process data", options=options):
+ if isinstance(message, SystemMessage) and message.subtype == "init":
+ unavailable_servers = [
+ s
+ for s in message.data.get("mcp_servers", [])
+ if s.get("status") in ("failed", "needs-auth")
+ ]
+
+ if unavailable_servers:
+ print(f"Unavailable MCP servers: {unavailable_servers}")
+
+ if (
+ isinstance(message, ResultMessage)
+ and message.subtype == "error_during_execution"
+ ):
+ print("Execution failed")
+ except Exception as error:
+ # A single-shot query() raises after yielding an error result. If the
+ # failure was an error result, the error subtype branch above has
+ # already run; a failure to start or reach the Claude Code process
+ # yields no result message. MCP servers that fail to connect don't
+ # raise: use the status check above, and note that servers still
+ # "pending" at init need a later status check.
+ print(f"Session ended with an error: {error}")
+
+ asyncio.run(main())
+
+##
+
+
+
+Troubleshooting
+
+###
+
+
+
+Server shows “failed” status
+
+Check the `init` message to see which servers failed to connect:
+
+TypeScript
+
+Python
+
+ if (message.type === "system" && message.subtype === "init") {
+ for (const server of message.mcp_servers) {
+ if (server.status === "failed") {
+ console.error(`Server ${server.name} failed to connect`);
+ }
+ }
+ }
+
+ if isinstance(message, SystemMessage) and message.subtype == "init":
+ for server in message.data.get("mcp_servers", []):
+ if server.get("status") == "failed":
+ print(f"Server {server['name']} failed to connect")
+
+A `"pending"` status doesn’t mean the server failed; see Error handling for the two cases it covers at init. To get updated statuses later in the session, call the query’s `mcpServerStatus()` method in the TypeScript SDK, or [`ClaudeSDKClient.get_mcp_status()`](</docs/en/agent-sdk/python#methods>) in Python. Common causes:
+
+ * **Missing environment variables** : Ensure required tokens and credentials are set. For stdio servers, check the `env` field matches what the server expects.
+ * **Server not installed** : For `npx` commands, verify the package exists and Node.js is in your PATH.
+ * **Invalid connection string** : For database servers, verify the connection string format and that the database is accessible.
+ * **Network issues** : For remote HTTP/SSE servers, check the URL is reachable and any firewalls allow the connection.
+
+###
+
+
+
+Tools not being called
+
+If Claude sees tools but doesn’t use them, check that you’ve granted permission with `allowedTools`:
+
+TypeScript
+
+Python
+
+ const _ = {
+ options: {
+ mcpServers: {
+ // your servers
+ },
+ allowedTools: ["mcp__servername__*"] // Auto-approve calls from this server
+ }
+ };
+
+ options = ClaudeAgentOptions(
+ mcp_servers={
+ # your servers
+ },
+ allowed_tools=["mcp__servername__*"], # Auto-approve calls from this server
+ )
+
+###
+
+
+
+Connection timeouts
+
+MCP server connections time out after 30 seconds by default. If your server takes longer to start, the connection fails. Raise the limit with the [`MCP_TIMEOUT`](</docs/en/env-vars>) environment variable, in milliseconds. For servers that need more startup time, also consider:
+
+ * Using a lighter-weight server if available
+ * Pre-warming the server before starting your agent
+ * Checking server logs for slow initialization causes
+
+###
+
+
+
+Tool output exceeds maximum allowed tokens
+
+The SDK applies the same MCP output limit as Claude Code. When a tool result is larger than 25,000 tokens, the full output is saved to a file and the tool result is replaced with an error message that names the file path, so the agent can read the output back in portions. Raise the limit with the [`MAX_MCP_OUTPUT_TOKENS`](</docs/en/env-vars>) environment variable. See [MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>) for the full behavior, including how a server can declare a higher per-tool limit.
+
+##
+
+
+
+Related resources
+
+ * **[Custom tools guide](</docs/en/agent-sdk/custom-tools>)** : Build your own MCP server that runs in-process with your SDK application
+ * **[Permissions](</docs/en/agent-sdk/permissions>)** : Control which MCP tools your agent can use with `allowedTools` and `disallowedTools`
+ * **[MCP output limits and warnings](</docs/en/mcp#mcp-output-limits-and-warnings>)** : How the SDK handles tool results that exceed `MAX_MCP_OUTPUT_TOKENS`, including the persist-to-disk fallback and the `anthropic/maxResultSizeChars` per-tool annotation
+ * **[TypeScript SDK reference](</docs/en/agent-sdk/typescript>)** : Full API reference including MCP configuration options
+ * **[Python SDK reference](</docs/en/agent-sdk/python>)** : Full API reference including MCP configuration options
+ * **[MCP server directory](<https://github.com/modelcontextprotocol/servers>)** : Browse available MCP servers for databases, APIs, and more
Show diff (161 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -76,7 +76,7 @@
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
-When configuring MCP servers via JSON in `.mcp.json`, `~/.claude.json`, or `claude mcp add-json`, the `type` field accepts `streamable-http` as an alias for `http`. The MCP specification uses the name `streamable-http` for this transport, so configurations copied from server documentation work without modification. A JSON entry that has a `url` but no `type` is a configuration error, because Claude Code reads an entry with no `type` as a stdio server. Claude Code skips that server and reports `MCP server "<name>" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry`. Before v2.1.202, Claude Code reported this misconfiguration as `command: expected string, received undefined`.
+When configuring MCP servers via JSON in `.mcp.json`, `~/.claude.json`, or `claude mcp add-json`, the `type` field accepts `streamable-http` as an alias for `http`. The MCP specification uses the name `streamable-http` for this transport, so configurations copied from server documentation work without modification. A JSON entry that has a `url` but no `type` is a configuration error, because Claude Code reads an entry with no `type` as a stdio server. Claude Code skips that server and reports `MCP server "<name>" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry`. Before v2.1.202, Claude Code reported this misconfiguration as `command: expected string, received undefined`. In `--output-format stream-json` runs, Claude Code also reports a skipped `--mcp-config` entry in the `system/init` event’s [`mcp_server_errors` field](</docs/en/headless#stream-responses>), so scripts can detect that the server never loaded. This requires Claude Code v2.1.219 or later.
###
@@ -153,13 +153,57 @@
# (within Claude Code) Check server status
/mcp
-`claude mcp add` confirms a successful add by printing an `Added ...` line, which means the configuration was written. `claude mcp list` then shows a health status next to each server it lists, such as `✔ Connected`, `! Needs authentication`, or `✘ Failed to connect`. A failure status means Claude Code couldn’t connect to that server, not that the list command failed. Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` and `claude mcp get <name>` as `⏸ Pending approval (run `claude` to approve)`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows rejected servers as `✘ Rejected (see disabledMcpjsonServers in settings)`. WebSocket servers don’t appear in `claude mcp list` output. Use `claude mcp get <name>` or the `/mcp` panel to check them. As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
+####
+
+
+
+Server status
+
+`claude mcp add` confirms a successful add by printing an `Added ...` line, which means the configuration was written. `claude mcp list` then shows a health status next to each server it lists, such as `✔ Connected`, `! Needs authentication`, or `✘ Failed to connect`. A failure status means Claude Code couldn’t connect to that server, not that the list command failed. Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` and `claude mcp get <name>` as `⏸ Pending approval (run `claude` to approve)`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows rejected servers as `✘ Rejected (see disabledMcpjsonServers in settings)`. WebSocket servers don’t appear in `claude mcp list` output. Use `claude mcp get <name>` or the `/mcp` panel to check them.
+
+####
+
+
+
+Project server approvals and workspace trust
+
+As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
* your user `~/.claude/settings.json`
* managed settings
* settings passed with `--settings`
-Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. In `/mcp`, a server’s menu, and the [`/plugin`](</docs/en/plugins>) manager, a remote (HTTP or SSE) server you’ve used before can show a `cached` status such as `cached 2h ago · connects on first use · 5 tools`. Claude Code loaded the server’s tool list from a previous session instead of connecting at startup, and it connects the server the first time Claude calls one of its tools. The tools are available from your first message, so you don’t need to do anything. To make every server connect at startup instead, set [`MCP_DISCOVERY_CACHE=0`](</docs/en/env-vars>). The discovery cache and its `cached` status require Claude Code v2.1.221 or later. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model earlier than the Claude 4.5 generation on Google Cloud’s Agent Platform, Claude uses the `WaitForMcpServers` tool instead. A Microsoft Foundry [deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>) starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API; after Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server.
+
+####
+
+
+
+Server status detail
+
+In `/mcp`, a server’s menu, and the [`/plugin`](</docs/en/plugins>) manager, a remote (HTTP or SSE) server you’ve used before can show a `cached` status such as `cached 2h ago · connects on first use · 5 tools`. Claude Code loaded the server’s tool list from a previous session instead of connecting at startup, and it connects the server the first time Claude calls one of its tools. The tools are available from your first message, so you don’t need to do anything. To make every server connect at startup instead, set [`MCP_DISCOVERY_CACHE=0`](</docs/en/env-vars>). The discovery cache and its `cached` status require Claude Code v2.1.221 or later. When a server’s status is `✘ Failed to connect`, `claude mcp list` appends the failure detail to that status line, and `claude mcp get <name>` shows it on an `Issue:` line: the HTTP status or error code, plus any error text the server returned. The server’s detail view in `/mcp` includes the same server-reported text in its `Issue:` row. Claude Code redacts credential-like text from this detail and never includes the expanded server URL, which can carry secrets. Claude Code appends no detail to a `✘ Connection error` status, because the exception text it would print there can embed that URL. Before v2.1.219, both commands showed only the bare failure status, without the status code or the server’s error text. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect.
+
+####
+
+
+
+Configuration warnings
+
+Claude Code also warns when an MCP config value carries hidden leading or trailing whitespace, which often comes from pasting a token with a trailing newline. Claude Code checks `command`, `url`, each `args` entry, and the values and key names under `env` and `headers`. Claude Code shows the warning in `claude mcp list` output and in `/mcp`, naming the affected fields without echoing their values, for example `Leading or trailing whitespace in: headers.Authorization`. Claude Code doesn’t trim the whitespace and uses the values exactly as written, so edit the configuration to remove it. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+
+####
+
+
+
+Tool availability
+
+The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. How the wait happens depends on your configuration:
+
+ * **Withtool search, the default**: the wait happens inside the `ToolSearch` call.
+ * **Without tool search** : Claude uses the `WaitForMcpServers` tool instead. Configurations without tool search include a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, and a model earlier than the Claude 4.5 generation on Google Cloud’s Agent Platform.
+ * **On a Microsoft Foundry[deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>)**: Claude starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API. After Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request.
+
+With tool search enabled, when a server finishes connecting while Claude is working, Claude Code lists the server’s tool names to Claude on its next request in the same turn. Claude can then search for and call those tools without waiting for your next message.
###
@@ -201,9 +245,9 @@
Tips:
* Use the `-s` or `--scope` flag to specify where the configuration is stored:
- * `local` (default): available only to you in the current project. Older versions called this scope `project`
+ * `local` (default): available only to you in the current project
* `project`: shared with everyone in the project via the `.mcp.json` file
- * `user`: available to you across all projects. Older versions called this scope `global`
+ * `user`: available to you across all projects
* Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)
* The `--transport` and `--header` flags also accept `-t` and `-H` short forms
* Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
@@ -278,22 +322,11 @@
* **User environment access** : access to the same environment variables as manually configured servers
* **Multiple transport types** : support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server
-**Viewing plugin MCP servers** :
-
- # Within Claude Code, see all MCP servers including plugin ones
- /mcp
-
-Plugin servers appear in the list with indicators showing they come from plugins. **Plugin MCP tool names** : Tools from a plugin-bundled MCP server include both the plugin name and the server key in their callable name. The full form is `mcp__plugin_<plugin-name>_<server-name>__<tool-name>`, where any character outside `A-Z`, `a-z`, `0-9`, `_`, and `-` is replaced with `_`. For the `database-tools` server bundled in a plugin named `my-plugin`, a `query` tool is callable as:
+Plugin servers appear in `/mcp` with indicators showing they come from plugins. **Plugin MCP tool names** : Tools from a plugin-bundled MCP server include both the plugin name and the server key in their callable name. The full form is `mcp__plugin_<plugin-name>_<server-name>__<tool-name>`, where any character outside `A-Z`, `a-z`, `0-9`, `_`, and `-` is replaced with `_`. For the `database-tools` server bundled in a plugin named `my-plugin`, a `query` tool is callable as:
mcp__plugin_my-plugin_database-tools__query
-Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>), or a [hook matcher](</docs/en/hooks#match-mcp-tools>). A hook matcher written against the bare server key, such as `mcp__database-tools__.*`, never fires for a plugin-bundled server. The server itself registers under the scoped name `plugin:<plugin-name>:<server-name>`, such as `plugin:my-plugin:database-tools`. Use that name where a configured server name is expected, such as an [`mcp_tool` hook’s `server` field](</docs/en/hooks#mcp-tool-hook-fields>). **Benefits of plugin MCP servers** :
-
- * **Bundled distribution** : tools and servers packaged together
- * **Automatic setup** : no manual MCP configuration needed
- * **Team consistency** : everyone gets the same tools when the plugin is installed
-
-See the [plugin components reference](</docs/en/plugins-reference#mcp-servers>) for details on bundling MCP servers with plugins.
+Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>), or a [hook matcher](</docs/en/hooks#match-mcp-tools>). A hook matcher written against the bare server key, such as `mcp__database-tools__.*`, never fires for a plugin-bundled server. The server itself registers under the scoped name `plugin:<plugin-name>:<server-name>`, such as `plugin:my-plugin:database-tools`. Use that name where a configured server name is expected, such as an [`mcp_tool` hook’s `server` field](</docs/en/hooks#mcp-tool-hook-fields>). See the [plugin components reference](</docs/en/plugins-reference#mcp-servers>) for details on bundling MCP servers with plugins.
##
@@ -465,7 +498,7 @@
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
--header "Authorization: Bearer YOUR_GITHUB_PAT"
-Replace `YOUR_GITHUB_PAT` with your personal access token. The `claude mcp add` command saves the configuration without validating credentials, so a placeholder value is accepted here but the server fails to connect later. To verify the connection, run `/mcp` and check that the server shows `connected`. A server with bad credentials shows `failed`. Then work with GitHub:
+Replace `YOUR_GITHUB_PAT` with your personal access token. The `claude mcp add` command saves the configuration without validating credentials, so a placeholder value is accepted here but the server fails to connect later. To verify the connection, run `/mcp` and check that the server shows `connected`. A server with bad credentials shows `failed`, and the failure detail includes the HTTP status the server returned, such as a 401. Then work with GitHub:
Review PR #456 and suggest improvements
@@ -498,7 +531,12 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow. For a claude.ai connector, a `401` caused by claude.ai rejecting your session token doesn’t flag the connector this way, because re-authorizing the connector can’t fix your login; Claude Code shows the [session-token-rejected state](</docs/en/errors#claude-ai-rejected-the-session-token>) instead. When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. The notice requires Claude Code v2.1.193 or later. It counts only servers you can sign in to from Claude Code. Before v2.1.218, it also counted claude.ai connectors that weren’t connected in claude.ai, which you can connect only from claude.ai settings. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. What Claude Code shows depends on the server:
+
+ * For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow.
+ * For a claude.ai connector, a `401` caused by claude.ai rejecting your session token doesn’t flag the connector, because re-authorizing the connector can’t fix your login. Claude Code shows the [session-token-rejected state](</docs/en/errors#claude-ai-rejected-the-session-token>) instead.
+
+When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. The notice requires Claude Code v2.1.193 or later. It counts only servers you can sign in to from Claude Code. Before v2.1.218, it also counted claude.ai connectors that weren’t connected in claude.ai, which you can connect only from claude.ai settings. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
@@ -837,8 +875,6 @@
* **Tool set to`ask`**: Claude Code prompts on every call with the reason `Your organization requires approval for this tool`. The prompt appears even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and never offers an option to remember your choice. [Allow rules](</docs/en/permissions>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead.
* **Tool set to`blocked`**: Claude Code filters the tool out before Claude sees it, so it never appears in the tool list.
-Enforcing these controls requires Claude Code v2.1.129 or later. Earlier versions ignore the settings and apply the standard permission flow.
-
###
@@ -904,7 +940,6 @@
Tips:
- * The server provides access to Claude’s tools like View, Edit, LS, etc.
* In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.
* This MCP server only exposes Claude Code’s tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
@@ -925,12 +960,6 @@
export MAX_MCP_OUTPUT_TOKENS=50000
claude
-
-This is particularly useful when working with MCP servers that:
-
- * Query large datasets or databases
- * Generate detailed reports or documentation
- * Process extensive log files or debugging information
###
--- a/mcp.md
+++ b/mcp.md
@@ -188,7 +188,7 @@
Automatic reconnection
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. When a configured server fails to connect, Claude Code tells Claude which server failed and its connection error, including in `ToolSearch` results that find no matching tool, so Claude reports the connection failure in its response. Requires tool search, which is enabled by default. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model that doesn’t support tool search, and on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code doesn’t report failed server connections to Claude. Before v2.1.205, Claude Code didn’t pass connection errors to Claude, and Claude could respond as if the failed server’s tools were never configured. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. When a configured server fails to connect, Claude Code tells Claude which server failed and its connection error, including in `ToolSearch` results that find no matching tool, so Claude reports the connection failure in its response. Requires tool search, which is enabled by default. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model that doesn’t support tool search, and on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code doesn’t report failed server connections to Claude. Before v2.1.205, Claude Code didn’t pass connection errors to Claude, and Claude could respond as if the failed server’s tools were never configured. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
###
@@ -362,7 +362,7 @@
}
}
-For security reasons, Claude Code prompts for approval before using project-scoped servers from `.mcp.json` files. If you need to reset these approval choices, use the `claude mcp reset-project-choices` command.
+For security reasons, Claude Code prompts for approval in interactive sessions before using project-scoped servers from `.mcp.json` files. To reset those approval choices, run `claude mcp reset-project-choices`. `claude -p` runs, [Agent SDK](</docs/en/headless>) sessions, and [cloud sessions](</docs/en/claude-code-on-the-web>) can’t show that prompt: Claude Code loads project-scoped servers there without asking. To keep a server out anyway, add it to [`disabledMcpjsonServers`](</docs/en/settings#available-settings>), which blocks it in every mode, or exclude project settings entirely with [`--setting-sources`](</docs/en/cli-reference>) or the SDK’s `settingSources` option.
###
@@ -1126,7 +1126,7 @@
}
}
-The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also makes startup wait for the server’s tools, capped at the standard 5-second connect timeout, since they must be present when the first prompt is built. A remote server with a valid `cached` entry supplies its tools from the cache without connecting, so it doesn’t hold startup. Other servers connect in the background by default; set [`MCP_CONNECTION_NONBLOCKING=0`](</docs/en/env-vars>) to make startup wait for them too.
+The `alwaysLoad` field is available on all server types. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also makes startup wait for the server’s tools, capped at the standard 5-second connect timeout, since they must be present when the first prompt is built. A remote server with a valid `cached` entry supplies its tools from the cache without connecting, so it doesn’t hold startup. Other servers connect in the background by default; set [`MCP_CONNECTION_NONBLOCKING=0`](</docs/en/env-vars>) to make startup wait for them too.
##
--- a/mcp.md
+++ b/mcp.md
@@ -159,7 +159,7 @@
* managed settings
* settings passed with `--settings`
-Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model earlier than the Claude 4.5 generation on Google Cloud’s Agent Platform, Claude uses the `WaitForMcpServers` tool instead. A Microsoft Foundry [deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>) starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API; after Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. In `/mcp`, a server’s menu, and the [`/plugin`](</docs/en/plugins>) manager, a remote (HTTP or SSE) server you’ve used before can show a `cached` status such as `cached 2h ago · connects on first use · 5 tools`. Claude Code loaded the server’s tool list from a previous session instead of connecting at startup, and it connects the server the first time Claude calls one of its tools. The tools are available from your first message, so you don’t need to do anything. To make every server connect at startup instead, set [`MCP_DISCOVERY_CACHE=0`](</docs/en/env-vars>). The discovery cache and its `cached` status require Claude Code v2.1.221 or later. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model earlier than the Claude 4.5 generation on Google Cloud’s Agent Platform, Claude uses the `WaitForMcpServers` tool instead. A Microsoft Foundry [deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>) starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API; after Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
###
@@ -269,7 +269,7 @@
**Plugin MCP features** :
* **Automatic lifecycle** : servers connect and disconnect at these points:
- * At session startup, Claude Code connects the servers for enabled plugins automatically
+ * At session startup, Claude Code connects the servers for enabled plugins automatically. In `/mcp`, a remote (HTTP or SSE) plugin server you’ve used before can show the `cached` status instead; Claude Code connects it when Claude first calls one of its tools
* If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers. When you reload, Claude Code keeps the live connections of plugin servers whose configuration is unchanged, and does the same when you [replace the session’s MCP server list](</docs/en/agent-sdk/typescript#mcpsetserversresult>) from the Agent SDK without naming them. Before v2.1.210, Claude Code disconnected plugin-provided MCP servers that the new SDK server list didn’t name
* In [web sessions](</docs/en/claude-code-on-the-web>), an MCP call to a plugin server that isn’t connected yet, such as right after an idle session wakes, starts the server on demand and waits for it to connect. Before v2.1.211, plugin servers in a web session reconnected only when the next message started a turn, so MCP calls after an idle session woke failed until then
* **Path placeholders** : `${CLAUDE_PLUGIN_ROOT}` resolves to the plugin’s installation directory, `${CLAUDE_PLUGIN_DATA}` to its [persistent state](</docs/en/plugins-reference#persistent-data-directory>) directory, and `${CLAUDE_PROJECT_DIR}` to the stable project root. Substitution applies to:
@@ -498,7 +498,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow. When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. The notice requires Claude Code v2.1.193 or later. It counts only servers you can sign in to from Claude Code. Before v2.1.218, it also counted claude.ai connectors that weren’t connected in claude.ai, which you can connect only from claude.ai settings. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow. For a claude.ai connector, a `401` caused by claude.ai rejecting your session token doesn’t flag the connector this way, because re-authorizing the connector can’t fix your login; Claude Code shows the [session-token-rejected state](</docs/en/errors#claude-ai-rejected-the-session-token>) instead. When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. The notice requires Claude Code v2.1.193 or later. It counts only servers you can sign in to from Claude Code. Before v2.1.218, it also counted claude.ai connectors that weren’t connected in claude.ai, which you can connect only from claude.ai settings. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
@@ -813,7 +813,18 @@
Servers from claude.ai appear in the list with indicators showing they come from claude.ai.
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is a claude.ai subscription login. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active, even if you previously ran `/login`. They also aren’t loaded when `CLAUDE_CODE_OAUTH_TOKEN` holds a token from [`claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>), which can only make model requests. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is a claude.ai subscription login. They aren’t loaded, even if you previously ran `/login`, when:
+
+ * `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, or `apiKeyHelper` is active
+ * A third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active
+ * `CLAUDE_CODE_OAUTH_TOKEN` holds a token from [`claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>), which can only make model requests
+
+If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. If `/mcp` shows a connector as `connected · session token rejected`, or its detail view shows [`claude.ai rejected the session token`](</docs/en/errors#claude-ai-rejected-the-session-token>), claude.ai rejected the token from your Claude Code login, usually because the login expired and couldn’t be refreshed. Authorizing the connector again doesn’t clear this state, because the connector’s own authorization in claude.ai isn’t what was rejected. To clear it:
+
+ 1. Run `/login` to sign in again.
+ 2. Reconnect the connector from `/mcp`.
+
+Before v2.1.222, Claude Code marked connectors as needing authentication instead, and authorizing them didn’t resolve it. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
###
@@ -1115,7 +1126,7 @@
}
}
-The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also blocks startup until the server connects, capped at the standard 5-second connect timeout. This applies even though MCP startup is otherwise [non-blocking by default](</docs/en/env-vars>), since the tools must be present when the first prompt is built. Other servers continue to connect in the background.
+The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also makes startup wait for the server’s tools, capped at the standard 5-second connect timeout, since they must be present when the first prompt is built. A remote server with a valid `cached` entry supplies its tools from the cache without connecting, so it doesn’t hold startup. Other servers connect in the background by default; set [`MCP_CONNECTION_NONBLOCKING=0`](</docs/en/env-vars>) to make startup wait for them too.
##
--- a/mcp.md
+++ b/mcp.md
@@ -35,7 +35,12 @@
/plugin install mcp-server-dev@claude-plugins-official
-If Claude Code reports `Marketplace "claude-plugins-official" not found`, add the marketplace with `/plugin marketplace add anthropics/claude-plugins-official`. If it reports that the plugin is not found in the marketplace, your local copy is outdated: refresh it with `/plugin marketplace update claude-plugins-official`. Then retry the install. Once installed, run `/reload-plugins` to activate it in the current session.
+If the install fails, match the message Claude Code reports:
+
+ * `Marketplace "claude-plugins-official" not found`: add the marketplace with `/plugin marketplace add anthropics/claude-plugins-official`, then retry the install.
+ * The plugin is not found in the marketplace: check the plugin name. Claude Code [refreshes a stale marketplace catalog and retries](</docs/en/discover-plugins#install-plugins>) before reporting this, so if you turned off [marketplace auto-update](</docs/en/discover-plugins#configure-auto-updates>), refresh manually with `/plugin marketplace update claude-plugins-official` and retry the install.
+
+Check the install summary: if it reports `Run /reload-plugins to activate.`, run that command.
2
@@ -154,7 +159,7 @@
* managed settings
* settings passed with `--settings`
-Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. A Microsoft Foundry [deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>) starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API; after Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model earlier than the Claude 4.5 generation on Google Cloud’s Agent Platform, Claude uses the `WaitForMcpServers` tool instead. A Microsoft Foundry [deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>) starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API; after Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
###
@@ -1063,12 +1068,17 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Google Cloud’s Agent Platform. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Setting [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`](</docs/en/env-vars>) keeps tool search off, and `ENABLE_TOOL_SEARCH` can’t override it. The variable strips the beta header that `defer_loading` tool definitions and `tool_reference` content blocks require. Tool search requires a model that supports `tool_reference` blocks: Claude Sonnet 4.5, Claude Haiku 4.5, Claude Opus 4.5, and later models. See [model compatibility in the API docs](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool#model-compatibility>) for the current list. On Google Cloud’s Agent Platform, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override that fallback. Setting [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`](</docs/en/env-vars>) keeps tool search off, and `ENABLE_TOOL_SEARCH` can’t override it. The variable strips the beta header that `defer_loading` tool definitions and `tool_reference` content blocks require. Tool search requires a model that supports `tool_reference` blocks: Claude Sonnet 4.5, Claude Haiku 4.5, Claude Opus 4.5, and later models. See [model compatibility in the API docs](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool#model-compatibility>) for the current list. On Google Cloud’s Agent Platform, Claude Code decides by model generation:
+
+ * **Claude Opus 4.5, Sonnet 4.5, Haiku 4.5, and later** : tool search is on by default, the same as on the Anthropic API.
+ * **Earlier Agent Platform models** : Claude Code loads all MCP tools upfront, because their serving stacks reject the required beta header. `ENABLE_TOOL_SEARCH=true` doesn’t override this.
+
+Before v2.1.221, Claude Code disabled tool search for all models on Google Cloud’s Agent Platform unless you set `ENABLE_TOOL_SEARCH=true`. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
-(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Google Cloud’s Agent Platform, when `ANTHROPIC_BASE_URL` is a non-first-party host, or on a Microsoft Foundry deployment hosted on Azure
-`true`| All MCP tools deferred, except on a Microsoft Foundry deployment hosted on Azure, where the server-side rejection still forces upfront loading. Claude Code sends the beta header even on Google Cloud’s Agent Platform and through proxies. Requests fail on Google Cloud’s Agent Platform models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that don’t support `tool_reference` blocks
+(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Google Cloud’s Agent Platform models earlier than the Claude 4.5 generation, when `ANTHROPIC_BASE_URL` is a non-first-party host, or on a Microsoft Foundry deployment hosted on Azure
+`true`| All MCP tools deferred, except on a Microsoft Foundry deployment hosted on Azure, where the server-side rejection still forces upfront loading, and on Google Cloud’s Agent Platform models earlier than the Claude 4.5 generation, where Claude Code keeps loading tools upfront. Claude Code sends the beta header through proxies, and requests fail on proxies that don’t support `tool_reference` blocks
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
`auto:N`| Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%
`false`| All MCP tools loaded upfront, no deferral
--- a/mcp.md
+++ b/mcp.md
@@ -341,7 +341,7 @@
Project scope
-Project-scoped servers enable team collaboration by storing configurations in a `.mcp.json` file at your project’s root directory. This file is designed to be checked into version control, ensuring all team members have access to the same MCP tools and services. When you add a project-scoped server, Claude Code automatically creates or updates this file with the appropriate configuration structure.
+Project-scoped servers enable team collaboration by storing configurations in a `.mcp.json` file at your project’s root directory. When you add a project-scoped server, Claude Code automatically creates or updates this file with the appropriate configuration structure. Check `.mcp.json` into version control so everyone on your team gets the same MCP tools and services.
# Add a project-scoped server
claude mcp add --transport http shared-server --scope project https://example.com/mcp
Show diff (144 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -81,6 +81,8 @@
The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.
+Some services still expose only an SSE endpoint. Use the same command as the HTTP transport, with `--transport sse`:
+
# Basic syntax
claude mcp add --transport sse <name> <url>
@@ -138,21 +140,21 @@
claude mcp list
# Get details for a specific server
- claude mcp get github
+ claude mcp get notion
# Remove a server
- claude mcp remove github
+ claude mcp remove notion
# (within Claude Code) Check server status
/mcp
-Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` and `claude mcp get <name>` as `⏸ Pending approval (run `claude` to approve)`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows rejected servers as `✘ Rejected (see disabledMcpjsonServers in settings)`. As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
+`claude mcp add` confirms a successful add by printing an `Added ...` line, which means the configuration was written. `claude mcp list` then shows a health status next to each server it lists, such as `✔ Connected`, `! Needs authentication`, or `✘ Failed to connect`. A failure status means Claude Code couldn’t connect to that server, not that the list command failed. Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` and `claude mcp get <name>` as `⏸ Pending approval (run `claude` to approve)`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows rejected servers as `✘ Rejected (see disabledMcpjsonServers in settings)`. WebSocket servers don’t appear in `claude mcp list` output. Use `claude mcp get <name>` or the `/mcp` panel to check them. As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
* your user `~/.claude/settings.json`
* managed settings
* settings passed with `--settings`
-Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. A Microsoft Foundry [deployment hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>) starts on the tool-search path rather than with `WaitForMcpServers`, since Claude Code discovers the deployment’s server-side rejection only from the API; after Claude Code switches that deployment to upfront loading, tools from a server that finishes connecting become available on Claude’s next request. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
###
@@ -263,7 +265,7 @@
* **Automatic lifecycle** : servers connect and disconnect at these points:
* At session startup, Claude Code connects the servers for enabled plugins automatically
- * If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
+ * If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers. When you reload, Claude Code keeps the live connections of plugin servers whose configuration is unchanged, and does the same when you [replace the session’s MCP server list](</docs/en/agent-sdk/typescript#mcpsetserversresult>) from the Agent SDK without naming them. Before v2.1.210, Claude Code disconnected plugin-provided MCP servers that the new SDK server list didn’t name
* In [web sessions](</docs/en/claude-code-on-the-web>), an MCP call to a plugin server that isn’t connected yet, such as right after an idle session wakes, starts the server on demand and waits for it to connect. Before v2.1.211, plugin servers in a web session reconnected only when the next message started a turn, so MCP calls after an idle session woke failed until then
* **Path placeholders** : `${CLAUDE_PLUGIN_ROOT}` resolves to the plugin’s installation directory, `${CLAUDE_PLUGIN_DATA}` to its [persistent state](</docs/en/plugins-reference#persistent-data-directory>) directory, and `${CLAUDE_PROJECT_DIR}` to the stable project root. Substitution applies to:
* `stdio` servers: `command`, `args`, `env`
@@ -342,16 +344,15 @@
Project-scoped servers enable team collaboration by storing configurations in a `.mcp.json` file at your project’s root directory. This file is designed to be checked into version control, ensuring all team members have access to the same MCP tools and services. When you add a project-scoped server, Claude Code automatically creates or updates this file with the appropriate configuration structure.
# Add a project-scoped server
- claude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp
+ claude mcp add --transport http shared-server --scope project https://example.com/mcp
The resulting `.mcp.json` file follows a standardized format:
{
"mcpServers": {
"shared-server": {
- "command": "/path/to/server",
- "args": [],
- "env": {}
+ "type": "http",
+ "url": "https://example.com/mcp"
}
}
}
@@ -383,7 +384,7 @@
4. [Plugin-provided servers](</docs/en/plugins>)
5. claude.ai connectors
-The three scopes match duplicates by name. Plugins and connectors match by endpoint, so one that points at the same URL or command as a server above is treated as a duplicate.
+The three scopes match duplicates by name. Plugins and connectors match by endpoint, so one that points at the same URL or command as a server above is treated as a duplicate. If you open a local session in the [Desktop app’s Code tab](</docs/en/desktop#mcp-servers-from-the-claude-desktop-chat-app>) with the same stdio server name at the top level of `~/.claude.json` (user scope) and in `.mcp.json`, the Code tab uses the `~/.claude.json` definition.
###
@@ -432,13 +433,15 @@
Example: Monitor errors with Sentry
+Sentry’s remote MCP server gives Claude access to the errors your applications report to Sentry. It authenticates through OAuth rather than an API key, so you don’t pass a credential when you add it. If you already added the `sentry` server in the [MCP quickstart](</docs/en/mcp-quickstart>), skip this command: running `claude mcp add` again with the same server name at the same scope fails with `MCP server sentry already exists in local config`.
+
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
Authenticate with your Sentry account:
/mcp
-Then debug production issues:
+Follow the sign-in steps in your browser. Once you’re signed in, the `sentry` server shows `connected` in the `/mcp` menu. Then debug production issues:
What are the most common errors in the last 24 hours?
@@ -471,10 +474,12 @@
Example: Query your PostgreSQL database
+[DBHub](<https://github.com/bytebase/dbhub>), the `@bytebase/dbhub` package, is an MCP server that connects Claude to a relational database through the connection string you pass in `--dsn`. Use a read-only database user in the connection string so the queries Claude runs can’t modify data:
+
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
--dsn "postgresql://readonly:pass@prod.db.com:5432/analytics"
-Then query your database naturally:
+To confirm the server starts, run `/mcp` and check that `db` shows `connected`. Then query your database naturally:
What's our total revenue this month?
@@ -494,7 +499,7 @@
Add the server that requires authentication
-For example:
+If you already added this server in the Sentry example or the [MCP quickstart](</docs/en/mcp-quickstart>), skip this step: running `claude mcp add` again with the same server name at the same scope fails with `MCP server sentry already exists in local config`. Otherwise, run:
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
@@ -849,7 +854,7 @@
# Start Claude as a stdio MCP server
claude mcp serve
-You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:
+The command prints nothing when it starts. A stdio MCP server communicates over stdin and stdout, so a silent, blocked terminal means the server is running and waiting for a client to connect. You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:
{
"mcpServers": {
@@ -1028,6 +1033,8 @@
Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window. Claude Code doesn’t impose a fixed per-server tool cap; the practical limit is your context window budget.
+Tool search isn’t supported on Microsoft Foundry [deployments hosted on Azure](<https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options>), which reject it server-side: Claude Code detects the rejection and loads MCP tools upfront for that deployment instead. `ENABLE_TOOL_SEARCH` can’t override this, since the rejection comes from the deployment itself.
+
###
@@ -1060,8 +1067,8 @@
Value| Behavior
---|---
-(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Google Cloud’s Agent Platform or when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| All MCP tools deferred. Claude Code sends the beta header even on Google Cloud’s Agent Platform and through proxies. Requests fail on Google Cloud’s Agent Platform models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that don’t support `tool_reference` blocks
+(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Google Cloud’s Agent Platform, when `ANTHROPIC_BASE_URL` is a non-first-party host, or on a Microsoft Foundry deployment hosted on Azure
+`true`| All MCP tools deferred, except on a Microsoft Foundry deployment hosted on Azure, where the server-side rejection still forces upfront loading. Claude Code sends the beta header even on Google Cloud’s Agent Platform and through proxies. Requests fail on Google Cloud’s Agent Platform models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that don’t support `tool_reference` blocks
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
`auto:N`| Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%
`false`| All MCP tools loaded upfront, no deferral
--- a/mcp.md
+++ b/mcp.md
@@ -153,6 +153,19 @@
* settings passed with `--settings`
Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+
+###
+
+
+
+Disable a server without removing it
+
+Toggle a server off in the `/mcp` panel to stop Claude Code from connecting to it without losing its configuration. Claude Code still lists the server in `/mcp`, marked as disabled. When you toggle a server, Claude Code records your choice per project in `~/.claude.json`, in one of two lists that cover disjoint sets of servers:
+
+ * `disabledMcpServers`: an opt-out list for user-configured servers, plugin servers, claude.ai connectors, and built-in servers that default to on. Claude Code doesn’t connect to a server you list here. When you disable a claude.ai connector with the per-project `/mcp` toggle described in Disable claude.ai connectors, Claude Code writes it to this list under its display name, for example `claude.ai Slack`.
+ * `enabledMcpServers`: an opt-in list for built-in servers that default to off, such as `computer-use`. Claude Code connects to a default-off server only when you list it here.
+
+Claude Code consults exactly one of the two lists for each server, so neither list overrides the other. If you add a regular server to `enabledMcpServers`, or a default-off built-in server to `disabledMcpServers`, Claude Code ignores the entry. `disabledMcpServers` and `enabledMcpServers` are unrelated to [`enabledMcpjsonServers` and `disabledMcpjsonServers`](</docs/en/settings#available-settings>), which control approval of servers defined in a project’s `.mcp.json` file.
###
@@ -213,12 +226,12 @@
Plugin-provided MCP servers
-[Plugins](</docs/en/plugins>) can bundle MCP servers, automatically providing tools and integrations when the plugin is enabled. Plugin MCP servers work identically to user-configured servers. **How plugin MCP servers work** :
+[Plugins](</docs/en/plugins>) can bundle MCP servers that provide tools and integrations when you enable the plugin. Plugin MCP servers work identically to user-configured servers. **How plugin MCP servers work** :
* Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`
- * When a plugin is enabled, its MCP servers start automatically
- * Plugin MCP tools appear alongside manually configured MCP tools
- * Plugin servers are managed through plugin installation, not `/mcp` commands
+ * When you enable a plugin, Claude Code starts its MCP servers automatically
+ * Claude Code offers plugin MCP tools alongside manually configured MCP tools
+ * You add and remove plugin servers by installing or uninstalling the plugin, not with `/mcp` commands. You can still toggle an installed plugin server off in `/mcp`, which stops Claude Code from connecting to it without removing the plugin
**Example plugin MCP configuration** : In `.mcp.json` at plugin root:
@@ -249,7 +262,7 @@
**Plugin MCP features** :
* **Automatic lifecycle** : servers connect and disconnect at these points:
- * At session startup, servers for enabled plugins connect automatically
+ * At session startup, Claude Code connects the servers for enabled plugins automatically
* If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
* In [web sessions](</docs/en/claude-code-on-the-web>), an MCP call to a plugin server that isn’t connected yet, such as right after an idle session wakes, starts the server on demand and waits for it to connect. Before v2.1.211, plugin servers in a web session reconnected only when the next message started a turn, so MCP calls after an idle session woke failed until then
* **Path placeholders** : `${CLAUDE_PLUGIN_ROOT}` resolves to the plugin’s installation directory, `${CLAUDE_PLUGIN_DATA}` to its [persistent state](</docs/en/plugins-reference#persistent-data-directory>) directory, and `${CLAUDE_PROJECT_DIR}` to the stable project root. Substitution applies to:
--- a/mcp.md
+++ b/mcp.md
@@ -475,7 +475,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow. When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. As of v2.1.193, Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow. When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. The notice requires Claude Code v2.1.193 or later. It counts only servers you can sign in to from Claude Code. Before v2.1.218, it also counted claude.ai connectors that weren’t connected in claude.ai, which you can connect only from claude.ai settings. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
--- a/mcp.md
+++ b/mcp.md
@@ -160,7 +160,7 @@
Dynamic tool updates
-Claude Code supports MCP `list_changed` notifications, allowing MCP servers to dynamically update their available tools, prompts, and resources without requiring you to disconnect and reconnect. When an MCP server sends a `list_changed` notification, Claude Code automatically refreshes the available capabilities from that server.
+Claude Code supports MCP `list_changed` notifications, allowing MCP servers to dynamically update their available tools, prompts, and resources without requiring you to disconnect and reconnect. When an MCP server sends a `list_changed` notification, Claude Code automatically refreshes the available capabilities from that server. If a refresh request fails, Claude Code keeps the server’s previously discovered tools, prompts, and resources until a later refresh succeeds. Before v2.1.214, a transient error during the refresh replaced the server’s tools, prompts, and resources with an empty list.
###
@@ -937,7 +937,7 @@
Require approval for a specific tool
-If you’re building an MCP server, you can mark a tool as requiring explicit approval on every call by setting `_meta["anthropic/requiresUserInteraction"]` to `true` in the tool’s `tools/list` response entry. The value must be the JSON boolean `true`; any other value is ignored. Claude Code shows that tool’s permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and doesn’t offer a “don’t ask again” option for it. [Allow rules](</docs/en/permissions#permission-rule-syntax>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead. The prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>), an `allow` result from the prompt tool for a flagged tool is converted to a deny with the message `MCP tool requires user interaction; not supported via --permission-prompt-tool`. The Agent SDK’s [`canUseTool` callback](</docs/en/agent-sdk/permissions>) does receive these calls and can approve them, because the SDK host is expected to show them to a user. Use this for tools whose permission prompt is itself the point, such as a consent or access-grant step where auto-approval would mean no human ever agreed. Other tools from the same server keep their normal permission behavior. The following `tools/list` entry marks one tool as always requiring approval.
+If you’re building an MCP server, you can mark a tool as requiring explicit approval on every call by setting `_meta["anthropic/requiresUserInteraction"]` to `true` in the tool’s `tools/list` response entry. The value must be the JSON boolean `true`; any other value is ignored. Claude Code shows that tool’s permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and doesn’t offer a “don’t ask again” option for it. [Allow rules](</docs/en/permissions#permission-rule-syntax>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead. The prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>), an `allow` result from the prompt tool for a flagged tool is converted to a deny with the message `MCP tool requires user interaction; not supported via --permission-prompt-tool`. The Agent SDK’s [`canUseTool` callback](</docs/en/agent-sdk/permissions>) does receive these calls and can approve them, because your SDK application is expected to show them to a user. Use this for tools whose permission prompt is itself the point, such as a consent or access-grant step where auto-approval would mean no human ever agreed. Other tools from the same server keep their normal permission behavior. The following `tools/list` entry marks one tool as always requiring approval.
{
"name": "grant_access",
@@ -947,7 +947,7 @@
}
}
-The `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow. When a session is connected to [Remote Control](</docs/en/remote-control>) or an SDK host, Claude Code marks the permission request as requiring user interaction, so the client shows the tool’s permission prompt for you to answer instead of a one-tap approve action.
+The `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow. Some surfaces, such as [Remote Control](</docs/en/remote-control>) and applications built on the [Agent SDK](</docs/en/agent-sdk/overview>), normally let you approve tool calls with one tap. For a tool marked with this annotation, Claude Code withholds the one-tap action and shows the tool’s full permission prompt instead, so approval still comes from a person answering the prompt rather than a tap. Claude Code withholds one-tap approval the same way for any permission request that only the terminal dialog can render in full, such as one that carries a safety warning or an always-allow option the remote surface can’t show. You answer that request in the terminal dialog rather than from Remote Control. Requires Claude Code v2.1.214 or later.
##
--- a/mcp.md
+++ b/mcp.md
@@ -444,7 +444,7 @@
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
--header "Authorization: Bearer YOUR_GITHUB_PAT"
-Then work with GitHub:
+Replace `YOUR_GITHUB_PAT` with your personal access token. The `claude mcp add` command saves the configuration without validating credentials, so a placeholder value is accepted here but the server fails to connect later. To verify the connection, run `/mcp` and check that the server shows `connected`. A server with bad credentials shows `failed`. Then work with GitHub:
Review PR #456 and suggest improvements
--- a/mcp.md
+++ b/mcp.md
@@ -191,7 +191,21 @@
* Claude Code displays a warning when MCP tool output exceeds 10,000 tokens and limits output to 25,000 tokens by default. To raise the limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`); the warning threshold is fixed. See MCP output limits and warnings
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. For an HTTP, SSE, or [claude.ai connector](</docs/en/mcp#use-mcp-servers-from-claude-ai>) server there is also a second, per-request timer that covers each request through to the server’s first response byte. That timer is 60 seconds unless you set the per-server `timeout` or `MCP_TOOL_TIMEOUT`; setting either to 60 seconds or higher raises the per-request timer to that value, a lower value doesn’t shorten it, and the 28-hour default of an unset `MCP_TOOL_TIMEOUT` never feeds it. Stdio and WebSocket servers have no per-request timer. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. For an HTTP, SSE, or [claude.ai connector](</docs/en/mcp#use-mcp-servers-from-claude-ai>) server there is also a second, per-request timer that covers each request through to the server’s first response byte. That timer is 60 seconds unless you set the per-server `timeout` or `MCP_TOOL_TIMEOUT`; setting either to 60 seconds or higher raises the per-request timer to that value, a lower value doesn’t shorten it, and the 28-hour default of an unset `MCP_TOOL_TIMEOUT` never feeds it. Stdio and WebSocket servers have no per-request timer. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. These timeouts bound how long a call can run, not always how long it blocks the session: on Claude Code v2.1.212 or later, a main-conversation call that runs past two minutes moves to a background task first. See Automatic backgrounding of long tool calls.
+
+###
+
+
+
+Automatic backgrounding of long tool calls
+
+An MCP tool call in the main conversation that is still running after two minutes moves to a background task instead of blocking the session. Claude receives the task ID immediately and keeps working, and the result arrives as a task notification when the call settles. Automatic backgrounding requires Claude Code v2.1.212 or later. The task appears in [`/tasks`](</docs/en/commands#all-commands>), where you can also stop it, and it doesn’t survive exiting the session. The per-call limits still apply while the call runs in the background: the wall-clock limit set by the per-server `timeout` or [`MCP_TOOL_TIMEOUT`](</docs/en/env-vars>), and the idle timeout set by [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>). Set the [`CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS`](</docs/en/env-vars>) environment variable in milliseconds to change the threshold, or set it to `0` to turn automatic backgrounding off. Setting `CLAUDE_CODE_DISABLE_BACKGROUND_TASKS` to `1` also turns it off, along with all other background task features. Some calls never move to the background:
+
+ * Calls from [subagents](</docs/en/sub-agents>); Claude Code backgrounds only main-conversation calls
+ * Calls to IDE servers
+ * Calls in [non-interactive mode](</docs/en/headless>), unless `CLAUDE_AUTO_BACKGROUND_TASKS` is set to `1`, since a one-shot run can end before the result arrives
+
+A call waiting on an open elicitation dialog isn’t backgrounded while the dialog is open; the server is blocked on your input, not slow, so Claude Code defers the move until the dialog closes.
###
@@ -776,7 +790,7 @@
Servers from claude.ai appear in the list with indicators showing they come from claude.ai.
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your claude.ai subscription. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active, even if you previously ran `/login`. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is a claude.ai subscription login. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active, even if you previously ran `/login`. They also aren’t loaded when `CLAUDE_CODE_OAUTH_TOKEN` holds a token from [`claude setup-token`](</docs/en/authentication#generate-a-long-lived-token>), which can only make model requests. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
###
--- a/mcp.md
+++ b/mcp.md
@@ -35,7 +35,7 @@
/plugin install mcp-server-dev@claude-plugins-official
-If Claude Code reports that the marketplace is not found, run `/plugin marketplace add anthropics/claude-plugins-official` first, then retry the install. Once installed, run `/reload-plugins` to activate it in the current session.
+If Claude Code reports `Marketplace "claude-plugins-official" not found`, add the marketplace with `/plugin marketplace add anthropics/claude-plugins-official`. If it reports that the plugin is not found in the marketplace, your local copy is outdated: refresh it with `/plugin marketplace update claude-plugins-official`. Then retry the install. Once installed, run `/reload-plugins` to activate it in the current session.
2
@@ -97,7 +97,7 @@
Option 3: Add a local stdio server
-Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. `CLAUDE_PROJECT_DIR` is the stable project root and doesn’t change when you add or remove working directories mid-session. A server that limits its own filesystem access to a set of allowed directories should implement the MCP `roots/list` request instead. Claude Code answers `roots/list` with the session’s launch directory plus every [additional working directory](</docs/en/permissions#working-directories>) you’ve granted with `--add-dir`, `/add-dir`, or the `additionalDirectories` setting. Claude Code sends `notifications/roots/list_changed` when that set changes. Before v2.1.203, `roots/list` returned only the launch directory and Claude Code didn’t send `notifications/roots/list_changed`. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in a project- or user-scoped `.mcp.json` `command` or `args` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default.
+Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. `CLAUDE_PROJECT_DIR` is the stable project root and doesn’t change when you add or remove working directories mid-session. A server that limits its own filesystem access to a set of allowed directories should implement the MCP `roots/list` request instead. Claude Code answers `roots/list` with the session’s launch directory plus every [additional working directory](</docs/en/permissions#working-directories>) you’ve granted with `--add-dir`, `/add-dir`, or the `additionalDirectories` setting. Claude Code sends `notifications/roots/list_changed` when that set changes. Before v2.1.203, `roots/list` returned only the launch directory and Claude Code didn’t send `notifications/roots/list_changed`. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in the `command` or `args` of a project-scoped `.mcp.json` entry or a local- or user-scoped server entry in `~/.claude.json` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default.
# Basic syntax
claude mcp add [options] <name> -- <command> [args...]
@@ -146,7 +146,7 @@
# (within Claude Code) Check server status
/mcp
-Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` as `⏸ Pending approval`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows pending servers as `⏸ Pending approval` and rejected servers as `✗ Rejected`. As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
+Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` and `claude mcp get <name>` as `⏸ Pending approval (run `claude` to approve)`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows rejected servers as `✘ Rejected (see disabledMcpjsonServers in settings)`. As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
* your user `~/.claude/settings.json`
* managed settings
@@ -234,7 +234,10 @@
**Plugin MCP features** :
- * **Automatic lifecycle** : at session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
+ * **Automatic lifecycle** : servers connect and disconnect at these points:
+ * At session startup, servers for enabled plugins connect automatically
+ * If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
+ * In [web sessions](</docs/en/claude-code-on-the-web>), an MCP call to a plugin server that isn’t connected yet, such as right after an idle session wakes, starts the server on demand and waits for it to connect. Before v2.1.211, plugin servers in a web session reconnected only when the next message started a turn, so MCP calls after an idle session woke failed until then
* **Path placeholders** : `${CLAUDE_PLUGIN_ROOT}` resolves to the plugin’s installation directory, `${CLAUDE_PLUGIN_DATA}` to its [persistent state](</docs/en/plugins-reference#persistent-data-directory>) directory, and `${CLAUDE_PROJECT_DIR}` to the stable project root. Substitution applies to:
* `stdio` servers: `command`, `args`, `env`
* `http`, `sse`, and `ws` servers: `url`, `headers`, and `headersHelper`. Before v2.1.195, `headersHelper` passed the placeholder through as a literal string
@@ -388,7 +391,7 @@
}
}
-If a referenced environment variable isn’t set and has no default value, Claude Code leaves the literal `${VAR}` text in the value and reports a missing-variable warning for that server. The config still loads, so set the variable or add a `:-default` fallback so the server starts with the value you intend.
+If a referenced environment variable isn’t set and has no default value, the config still loads: Claude Code reports a missing-variable warning for that server in `claude mcp list` output and uses the unexpanded `${VAR}` text as-is. Set the variable or add a `:-default` fallback so the server starts with the value you intend.
##
--- a/mcp.md
+++ b/mcp.md
@@ -168,7 +168,7 @@
Automatic reconnection
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. When a configured server fails to connect, Claude Code tells Claude which server failed and its connection error, including in `ToolSearch` results that find no matching tool, so Claude reports the connection failure in its response. Requires tool search, which is enabled by default. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a Haiku model, and on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code doesn’t report failed server connections to Claude. Before v2.1.205, Claude Code didn’t pass connection errors to Claude, and Claude could respond as if the failed server’s tools were never configured. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. When a configured server fails to connect, Claude Code tells Claude which server failed and its connection error, including in `ToolSearch` results that find no matching tool, so Claude reports the connection failure in its response. Requires tool search, which is enabled by default. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a model that doesn’t support tool search, and on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code doesn’t report failed server connections to Claude. Before v2.1.205, Claude Code didn’t pass connection errors to Claude, and Claude could respond as if the failed server’s tools were never configured. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
###
@@ -188,7 +188,7 @@
* The `--transport` and `--header` flags also accept `-t` and `-H` short forms
* Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
* Set a per-server tool execution timeout by adding a `timeout` field in milliseconds to that server’s `.mcp.json` entry, for example `"timeout": 600000` for ten minutes. This overrides the `MCP_TOOL_TIMEOUT` environment variable for that server only
- * Claude Code displays a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
+ * Claude Code displays a warning when MCP tool output exceeds 10,000 tokens and limits output to 25,000 tokens by default. To raise the limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`); the warning threshold is fixed. See MCP output limits and warnings
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. For an HTTP, SSE, or [claude.ai connector](</docs/en/mcp#use-mcp-servers-from-claude-ai>) server there is also a second, per-request timer that covers each request through to the server’s first response byte. That timer is 60 seconds unless you set the per-server `timeout` or `MCP_TOOL_TIMEOUT`; setting either to 60 seconds or higher raises the per-request timer to that value, a lower value doesn’t shorten it, and the 28-hour default of an unset `MCP_TOOL_TIMEOUT` never feeds it. Stdio and WebSocket servers have no per-request timer. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.
@@ -749,7 +749,7 @@
Use MCP servers from claude.ai
-If you’ve logged into Claude Code with a [claude.ai](<https://claude.ai>) account, MCP servers you’ve added in claude.ai are automatically available in Claude Code:
+If you’ve logged into Claude Code with a [claude.ai](<https://claude.ai>) account, MCP servers you’ve added in claude.ai, known as [connectors](<https://claude.com/docs/connectors>), are automatically available in Claude Code:
1
@@ -774,6 +774,19 @@
Servers from claude.ai appear in the list with indicators showing they come from claude.ai.
From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your claude.ai subscription. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active, even if you previously ran `/login`. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
+
+###
+
+
+
+Organization controls on connector tools
+
+Your organization can set per-tool controls on [claude.ai connectors](<https://claude.com/docs/connectors>). Claude Code reads these settings at startup and enforces them locally. Run `/mcp` to see which setting applies to each tool on a connector.
+
+ * **Tool set to`ask`**: Claude Code prompts on every call with the reason `Your organization requires approval for this tool`. The prompt appears even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and never offers an option to remember your choice. [Allow rules](</docs/en/permissions>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead.
+ * **Tool set to`blocked`**: Claude Code filters the tool out before Claude sees it, so it never appears in the tool list.
+
+Enforcing these controls requires Claude Code v2.1.129 or later. Earlier versions ignore the settings and apply the standard permission flow.
###
@@ -1013,7 +1026,7 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Google Cloud’s Agent Platform. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks. Haiku models don’t support it. On Google Cloud’s Agent Platform, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Google Cloud’s Agent Platform. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Setting [`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`](</docs/en/env-vars>) keeps tool search off, and `ENABLE_TOOL_SEARCH` can’t override it. The variable strips the beta header that `defer_loading` tool definitions and `tool_reference` content blocks require. Tool search requires a model that supports `tool_reference` blocks: Claude Sonnet 4.5, Claude Haiku 4.5, Claude Opus 4.5, and later models. See [model compatibility in the API docs](<https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool#model-compatibility>) for the current list. On Google Cloud’s Agent Platform, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
--- a/mcp.md
+++ b/mcp.md
@@ -152,7 +152,7 @@
* managed settings
* settings passed with `--settings`
-Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. A remote server whose configuration has an empty `url` shows as `not configured` in `/mcp`, in `claude mcp list`, and in the [`/plugin`](</docs/en/plugins>) manager, and Claude Code doesn’t attempt to connect to it. A plugin can include a placeholder entry like this for a connector you configure later, so Claude Code doesn’t report it as an error or a setup issue. The server’s detail view in `/mcp` reads `No URL configured for this server`; set the entry’s `url` to connect it. Before v2.1.208, Claude Code reported an empty `url` as a configuration issue with a prompt to reconnect. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
###
@@ -235,7 +235,9 @@
**Plugin MCP features** :
* **Automatic lifecycle** : at session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
- * **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root
+ * **Path placeholders** : `${CLAUDE_PLUGIN_ROOT}` resolves to the plugin’s installation directory, `${CLAUDE_PLUGIN_DATA}` to its [persistent state](</docs/en/plugins-reference#persistent-data-directory>) directory, and `${CLAUDE_PROJECT_DIR}` to the stable project root. Substitution applies to:
+ * `stdio` servers: `command`, `args`, `env`
+ * `http`, `sse`, and `ws` servers: `url`, `headers`, and `headersHelper`. Before v2.1.195, `headersHelper` passed the placeholder through as a literal string
* **User environment access** : access to the same environment variables as manually configured servers
* **Multiple transport types** : support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server
@@ -653,7 +655,7 @@
**Requirements:**
* The command must write a JSON object of string key-value pairs to stdout
- * The command runs in a shell with a 10-second timeout
+ * The command runs in a shell with a 10-second timeout, from the session’s current working directory. Use an absolute path or a command on `PATH` for the script
* Dynamic headers override any static `headers` with the same name
The helper runs fresh on each connection, at session start and on reconnect. There is no caching, so your script is responsible for any token reuse. As of v2.1.193, if a tool call returns `401 Unauthorized` or `403 Forbidden`, Claude Code automatically re-runs the helper, reconnects with the fresh headers, and retries the call once. Claude Code marks the server as needing authentication in `/mcp` only if that retry also fails. Claude Code sets these environment variables when executing the helper:
--- a/mcp.md
+++ b/mcp.md
@@ -151,9 +151,8 @@
* your user `~/.claude/settings.json`
* managed settings
* settings passed with `--settings`
- * `.claude/settings.local.json`, as long as git doesn’t track it
-
-A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
+
+Approvals in an untracked `.claude/settings.local.json` also apply, but only after you accept a trust dialog for that folder or one of its parent directories: Claude Code runs git to check whether the file is tracked, and it runs that check only in a trusted folder. In a folder you’ve never trusted, the file’s approvals wait for the trust dialog unless the folder is your own configuration home: your home directory, or a directory whose `.claude` you’ve set as [`CLAUDE_CONFIG_DIR`](</docs/en/env-vars>). Before v2.1.207, an untracked `.claude/settings.local.json` approved servers in a folder you’d never trusted. A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
###
@@ -192,7 +191,7 @@
* Claude Code displays a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. For an HTTP, SSE, or [claude.ai connector](</docs/en/mcp#use-mcp-servers-from-claude-ai>) server there is also a second, per-request timer that covers each request through to the server’s first response byte. That timer is 60 seconds unless you set the per-server `timeout` or `MCP_TOOL_TIMEOUT`; setting either to 60 seconds or higher raises the per-request timer to that value, a lower value doesn’t shorten it, and the 28-hour default of an unset `MCP_TOOL_TIMEOUT` never feeds it. Stdio and WebSocket servers have no per-request timer. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.
###
@@ -387,7 +386,7 @@
}
}
-If a required environment variable isn’t set and has no default value, Claude Code fails to parse the config.
+If a referenced environment variable isn’t set and has no default value, Claude Code leaves the literal `${VAR}` text in the value and reports a missing-variable warning for that server. The config still loads, so set the variable or add a `:-default` fallback so the server starts with the value you intend.
##
@@ -457,7 +456,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. As of v2.1.193, Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. For a server you haven’t signed in to, either status code flags it in `/mcp` so you can complete the OAuth flow. When a request to an OAuth server you already signed in to returns `401 Unauthorized`, Claude Code refreshes the stored token, reconnects, and retries the request once. It flags the server in `/mcp` only if that retry also fails. Before v2.1.206, a token refresh that failed for a transient reason, such as a network error, flagged an OAuth server as needing authentication for the rest of the session even though its refresh token was still valid. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. As of v2.1.193, Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
@@ -597,7 +596,7 @@
}
}
-The URL must use `https://`. `authServerMetadataUrl` requires Claude Code v2.1.64 or later. The metadata URL’s `scopes_supported` overrides the scopes the upstream server advertises.
+The URL must use `https://`. The metadata URL’s `scopes_supported` overrides the scopes the upstream server advertises.
###
@@ -665,7 +664,7 @@
`CLAUDE_CODE_MCP_SERVER_URL`| the URL of the MCP server
`CLAUDE_PLUGIN_ROOT`| the plugin’s root directory. Set only when a [plugin](</docs/en/plugins-reference#mcp-servers>) provides the server
-Use these to write a single helper script that serves multiple MCP servers. For a plugin-provided server, the helper also runs with its working directory set to the plugin root, so a relative `headersHelper` path resolves inside the plugin directory rather than against the session’s working directory. Requires Claude Code v2.1.195 or later.
+Use these to write a single helper script that serves multiple MCP servers. For a plugin-provided server, the helper also runs with its working directory set to the plugin root, so a relative `headersHelper` path resolves inside the plugin directory rather than against the session’s working directory. Requires Claude Code v2.1.195 or later. A plugin-provided `headersHelper` can’t reference the plugin’s [`${user_config.*}`](</docs/en/plugins-reference#user-configuration>) values, because the command runs through a shell. Claude Code reports the server as misconfigured with an [error](</docs/en/errors#plugin-command-references-user-config>) and doesn’t substitute the value. Put `${user_config.KEY}` in the server’s `headers` field instead, which isn’t shell-parsed, or have the helper script read the value from its own environment or a config file. Before v2.1.207, `headersHelper` substituted `${user_config.*}` values.
`headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.
--- a/mcp.md
+++ b/mcp.md
@@ -153,7 +153,7 @@
* settings passed with `--settings`
* `.claude/settings.local.json`, as long as git doesn’t track it
-A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
+A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. Some server names are reserved for Claude Code’s built-in servers: `workspace`, `claude-in-chrome`, `computer-use`, `Claude Preview`, and `Claude Browser`. If your configuration defines a server with a reserved name, Claude Code skips it at load time and shows a warning asking you to rename it. `claude mcp add` rejects a reserved name with an error. `Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app’s preview pane](</docs/en/desktop#preview-your-app>) uses. Before v2.1.205, `Claude Browser` wasn’t reserved, so a user-configured server could register under that name.
###
@@ -169,7 +169,7 @@
Automatic reconnection
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. When a configured server fails to connect, Claude Code tells Claude which server failed and its connection error, including in `ToolSearch` results that find no matching tool, so Claude reports the connection failure in its response. Requires tool search, which is enabled by default. In configurations without tool search, such as a custom `ANTHROPIC_BASE_URL`, `ENABLE_TOOL_SEARCH=false`, or a Haiku model, and on Amazon Bedrock, Google Cloud’s Agent Platform, and Microsoft Foundry, Claude Code doesn’t report failed server connections to Claude. Before v2.1.205, Claude Code didn’t pass connection errors to Claude, and Claude could respond as if the failed server’s tools were never configured. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
###
@@ -732,12 +732,14 @@
claude mcp list
+Server names added through `claude mcp` commands can contain only letters, numbers, hyphens, and underscores. Claude Desktop doesn’t apply that restriction, so a Claude Desktop server whose name contains any other character, such as a space, can’t be imported. The import reports each name it rejects and still imports the other servers you selected. Before v2.1.205, the first invalid name stopped the import and none of the selected servers were added.
+
Tips:
* This feature only works on macOS and Windows Subsystem for Linux (WSL)
* It reads the Claude Desktop configuration file from its standard location on those platforms
* Use the `--scope user` flag to add servers to your user configuration
- * Imported servers keep the same names as in Claude Desktop
+ * Imported servers keep the same names as in Claude Desktop when the name contains only letters, numbers, hyphens, and underscores. Claude Code reports a server whose name contains any other character and skips it
* If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)
##
--- a/mcp.md
+++ b/mcp.md
@@ -97,7 +97,7 @@
Option 3: Add a local stdio server
-Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. Your server can also call the MCP `roots/list` request, which returns the directory Claude Code was launched from. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in a project- or user-scoped `.mcp.json` `command` or `args` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default.
+Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. `CLAUDE_PROJECT_DIR` is the stable project root and doesn’t change when you add or remove working directories mid-session. A server that limits its own filesystem access to a set of allowed directories should implement the MCP `roots/list` request instead. Claude Code answers `roots/list` with the session’s launch directory plus every [additional working directory](</docs/en/permissions#working-directories>) you’ve granted with `--add-dir`, `/add-dir`, or the `additionalDirectories` setting. Claude Code sends `notifications/roots/list_changed` when that set changes. Before v2.1.203, `roots/list` returned only the launch directory and Claude Code didn’t send `notifications/roots/list_changed`. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in a project- or user-scoped `.mcp.json` `command` or `args` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default.
# Basic syntax
claude mcp add [options] <name> -- <command> [args...]
@@ -192,7 +192,7 @@
* Claude Code displays a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. As of v2.1.187, a tool call to a remote HTTP, SSE, WebSocket, or claude.ai connector server that sends no response and no progress notification for 5 minutes aborts with an error instead of waiting for the wall-clock limit. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. Stdio servers are local processes and are not subject to the idle timeout.
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. A per-server `timeout` of at least 1000 also acts as a floor on the idle timeout described below: Claude Code never aborts that server’s tool calls for idleness sooner than the per-server `timeout`. Requires Claude Code v2.1.203 or later. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. A tool call to an MCP server that sends no response and no progress notification for the idle window aborts with an error instead of waiting for the wall-clock limit. The idle timeout requires Claude Code v2.1.187 or later. It applies to every server type except IDE servers and SDK in-process servers. The idle window defaults to five minutes for HTTP, SSE, WebSocket, and claude.ai connector servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.
###
--- a/mcp.md
+++ b/mcp.md
@@ -181,11 +181,12 @@
Tips:
- * Use the `--scope` flag to specify where the configuration is stored:
+ * Use the `-s` or `--scope` flag to specify where the configuration is stored:
* `local` (default): available only to you in the current project. Older versions called this scope `project`
* `project`: shared with everyone in the project via the `.mcp.json` file
* `user`: available to you across all projects. Older versions called this scope `global`
- * Set environment variables with `--env` flags (for example, `--env KEY=value`)
+ * Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)
+ * The `--transport` and `--header` flags also accept `-t` and `-H` short forms
* Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
* Set a per-server tool execution timeout by adding a `timeout` field in milliseconds to that server’s `.mcp.json` entry, for example `"timeout": 600000` for ten minutes. This overrides the `MCP_TOOL_TIMEOUT` environment variable for that server only
* Claude Code displays a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
@@ -248,7 +249,7 @@
mcp__plugin_my-plugin_database-tools__query
-Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, or a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>). **Benefits of plugin MCP servers** :
+Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>), or a [hook matcher](</docs/en/hooks#match-mcp-tools>). A hook matcher written against the bare server key, such as `mcp__database-tools__.*`, never fires for a plugin-bundled server. The server itself registers under the scoped name `plugin:<plugin-name>:<server-name>`, such as `plugin:my-plugin:database-tools`. Use that name where a configured server name is expected, such as an [`mcp_tool` hook’s `server` field](</docs/en/hooks#mcp-tool-hook-fields>). **Benefits of plugin MCP servers** :
* **Bundled distribution** : tools and servers packaged together
* **Automatic setup** : no manual MCP configuration needed
--- a/mcp.md
+++ b/mcp.md
@@ -71,7 +71,7 @@
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
-When configuring MCP servers via JSON in `.mcp.json`, `~/.claude.json`, or `claude mcp add-json`, the `type` field accepts `streamable-http` as an alias for `http`. The MCP specification uses the name `streamable-http` for this transport, so configurations copied from server documentation work without modification.
+When configuring MCP servers via JSON in `.mcp.json`, `~/.claude.json`, or `claude mcp add-json`, the `type` field accepts `streamable-http` as an alias for `http`. The MCP specification uses the name `streamable-http` for this transport, so configurations copied from server documentation work without modification. A JSON entry that has a `url` but no `type` is a configuration error, because Claude Code reads an entry with no `type` as a stdio server. Claude Code skips that server and reports `MCP server "<name>" has a "url" but no "type"; add "type": "http" (or "sse" / "ws") to this entry`. Before v2.1.202, Claude Code reported this misconfiguration as `command: expected string, received undefined`.
###
--- a/mcp.md
+++ b/mcp.md
@@ -153,7 +153,7 @@
* settings passed with `--settings`
* `.claude/settings.local.json`, as long as git doesn’t track it
-A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Vertex AI, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
+A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Google Cloud’s Agent Platform, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
###
@@ -769,7 +769,7 @@
Servers from claude.ai appear in the list with indicators showing they come from claude.ai.
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your claude.ai subscription. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your claude.ai subscription. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Amazon Bedrock or Google Cloud’s Agent Platform is active, even if you previously ran `/login`. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
###
@@ -1009,12 +1009,12 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Vertex AI. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks. Haiku models don’t support it. On Vertex AI, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Google Cloud’s Agent Platform. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks. Haiku models don’t support it. On Google Cloud’s Agent Platform, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
-(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Vertex AI or when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail on Vertex AI models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that don’t support `tool_reference` blocks
+(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Google Cloud’s Agent Platform or when `ANTHROPIC_BASE_URL` is a non-first-party host
+`true`| All MCP tools deferred. Claude Code sends the beta header even on Google Cloud’s Agent Platform and through proxies. Requests fail on Google Cloud’s Agent Platform models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that don’t support `tool_reference` blocks
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
`auto:N`| Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%
`false`| All MCP tools loaded upfront, no deferral
--- a/mcp.md
+++ b/mcp.md
@@ -888,6 +888,37 @@
+Tool input schemas with a root-level combinator
+
+Some MCP servers declare a tool’s input schema as a JSON Schema union, with `anyOf`, `oneOf`, or `allOf` at the top level of the schema. The Claude API doesn’t accept those keywords at the schema root. It does accept combinators nested inside `properties`, which Claude Code sends unchanged. As of Claude Code v2.1.195, tools with a root-level combinator stay available. Before sending the tool to the API, Claude Code flattens the schema into a single object and prepends a sentence to the tool’s description that tells Claude which parameter groups belong together:
+
+ * `allOf`: properties from every branch are merged, and each branch’s `required` list still applies
+ * `anyOf` and `oneOf`: properties from every branch are merged, and each branch’s `required` list is described in the tool description instead of enforced by the schema
+
+Your server receives whichever arguments Claude chose, so keep validating the combination server-side. When Claude Code can’t produce a schema the API accepts, or on a deployment that doesn’t receive the remote configuration that enables the rewrite, such as an offline machine, it skips that one tool, records the reason in the server’s log, and leaves the server’s other tools available. Versions earlier than v2.1.195 skip every tool whose input schema has a root-level `anyOf`, `oneOf`, or `allOf`.
+
+##
+
+
+
+Require approval for a specific tool
+
+If you’re building an MCP server, you can mark a tool as requiring explicit approval on every call by setting `_meta["anthropic/requiresUserInteraction"]` to `true` in the tool’s `tools/list` response entry. The value must be the JSON boolean `true`; any other value is ignored. Claude Code shows that tool’s permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](</docs/en/permissions#permission-modes>), and doesn’t offer a “don’t ask again” option for it. [Allow rules](</docs/en/permissions#permission-rule-syntax>) that match the tool don’t skip the prompt either. In `dontAsk` mode, which never prompts, Claude Code denies the call instead. The prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](</docs/en/cli-reference#cli-flags>), an `allow` result from the prompt tool for a flagged tool is converted to a deny with the message `MCP tool requires user interaction; not supported via --permission-prompt-tool`. The Agent SDK’s [`canUseTool` callback](</docs/en/agent-sdk/permissions>) does receive these calls and can approve them, because the SDK host is expected to show them to a user. Use this for tools whose permission prompt is itself the point, such as a consent or access-grant step where auto-approval would mean no human ever agreed. Other tools from the same server keep their normal permission behavior. The following `tools/list` entry marks one tool as always requiring approval.
+
+ {
+ "name": "grant_access",
+ "description": "Requests access to a protected resource",
+ "_meta": {
+ "anthropic/requiresUserInteraction": true
+ }
+ }
+
+The `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow. When a session is connected to [Remote Control](</docs/en/remote-control>) or an SDK host, Claude Code marks the permission request as requiring user interaction, so the client shows the tool’s permission prompt for you to answer instead of a one-tap approve action.
+
+##
+
+
+
Respond to MCP elicitation requests
MCP servers can request structured input from you mid-task using elicitation. When a server needs information it can’t get on its own, Claude Code displays an interactive dialog and passes your response back to the server. No configuration is required on your side: elicitation dialogs appear automatically when a server requests them. Servers can request input in two ways:
--- a/mcp.md
+++ b/mcp.md
@@ -146,7 +146,14 @@
# (within Claude Code) Check server status
/mcp
-Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` as `⏸ Pending approval`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows pending servers as `⏸ Pending approval` and rejected servers as `✗ Rejected`. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Vertex AI, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
+Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` as `⏸ Pending approval`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows pending servers as `⏸ Pending approval` and rejected servers as `✗ Rejected`. As of v2.1.196, `claude mcp list` and `claude mcp get` read `.mcp.json` approvals only from settings files that aren’t checked into the repository until you trust the workspace by running `claude` in it and accepting the workspace trust dialog. A cloned repository can’t approve its own servers: [`enableAllProjectMcpServers` or `enabledMcpjsonServers`](</docs/en/settings#available-settings>) committed to the project’s `.claude/settings.json` is ignored in an untrusted folder, and the server stays at `⏸ Pending approval` instead of being connected and health-checked. Approvals from these sources still apply in an untrusted folder:
+
+ * your user `~/.claude/settings.json`
+ * managed settings
+ * settings passed with `--settings`
+ * `.claude/settings.local.json`, as long as git doesn’t track it
+
+A `disabledMcpjsonServers` entry in any settings file still rejects the server. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Vertex AI, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
###
@@ -449,7 +456,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. As of v2.1.195, when a token refresh fails because the server rejects the stored refresh token, Claude Code immediately shows a notice pointing at `/mcp`. The connected server’s menu there offers Re-authenticate, so you can sign in again before the next tool call fails. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. As of v2.1.193, Claude Code also shows a startup notice when one or more configured servers need authentication, so you don’t have to open `/mcp` to discover which servers need sign-in. In non-interactive mode there’s no `/mcp` panel, so Claude Code can’t run the OAuth flow for you. As of v2.1.196, when a configured server needs authentication during a `claude -p` or Agent SDK run with tool search enabled, which is the default, Claude Code tells Claude that the server’s tools are unavailable until you authorize it. Claude can then name the server that needs sign-in instead of responding as if the server weren’t configured. Complete the sign-in from an interactive session with `/mcp` or `claude mcp login <name>`. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
@@ -611,7 +618,7 @@
}
}
-`oauth.scopes` takes precedence over both `authServerMetadataUrl` and the scopes the server discovers at `/.well-known`. Leave it unset to let the MCP server determine the requested scope set. If the authorization server advertises `offline_access` in `scopes_supported`, Claude Code appends it to the pinned scopes so the access token can be refreshed without a new browser sign-in. If the server later returns a 403 `insufficient_scope` for a tool call, Claude Code re-authenticates with the same pinned scopes. Widen `oauth.scopes` when a tool you need requires a scope outside the pinned set.
+`oauth.scopes` takes precedence over both `authServerMetadataUrl` and the scopes the server discovers at `/.well-known`. Leave it unset to let the MCP server determine the requested scope set. As of v2.1.196, when `oauth.scopes` isn’t set, Claude Code requests the scope provided by the server’s `WWW-Authenticate` header or its protected resource metadata, and sends no `scope` parameter when neither provides one. It no longer requests the full `scopes_supported` catalog from automatically discovered authorization server metadata. Requesting that catalog made identity providers that advertise admin-only or template scopes reject the authorization request with an `invalid_scope` error. Metadata fetched from a configured `authServerMetadataUrl` still supplies its `scopes_supported` as the requested scopes. If the authorization server advertises `offline_access` in `scopes_supported`, Claude Code appends it to the pinned scopes so the access token can be refreshed without a new browser sign-in. If the server later returns a 403 `insufficient_scope` for a tool call, Claude Code re-authenticates with the same pinned scopes. Widen `oauth.scopes` when a tool you need requires a scope outside the pinned set.
###
@@ -649,14 +656,15 @@
* The command runs in a shell with a 10-second timeout
* Dynamic headers override any static `headers` with the same name
-The helper runs fresh on each connection, at session start and on reconnect. There is no caching, so your script is responsible for any token reuse. Claude Code sets these environment variables when executing the helper:
+The helper runs fresh on each connection, at session start and on reconnect. There is no caching, so your script is responsible for any token reuse. As of v2.1.193, if a tool call returns `401 Unauthorized` or `403 Forbidden`, Claude Code automatically re-runs the helper, reconnects with the fresh headers, and retries the call once. Claude Code marks the server as needing authentication in `/mcp` only if that retry also fails. Claude Code sets these environment variables when executing the helper:
Variable| Value
---|---
`CLAUDE_CODE_MCP_SERVER_NAME`| the name of the MCP server
`CLAUDE_CODE_MCP_SERVER_URL`| the URL of the MCP server
-
-Use these to write a single helper script that serves multiple MCP servers.
+`CLAUDE_PLUGIN_ROOT`| the plugin’s root directory. Set only when a [plugin](</docs/en/plugins-reference#mcp-servers>) provides the server
+
+Use these to write a single helper script that serves multiple MCP servers. For a plugin-provided server, the helper also runs with its working directory set to the plugin root, so a relative `headersHelper` path resolves inside the plugin directory rather than against the session’s working directory. Requires Claude Code v2.1.195 or later.
`headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.
Show diff (305 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -13,7 +13,7 @@
* **Query databases** : “Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.”
* **Integrate designs** : “Update our standard email template based on the new Figma designs that were posted in Slack”
* **Automate workflows** : “Create Gmail drafts inviting these 10 users to a feedback session about the new feature.”
- * **React to external events** : An MCP server can also act as a [channel](</docs/en/channels>) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you’re away.
+ * **React to external events** : an MCP server can also act as a [channel](</docs/en/channels>) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you’re away.
##
@@ -124,7 +124,7 @@
claude mcp add-json events-server \
'{"type":"ws","url":"wss://mcp.example.com/socket","headers":{"Authorization":"Bearer YOUR_TOKEN"}}'
-The `type: "ws"` entry accepts the same `url`, `headers`, `headersHelper`, `timeout`, and `alwaysLoad` fields as `http`. Authentication is header-only, so pass a static token in `headers` or generate one at connect time with `headersHelper`. The `claude mcp add --transport` flag does not accept `ws`.
+The `type: "ws"` entry accepts the same `url`, `headers`, `headersHelper`, `timeout`, and `alwaysLoad` fields as `http`. Authentication is header-only, so pass a static token in `headers` or generate one at connect time with `headersHelper`. The `claude mcp add --transport` flag doesn’t accept `ws`.
###
@@ -162,7 +162,7 @@
Automatic reconnection
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still cannot connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still can’t connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
###
@@ -175,16 +175,16 @@
Tips:
* Use the `--scope` flag to specify where the configuration is stored:
- * `local` (default): Available only to you in the current project (was called `project` in older versions)
- * `project`: Shared with everyone in the project via `.mcp.json` file
- * `user`: Available to you across all projects (was called `global` in older versions)
+ * `local` (default): available only to you in the current project. Older versions called this scope `project`
+ * `project`: shared with everyone in the project via the `.mcp.json` file
+ * `user`: available to you across all projects. Older versions called this scope `global`
* Set environment variables with `--env` flags (for example, `--env KEY=value`)
- * Configure MCP server startup timeout using the MCP_TIMEOUT environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
+ * Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
* Set a per-server tool execution timeout by adding a `timeout` field in milliseconds to that server’s `.mcp.json` entry, for example `"timeout": 600000` for ten minutes. This overrides the `MCP_TOOL_TIMEOUT` environment variable for that server only
- * Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
+ * Claude Code displays a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. As of v2.1.187, a tool call to a remote HTTP, SSE, WebSocket, or claude.ai connector server that sends no response and no progress notification for 5 minutes aborts with an error instead of waiting for the wall-clock limit. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. Stdio servers are local processes and are not subject to the idle timeout.
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server don’t extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. As of v2.1.187, a tool call to a remote HTTP, SSE, WebSocket, or claude.ai connector server that sends no response and no progress notification for 5 minutes aborts with an error instead of waiting for the wall-clock limit. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. Stdio servers are local processes and are not subject to the idle timeout.
###
@@ -197,7 +197,7 @@
* Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`
* When a plugin is enabled, its MCP servers start automatically
* Plugin MCP tools appear alongside manually configured MCP tools
- * Plugin servers are managed through plugin installation (not `/mcp` commands)
+ * Plugin servers are managed through plugin installation, not `/mcp` commands
**Example plugin MCP configuration** : In `.mcp.json` at plugin root:
@@ -227,10 +227,10 @@
**Plugin MCP features** :
- * **Automatic lifecycle** : At session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
+ * **Automatic lifecycle** : at session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
* **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root
- * **User environment access** : Access to same environment variables as manually configured servers
- * **Multiple transport types** : Support stdio, SSE, HTTP, and WebSocket transports (transport support may vary by server)
+ * **User environment access** : access to the same environment variables as manually configured servers
+ * **Multiple transport types** : support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server
**Viewing plugin MCP servers** :
@@ -243,9 +243,9 @@
Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, or a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>). **Benefits of plugin MCP servers** :
- * **Bundled distribution** : Tools and servers packaged together
- * **Automatic setup** : No manual MCP configuration needed
- * **Team consistency** : Everyone gets the same tools when plugin is installed
+ * **Bundled distribution** : tools and servers packaged together
+ * **Automatic setup** : no manual MCP configuration needed
+ * **Team consistency** : everyone gets the same tools when the plugin is installed
See the [plugin components reference](</docs/en/plugins-reference#mcp-servers>) for details on bundling MCP servers with plugins.
@@ -354,16 +354,16 @@
Claude Code supports environment variable expansion in `.mcp.json` files, allowing teams to share configurations while maintaining flexibility for machine-specific paths and sensitive values like API keys. **Supported syntax:**
- * `${VAR}` \- Expands to the value of environment variable `VAR`
- * `${VAR:-default}` \- Expands to `VAR` if set, otherwise uses `default`
+ * `${VAR}`: expands to the value of environment variable `VAR`
+ * `${VAR:-default}`: expands to `VAR` if set, otherwise uses `default`
**Expansion locations:** Environment variables can be expanded in:
- * `command` \- The server executable path
- * `args` \- Command-line arguments
- * `env` \- Environment variables passed to the server
- * `url` \- For HTTP server types
- * `headers` \- For HTTP server authentication
+ * `command`: the server executable path
+ * `args`: command-line arguments
+ * `env`: environment variables passed to the server
+ * `url`: for HTTP server types
+ * `headers`: for HTTP server authentication
**Example with variable expansion:**
@@ -379,7 +379,7 @@
}
}
-If a required environment variable is not set and has no default value, Claude Code will fail to parse the config.
+If a required environment variable isn’t set and has no default value, Claude Code fails to parse the config.
##
@@ -463,11 +463,11 @@
Use the /mcp command within Claude Code
-In Claude code, use the command:
+In Claude Code, use the command:
/mcp
-Then follow the steps in your browser to login.
+Then follow the steps in your browser to log in.
Tips:
@@ -522,7 +522,7 @@
Add the server with your credentials
-Choose one of the following methods. The port used for `--callback-port` can be any available port. It just needs to match the redirect URI you registered in the previous step.
+Choose one of the following methods. The port used for `--callback-port` can be any available port. It needs to match the redirect URI you registered in the previous step.
* claude mcp add
@@ -611,7 +611,7 @@
}
}
-`oauth.scopes` takes precedence over both `authServerMetadataUrl` and the scopes the server discovers at `/.well-known`. Leave it unset to let the MCP server determine the requested scope set. If the authorization server advertises `offline_access` in `scopes_supported`, Claude Code appends it to the pinned scopes so the access token can be refreshed without a new browser sign-in. If the server later returns a 403 `insufficient_scope` for a tool call, Claude Code re-authenticates with the same pinned scopes. Widen `oauth.scopes` when a tool you need requires a scope outside the pin.
+`oauth.scopes` takes precedence over both `authServerMetadataUrl` and the scopes the server discovers at `/.well-known`. Leave it unset to let the MCP server determine the requested scope set. If the authorization server advertises `offline_access` in `scopes_supported`, Claude Code appends it to the pinned scopes so the access token can be refreshed without a new browser sign-in. If the server later returns a 403 `insufficient_scope` for a tool call, Claude Code re-authenticates with the same pinned scopes. Widen `oauth.scopes` when a tool you need requires a scope outside the pinned set.
###
@@ -619,7 +619,7 @@
Use dynamic headers for custom authentication
-If your MCP server uses an authentication scheme other than OAuth (such as Kerberos, short-lived tokens, or an internal SSO), use `headersHelper` to generate request headers at connection time. Claude Code runs the command and merges its output into the connection headers.
+If your MCP server uses an authentication scheme other than OAuth, such as Kerberos, short-lived tokens, or an internal SSO, use `headersHelper` to generate request headers at connection time. Claude Code runs the command and merges its output into the connection headers.
{
"mcpServers": {
@@ -649,7 +649,7 @@
* The command runs in a shell with a 10-second timeout
* Dynamic headers override any static `headers` with the same name
-The helper runs fresh on each connection (at session start and on reconnect). There is no caching, so your script is responsible for any token reuse. Claude Code sets these environment variables when executing the helper:
+The helper runs fresh on each connection, at session start and on reconnect. There is no caching, so your script is responsible for any token reuse. Claude Code sets these environment variables when executing the helper:
Variable| Value
---|---
@@ -728,20 +728,20 @@
* This feature only works on macOS and Windows Subsystem for Linux (WSL)
* It reads the Claude Desktop configuration file from its standard location on those platforms
* Use the `--scope user` flag to add servers to your user configuration
- * Imported servers will have the same names as in Claude Desktop
- * If servers with the same names already exist, they will get a numerical suffix (for example, `server_1`)
-
-##
-
-
-
-Use MCP servers from Claude.ai
-
-If you’ve logged into Claude Code with a [Claude.ai](<https://claude.ai>) account, MCP servers you’ve added in Claude.ai are automatically available in Claude Code:
+ * Imported servers keep the same names as in Claude Desktop
+ * If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)
+
+##
+
+
+
+Use MCP servers from claude.ai
+
+If you’ve logged into Claude Code with a [claude.ai](<https://claude.ai>) account, MCP servers you’ve added in claude.ai are automatically available in Claude Code:
1
-Configure MCP servers in Claude.ai
+Configure MCP servers in claude.ai
Add servers at [claude.ai/customize/connectors](<https://claude.ai/customize/connectors>). On Team and Enterprise plans, only admins can add servers.
@@ -749,7 +749,7 @@
Authenticate the MCP server
-Complete any required authentication steps in Claude.ai.
+Complete any required authentication steps in claude.ai.
3
@@ -759,9 +759,9 @@
/mcp
-Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
-
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, do not support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
+Servers from claude.ai appear in the list with indicators showing they come from claude.ai.
+
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Connectors from claude.ai are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your claude.ai subscription. They aren’t loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` doesn’t list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, don’t support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
###
@@ -775,13 +775,13 @@
"disableClaudeAiConnectors": true
}
-This setting uses any-source-true semantics: `true` in any settings source takes precedence. A checked-in project `.claude/settings.json` can opt a repository out of cloud connectors, but a project-level `false` cannot re-enable connectors that a user- or policy-level `true` has disabled. Servers passed explicitly via `--mcp-config` are unaffected. You can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:
+This setting uses any-source-true semantics: `true` in any settings source takes precedence. A checked-in project `.claude/settings.json` can opt a repository out of cloud connectors, but a project-level `false` can’t re-enable connectors that a user- or policy-level `true` has disabled. Servers passed explicitly via `--mcp-config` are unaffected. You can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
To block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](</docs/en/managed-mcp>) by name or by URL pattern. For example, a `serverName` entry of `"claude.ai Slack"` blocks the Slack connector. To toggle a connector on or off for the current project only, use the `/mcp` panel.
-These client-side settings govern local Claude Code sessions. In [Claude Code on the web](</docs/en/claude-code-on-the-web>) sessions, claude.ai connectors are provisioned by the remote host and arrive as explicit `--mcp-config` entries, so `disableClaudeAiConnectors` does not apply there. Connector URLs are also rewritten through the session proxy, so a `deniedMcpServers` `serverUrl` pattern targeting the vendor URL will not match. Manage which connectors a cloud session can use from your claude.ai organization settings.
+These client-side settings govern local Claude Code sessions. In [Claude Code on the web](</docs/en/claude-code-on-the-web>) sessions, claude.ai connectors are provisioned by the remote host and arrive as explicit `--mcp-config` entries, so `disableClaudeAiConnectors` doesn’t apply there. Connector URLs are also rewritten through the session proxy, so a `deniedMcpServers` `serverUrl` pattern targeting the vendor URL won’t match. Manage which connectors a cloud session can use from your claude.ai organization settings.
##
@@ -807,7 +807,7 @@
}
}
-**Configuring the executable path** : The `command` field must reference the Claude Code executable. If the `claude` command is not in your system’s PATH, you’ll need to specify the full path to the executable.To find the full path:
+**Configuring the executable path** : the `command` field must reference the Claude Code executable. If the `claude` command is not in your system’s PATH, you’ll need to specify the full path to the executable.To find the full path:
which claude
@@ -830,7 +830,7 @@
* The server provides access to Claude’s tools like View, Edit, LS, etc.
* In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.
- * Note that this MCP server is only exposing Claude Code’s tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
+ * This MCP server only exposes Claude Code’s tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
##
@@ -938,9 +938,9 @@
-Scale with MCP Tool Search
-
-Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window. Claude Code does not impose a fixed per-server tool cap; the practical limit is your context window budget.
+Scale with MCP tool search
+
+Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window. Claude Code doesn’t impose a fixed per-server tool cap; the practical limit is your context window budget.
###
@@ -956,7 +956,7 @@
For MCP server authors
-If you’re building an MCP server, the server instructions field becomes more useful with Tool Search enabled. Server instructions help Claude understand when to search for your tools, similar to how [skills](</docs/en/skills>) work. Add clear, descriptive server instructions that explain:
+If you’re building an MCP server, the server instructions field becomes more useful with tool search enabled. Server instructions help Claude understand when to search for your tools, similar to how [skills](</docs/en/skills>) work. Add clear, descriptive server instructions that explain:
* What category of tasks your tools handle
* When Claude should search for your tools
@@ -970,12 +970,12 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Vertex AI. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks. Haiku models do not support it. On Vertex AI, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Vertex AI. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies don’t forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks. Haiku models don’t support it. On Vertex AI, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Vertex AI or when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail on Vertex AI models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that do not support `tool_reference` blocks
+`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail on Vertex AI models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that don’t support `tool_reference` blocks
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
`auto:N`| Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%
`false`| All MCP tools loaded upfront, no deferral
@@ -1055,7 +1055,7 @@
* MCP prompts are dynamically discovered from connected servers
* Arguments are parsed based on the prompt’s defined parameters
* Prompt results are injected directly into the conversation
- * Server and prompt names are normalized (spaces become underscores)
+ * Server and prompt names are normalized, with spaces converted to underscores
##
--- a/mcp.md
+++ b/mcp.md
@@ -162,7 +162,7 @@
Automatic reconnection
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still cannot connect. Authentication and not-found errors are not retried because they require a configuration change to resolve.
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still cannot connect. Authentication and not-found errors are not retried because they require a configuration change to resolve. As of v2.1.191, the capability discovery requests that run after a successful connection, such as `tools/list`, `prompts/list`, and `resources/list`, also retry transient network and server errors up to three times with short backoff. Authentication errors, 4xx responses, and request timeouts are not retried.
###
@@ -184,7 +184,7 @@
* Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum.
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum. As of v2.1.187, a tool call to a remote HTTP, SSE, WebSocket, or claude.ai connector server that sends no response and no progress notification for 5 minutes aborts with an error instead of waiting for the wall-clock limit. Set the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](</docs/en/env-vars>) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check. Stdio servers are local processes and are not subject to the idle timeout.
###
@@ -487,7 +487,7 @@
claude mcp login sentry
-To clear stored credentials later, run `claude mcp logout <name>`. When you’re connected over SSH, add `--no-browser` so the command prints the authorization URL instead of opening a browser. Open the URL on your local machine, then paste the full redirect URL from your browser’s address bar back at the prompt. The command needs an interactive terminal for the paste step, so connect with `ssh -t`.
+To clear stored credentials later, run `claude mcp logout <name>`. As of v2.1.191, the command detects when no local browser is available, such as during an SSH session or on Linux without a display server, and prints the authorization URL instead of trying to open a browser. Open the URL on your local machine, then paste the full redirect URL from your browser’s address bar back at the prompt. The command needs an interactive terminal for the paste step, so connect with `ssh -t`. Pass `--no-browser` to force the URL prompt even when a local browser is detected.
claude mcp login sentry --no-browser
--- a/mcp.md
+++ b/mcp.md
@@ -481,6 +481,20 @@
+Authenticate from the command line
+
+From v2.1.186, `claude mcp login <name>` runs a configured server’s OAuth flow directly from your shell, so you don’t need to open the `/mcp` panel inside a session.
+
+ claude mcp login sentry
+
+To clear stored credentials later, run `claude mcp logout <name>`. When you’re connected over SSH, add `--no-browser` so the command prints the authorization URL instead of opening a browser. Open the URL on your local machine, then paste the full redirect URL from your browser’s address bar back at the prompt. The command needs an interactive terminal for the paste step, so connect with `ssh -t`.
+
+ claude mcp login sentry --no-browser
+
+###
+
+
+
Use a fixed OAuth callback port
Some MCP servers require a specific redirect URI registered in advance. By default, Claude Code picks a random available port for the OAuth callback. Use `--callback-port` to fix the port so it matches a pre-registered redirect URI of the form `http://localhost:PORT/callback`. You can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).
--- a/mcp.md
+++ b/mcp.md
@@ -747,9 +747,27 @@
Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, do not support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, do not support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically.
+
+###
+
+
+
+Disable claude.ai connectors
+
+To disable claude.ai MCP servers in Claude Code, set [`disableClaudeAiConnectors`](</docs/en/settings#available-settings>) to `true` in any settings scope:
+
+ {
+ "disableClaudeAiConnectors": true
+ }
+
+This setting uses any-source-true semantics: `true` in any settings source takes precedence. A checked-in project `.claude/settings.json` can opt a repository out of cloud connectors, but a project-level `false` cannot re-enable connectors that a user- or policy-level `true` has disabled. Servers passed explicitly via `--mcp-config` are unaffected. You can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
+
+To block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](</docs/en/managed-mcp>) by name or by URL pattern. For example, a `serverName` entry of `"claude.ai Slack"` blocks the Slack connector. To toggle a connector on or off for the current project only, use the `/mcp` panel.
+
+These client-side settings govern local Claude Code sessions. In [Claude Code on the web](</docs/en/claude-code-on-the-web>) sessions, claude.ai connectors are provisioned by the remote host and arrive as explicit `--mcp-config` entries, so `disableClaudeAiConnectors` does not apply there. Connector URLs are also rewritten through the session proxy, so a `deniedMcpServers` `serverUrl` pattern targeting the vendor URL will not match. Manage which connectors a cloud session can use from your claude.ai organization settings.
##
--- a/mcp.md
+++ b/mcp.md
@@ -237,7 +237,11 @@
# Within Claude Code, see all MCP servers including plugin ones
/mcp
-Plugin servers appear in the list with indicators showing they come from plugins. **Benefits of plugin MCP servers** :
+Plugin servers appear in the list with indicators showing they come from plugins. **Plugin MCP tool names** : Tools from a plugin-bundled MCP server include both the plugin name and the server key in their callable name. The full form is `mcp__plugin_<plugin-name>_<server-name>__<tool-name>`, where any character outside `A-Z`, `a-z`, `0-9`, `_`, and `-` is replaced with `_`. For the `database-tools` server bundled in a plugin named `my-plugin`, a `query` tool is callable as:
+
+ mcp__plugin_my-plugin_database-tools__query
+
+Use this full name when referencing the tool in [permission rules](</docs/en/permissions>), a skill’s `allowed-tools` list, or a [subagent’s `tools` field](</docs/en/sub-agents#available-tools>). **Benefits of plugin MCP servers** :
* **Bundled distribution** : Tools and servers packaged together
* **Automatic setup** : No manual MCP configuration needed
--- a/mcp.md
+++ b/mcp.md
@@ -904,7 +904,7 @@
Scale with MCP Tool Search
-Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window.
+Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window. Claude Code does not impose a fixed per-server tool cap; the practical limit is your context window budget.
###
@@ -934,7 +934,7 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Vertex AI. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support it. On Vertex AI, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Vertex AI. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks. Haiku models do not support it. On Vertex AI, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
--- a/mcp.md
+++ b/mcp.md
@@ -103,15 +103,15 @@
claude mcp add [options] <name> -- <command> [args...]
# Real example: Add Airtable server
- claude mcp add --transport stdio --env AIRTABLE_API_KEY=YOUR_KEY airtable \
+ claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \
-- npx -y airtable-mcp-server
-**Important: Option ordering** All options (`--transport`, `--env`, `--scope`, `--header`) must come **before** the server name. The `--` (double dash) then separates the server name from the command and arguments that get passed to the MCP server.For example:
+**Important: Separate server arguments with`--`**For stdio servers, the `--` (double dash) separates Claude’s own options, such as `--transport`, `--env`, and `--scope`, from the command and arguments that run the server. Everything after `--` is passed to the server untouched.For example:
* `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`
- * `claude mcp add --transport stdio --env KEY=value myserver -- python server.py --port 8080` → runs `python server.py --port 8080` with `KEY=value` in environment
-
-This prevents conflicts between Claude’s flags and the server’s flags.
+ * `claude mcp add --env KEY=value --transport stdio myserver -- python server.py --port 8080` → runs `python server.py --port 8080` with `KEY=value` in environment
+
+Without `--`, Claude Code would try to parse the server’s flags, like `--port` above, as its own options.`--env` accepts multiple `KEY=value` pairs. If the server name comes directly after `--env`, the CLI reads the name as another pair and rejects it, so place at least one other option between `--env` and the server name, as in the examples above.
###
@@ -184,7 +184,7 @@
* Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are floored to one second. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum regardless of this value, so only the tool-call watchdog honors smaller values.
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are ignored and fall through to `MCP_TOOL_TIMEOUT`, or to its default of about 28 hours when that variable is unset. Before v2.1.162, values below 1000 were floored to one second instead. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum.
###
@@ -743,7 +743,7 @@
Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
-From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. Some Anthropic-hosted connectors, such as Microsoft 365, Gmail, and Google Calendar, do not support local OAuth from Claude Code because the upstream identity provider only accepts the redirect URL that claude.ai registered. From v2.1.162, authenticating one of these hosts in `/mcp` shows a message directing you to connect it at Settings → Connectors on claude.ai instead. Once connected there, the connector appears in Claude Code automatically. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
--- a/mcp.md
+++ b/mcp.md
@@ -1,9 +1,3 @@
-> ## Documentation Index
->
-> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt>
->
-> Use this file to discover all available pages before exploring further.
-
Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs. Connect a server when you find yourself copying data into chat from another tool, like an issue tracker or a monitoring dashboard. Once connected, Claude can read and act on that system directly instead of working from what you paste. If you’re connecting your first server, start with the [MCP quickstart](</docs/en/mcp-quickstart>) for a step-by-step walkthrough. This page is the full reference.
##
@@ -749,7 +743,7 @@
Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
-Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
+From v2.1.161, connectors you have never signed in to are collapsed behind a `Show unused connectors` row at the end of the claude.ai section, so an organization-provisioned list doesn’t fill the panel. Select the row to expand them. A connector you signed in to before stays visible even when it currently needs re-authentication. Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
--- a/mcp.md
+++ b/mcp.md
@@ -4,7 +4,7 @@
>
> Use this file to discover all available pages before exploring further.
-Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs. Connect a server when you find yourself copying data into chat from another tool, like an issue tracker or a monitoring dashboard. Once connected, Claude can read and act on that system directly instead of working from what you paste.
+Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs. Connect a server when you find yourself copying data into chat from another tool, like an issue tracker or a monitoring dashboard. Once connected, Claude can read and act on that system directly instead of working from what you paste. If you’re connecting your first server, start with the [MCP quickstart](</docs/en/mcp-quickstart>) for a step-by-step walkthrough. This page is the full reference.
##
@@ -910,7 +910,7 @@
Scale with MCP Tool Search
-Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names load at session start, so adding more MCP servers has minimal impact on your context window.
+Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names and server instructions load at session start, so adding more MCP servers has minimal impact on your context window.
###
--- a/mcp.md
+++ b/mcp.md
@@ -57,7 +57,7 @@
Installing MCP servers
-MCP servers can be configured in three different ways depending on your needs:
+MCP servers can be configured in several ways depending on your needs:
###
@@ -118,6 +118,19 @@
* `claude mcp add --transport stdio --env KEY=value myserver -- python server.py --port 8080` → runs `python server.py --port 8080` with `KEY=value` in environment
This prevents conflicts between Claude’s flags and the server’s flags.
+
+###
+
+
+
+Option 4: Add a remote WebSocket server
+
+WebSocket servers hold a persistent bidirectional connection, which suits remote MCP servers that push events to Claude unprompted. Use HTTP instead when your server only responds to requests, since HTTP supports OAuth and the `claude mcp add --transport` flag, while WebSocket supports neither. Configure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:
+
+ claude mcp add-json events-server \
+ '{"type":"ws","url":"wss://mcp.example.com/socket","headers":{"Authorization":"Bearer YOUR_TOKEN"}}'
+
+The `type: "ws"` entry accepts the same `url`, `headers`, `headersHelper`, `timeout`, and `alwaysLoad` fields as `http`. Authentication is header-only, so pass a static token in `headers` or generate one at connect time with `headersHelper`. The `claude mcp add --transport` flag does not accept `ws`.
###
@@ -223,7 +236,7 @@
* **Automatic lifecycle** : At session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
* **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root
* **User environment access** : Access to same environment variables as manually configured servers
- * **Multiple transport types** : Support stdio, SSE, and HTTP transports (transport support may vary by server)
+ * **Multiple transport types** : Support stdio, SSE, HTTP, and WebSocket transports (transport support may vary by server)
**Viewing plugin MCP servers** :
@@ -438,7 +451,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server. If you configured `headers.Authorization` for the server and the server rejects that header, Claude Code reports the connection as failed instead of falling back to OAuth. Check that the token is valid for the MCP endpoint, or remove the header to use the OAuth flow.
1
--- a/mcp.md
+++ b/mcp.md
@@ -139,7 +139,7 @@
# (within Claude Code) Check server status
/mcp
-The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Vertex AI, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
+Project-scoped servers from `.mcp.json` that are awaiting your approval appear in `claude mcp list` as `⏸ Pending approval`. Run `claude` interactively to review and approve them. `claude mcp get <name>` shows pending servers as `⏸ Pending approval` and rejected servers as `✗ Rejected`. The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Vertex AI, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
###
--- a/mcp.md
+++ b/mcp.md
@@ -41,7 +41,7 @@
/plugin install mcp-server-dev@claude-plugins-official
-Then run `/reload-plugins` to activate it in the current session.
+If Claude Code reports that the marketplace is not found, run `/plugin marketplace add anthropics/claude-plugins-official` first, then retry the install. Once installed, run `/reload-plugins` to activate it in the current session.
2
@@ -325,7 +325,7 @@
Scope hierarchy and precedence
-When the same server is defined in more than one place, Claude Code connects to it once, using the definition from the highest-precedence source:
+When the same server is defined in more than one place, Claude Code connects to it once, using the definition from the highest-precedence source. The entire server entry from that source is used; fields are not merged across scopes.
1. Local scope
2. Project scope
Show diff (258 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -173,8 +173,11 @@
* `user`: Available to you across all projects (was called `global` in older versions)
* Set environment variables with `--env` flags (for example, `--env KEY=value`)
* Configure MCP server startup timeout using the MCP_TIMEOUT environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
+ * Set a per-server tool execution timeout by adding a `timeout` field in milliseconds to that server’s `.mcp.json` entry, for example `"timeout": 600000` for ten minutes. This overrides the `MCP_TOOL_TIMEOUT` environment variable for that server only
* Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
+
+The per-server `timeout` is a hard wall-clock limit per tool call, and progress notifications from the server do not extend it. Values below 1000 are floored to one second. For HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum regardless of this value, so only the tool-call watchdog honors smaller values.
###
@@ -1017,242 +1020,4 @@
Managed MCP configuration
-For organizations that need centralized control over MCP servers, Claude Code supports two configuration options:
-
- 1. **Exclusive control with`managed-mcp.json`**: Deploy a fixed set of MCP servers that users cannot modify or extend
- 2. **Policy-based control with allowlists/denylists** : Allow users to add their own servers, but restrict which ones are permitted
-
-These options allow IT administrators to:
-
- * **Control which MCP servers employees can access** : Deploy a standardized set of approved MCP servers across the organization
- * **Prevent unauthorized MCP servers** : Restrict users from adding unapproved MCP servers
- * **Disable MCP entirely** : Remove MCP functionality completely if needed
-
-###
-
-
-
-Option 1: Exclusive control with managed-mcp.json
-
-When you deploy a `managed-mcp.json` file, it takes **exclusive control** over all MCP servers. Users cannot add, modify, or use any MCP servers other than those defined in this file. This is the simplest approach for organizations that want complete control. System administrators deploy the configuration file to a system-wide directory:
-
- * 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`
-
-These are system-wide paths (not user home directories like `~/Library/...`) that require administrator privileges. They are designed to be deployed by IT administrators.
-
-The `managed-mcp.json` file uses the same format as a standard `.mcp.json` file:
-
- {
- "mcpServers": {
- "github": {
- "type": "http",
- "url": "https://api.githubcopilot.com/mcp/"
- },
- "sentry": {
- "type": "http",
- "url": "https://mcp.sentry.dev/mcp"
- },
- "company-internal": {
- "type": "stdio",
- "command": "/usr/local/bin/company-mcp-server",
- "args": ["--config", "/etc/company/mcp-config.json"],
- "env": {
- "COMPANY_API_URL": "https://internal.company.com"
- }
- }
- }
- }
-
-###
-
-
-
-Option 2: Policy-based control with allowlists and denylists
-
-Instead of taking exclusive control, administrators can allow users to configure their own MCP servers while enforcing restrictions on which servers are permitted. This approach uses `allowedMcpServers` and `deniedMcpServers` in the [managed settings file](</docs/en/settings#settings-files>).
-
-**Choosing between options** : Use Option 1 (`managed-mcp.json`) when you want to deploy a fixed set of servers with no user customization. Use Option 2 (allowlists/denylists) when you want to allow users to add their own servers within policy constraints.
-
-####
-
-
-
-Restriction options
-
-Each entry in the allowlist or denylist can restrict servers in three ways:
-
- 1. **By server name** (`serverName`): Matches the configured name of the server
- 2. **By command** (`serverCommand`): Matches the exact command and arguments used to start stdio servers
- 3. **By URL pattern** (`serverUrl`): Matches remote server URLs with wildcard support
-
-**Important** : Each entry must have exactly one of `serverName`, `serverCommand`, or `serverUrl`.
-
-####
-
-
-
-Example configuration
-
- {
- "allowedMcpServers": [
- // Allow by server name
- { "serverName": "github" },
- { "serverName": "sentry" },
-
- // Allow by exact command (for stdio servers)
- { "serverCommand": ["npx", "-y", "@modelcontextprotocol/server-filesystem"] },
- { "serverCommand": ["python", "/usr/local/bin/approved-server.py"] },
-
- // Allow by URL pattern (for remote servers)
- { "serverUrl": "https://mcp.company.com/*" },
- { "serverUrl": "https://*.internal.corp/*" }
- ],
- "deniedMcpServers": [
- // Block by server name
- { "serverName": "dangerous-server" },
-
- // Block by exact command (for stdio servers)
- { "serverCommand": ["npx", "-y", "unapproved-package"] },
-
- // Block by URL pattern (for remote servers)
- { "serverUrl": "https://*.untrusted.com/*" }
- ]
- }
-
-####
-
-
-
-How command-based restrictions work
-
-**Exact matching** :
-
- * Command arrays must match **exactly** \- both the command and all arguments in the correct order
- * Example: `["npx", "-y", "server"]` will NOT match `["npx", "server"]` or `["npx", "-y", "server", "--flag"]`
-
-**Stdio server behavior** :
-
- * When the allowlist contains **any** `serverCommand` entries, stdio servers **must** match one of those commands
- * Stdio servers cannot pass by name alone when command restrictions are present
- * This ensures administrators can enforce which commands are allowed to run
-
-**Non-stdio server behavior** :
-
- * Remote servers (HTTP, SSE, WebSocket) use URL-based matching when `serverUrl` entries exist in the allowlist
- * If no URL entries exist, remote servers fall back to name-based matching
- * Command restrictions do not apply to remote servers
-
-####
-
-
-
-How URL-based restrictions work
-
-URL patterns support wildcards using `*` to match any sequence of characters. This is useful for allowing entire domains or subdomains. **Wildcard examples** :
-
- * `https://mcp.company.com/*` \- Allow all paths on a specific domain
- * `https://*.example.com/*` \- Allow any subdomain of example.com
- * `http://localhost:*/*` \- Allow any port on localhost
-
-Hostname matching is case-insensitive and ignores a trailing FQDN dot, matching DNS semantics. A pattern like `*://Mcp.Example.com/*` matches `https://mcp.example.com/api`, and `https://mcp.example.com.` is treated the same as `https://mcp.example.com`. Paths remain case-sensitive. **Remote server behavior** :
-
- * When the allowlist contains **any** `serverUrl` entries, remote servers **must** match one of those URL patterns
- * Remote servers cannot pass by name alone when URL restrictions are present
- * This ensures administrators can enforce which remote endpoints are allowed
-
-Example: URL-only allowlist
-
- {
- "allowedMcpServers": [
- { "serverUrl": "https://mcp.company.com/*" },
- { "serverUrl": "https://*.internal.corp/*" }
- ]
- }
-
-**Result** :
-
- * HTTP server at `https://mcp.company.com/api`: ✅ Allowed (matches URL pattern)
- * HTTP server at `https://api.internal.corp/mcp`: ✅ Allowed (matches wildcard subdomain)
- * HTTP server at `https://external.com/mcp`: ❌ Blocked (doesn’t match any URL pattern)
- * Stdio server with any command: ❌ Blocked (no name or command entries to match)
-
-Example: Command-only allowlist
-
- {
- "allowedMcpServers": [
- { "serverCommand": ["npx", "-y", "approved-package"] }
- ]
- }
-
-**Result** :
-
- * Stdio server with `["npx", "-y", "approved-package"]`: ✅ Allowed (matches command)
- * Stdio server with `["node", "server.js"]`: ❌ Blocked (doesn’t match command)
- * HTTP server named “my-api”: ❌ Blocked (no name entries to match)
-
-Example: Mixed name and command allowlist
-
- {
- "allowedMcpServers": [
- { "serverName": "github" },
- { "serverCommand": ["npx", "-y", "approved-package"] }
- ]
- }
-
-**Result** :
-
- * Stdio server named “local-tool” with `["npx", "-y", "approved-package"]`: ✅ Allowed (matches command)
- * Stdio server named “local-tool” with `["node", "server.js"]`: ❌ Blocked (command entries exist but doesn’t match)
- * Stdio server named “github” with `["node", "server.js"]`: ❌ Blocked (stdio servers must match commands when command entries exist)
- * HTTP server named “github”: ✅ Allowed (matches name)
- * HTTP server named “other-api”: ❌ Blocked (name doesn’t match)
-
-Example: Name-only allowlist
-
- {
- "allowedMcpServers": [
- { "serverName": "github" },
- { "serverName": "internal-tool" }
- ]
- }
-
-**Result** :
-
- * Stdio server named “github” with any command: ✅ Allowed (no command restrictions)
- * Stdio server named “internal-tool” with any command: ✅ Allowed (no command restrictions)
- * HTTP server named “github”: ✅ Allowed (matches name)
- * Any server named “other”: ❌ Blocked (name doesn’t match)
-
-####
-
-
-
-Allowlist behavior (`allowedMcpServers`)
-
- * `undefined` (default): No restrictions - users can configure any MCP server
- * Empty array `[]`: Complete lockdown - users cannot configure any MCP servers
- * List of entries: Users can only configure servers that match by name, command, or URL pattern
-
-####
-
-
-
-Denylist behavior (`deniedMcpServers`)
-
- * `undefined` (default): No servers are blocked
- * Empty array `[]`: No servers are blocked
- * List of entries: Specified servers are explicitly blocked across all scopes
-
-####
-
-
-
-Important notes
-
- * **Option 1 and Option 2 can be combined** : If `managed-mcp.json` exists, it has exclusive control and users cannot add servers. Allowlists/denylists still apply to the managed servers themselves.
- * **Denylist takes absolute precedence** : If a server matches a denylist entry (by name, command, or URL), it will be blocked even if it’s on the allowlist
- * Name-based, command-based, and URL-based restrictions work together: a server passes if it matches **either** a name entry, a command entry, or a URL pattern (unless blocked by denylist)
-
-**When using`managed-mcp.json`**: Users cannot add MCP servers through `claude mcp add` or configuration files. The `allowedMcpServers` and `deniedMcpServers` settings still apply to filter which managed servers are actually loaded.
+For organizations that need centralized control over which MCP servers users can connect to, see [Managed MCP configuration](</docs/en/managed-mcp>). It covers deploying a fixed server set with `managed-mcp.json`, restricting servers with `allowedMcpServers` and `deniedMcpServers`, and what users see when a server is blocked.
--- a/mcp.md
+++ b/mcp.md
@@ -733,7 +733,7 @@
Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
-A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
+Claude.ai connectors are fetched only when your active [authentication method](</docs/en/authentication#authentication-precedence>) is your Claude.ai subscription. They are not loaded when `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `apiKeyHelper`, or a third-party provider such as Bedrock or Vertex is active, even if you previously ran `/login`. If `/mcp` does not list a connector you added, run `/status` to confirm which authentication method is active, unset that environment variable or remove the `apiKeyHelper` setting, then run `/login` to select your Claude.ai account. A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
--- a/mcp.md
+++ b/mcp.md
@@ -139,7 +139,7 @@
# (within Claude Code) Check server status
/mcp
-The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
+The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. If your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With tool search enabled, which is the default, the wait happens inside the `ToolSearch` call. In configurations without tool search, such as Vertex AI, a custom `ANTHROPIC_BASE_URL`, or `ENABLE_TOOL_SEARCH=false`, Claude uses the `WaitForMcpServers` tool instead. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
###
@@ -966,7 +966,7 @@
}
}
-The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also blocks startup until the server connects, capped at the standard 5-second connect timeout. This applies even when [`MCP_CONNECTION_NONBLOCKING=1`](</docs/en/env-vars>) is set, since the tools must be present when the first prompt is built. Other servers still connect in the background when nonblocking is enabled.
+The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also blocks startup until the server connects, capped at the standard 5-second connect timeout. This applies even though MCP startup is otherwise [non-blocking by default](</docs/en/env-vars>), since the tools must be present when the first prompt is built. Other servers continue to connect in the background.
##
--- a/mcp.md
+++ b/mcp.md
@@ -924,14 +924,14 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. If your proxy forwards `tool_reference` blocks, set `ENABLE_TOOL_SEARCH` explicitly to override the fallback. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. Claude Code disables it by default on Vertex AI. It is also disabled when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to override either fallback. Tool search requires a model that supports `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support it. On Vertex AI, tool search is supported for Claude Sonnet 4.5 and later and Claude Opus 4.5 and later. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Vertex AI or when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail if the backend does not support `tool_reference` blocks
+`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail on Vertex AI models earlier than Sonnet 4.5 or Opus 4.5, or on proxies that do not support `tool_reference` blocks
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
-`auto:<N>`| Threshold mode with a custom percentage, where `<N>` is 0-100 (e.g., `auto:5` for 5%)
+`auto:N`| Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%
`false`| All MCP tools loaded upfront, no deferral
# Use a custom 5% threshold
--- a/mcp.md
+++ b/mcp.md
@@ -435,7 +435,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` and a `WWW-Authenticate` header pointing to its authorization server. Any custom server that returns that response gets the same `/mcp` authentication flow as any other remote server.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` or `403 Forbidden`. Either status code flags the server in `/mcp` so you can complete the OAuth flow. A custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.
1
--- a/mcp.md
+++ b/mcp.md
@@ -25,13 +25,31 @@
-Popular MCP servers
-
-Here are some commonly used MCP servers you can connect to Claude Code:
-
-Use third party MCP servers at your own risk - Anthropic has not verified the correctness or security of all these servers. Make sure you trust MCP servers you are installing. Be especially careful when using MCP servers that could fetch untrusted content, as these can expose you to prompt injection risk.
-
-**Need a specific integration?** [Find hundreds more MCP servers on GitHub](<https://github.com/modelcontextprotocol/servers>), or build your own using the [MCP SDK](<https://modelcontextprotocol.io/quickstart/server>).
+Find and build MCP servers
+
+Browse reviewed connectors in the [Anthropic Directory](<https://claude.ai/directory>). Directory connectors use the same MCP infrastructure as Claude Code, so you can add any remote server listed there with `claude mcp add`.
+
+Verify you trust each server before connecting it. Servers that fetch external content can expose you to [prompt injection risk](</docs/en/security#protect-against-prompt-injection>).
+
+To build your own server, see the [MCP server guide](<https://modelcontextprotocol.io/docs/develop/build-server>) for protocol fundamentals and the [Claude connector building docs](<https://claude.com/docs/connectors/building>) for authentication, testing, and Directory submission. You can also have Claude scaffold a server for you with the official [`mcp-server-dev` plugin](<https://github.com/anthropics/claude-plugins-official/tree/main/plugins/mcp-server-dev>).
+
+1
+
+Install the plugin
+
+In a Claude Code session, run:
+
+ /plugin install mcp-server-dev@claude-plugins-official
+
+Then run `/reload-plugins` to activate it in the current session.
+
+2
+
+Run the build skill
+
+ /mcp-server-dev:build-mcp-server
+
+Claude asks about your use case and scaffolds a remote HTTP or local stdio server.
##
--- a/mcp.md
+++ b/mcp.md
@@ -85,7 +85,7 @@
Option 3: Add a local stdio server
-Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts.
+Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts. Claude Code sets `CLAUDE_PROJECT_DIR` in the spawned server’s environment to the project root, so your server can resolve project-relative paths without depending on the working directory. This is the same directory hooks receive in their `CLAUDE_PROJECT_DIR` variable. Read it from inside your server process, for example `process.env.CLAUDE_PROJECT_DIR` in Node or `os.environ["CLAUDE_PROJECT_DIR"]` in Python. Your server can also call the MCP `roots/list` request, which returns the directory Claude Code was launched from. This variable is set in the server’s environment, not in Claude Code’s own environment, so referencing it via `${VAR}` expansion in a project- or user-scoped `.mcp.json` `command` or `args` requires a default such as `${CLAUDE_PROJECT_DIR:-.}`. Plugin-provided MCP configurations substitute `${CLAUDE_PROJECT_DIR}` directly and don’t need the default.
# Basic syntax
claude mcp add [options] <name> -- <command> [args...]
@@ -200,7 +200,7 @@
**Plugin MCP features** :
* **Automatic lifecycle** : At session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
- * **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files and `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates
+ * **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root
* **User environment access** : Access to same environment variables as manually configured servers
* **Multiple transport types** : Support stdio, SSE, and HTTP transports (transport support may vary by server)
@@ -417,7 +417,7 @@
Authenticate with remote MCP servers
-Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections.
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections. Claude Code marks a remote server as needing authentication when the server responds with `401 Unauthorized` and a `WWW-Authenticate` header pointing to its authorization server. Any custom server that returns that response gets the same `/mcp` authentication flow as any other remote server.
1
@@ -906,12 +906,12 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to opt in. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. If your proxy forwards `tool_reference` blocks, set `ENABLE_TOOL_SEARCH` explicitly to override the fallback. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Vertex AI or when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| All MCP tools deferred, including on Vertex AI and for non-first-party `ANTHROPIC_BASE_URL`
+`true`| All MCP tools deferred. Claude Code sends the beta header even on Vertex AI and through proxies. Requests fail if the backend does not support `tool_reference` blocks
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
`auto:<N>`| Threshold mode with a custom percentage, where `<N>` is 0-100 (e.g., `auto:5` for 5%)
`false`| All MCP tools loaded upfront, no deferral
--- a/mcp.md
+++ b/mcp.md
@@ -58,6 +58,8 @@
# Example with Bearer token
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
+
+When configuring MCP servers via JSON in `.mcp.json`, `~/.claude.json`, or `claude mcp add-json`, the `type` field accepts `streamable-http` as an alias for `http`. The MCP specification uses the name `streamable-http` for this transport, so configurations copied from server documentation work without modification.
###
--- a/mcp.md
+++ b/mcp.md
@@ -221,7 +221,7 @@
MCP installation scopes
-MCP servers can be configured at three scopes. The scope you choose controls which projects the server loads in and whether the configuration is shared with your team.
+MCP servers can be configured at three scopes. The scope you choose controls which projects the server loads in and whether the configuration is shared with your team. Administrators can also deploy servers at the enterprise level via managed configuration.
Scope| Loads in| Shared with team| Stored in
---|---|---|---
--- a/mcp.md
+++ b/mcp.md
@@ -1136,7 +1136,7 @@
* `https://*.example.com/*` \- Allow any subdomain of example.com
* `http://localhost:*/*` \- Allow any port on localhost
-**Remote server behavior** :
+Hostname matching is case-insensitive and ignores a trailing FQDN dot, matching DNS semantics. A pattern like `*://Mcp.Example.com/*` matches `https://mcp.example.com/api`, and `https://mcp.example.com.` is treated the same as `https://mcp.example.com`. Paths remain case-sensitive. **Remote server behavior** :
* When the allowlist contains **any** `serverUrl` entries, remote servers **must** match one of those URL patterns
* Remote servers cannot pass by name alone when URL restrictions are present
--- a/mcp.md
+++ b/mcp.md
@@ -118,6 +118,8 @@
# (within Claude Code) Check server status
/mcp
+
+The `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools. The server name `workspace` is reserved for internal use. If your configuration defines a server with that name, Claude Code skips it at load time and shows a warning asking you to rename it.
###
@@ -944,7 +946,7 @@
}
}
-The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only.
+The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only. Setting `alwaysLoad: true` also blocks startup until the server connects, capped at the standard 5-second connect timeout. This applies even when [`MCP_CONNECTION_NONBLOCKING=1`](</docs/en/env-vars>) is set, since the tools must be present when the first prompt is built. Other servers still connect in the background when nonblocking is enabled.
##
--- a/mcp.md
+++ b/mcp.md
@@ -1,3 +1,9 @@
+> ## Documentation Index
+>
+> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt>
+>
+> Use this file to discover all available pages before exploring further.
+
Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs. Connect a server when you find yourself copying data into chat from another tool, like an issue tracker or a monitoring dashboard. Once connected, Claude can read and act on that system directly instead of working from what you paste.
##
@@ -705,7 +711,7 @@
Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
-To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
+A server you’ve added in Claude Code takes precedence over a claude.ai connector that points at the same URL. When this happens, `/mcp` lists the connector as hidden and shows how to remove the duplicate if you’d rather use the connector. To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
--- a/mcp.md
+++ b/mcp.md
@@ -127,7 +127,7 @@
Automatic reconnection
-If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically.
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically. The same backoff applies when an HTTP or SSE server fails its initial connection at startup. As of v2.1.121, Claude Code retries the initial connection up to three times on transient errors such as a 5xx response, a connection refused, or a timeout, then marks the server as failed if it still cannot connect. Authentication and not-found errors are not retried because they require a configuration change to resolve.
###
@@ -919,6 +919,26 @@
"deny": ["ToolSearch"]
}
}
+
+###
+
+
+
+Exempt a server from deferral
+
+If a server’s tools should always be visible to Claude without a search step, set `alwaysLoad` to `true` in that server’s configuration. Every tool from that server then loads into context at session start regardless of the `ENABLE_TOOL_SEARCH` setting. Use this for a small number of tools that Claude needs on every turn, since each upfront tool consumes context that would otherwise be available for your conversation. The following `.mcp.json` entry exempts one HTTP server while leaving other servers deferred:
+
+ {
+ "mcpServers": {
+ "core-tools": {
+ "type": "http",
+ "url": "https://mcp.example.com/mcp",
+ "alwaysLoad": true
+ }
+ }
+ }
+
+The `alwaysLoad` field is available on all server types and requires Claude Code v2.1.121 or later. An MCP server can also mark individual tools as always-loaded by including `"anthropic/alwaysLoad": true` in the tool’s `_meta` object, which has the same effect for that tool only.
##
--- a/mcp.md
+++ b/mcp.md
@@ -147,13 +147,6 @@
* Configure MCP server startup timeout using the MCP_TIMEOUT environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
* Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
* Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
-
-**Windows Users** : On native Windows (not WSL), local MCP servers that use `npx` require the `cmd /c` wrapper to ensure proper execution.
-
- # This creates command="cmd" which Windows can execute
- claude mcp add --transport stdio my-server -- cmd /c npx -y @some/package
-
-Without the `cmd /c` wrapper, you’ll encounter “Connection closed” errors because Windows cannot directly execute `npx`. (See the note above for an explanation of the `--` parameter.)
###
@@ -903,12 +896,12 @@
Configure tool search
-Tool search is enabled by default: MCP tools are deferred and discovered on demand. When `ANTHROPIC_BASE_URL` points to a non-first-party host, tool search is disabled by default because most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly if your proxy does. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. It is disabled by default on Vertex AI, which does not accept the tool search beta header, and when `ANTHROPIC_BASE_URL` points to a non-first-party host, since most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly to opt in. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
Value| Behavior
---|---
-(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| All MCP tools deferred, including for non-first-party `ANTHROPIC_BASE_URL`
+(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront on Vertex AI or when `ANTHROPIC_BASE_URL` is a non-first-party host
+`true`| All MCP tools deferred, including on Vertex AI and for non-first-party `ANTHROPIC_BASE_URL`
`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
`auto:<N>`| Threshold mode with a custom percentage, where `<N>` is 0-100 (e.g., `auto:5` for 5%)
`false`| All MCP tools loaded upfront, no deferral
--- a/mcp.md
+++ b/mcp.md
@@ -378,11 +378,10 @@
Example: Connect to GitHub for code reviews
- claude mcp add --transport http github https://api.githubcopilot.com/mcp/
-
-Authenticate if needed by selecting “Authenticate” for GitHub:
-
- /mcp
+GitHub’s remote MCP server authenticates with a GitHub personal access token passed as a header. To get one, open your [GitHub token settings](<https://github.com/settings/personal-access-tokens>), generate a new fine-grained token with access to the repositories you want Claude to work with, then add the server:
+
+ claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
+ --header "Authorization: Bearer YOUR_GITHUB_PAT"
Then work with GitHub:
--- a/mcp.md
+++ b/mcp.md
@@ -695,7 +695,7 @@
Configure MCP servers in Claude.ai
-Add servers at [claude.ai/settings/connectors](<https://claude.ai/settings/connectors>). On Team and Enterprise plans, only admins can add servers.
+Add servers at [claude.ai/customize/connectors](<https://claude.ai/customize/connectors>). On Team and Enterprise plans, only admins can add servers.
2
--- a/mcp.md
+++ b/mcp.md
@@ -120,6 +120,14 @@
Dynamic tool updates
Claude Code supports MCP `list_changed` notifications, allowing MCP servers to dynamically update their available tools, prompts, and resources without requiring you to disconnect and reconnect. When an MCP server sends a `list_changed` notification, Claude Code automatically refreshes the available capabilities from that server.
+
+###
+
+
+
+Automatic reconnection
+
+If an HTTP or SSE server disconnects mid-session, Claude Code automatically reconnects with exponential backoff: up to five attempts, starting at a one-second delay and doubling each time. The server appears as pending in `/mcp` while reconnection is in progress. After five failed attempts the server is marked as failed and you can retry manually from `/mcp`. Stdio servers are local processes and are not reconnected automatically.
###
@@ -519,7 +527,7 @@
Override OAuth metadata discovery
-If your MCP server’s standard OAuth metadata endpoints return errors but the server exposes a working OIDC endpoint, you can point Claude Code at a specific metadata URL to bypass the default discovery chain. By default, Claude Code first checks RFC 9728 Protected Resource Metadata at `/.well-known/oauth-protected-resource`, then falls back to RFC 8414 authorization server metadata at `/.well-known/oauth-authorization-server`. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
+Point Claude Code at a specific OAuth authorization server metadata URL to bypass the default discovery chain. Set `authServerMetadataUrl` when the MCP server’s standard endpoints error, or when you want to route discovery through an internal proxy. By default, Claude Code first checks RFC 9728 Protected Resource Metadata at `/.well-known/oauth-protected-resource`, then falls back to RFC 8414 authorization server metadata at `/.well-known/oauth-authorization-server`. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
{
"mcpServers": {
@@ -533,7 +541,29 @@
}
}
-The URL must use `https://`. This option requires Claude Code v2.1.64 or later.
+The URL must use `https://`. `authServerMetadataUrl` requires Claude Code v2.1.64 or later. The metadata URL’s `scopes_supported` overrides the scopes the upstream server advertises.
+
+###
+
+
+
+Restrict OAuth scopes
+
+Set `oauth.scopes` to pin the scopes Claude Code requests during the authorization flow. This is the supported way to restrict an MCP server to a security-team-approved subset when the upstream authorization server advertises more scopes than you want to grant. The value is a single space-separated string, matching the `scope` parameter format in RFC 6749 §3.3.
+
+ {
+ "mcpServers": {
+ "slack": {
+ "type": "http",
+ "url": "https://mcp.slack.com/mcp",
+ "oauth": {
+ "scopes": "channels:read chat:write search:read"
+ }
+ }
+ }
+ }
+
+`oauth.scopes` takes precedence over both `authServerMetadataUrl` and the scopes the server discovers at `/.well-known`. Leave it unset to let the MCP server determine the requested scope set. If the authorization server advertises `offline_access` in `scopes_supported`, Claude Code appends it to the pinned scopes so the access token can be refreshed without a new browser sign-in. If the server later returns a 403 `insufficient_scope` for a tool call, Claude Code re-authenticates with the same pinned scopes. Widen `oauth.scopes` when a tool you need requires a scope outside the pin.
###
--- a/mcp.md
+++ b/mcp.md
@@ -391,7 +391,7 @@
Example: Query your PostgreSQL database
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
- --dsn "postgresql://readonly:[[email protected]](</cdn-cgi/l/email-protection>):5432/analytics"
+ --dsn "postgresql://readonly:pass@prod.db.com:5432/analytics"
Then query your database naturally:
--- a/mcp.md
+++ b/mcp.md
@@ -293,7 +293,15 @@
Scope hierarchy and precedence
-MCP server configurations follow a clear precedence hierarchy. When servers with the same name exist at multiple scopes, the system resolves conflicts by prioritizing local-scoped servers first, followed by project-scoped servers, and finally user-scoped servers. This design ensures that personal configurations can override shared ones when needed. If a server is configured both locally and through a claude.ai connector, the local configuration takes precedence and the connector entry is skipped.
+When the same server is defined in more than one place, Claude Code connects to it once, using the definition from the highest-precedence source:
+
+ 1. Local scope
+ 2. Project scope
+ 3. User scope
+ 4. [Plugin-provided servers](</docs/en/plugins>)
+ 5. claude.ai connectors
+
+The three scopes match duplicates by name. Plugins and connectors match by endpoint, so one that points at the same URL or command as a server above is treated as a duplicate.
###
--- a/mcp.md
+++ b/mcp.md
@@ -1,4 +1,4 @@
-Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs.
+Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs. Connect a server when you find yourself copying data into chat from another tool, like an issue tracker or a monitoring dashboard. Once connected, Claude can read and act on that system directly instead of working from what you paste.
##
Show diff (115 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -212,7 +212,13 @@
MCP installation scopes
-MCP servers can be configured at three different scope levels, each serving distinct purposes for managing server accessibility and sharing. Understanding these scopes helps you determine the best way to configure servers for your specific needs.
+MCP servers can be configured at three scopes. The scope you choose controls which projects the server loads in and whether the configuration is shared with your team.
+
+Scope| Loads in| Shared with team| Stored in
+---|---|---|---
+Local| Current project only| No| `~/.claude.json`
+Project| Current project only| Yes, via version control| `.mcp.json` in project root
+User| All your projects| No| `~/.claude.json`
###
@@ -220,7 +226,7 @@
Local scope
-Local-scoped servers represent the default configuration level and are stored in `~/.claude.json` under your project’s path. These servers remain private to you and are only accessible when working within the current project directory. This scope is ideal for personal development servers, experimental configurations, or servers containing sensitive credentials that shouldn’t be shared.
+Local scope is the default. A local-scoped server loads only in the project where you added it and stays private to you. Claude Code stores it in `~/.claude.json` under that project’s path, so the same server won’t appear in your other projects. Use local scope for personal development servers, experimental configurations, or servers with credentials you don’t want in version control.
The term “local scope” for MCP servers differs from general local settings. MCP local-scoped servers are stored in `~/.claude.json` (your home directory), while general local settings use `.claude/settings.local.json` (in the project directory). See [Settings](</docs/en/settings#settings-files>) for details on settings file locations.
@@ -229,6 +235,21 @@
# Explicitly specify local scope
claude mcp add --transport http stripe --scope local https://mcp.stripe.com
+
+The command writes the server into the entry for your current project inside `~/.claude.json`. The example below shows the result when you run it from `/path/to/your/project`:
+
+ {
+ "projects": {
+ "/path/to/your/project": {
+ "mcpServers": {
+ "stripe": {
+ "type": "http",
+ "url": "https://mcp.stripe.com"
+ }
+ }
+ }
+ }
+ }
###
@@ -265,24 +286,6 @@
# Add a user server
claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
-
-###
-
-
-
-Choosing the right scope
-
-Select your scope based on:
-
- * **Local scope** : Personal servers, experimental configurations, or sensitive credentials specific to one project
- * **Project scope** : Team-shared servers, project-specific tools, or services required for collaboration
- * **User scope** : Personal utilities needed across multiple projects, development tools, or frequently used services
-
-**Where are MCP servers stored?**
-
- * **User and local scope** : `~/.claude.json` (in the `mcpServers` field or under project paths)
- * **Project scope** : `.mcp.json` in your project root (checked into source control)
- * **Managed** : `managed-mcp.json` in system directories (see Managed MCP configuration)
###
@@ -734,8 +737,9 @@
When MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:
* **Output warning threshold** : Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens
- * **Configurable limit** : You can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable
- * **Default limit** : The default maximum is 25,000 tokens
+ * **Configurable limit** : you can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable
+ * **Default limit** : the default maximum is 25,000 tokens
+ * **Scope** : the environment variable applies to tools that don’t declare their own limit. Tools that set `anthropic/maxResultSizeChars` use that value instead for text content, regardless of what `MAX_MCP_OUTPUT_TOKENS` is set to. Tools that return image data are still subject to `MAX_MCP_OUTPUT_TOKENS`
To increase the limit for tools that produce large outputs:
@@ -752,7 +756,7 @@
-Override result size per tool
+Raise the limit for a specific tool
If you’re building an MCP server, you can allow individual tools to return results larger than the default persist-to-disk threshold by setting `_meta["anthropic/maxResultSizeChars"]` in the tool’s `tools/list` response entry. Claude Code raises that tool’s threshold to the annotated value, up to a hard ceiling of 500,000 characters. This is useful for tools that return inherently large but necessary outputs, such as database schemas or full file trees. Without the annotation, results that exceed the default threshold are persisted to disk and replaced with a file reference in the conversation.
@@ -760,13 +764,13 @@
"name": "get_schema",
"description": "Returns the full database schema",
"_meta": {
- "anthropic/maxResultSizeChars": 500000
- }
- }
-
-The annotation raises the per-tool persist threshold but does not bypass the global `MAX_MCP_OUTPUT_TOKENS` limit, which defaults to 25,000 tokens or roughly 100,000 characters. To return results larger than that, users must also raise `MAX_MCP_OUTPUT_TOKENS`.
-
-If you frequently encounter output warnings with specific MCP servers you don’t control, consider increasing the `MAX_MCP_OUTPUT_TOKENS` limit. You can also ask the server author to add the `anthropic/maxResultSizeChars` annotation or to paginate their responses.
+ "anthropic/maxResultSizeChars": 200000
+ }
+ }
+
+The annotation applies independently of `MAX_MCP_OUTPUT_TOKENS` for text content, so users don’t need to raise the environment variable for tools that declare it. Tools that return image data are still subject to the token limit.
+
+If you frequently encounter output warnings with specific MCP servers you don’t control, consider increasing the `MAX_MCP_OUTPUT_TOKENS` limit. You can also ask the server author to add the `anthropic/maxResultSizeChars` annotation or to paginate their responses. The annotation has no effect on tools that return image content; for those, raising `MAX_MCP_OUTPUT_TOKENS` is the only option.
##
--- a/mcp.md
+++ b/mcp.md
@@ -754,7 +754,7 @@
Override result size per tool
-If you’re building an MCP server, you can allow individual tools to return results larger than the default limit by setting `_meta["anthropic/maxResultSizeChars"]` in the tool’s `tools/list` response entry. Claude Code uses this value as the maximum result size for that tool, up to a hard ceiling of 500,000 characters. This is useful for tools that return inherently large but necessary outputs, such as database schemas or full file trees. Without the annotation, results that exceed the default limit are persisted to disk and replaced with a file reference in the conversation.
+If you’re building an MCP server, you can allow individual tools to return results larger than the default persist-to-disk threshold by setting `_meta["anthropic/maxResultSizeChars"]` in the tool’s `tools/list` response entry. Claude Code raises that tool’s threshold to the annotated value, up to a hard ceiling of 500,000 characters. This is useful for tools that return inherently large but necessary outputs, such as database schemas or full file trees. Without the annotation, results that exceed the default threshold are persisted to disk and replaced with a file reference in the conversation.
{
"name": "get_schema",
@@ -764,7 +764,9 @@
}
}
-If you frequently encounter output warnings with specific MCP servers you don’t control, consider increasing the `MAX_MCP_OUTPUT_TOKENS` limit or asking the server author to add the `anthropic/maxResultSizeChars` annotation.
+The annotation raises the per-tool persist threshold but does not bypass the global `MAX_MCP_OUTPUT_TOKENS` limit, which defaults to 25,000 tokens or roughly 100,000 characters. To return results larger than that, users must also raise `MAX_MCP_OUTPUT_TOKENS`.
+
+If you frequently encounter output warnings with specific MCP servers you don’t control, consider increasing the `MAX_MCP_OUTPUT_TOKENS` limit. You can also ask the server author to add the `anthropic/maxResultSizeChars` annotation or to paginate their responses.
##
--- a/mcp.md
+++ b/mcp.md
@@ -739,7 +739,6 @@
To increase the limit for tools that produce large outputs:
- # Set a higher limit for MCP tool outputs
export MAX_MCP_OUTPUT_TOKENS=50000
claude
@@ -749,7 +748,23 @@
* Generate detailed reports or documentation
* Process extensive log files or debugging information
-If you frequently encounter output warnings with specific MCP servers, consider increasing the limit or configuring the server to paginate or filter its responses.
+###
+
+
+
+Override result size per tool
+
+If you’re building an MCP server, you can allow individual tools to return results larger than the default limit by setting `_meta["anthropic/maxResultSizeChars"]` in the tool’s `tools/list` response entry. Claude Code uses this value as the maximum result size for that tool, up to a hard ceiling of 500,000 characters. This is useful for tools that return inherently large but necessary outputs, such as database schemas or full file trees. Without the annotation, results that exceed the default limit are persisted to disk and replaced with a file reference in the conversation.
+
+ {
+ "name": "get_schema",
+ "description": "Returns the full database schema",
+ "_meta": {
+ "anthropic/maxResultSizeChars": 500000
+ }
+ }
+
+If you frequently encounter output warnings with specific MCP servers you don’t control, consider increasing the `MAX_MCP_OUTPUT_TOKENS` limit or asking the server author to add the `anthropic/maxResultSizeChars` annotation.
##
--- a/mcp.md
+++ b/mcp.md
@@ -861,11 +861,11 @@
# Disable tool search entirely
ENABLE_TOOL_SEARCH=false claude
-Or set the value in your [settings.json `env` field](</docs/en/settings#available-settings>). You can also disable the MCPSearch tool specifically using the `disallowedTools` setting:
+Or set the value in your [settings.json `env` field](</docs/en/settings#available-settings>). You can also disable the `ToolSearch` tool specifically:
{
"permissions": {
- "deny": ["MCPSearch"]
+ "deny": ["ToolSearch"]
}
}
--- a/mcp.md
+++ b/mcp.md
@@ -508,7 +508,7 @@
Override OAuth metadata discovery
-If your MCP server returns errors on the standard OAuth metadata endpoint (`/.well-known/oauth-authorization-server`) but exposes a working OIDC endpoint, you can tell Claude Code to fetch OAuth metadata directly from a URL you specify, bypassing the standard discovery chain. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
+If your MCP server’s standard OAuth metadata endpoints return errors but the server exposes a working OIDC endpoint, you can point Claude Code at a specific metadata URL to bypass the default discovery chain. By default, Claude Code first checks RFC 9728 Protected Resource Metadata at `/.well-known/oauth-protected-resource`, then falls back to RFC 8414 authorization server metadata at `/.well-known/oauth-authorization-server`. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
{
"mcpServers": {
@@ -560,7 +560,14 @@
* The command runs in a shell with a 10-second timeout
* Dynamic headers override any static `headers` with the same name
-The helper runs fresh on each connection (at session start and on reconnect). There is no caching, so your script is responsible for any token reuse.
+The helper runs fresh on each connection (at session start and on reconnect). There is no caching, so your script is responsible for any token reuse. Claude Code sets these environment variables when executing the helper:
+
+Variable| Value
+---|---
+`CLAUDE_CODE_MCP_SERVER_NAME`| the name of the MCP server
+`CLAUDE_CODE_MCP_SERVER_URL`| the URL of the MCP server
+
+Use these to write a single helper script that serves multiple MCP servers.
`headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.
@@ -842,11 +849,11 @@
Value| Behavior
---|---
-(unset)| Enabled by default. Disabled when `ANTHROPIC_BASE_URL` is a non-first-party host
-`true`| Always enabled, including for non-first-party `ANTHROPIC_BASE_URL`
-`auto`| Activates when MCP tools exceed 10% of context
-`auto:<N>`| Activates at custom threshold, where `<N>` is a percentage (e.g., `auto:5` for 5%)
-`false`| Disabled, all MCP tools loaded upfront
+(unset)| All MCP tools deferred and loaded on demand. Falls back to loading upfront when `ANTHROPIC_BASE_URL` is a non-first-party host
+`true`| All MCP tools deferred, including for non-first-party `ANTHROPIC_BASE_URL`
+`auto`| Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise
+`auto:<N>`| Threshold mode with a custom percentage, where `<N>` is 0-100 (e.g., `auto:5` for 5%)
+`false`| All MCP tools loaded upfront, no deferral
# Use a custom 5% threshold
ENABLE_TOOL_SEARCH=auto:5 claude
Show diff (780 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -43,12 +43,6 @@
HTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Basic syntax
claude mcp add --transport http <name> <url>
@@ -67,12 +61,6 @@
The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Basic syntax
claude mcp add --transport sse <name> <url>
@@ -91,12 +79,6 @@
Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Basic syntax
claude mcp add [options] <name> -- <command> [args...]
@@ -118,12 +100,6 @@
Managing your servers
Once configured, you can manage your MCP servers with these commands:
-
-Report incorrect code
-
-Copy
-
-Ask AI
# List all configured servers
claude mcp list
@@ -166,12 +142,6 @@
**Windows Users** : On native Windows (not WSL), local MCP servers that use `npx` require the `cmd /c` wrapper to ensure proper execution.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# This creates command="cmd" which Windows can execute
claude mcp add --transport stdio my-server -- cmd /c npx -y @some/package
@@ -191,12 +161,6 @@
* Plugin servers are managed through plugin installation (not `/mcp` commands)
**Example plugin MCP configuration** : In `.mcp.json` at plugin root:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -212,12 +176,6 @@
Or inline in `plugin.json`:
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"name": "my-plugin",
"mcpServers": {
@@ -237,12 +195,6 @@
**Viewing plugin MCP servers** :
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Within Claude Code, see all MCP servers including plugin ones
/mcp
@@ -272,12 +224,6 @@
The term “local scope” for MCP servers differs from general local settings. MCP local-scoped servers are stored in `~/.claude.json` (your home directory), while general local settings use `.claude/settings.local.json` (in the project directory). See [Settings](</docs/en/settings#settings-files>) for details on settings file locations.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Add a local-scoped server (default)
claude mcp add --transport http stripe https://mcp.stripe.com
@@ -292,22 +238,10 @@
Project-scoped servers enable team collaboration by storing configurations in a `.mcp.json` file at your project’s root directory. This file is designed to be checked into version control, ensuring all team members have access to the same MCP tools and services. When you add a project-scoped server, Claude Code automatically creates or updates this file with the appropriate configuration structure.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Add a project-scoped server
claude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp
The resulting `.mcp.json` file follows a standardized format:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -329,12 +263,6 @@
User-scoped servers are stored in `~/.claude.json` and provide cross-project accessibility, making them available across all projects on your machine while remaining private to your user account. This scope works well for personal utility servers, development tools, or services you frequently use across different projects.
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Add a user server
claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
@@ -362,7 +290,7 @@
Scope hierarchy and precedence
-MCP server configurations follow a clear precedence hierarchy. When servers with the same name exist at multiple scopes, the system resolves conflicts by prioritizing local-scoped servers first, followed by project-scoped servers, and finally user-scoped servers. This design ensures that personal configurations can override shared ones when needed.
+MCP server configurations follow a clear precedence hierarchy. When servers with the same name exist at multiple scopes, the system resolves conflicts by prioritizing local-scoped servers first, followed by project-scoped servers, and finally user-scoped servers. This design ensures that personal configurations can override shared ones when needed. If a server is configured both locally and through a claude.ai connector, the local configuration takes precedence and the connector entry is skipped.
###
@@ -384,12 +312,6 @@
* `headers` \- For HTTP server authentication
**Example with variable expansion:**
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -417,48 +339,18 @@
Example: Monitor errors with Sentry
-Report incorrect code
-
-Copy
-
-Ask AI
-
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
Authenticate with your Sentry account:
-Report incorrect code
-
-Copy
-
-Ask AI
-
/mcp
Then debug production issues:
-Report incorrect code
-
-Copy
-
-Ask AI
-
What are the most common errors in the last 24 hours?
-Report incorrect code
-
-Copy
-
-Ask AI
-
Show me the stack trace for error ID abc123
-Report incorrect code
-
-Copy
-
-Ask AI
-
Which deployment introduced these new errors?
###
@@ -467,48 +359,18 @@
Example: Connect to GitHub for code reviews
-Report incorrect code
-
-Copy
-
-Ask AI
-
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
Authenticate if needed by selecting “Authenticate” for GitHub:
-Report incorrect code
-
-Copy
-
-Ask AI
-
/mcp
Then work with GitHub:
-Report incorrect code
-
-Copy
-
-Ask AI
-
Review PR #456 and suggest improvements
-Report incorrect code
-
-Copy
-
-Ask AI
-
Create a new issue for the bug we just found
-Report incorrect code
-
-Copy
-
-Ask AI
-
Show me all open PRs assigned to me
###
@@ -516,40 +378,16 @@
Example: Query your PostgreSQL database
-
-Report incorrect code
-
-Copy
-
-Ask AI
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
--dsn "postgresql://readonly:[[email protected]](</cdn-cgi/l/email-protection>):5432/analytics"
Then query your database naturally:
-Report incorrect code
-
-Copy
-
-Ask AI
-
What's our total revenue this month?
-Report incorrect code
-
-Copy
-
-Ask AI
-
Show me the schema for the orders table
-Report incorrect code
-
-Copy
-
-Ask AI
-
Find customers who haven't made a purchase in 90 days
##
@@ -566,12 +404,6 @@
For example:
-Report incorrect code
-
-Copy
-
-Ask AI
-
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
2
@@ -579,12 +411,6 @@
Use the /mcp command within Claude Code
In Claude code, use the command:
-
-Report incorrect code
-
-Copy
-
-Ask AI
/mcp
@@ -606,12 +432,6 @@
Some MCP servers require a specific redirect URI registered in advance. By default, Claude Code picks a random available port for the OAuth callback. Use `--callback-port` to fix the port so it matches a pre-registered redirect URI of the form `http://localhost:PORT/callback`. You can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Fixed callback port with dynamic client registration
claude mcp add --transport http \
--callback-port 8080 \
@@ -647,46 +467,22 @@
Use `--client-id` to pass your app’s client ID. The `--client-secret` flag prompts for the secret with masked input:
-Report incorrect code
-
-Copy
-
-Ask AI
-
claude mcp add --transport http \
--client-id your-client-id --client-secret --callback-port 8080 \
my-server https://mcp.example.com/mcp
Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:
-Report incorrect code
-
-Copy
-
-Ask AI
-
claude mcp add-json my-server \
'{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"clientId":"your-client-id","callbackPort":8080}}' \
--client-secret
Use `--callback-port` without a client ID to fix the port while using dynamic client registration:
-Report incorrect code
-
-Copy
-
-Ask AI
-
claude mcp add-json my-server \
'{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"callbackPort":8080}}'
Set the secret via environment variable to skip the interactive prompt:
-
-Report incorrect code
-
-Copy
-
-Ask AI
MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \
--client-id your-client-id --client-secret --callback-port 8080 \
@@ -713,12 +509,6 @@
Override OAuth metadata discovery
If your MCP server returns errors on the standard OAuth metadata endpoint (`/.well-known/oauth-authorization-server`) but exposes a working OIDC endpoint, you can tell Claude Code to fetch OAuth metadata directly from a URL you specify, bypassing the standard discovery chain. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -742,12 +532,6 @@
If your MCP server uses an authentication scheme other than OAuth (such as Kerberos, short-lived tokens, or an internal SSO), use `headersHelper` to generate request headers at connection time. Claude Code runs the command and merges its output into the connection headers.
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"mcpServers": {
"internal-api": {
@@ -760,12 +544,6 @@
The command can also be inline:
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"mcpServers": {
"internal-api": {
@@ -798,12 +576,6 @@
Add an MCP server from JSON
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Basic syntax
claude mcp add-json <name> '<json>'
@@ -819,12 +591,6 @@
2
Verify the server was added
-
-Report incorrect code
-
-Copy
-
-Ask AI
claude mcp get weather-api
@@ -846,12 +612,6 @@
Import servers from Claude Desktop
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Basic syntax
claude mcp add-from-claude-desktop
@@ -864,12 +624,6 @@
3
Verify the servers were imported
-
-Report incorrect code
-
-Copy
-
-Ask AI
claude mcp list
@@ -907,24 +661,12 @@
In Claude Code, use the command:
-Report incorrect code
-
-Copy
-
-Ask AI
-
/mcp
Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
-Report incorrect code
-
-Copy
-
-Ask AI
-
ENABLE_CLAUDEAI_MCP_SERVERS=false claude
##
@@ -934,23 +676,11 @@
Use Claude Code as an MCP server
You can use Claude Code itself as an MCP server that other applications can connect to:
-
-Report incorrect code
-
-Copy
-
-Ask AI
# Start Claude as a stdio MCP server
claude mcp serve
You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -965,21 +695,9 @@
**Configuring the executable path** : The `command` field must reference the Claude Code executable. If the `claude` command is not in your system’s PATH, you’ll need to specify the full path to the executable.To find the full path:
-Report incorrect code
-
-Copy
-
-Ask AI
-
which claude
Then use the full path in your configuration:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -1014,12 +732,6 @@
To increase the limit for tools that produce large outputs:
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Set a higher limit for MCP tool outputs
export MAX_MCP_OUTPUT_TOKENS=50000
claude
@@ -1071,20 +783,8 @@
Use the format `@server:protocol://resource/path` to reference a resource:
-Report incorrect code
-
-Copy
-
-Ask AI
-
Can you analyze @github:issue://123 and suggest a fix?
-Report incorrect code
-
-Copy
-
-Ask AI
-
Please review the API documentation at @docs:file://api/authentication
3
@@ -1092,12 +792,6 @@
Multiple resource references
You can reference multiple resources in a single prompt:
-
-Report incorrect code
-
-Copy
-
-Ask AI
Compare @postgres:schema://users with @docs:file://database/user-model
@@ -1114,7 +808,7 @@
Scale with MCP Tool Search
-When you have many MCP servers configured, tool definitions can consume a significant portion of your context window. MCP Tool Search solves this by dynamically loading tools on-demand instead of preloading all of them.
+Tool search keeps MCP context usage low by deferring tool definitions until Claude needs them. Only tool names load at session start, so adding more MCP servers has minimal impact on your context window.
###
@@ -1122,12 +816,7 @@
How it works
-Claude Code automatically enables Tool Search when your MCP tool descriptions would consume more than 10% of the context window. You can adjust this threshold or disable tool search entirely. When triggered:
-
- 1. MCP tools are deferred rather than loaded into context upfront
- 2. Claude uses a search tool to discover relevant MCP tools when needed
- 3. Only the tools Claude actually needs are loaded into context
- 4. MCP tools continue to work exactly as before from your perspective
+Tool search is enabled by default. MCP tools are deferred rather than loaded into context upfront, and Claude uses a search tool to discover relevant ones when a task needs them. Only the tools Claude actually uses enter context. From your perspective, MCP tools work exactly as before. If you prefer threshold-based loading, set `ENABLE_TOOL_SEARCH=auto` to load schemas upfront when they fit within 10% of the context window and defer only the overflow. See Configure tool search for all options.
###
@@ -1140,6 +829,8 @@
* What category of tasks your tools handle
* When Claude should search for your tools
* Key capabilities your server provides
+
+Claude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.
###
@@ -1157,12 +848,6 @@
`auto:<N>`| Activates at custom threshold, where `<N>` is a percentage (e.g., `auto:5` for 5%)
`false`| Disabled, all MCP tools loaded upfront
-Report incorrect code
-
-Copy
-
-Ask AI
-
# Use a custom 5% threshold
ENABLE_TOOL_SEARCH=auto:5 claude
@@ -1170,12 +855,6 @@
ENABLE_TOOL_SEARCH=false claude
Or set the value in your [settings.json `env` field](</docs/en/settings#available-settings>). You can also disable the MCPSearch tool specifically using the `disallowedTools` setting:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"permissions": {
@@ -1207,12 +886,6 @@
Execute a prompt without arguments
-Report incorrect code
-
-Copy
-
-Ask AI
-
/mcp__github__list_prs
3
@@ -1221,19 +894,7 @@
Many prompts accept arguments. Pass them space-separated after the command:
-Report incorrect code
-
-Copy
-
-Ask AI
-
/mcp__github__pr_review 456
-
-Report incorrect code
-
-Copy
-
-Ask AI
/mcp__jira__create_issue "Bug in login flow" high
@@ -1276,12 +937,6 @@
These are system-wide paths (not user home directories like `~/Library/...`) that require administrator privileges. They are designed to be deployed by IT administrators.
The `managed-mcp.json` file uses the same format as a standard `.mcp.json` file:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"mcpServers": {
@@ -1334,12 +989,6 @@
Example configuration
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"allowedMcpServers": [
// Allow by server name
@@ -1409,12 +1058,6 @@
Example: URL-only allowlist
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"allowedMcpServers": [
{ "serverUrl": "https://mcp.company.com/*" },
@@ -1431,12 +1074,6 @@
Example: Command-only allowlist
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"allowedMcpServers": [
{ "serverCommand": ["npx", "-y", "approved-package"] }
@@ -1450,12 +1087,6 @@
* HTTP server named “my-api”: ❌ Blocked (no name entries to match)
Example: Mixed name and command allowlist
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"allowedMcpServers": [
@@ -1474,12 +1105,6 @@
Example: Name-only allowlist
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"allowedMcpServers": [
{ "serverName": "github" },
--- a/mcp.md
+++ b/mcp.md
@@ -199,11 +199,13 @@
Ask AI
{
- "database-tools": {
- "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
- "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
- "env": {
- "DB_URL": "${DB_URL}"
+ "mcpServers": {
+ "database-tools": {
+ "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
+ "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
+ "env": {
+ "DB_URL": "${DB_URL}"
+ }
}
}
}
@@ -731,6 +733,58 @@
}
The URL must use `https://`. This option requires Claude Code v2.1.64 or later.
+
+###
+
+
+
+Use dynamic headers for custom authentication
+
+If your MCP server uses an authentication scheme other than OAuth (such as Kerberos, short-lived tokens, or an internal SSO), use `headersHelper` to generate request headers at connection time. Claude Code runs the command and merges its output into the connection headers.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "internal-api": {
+ "type": "http",
+ "url": "https://mcp.internal.example.com",
+ "headersHelper": "/opt/bin/get-mcp-auth-headers.sh"
+ }
+ }
+ }
+
+The command can also be inline:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "internal-api": {
+ "type": "http",
+ "url": "https://mcp.internal.example.com",
+ "headersHelper": "echo '{\"Authorization\": \"Bearer '\"$(get-token)\"'\"}'"
+ }
+ }
+ }
+
+**Requirements:**
+
+ * The command must write a JSON object of string key-value pairs to stdout
+ * The command runs in a shell with a 10-second timeout
+ * Dynamic headers override any static `headers` with the same name
+
+The helper runs fresh on each connection (at session start and on reconnect). There is no caching, so your script is responsible for any token reuse.
+
+`headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.
##
Show diff (1476 lines)
--- a/mcp.md
+++ b/mcp.md
@@ -0,0 +1,1473 @@
+Claude Code can connect to hundreds of external tools and data sources through the [Model Context Protocol (MCP)](<https://modelcontextprotocol.io/introduction>), an open source standard for AI-tool integrations. MCP servers give Claude Code access to your tools, databases, and APIs.
+
+##
+
+
+
+What you can do with MCP
+
+With MCP servers connected, you can ask Claude Code to:
+
+ * **Implement features from issue trackers** : “Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.”
+ * **Analyze monitoring data** : “Check Sentry and Statsig to check the usage of the feature described in ENG-4521.”
+ * **Query databases** : “Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.”
+ * **Integrate designs** : “Update our standard email template based on the new Figma designs that were posted in Slack”
+ * **Automate workflows** : “Create Gmail drafts inviting these 10 users to a feedback session about the new feature.”
+ * **React to external events** : An MCP server can also act as a [channel](</docs/en/channels>) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you’re away.
+
+##
+
+
+
+Popular MCP servers
+
+Here are some commonly used MCP servers you can connect to Claude Code:
+
+Use third party MCP servers at your own risk - Anthropic has not verified the correctness or security of all these servers. Make sure you trust MCP servers you are installing. Be especially careful when using MCP servers that could fetch untrusted content, as these can expose you to prompt injection risk.
+
+**Need a specific integration?** [Find hundreds more MCP servers on GitHub](<https://github.com/modelcontextprotocol/servers>), or build your own using the [MCP SDK](<https://modelcontextprotocol.io/quickstart/server>).
+
+##
+
+
+
+Installing MCP servers
+
+MCP servers can be configured in three different ways depending on your needs:
+
+###
+
+
+
+Option 1: Add a remote HTTP server
+
+HTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # 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"
+
+###
+
+
+
+Option 2: Add a remote SSE server
+
+The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # 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"
+
+###
+
+
+
+Option 3: Add a local stdio server
+
+Stdio servers run as local processes on your machine. They’re ideal for tools that need direct system access or custom scripts.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Basic syntax
+ claude mcp add [options] <name> -- <command> [args...]
+
+ # Real example: Add Airtable server
+ claude mcp add --transport stdio --env AIRTABLE_API_KEY=YOUR_KEY airtable \
+ -- npx -y airtable-mcp-server
+
+**Important: Option ordering** All options (`--transport`, `--env`, `--scope`, `--header`) must come **before** the server name. The `--` (double dash) then separates the server name from the command and arguments that get passed to the MCP server.For example:
+
+ * `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`
+ * `claude mcp add --transport stdio --env KEY=value myserver -- python server.py --port 8080` → runs `python server.py --port 8080` with `KEY=value` in environment
+
+This prevents conflicts between Claude’s flags and the server’s flags.
+
+###
+
+
+
+Managing your servers
+
+Once configured, you can manage your MCP servers with these commands:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # List all configured servers
+ claude mcp list
+
+ # Get details for a specific server
+ claude mcp get github
+
+ # Remove a server
+ claude mcp remove github
+
+ # (within Claude Code) Check server status
+ /mcp
+
+###
+
+
+
+Dynamic tool updates
+
+Claude Code supports MCP `list_changed` notifications, allowing MCP servers to dynamically update their available tools, prompts, and resources without requiring you to disconnect and reconnect. When an MCP server sends a `list_changed` notification, Claude Code automatically refreshes the available capabilities from that server.
+
+###
+
+
+
+Push messages with channels
+
+An MCP server can also push messages directly into your session so Claude can react to external events like CI results, monitoring alerts, or chat messages. To enable this, your server declares the `claude/channel` capability and you opt it in with the `--channels` flag at startup. See [Channels](</docs/en/channels>) to use an officially supported channel, or [Channels reference](</docs/en/channels-reference>) to build your own.
+
+Tips:
+
+ * Use the `--scope` flag to specify where the configuration is stored:
+ * `local` (default): Available only to you in the current project (was called `project` in older versions)
+ * `project`: Shared with everyone in the project via `.mcp.json` file
+ * `user`: Available to you across all projects (was called `global` in older versions)
+ * Set environment variables with `--env` flags (for example, `--env KEY=value`)
+ * Configure MCP server startup timeout using the MCP_TIMEOUT environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)
+ * Claude Code will display a warning when MCP tool output exceeds 10,000 tokens. To increase this limit, set the `MAX_MCP_OUTPUT_TOKENS` environment variable (for example, `MAX_MCP_OUTPUT_TOKENS=50000`)
+ * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication
+
+**Windows Users** : On native Windows (not WSL), local MCP servers that use `npx` require the `cmd /c` wrapper to ensure proper execution.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # This creates command="cmd" which Windows can execute
+ claude mcp add --transport stdio my-server -- cmd /c npx -y @some/package
+
+Without the `cmd /c` wrapper, you’ll encounter “Connection closed” errors because Windows cannot directly execute `npx`. (See the note above for an explanation of the `--` parameter.)
+
+###
+
+
+
+Plugin-provided MCP servers
+
+[Plugins](</docs/en/plugins>) can bundle MCP servers, automatically providing tools and integrations when the plugin is enabled. Plugin MCP servers work identically to user-configured servers. **How plugin MCP servers work** :
+
+ * Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`
+ * When a plugin is enabled, its MCP servers start automatically
+ * Plugin MCP tools appear alongside manually configured MCP tools
+ * Plugin servers are managed through plugin installation (not `/mcp` commands)
+
+**Example plugin MCP configuration** : In `.mcp.json` at plugin root:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "database-tools": {
+ "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
+ "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
+ "env": {
+ "DB_URL": "${DB_URL}"
+ }
+ }
+ }
+
+Or inline in `plugin.json`:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "name": "my-plugin",
+ "mcpServers": {
+ "plugin-api": {
+ "command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
+ "args": ["--port", "8080"]
+ }
+ }
+ }
+
+**Plugin MCP features** :
+
+ * **Automatic lifecycle** : At session startup, servers for enabled plugins connect automatically. If you enable or disable a plugin during a session, run `/reload-plugins` to connect or disconnect its MCP servers
+ * **Environment variables** : use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files and `${CLAUDE_PLUGIN_DATA}` for [persistent state](</docs/en/plugins-reference#persistent-data-directory>) that survives plugin updates
+ * **User environment access** : Access to same environment variables as manually configured servers
+ * **Multiple transport types** : Support stdio, SSE, and HTTP transports (transport support may vary by server)
+
+**Viewing plugin MCP servers** :
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Within Claude Code, see all MCP servers including plugin ones
+ /mcp
+
+Plugin servers appear in the list with indicators showing they come from plugins. **Benefits of plugin MCP servers** :
+
+ * **Bundled distribution** : Tools and servers packaged together
+ * **Automatic setup** : No manual MCP configuration needed
+ * **Team consistency** : Everyone gets the same tools when plugin is installed
+
+See the [plugin components reference](</docs/en/plugins-reference#mcp-servers>) for details on bundling MCP servers with plugins.
+
+##
+
+
+
+MCP installation scopes
+
+MCP servers can be configured at three different scope levels, each serving distinct purposes for managing server accessibility and sharing. Understanding these scopes helps you determine the best way to configure servers for your specific needs.
+
+###
+
+
+
+Local scope
+
+Local-scoped servers represent the default configuration level and are stored in `~/.claude.json` under your project’s path. These servers remain private to you and are only accessible when working within the current project directory. This scope is ideal for personal development servers, experimental configurations, or servers containing sensitive credentials that shouldn’t be shared.
+
+The term “local scope” for MCP servers differs from general local settings. MCP local-scoped servers are stored in `~/.claude.json` (your home directory), while general local settings use `.claude/settings.local.json` (in the project directory). See [Settings](</docs/en/settings#settings-files>) for details on settings file locations.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Add a local-scoped server (default)
+ claude mcp add --transport http stripe https://mcp.stripe.com
+
+ # Explicitly specify local scope
+ claude mcp add --transport http stripe --scope local https://mcp.stripe.com
+
+###
+
+
+
+Project scope
+
+Project-scoped servers enable team collaboration by storing configurations in a `.mcp.json` file at your project’s root directory. This file is designed to be checked into version control, ensuring all team members have access to the same MCP tools and services. When you add a project-scoped server, Claude Code automatically creates or updates this file with the appropriate configuration structure.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Add a project-scoped server
+ claude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp
+
+The resulting `.mcp.json` file follows a standardized format:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "shared-server": {
+ "command": "/path/to/server",
+ "args": [],
+ "env": {}
+ }
+ }
+ }
+
+For security reasons, Claude Code prompts for approval before using project-scoped servers from `.mcp.json` files. If you need to reset these approval choices, use the `claude mcp reset-project-choices` command.
+
+###
+
+
+
+User scope
+
+User-scoped servers are stored in `~/.claude.json` and provide cross-project accessibility, making them available across all projects on your machine while remaining private to your user account. This scope works well for personal utility servers, development tools, or services you frequently use across different projects.
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Add a user server
+ claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic
+
+###
+
+
+
+Choosing the right scope
+
+Select your scope based on:
+
+ * **Local scope** : Personal servers, experimental configurations, or sensitive credentials specific to one project
+ * **Project scope** : Team-shared servers, project-specific tools, or services required for collaboration
+ * **User scope** : Personal utilities needed across multiple projects, development tools, or frequently used services
+
+**Where are MCP servers stored?**
+
+ * **User and local scope** : `~/.claude.json` (in the `mcpServers` field or under project paths)
+ * **Project scope** : `.mcp.json` in your project root (checked into source control)
+ * **Managed** : `managed-mcp.json` in system directories (see Managed MCP configuration)
+
+###
+
+
+
+Scope hierarchy and precedence
+
+MCP server configurations follow a clear precedence hierarchy. When servers with the same name exist at multiple scopes, the system resolves conflicts by prioritizing local-scoped servers first, followed by project-scoped servers, and finally user-scoped servers. This design ensures that personal configurations can override shared ones when needed.
+
+###
+
+
+
+Environment variable expansion in `.mcp.json`
+
+Claude Code supports environment variable expansion in `.mcp.json` files, allowing teams to share configurations while maintaining flexibility for machine-specific paths and sensitive values like API keys. **Supported syntax:**
+
+ * `${VAR}` \- Expands to the value of environment variable `VAR`
+ * `${VAR:-default}` \- Expands to `VAR` if set, otherwise uses `default`
+
+**Expansion locations:** Environment variables can be expanded in:
+
+ * `command` \- The server executable path
+ * `args` \- Command-line arguments
+ * `env` \- Environment variables passed to the server
+ * `url` \- For HTTP server types
+ * `headers` \- For HTTP server authentication
+
+**Example with variable expansion:**
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "api-server": {
+ "type": "http",
+ "url": "${API_BASE_URL:-https://api.example.com}/mcp",
+ "headers": {
+ "Authorization": "Bearer ${API_KEY}"
+ }
+ }
+ }
+ }
+
+If a required environment variable is not set and has no default value, Claude Code will fail to parse the config.
+
+##
+
+
+
+Practical examples
+
+###
+
+
+
+Example: Monitor errors with Sentry
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
+
+Authenticate with your Sentry account:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp
+
+Then debug production issues:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ What are the most common errors in the last 24 hours?
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Show me the stack trace for error ID abc123
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Which deployment introduced these new errors?
+
+###
+
+
+
+Example: Connect to GitHub for code reviews
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add --transport http github https://api.githubcopilot.com/mcp/
+
+Authenticate if needed by selecting “Authenticate” for GitHub:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp
+
+Then work with GitHub:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Review PR #456 and suggest improvements
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Create a new issue for the bug we just found
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Show me all open PRs assigned to me
+
+###
+
+
+
+Example: Query your PostgreSQL database
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add --transport stdio db -- npx -y @bytebase/dbhub \
+ --dsn "postgresql://readonly:[[email protected]](</cdn-cgi/l/email-protection>):5432/analytics"
+
+Then query your database naturally:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ What's our total revenue this month?
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Show me the schema for the orders table
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Find customers who haven't made a purchase in 90 days
+
+##
+
+
+
+Authenticate with remote MCP servers
+
+Many cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections.
+
+1
+
+Add the server that requires authentication
+
+For example:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
+
+2
+
+Use the /mcp command within Claude Code
+
+In Claude code, use the command:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp
+
+Then follow the steps in your browser to login.
+
+Tips:
+
+ * Authentication tokens are stored securely and refreshed automatically
+ * Use “Clear authentication” in the `/mcp` menu to revoke access
+ * If your browser doesn’t open automatically, copy the provided URL and open it manually
+ * If the browser redirect fails with a connection error after authenticating, paste the full callback URL from your browser’s address bar into the URL prompt that appears in Claude Code
+ * OAuth authentication works with HTTP servers
+
+###
+
+
+
+Use a fixed OAuth callback port
+
+Some MCP servers require a specific redirect URI registered in advance. By default, Claude Code picks a random available port for the OAuth callback. Use `--callback-port` to fix the port so it matches a pre-registered redirect URI of the form `http://localhost:PORT/callback`. You can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Fixed callback port with dynamic client registration
+ claude mcp add --transport http \
+ --callback-port 8080 \
+ my-server https://mcp.example.com/mcp
+
+###
+
+
+
+Use pre-configured OAuth credentials
+
+Some MCP servers don’t support automatic OAuth setup via Dynamic Client Registration. If you see an error like “Incompatible auth server: does not support dynamic client registration,” the server requires pre-configured credentials. Claude Code also supports servers that use a Client ID Metadata Document (CIMD) instead of Dynamic Client Registration, and discovers these automatically. If automatic discovery fails, register an OAuth app through the server’s developer portal first, then provide the credentials when adding the server.
+
+1
+
+Register an OAuth app with the server
+
+Create an app through the server’s developer portal and note your client ID and client secret.Many servers also require a redirect URI. If so, choose a port and register a redirect URI in the format `http://localhost:PORT/callback`. Use that same port with `--callback-port` in the next step.
+
+2
+
+Add the server with your credentials
+
+Choose one of the following methods. The port used for `--callback-port` can be any available port. It just needs to match the redirect URI you registered in the previous step.
+
+ * claude mcp add
+
+ * claude mcp add-json
+
+ * claude mcp add-json (callback port only)
+
+ * CI / env var
+
+Use `--client-id` to pass your app’s client ID. The `--client-secret` flag prompts for the secret with masked input:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add --transport http \
+ --client-id your-client-id --client-secret --callback-port 8080 \
+ my-server https://mcp.example.com/mcp
+
+Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add-json my-server \
+ '{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"clientId":"your-client-id","callbackPort":8080}}' \
+ --client-secret
+
+Use `--callback-port` without a client ID to fix the port while using dynamic client registration:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp add-json my-server \
+ '{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"callbackPort":8080}}'
+
+Set the secret via environment variable to skip the interactive prompt:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \
+ --client-id your-client-id --client-secret --callback-port 8080 \
+ my-server https://mcp.example.com/mcp
+
+3
+
+Authenticate in Claude Code
+
+Run `/mcp` in Claude Code and follow the browser login flow.
+
+Tips:
+
+ * The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config
+ * If the server uses a public OAuth client with no secret, use only `--client-id` without `--client-secret`
+ * `--callback-port` can be used with or without `--client-id`
+ * These flags only apply to HTTP and SSE transports. They have no effect on stdio servers
+ * Use `claude mcp get <name>` to verify that OAuth credentials are configured for a server
+
+###
+
+
+
+Override OAuth metadata discovery
+
+If your MCP server returns errors on the standard OAuth metadata endpoint (`/.well-known/oauth-authorization-server`) but exposes a working OIDC endpoint, you can tell Claude Code to fetch OAuth metadata directly from a URL you specify, bypassing the standard discovery chain. Set `authServerMetadataUrl` in the `oauth` object of your server’s config in `.mcp.json`:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "my-server": {
+ "type": "http",
+ "url": "https://mcp.example.com/mcp",
+ "oauth": {
+ "authServerMetadataUrl": "https://auth.example.com/.well-known/openid-configuration"
+ }
+ }
+ }
+ }
+
+The URL must use `https://`. This option requires Claude Code v2.1.64 or later.
+
+##
+
+
+
+Add MCP servers from JSON configuration
+
+If you have a JSON configuration for an MCP server, you can add it directly:
+
+1
+
+Add an MCP server from JSON
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # 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"}}'
+
+ # Example: Adding a stdio server with JSON configuration
+ claude mcp add-json local-weather '{"type":"stdio","command":"/path/to/weather-cli","args":["--api-key","abc123"],"env":{"CACHE_DIR":"/tmp"}}'
+
+ # Example: Adding an HTTP server with pre-configured OAuth credentials
+ claude mcp add-json my-server '{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"clientId":"your-client-id","callbackPort":8080}}' --client-secret
+
+2
+
+Verify the server was added
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp get weather-api
+
+Tips:
+
+ * Make sure the JSON is properly escaped in your shell
+ * The JSON must conform to the MCP server configuration schema
+ * You can use `--scope user` to add the server to your user configuration instead of the project-specific one
+
+##
+
+
+
+Import MCP servers from Claude Desktop
+
+If you’ve already configured MCP servers in Claude Desktop, you can import them:
+
+1
+
+Import servers from Claude Desktop
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Basic syntax
+ claude mcp add-from-claude-desktop
+
+2
+
+Select which servers to import
+
+After running the command, you’ll see an interactive dialog that allows you to select which servers you want to import.
+
+3
+
+Verify the servers were imported
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ claude mcp list
+
+Tips:
+
+ * This feature only works on macOS and Windows Subsystem for Linux (WSL)
+ * It reads the Claude Desktop configuration file from its standard location on those platforms
+ * Use the `--scope user` flag to add servers to your user configuration
+ * Imported servers will have the same names as in Claude Desktop
+ * If servers with the same names already exist, they will get a numerical suffix (for example, `server_1`)
+
+##
+
+
+
+Use MCP servers from Claude.ai
+
+If you’ve logged into Claude Code with a [Claude.ai](<https://claude.ai>) account, MCP servers you’ve added in Claude.ai are automatically available in Claude Code:
+
+1
+
+Configure MCP servers in Claude.ai
+
+Add servers at [claude.ai/settings/connectors](<https://claude.ai/settings/connectors>). On Team and Enterprise plans, only admins can add servers.
+
+2
+
+Authenticate the MCP server
+
+Complete any required authentication steps in Claude.ai.
+
+3
+
+View and manage servers in Claude Code
+
+In Claude Code, use the command:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp
+
+Claude.ai servers appear in the list with indicators showing they come from Claude.ai.
+
+To disable claude.ai MCP servers in Claude Code, set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ ENABLE_CLAUDEAI_MCP_SERVERS=false claude
+
+##
+
+
+
+Use Claude Code as an MCP server
+
+You can use Claude Code itself as an MCP server that other applications can connect to:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Start Claude as a stdio MCP server
+ claude mcp serve
+
+You can use this in Claude Desktop by adding this configuration to claude_desktop_config.json:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "claude-code": {
+ "type": "stdio",
+ "command": "claude",
+ "args": ["mcp", "serve"],
+ "env": {}
+ }
+ }
+ }
+
+**Configuring the executable path** : The `command` field must reference the Claude Code executable. If the `claude` command is not in your system’s PATH, you’ll need to specify the full path to the executable.To find the full path:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ which claude
+
+Then use the full path in your configuration:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "claude-code": {
+ "type": "stdio",
+ "command": "/full/path/to/claude",
+ "args": ["mcp", "serve"],
+ "env": {}
+ }
+ }
+ }
+
+Without the correct executable path, you’ll encounter errors like `spawn claude ENOENT`.
+
+Tips:
+
+ * The server provides access to Claude’s tools like View, Edit, LS, etc.
+ * In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.
+ * Note that this MCP server is only exposing Claude Code’s tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
+
+##
+
+
+
+MCP output limits and warnings
+
+When MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:
+
+ * **Output warning threshold** : Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens
+ * **Configurable limit** : You can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable
+ * **Default limit** : The default maximum is 25,000 tokens
+
+To increase the limit for tools that produce large outputs:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Set a higher limit for MCP tool outputs
+ export MAX_MCP_OUTPUT_TOKENS=50000
+ claude
+
+This is particularly useful when working with MCP servers that:
+
+ * Query large datasets or databases
+ * Generate detailed reports or documentation
+ * Process extensive log files or debugging information
+
+If you frequently encounter output warnings with specific MCP servers, consider increasing the limit or configuring the server to paginate or filter its responses.
+
+##
+
+
+
+Respond to MCP elicitation requests
+
+MCP servers can request structured input from you mid-task using elicitation. When a server needs information it can’t get on its own, Claude Code displays an interactive dialog and passes your response back to the server. No configuration is required on your side: elicitation dialogs appear automatically when a server requests them. Servers can request input in two ways:
+
+ * **Form mode** : Claude Code shows a dialog with form fields defined by the server (for example, a username and password prompt). Fill in the fields and submit.
+ * **URL mode** : Claude Code opens a browser URL for authentication or approval. Complete the flow in the browser, then confirm in the CLI.
+
+To auto-respond to elicitation requests without showing a dialog, use the [`Elicitation` hook](</docs/en/hooks#elicitation>). If you’re building an MCP server that uses elicitation, see the [MCP elicitation specification](<https://modelcontextprotocol.io/docs/learn/client-concepts#elicitation>) for protocol details and schema examples.
+
+##
+
+
+
+Use MCP resources
+
+MCP servers can expose resources that you can reference using @ mentions, similar to how you reference files.
+
+###
+
+
+
+Reference MCP resources
+
+1
+
+List available resources
+
+Type `@` in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu.
+
+2
+
+Reference a specific resource
+
+Use the format `@server:protocol://resource/path` to reference a resource:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Can you analyze @github:issue://123 and suggest a fix?
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Please review the API documentation at @docs:file://api/authentication
+
+3
+
+Multiple resource references
+
+You can reference multiple resources in a single prompt:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ Compare @postgres:schema://users with @docs:file://database/user-model
+
+Tips:
+
+ * Resources are automatically fetched and included as attachments when referenced
+ * Resource paths are fuzzy-searchable in the @ mention autocomplete
+ * Claude Code automatically provides tools to list and read MCP resources when servers support them
+ * Resources can contain any type of content that the MCP server provides (text, JSON, structured data, etc.)
+
+##
+
+
+
+Scale with MCP Tool Search
+
+When you have many MCP servers configured, tool definitions can consume a significant portion of your context window. MCP Tool Search solves this by dynamically loading tools on-demand instead of preloading all of them.
+
+###
+
+
+
+How it works
+
+Claude Code automatically enables Tool Search when your MCP tool descriptions would consume more than 10% of the context window. You can adjust this threshold or disable tool search entirely. When triggered:
+
+ 1. MCP tools are deferred rather than loaded into context upfront
+ 2. Claude uses a search tool to discover relevant MCP tools when needed
+ 3. Only the tools Claude actually needs are loaded into context
+ 4. MCP tools continue to work exactly as before from your perspective
+
+###
+
+
+
+For MCP server authors
+
+If you’re building an MCP server, the server instructions field becomes more useful with Tool Search enabled. Server instructions help Claude understand when to search for your tools, similar to how [skills](</docs/en/skills>) work. Add clear, descriptive server instructions that explain:
+
+ * What category of tasks your tools handle
+ * When Claude should search for your tools
+ * Key capabilities your server provides
+
+###
+
+
+
+Configure tool search
+
+Tool search is enabled by default: MCP tools are deferred and discovered on demand. When `ANTHROPIC_BASE_URL` points to a non-first-party host, tool search is disabled by default because most proxies do not forward `tool_reference` blocks. Set `ENABLE_TOOL_SEARCH` explicitly if your proxy does. This feature requires models that support `tool_reference` blocks: Sonnet 4 and later, or Opus 4 and later. Haiku models do not support tool search. Control tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:
+
+Value| Behavior
+---|---
+(unset)| Enabled by default. Disabled when `ANTHROPIC_BASE_URL` is a non-first-party host
+`true`| Always enabled, including for non-first-party `ANTHROPIC_BASE_URL`
+`auto`| Activates when MCP tools exceed 10% of context
+`auto:<N>`| Activates at custom threshold, where `<N>` is a percentage (e.g., `auto:5` for 5%)
+`false`| Disabled, all MCP tools loaded upfront
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ # Use a custom 5% threshold
+ ENABLE_TOOL_SEARCH=auto:5 claude
+
+ # Disable tool search entirely
+ ENABLE_TOOL_SEARCH=false claude
+
+Or set the value in your [settings.json `env` field](</docs/en/settings#available-settings>). You can also disable the MCPSearch tool specifically using the `disallowedTools` setting:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "permissions": {
+ "deny": ["MCPSearch"]
+ }
+ }
+
+##
+
+
+
+Use MCP prompts as commands
+
+MCP servers can expose prompts that become available as commands in Claude Code.
+
+###
+
+
+
+Execute MCP prompts
+
+1
+
+Discover available prompts
+
+Type `/` to see all available commands, including those from MCP servers. MCP prompts appear with the format `/mcp__servername__promptname`.
+
+2
+
+Execute a prompt without arguments
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp__github__list_prs
+
+3
+
+Execute a prompt with arguments
+
+Many prompts accept arguments. Pass them space-separated after the command:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp__github__pr_review 456
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /mcp__jira__create_issue "Bug in login flow" high
+
+Tips:
+
+ * MCP prompts are dynamically discovered from connected servers
+ * Arguments are parsed based on the prompt’s defined parameters
+ * Prompt results are injected directly into the conversation
+ * Server and prompt names are normalized (spaces become underscores)
+
+##
+
+
+
+Managed MCP configuration
+
+For organizations that need centralized control over MCP servers, Claude Code supports two configuration options:
+
+ 1. **Exclusive control with`managed-mcp.json`**: Deploy a fixed set of MCP servers that users cannot modify or extend
+ 2. **Policy-based control with allowlists/denylists** : Allow users to add their own servers, but restrict which ones are permitted
+
+These options allow IT administrators to:
+
+ * **Control which MCP servers employees can access** : Deploy a standardized set of approved MCP servers across the organization
+ * **Prevent unauthorized MCP servers** : Restrict users from adding unapproved MCP servers
+ * **Disable MCP entirely** : Remove MCP functionality completely if needed
+
+###
+
+
+
+Option 1: Exclusive control with managed-mcp.json
+
+When you deploy a `managed-mcp.json` file, it takes **exclusive control** over all MCP servers. Users cannot add, modify, or use any MCP servers other than those defined in this file. This is the simplest approach for organizations that want complete control. System administrators deploy the configuration file to a system-wide directory:
+
+ * 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`
+
+These are system-wide paths (not user home directories like `~/Library/...`) that require administrator privileges. They are designed to be deployed by IT administrators.
+
+The `managed-mcp.json` file uses the same format as a standard `.mcp.json` file:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "mcpServers": {
+ "github": {
+ "type": "http",
+ "url": "https://api.githubcopilot.com/mcp/"
+ },
+ "sentry": {
+ "type": "http",
+ "url": "https://mcp.sentry.dev/mcp"
+ },
+ "company-internal": {
+ "type": "stdio",
+ "command": "/usr/local/bin/company-mcp-server",
+ "args": ["--config", "/etc/company/mcp-config.json"],
+ "env": {
+ "COMPANY_API_URL": "https://internal.company.com"
+ }
+ }
+ }
+ }
+
+###
+
+
+
+Option 2: Policy-based control with allowlists and denylists
+
+Instead of taking exclusive control, administrators can allow users to configure their own MCP servers while enforcing restrictions on which servers are permitted. This approach uses `allowedMcpServers` and `deniedMcpServers` in the [managed settings file](</docs/en/settings#settings-files>).
+
+**Choosing between options** : Use Option 1 (`managed-mcp.json`) when you want to deploy a fixed set of servers with no user customization. Use Option 2 (allowlists/denylists) when you want to allow users to add their own servers within policy constraints.
+
+####
+
+
+
+Restriction options
+
+Each entry in the allowlist or denylist can restrict servers in three ways:
+
+ 1. **By server name** (`serverName`): Matches the configured name of the server
+ 2. **By command** (`serverCommand`): Matches the exact command and arguments used to start stdio servers
+ 3. **By URL pattern** (`serverUrl`): Matches remote server URLs with wildcard support
+
+**Important** : Each entry must have exactly one of `serverName`, `serverCommand`, or `serverUrl`.
+
+####
+
+
+
+Example configuration
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "allowedMcpServers": [
+ // Allow by server name
+ { "serverName": "github" },
+ { "serverName": "sentry" },
+
+ // Allow by exact command (for stdio servers)
+ { "serverCommand": ["npx", "-y", "@modelcontextprotocol/server-filesystem"] },
+ { "serverCommand": ["python", "/usr/local/bin/approved-server.py"] },
+
+ // Allow by URL pattern (for remote servers)
+ { "serverUrl": "https://mcp.company.com/*" },
+ { "serverUrl": "https://*.internal.corp/*" }
+ ],
+ "deniedMcpServers": [
+ // Block by server name
+ { "serverName": "dangerous-server" },
+
+ // Block by exact command (for stdio servers)
+ { "serverCommand": ["npx", "-y", "unapproved-package"] },
+
+ // Block by URL pattern (for remote servers)
+ { "serverUrl": "https://*.untrusted.com/*" }
+ ]
+ }
+
+####
+
+
+
+How command-based restrictions work
+
+**Exact matching** :
+
+ * Command arrays must match **exactly** \- both the command and all arguments in the correct order
+ * Example: `["npx", "-y", "server"]` will NOT match `["npx", "server"]` or `["npx", "-y", "server", "--flag"]`
+
+**Stdio server behavior** :
+
+ * When the allowlist contains **any** `serverCommand` entries, stdio servers **must** match one of those commands
+ * Stdio servers cannot pass by name alone when command restrictions are present
+ * This ensures administrators can enforce which commands are allowed to run
+
+**Non-stdio server behavior** :
+
+ * Remote servers (HTTP, SSE, WebSocket) use URL-based matching when `serverUrl` entries exist in the allowlist
+ * If no URL entries exist, remote servers fall back to name-based matching
+ * Command restrictions do not apply to remote servers
+
+####
+
+
+
+How URL-based restrictions work
+
+URL patterns support wildcards using `*` to match any sequence of characters. This is useful for allowing entire domains or subdomains. **Wildcard examples** :
+
+ * `https://mcp.company.com/*` \- Allow all paths on a specific domain
+ * `https://*.example.com/*` \- Allow any subdomain of example.com
+ * `http://localhost:*/*` \- Allow any port on localhost
+
+**Remote server behavior** :
+
+ * When the allowlist contains **any** `serverUrl` entries, remote servers **must** match one of those URL patterns
+ * Remote servers cannot pass by name alone when URL restrictions are present
+ * This ensures administrators can enforce which remote endpoints are allowed
+
+Example: URL-only allowlist
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "allowedMcpServers": [
+ { "serverUrl": "https://mcp.company.com/*" },
+ { "serverUrl": "https://*.internal.corp/*" }
+ ]
+ }
+
+**Result** :
+
+ * HTTP server at `https://mcp.company.com/api`: ✅ Allowed (matches URL pattern)
+ * HTTP server at `https://api.internal.corp/mcp`: ✅ Allowed (matches wildcard subdomain)
+ * HTTP server at `https://external.com/mcp`: ❌ Blocked (doesn’t match any URL pattern)
+ * Stdio server with any command: ❌ Blocked (no name or command entries to match)
+
+Example: Command-only allowlist
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "allowedMcpServers": [
+ { "serverCommand": ["npx", "-y", "approved-package"] }
+ ]
+ }
+
+**Result** :
+
+ * Stdio server with `["npx", "-y", "approved-package"]`: ✅ Allowed (matches command)
+ * Stdio server with `["node", "server.js"]`: ❌ Blocked (doesn’t match command)
+ * HTTP server named “my-api”: ❌ Blocked (no name entries to match)
+
+Example: Mixed name and command allowlist
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "allowedMcpServers": [
+ { "serverName": "github" },
+ { "serverCommand": ["npx", "-y", "approved-package"] }
+ ]
+ }
+
+**Result** :
+
+ * Stdio server named “local-tool” with `["npx", "-y", "approved-package"]`: ✅ Allowed (matches command)
+ * Stdio server named “local-tool” with `["node", "server.js"]`: ❌ Blocked (command entries exist but doesn’t match)
+ * Stdio server named “github” with `["node", "server.js"]`: ❌ Blocked (stdio servers must match commands when command entries exist)
+ * HTTP server named “github”: ✅ Allowed (matches name)
+ * HTTP server named “other-api”: ❌ Blocked (name doesn’t match)
+
+Example: Name-only allowlist
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "allowedMcpServers": [
+ { "serverName": "github" },
+ { "serverName": "internal-tool" }
+ ]
+ }
+
+**Result** :
+
+ * Stdio server named “github” with any command: ✅ Allowed (no command restrictions)
+ * Stdio server named “internal-tool” with any command: ✅ Allowed (no command restrictions)
+ * HTTP server named “github”: ✅ Allowed (matches name)
+ * Any server named “other”: ❌ Blocked (name doesn’t match)
+
+####
+
+
+
+Allowlist behavior (`allowedMcpServers`)
+
+ * `undefined` (default): No restrictions - users can configure any MCP server
+ * Empty array `[]`: Complete lockdown - users cannot configure any MCP servers
+ * List of entries: Users can only configure servers that match by name, command, or URL pattern
+
+####
+
+
+
+Denylist behavior (`deniedMcpServers`)
+
+ * `undefined` (default): No servers are blocked
+ * Empty array `[]`: No servers are blocked
+ * List of entries: Specified servers are explicitly blocked across all scopes
+
+####
+
+
+
+Important notes
+
+ * **Option 1 and Option 2 can be combined** : If `managed-mcp.json` exists, it has exclusive control and users cannot add servers. Allowlists/denylists still apply to the managed servers themselves.
+ * **Denylist takes absolute precedence** : If a server matches a denylist entry (by name, command, or URL), it will be blocked even if it’s on the allowlist
+ * Name-based, command-based, and URL-based restrictions work together: a server passes if it matches **either** a name entry, a command entry, or a URL pattern (unless blocked by denylist)
+
+**When using`managed-mcp.json`**: Users cannot add MCP servers through `claude mcp add` or configuration files. The `allowedMcpServers` and `deniedMcpServers` settings still apply to filter which managed servers are actually loaded.