Connect to external tools with MCP changedagent-sdk/mcp
Nearest release: v2.1.335, published 8 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 3 Dec 2026 06:02 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 3 Dec 2026 06:07 UTC.
Upstream edited
Recorded here
Lines+18added
Lines−21removed
From line
138
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits29to this page, all time
The whole hunk
from line 138, old and new numbered
/
from line 138
138138
139139## Connection timing
140140
141Claude Code starts connecting your MCP servers when the session starts, and sends the [init message](#error-handling) 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.
141Your MCP servers start connecting when the session starts, and the first turn waits for some of them so Claude can use their tools right away.
142142
143For a server in `options.mcpServers`, find its type in the first column to see how long the first turn waits for it.
143The following table shows how long the first turn waits for servers from `options.mcpServers`, plugins, and settings files:
144144
145| Server type | Delays the first turn? | First-turn wait timeout |
146| :- | :- | :- |
147| stdio server, or HTTP/SSE server without a cached tool list | Yes, until it connects | [`MCP_TIMEOUT`](https://code.claude.com/docs/en/env-vars), 30 seconds by default; the connection fails at that deadline |
148| 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 |
149| In-process [SDK server](#sdk-mcp-servers) | Yes, until it connects and lists its tools | [`MCP_TIMEOUT`](https://code.claude.com/docs/en/env-vars), 30 seconds by default, per connect attempt; the connection fails at that deadline |
145| Server | How long the first turn waits |
146| :- | :- |
147| HTTP or SSE server with a [cached tool list](https://code.claude.com/docs/en/mcp.md#server-status-detail) | No wait. The first turn starts with the cached tools, and the server connects on its first tool call |
148| Any other server that provides your [`permissionPromptToolName`](https://code.claude.com/docs/en/agent-sdk/typescript#options) tool | Up to the [`MCP_TIMEOUT`](https://code.claude.com/docs/en/env-vars) value, 30 seconds by default |
149| Any other stdio, HTTP, or SSE server in `options.mcpServers` | Until the server connects or fails. The connection [times out](#connection-timeouts) after `MCP_TIMEOUT` |
150| In-process [SDK server](#sdk-mcp-servers) in `options.mcpServers` | Until the server connects and lists its tools. Each connect attempt times out after `MCP_TIMEOUT` |
151| Any other server from a plugin or a [settings file](#from-a-config-file) such as `.mcp.json`, when `options.mcpServers` has a stdio, HTTP, or SSE server | Up to `MCP_TIMEOUT` |
152| Any other server from a plugin or a settings file, when you turn [tool search](https://code.claude.com/docs/en/agent-sdk/tool-search.md#configure-tool-search) off, your model lacks it, or you set `ANTHROPIC_BASE_URL` to a [gateway](https://code.claude.com/docs/en/mcp.md#tool-search-through-a-gateway) and leave `ENABLE_TOOL_SEARCH` unset | Up to 2 seconds |
153| Any other server from a plugin or a settings file | Up to 2 seconds for a [named server](#named-servers) or one that sets [`alwaysLoad: true`](#make-startup-wait-for-servers), and no wait for other servers |
150154
151A server has a cached tool list only when the [MCP discovery cache](https://code.claude.com/docs/en/mcp.md#server-status-detail) is on.
155A server that's still connecting when the first turn starts shows a `pending` status in the [init message](#error-handling). It keeps connecting in the background, and Claude can [use the server's tools](https://code.claude.com/docs/en/mcp.md#tool-availability) once it connects.
152156
153Servers from [settings files](#from-a-config-file) 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:
154
155* **`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`.
156* **Otherwise, when `ANTHROPIC_BASE_URL` points to a [gateway](https://code.claude.com/docs/en/mcp.md#tool-search-through-a-gateway) and [`ENABLE_TOOL_SEARCH`](https://code.claude.com/docs/en/mcp#configure-tool-search) is unset**: the first turn waits up to 2 seconds for every pending settings-file and plugin server.
157* **Otherwise, with [tool search](https://code.claude.com/docs/en/agent-sdk/tool-search.md) on, which is the default**: the first turn waits up to 2 seconds, and only for pending servers that set [`alwaysLoad: true`](https://code.claude.com/docs/en/mcp#exempt-a-server-from-deferral) or that you [named](#named-servers). The rest keep connecting in the background, and Claude [reaches their tools](https://code.claude.com/docs/en/mcp.md#tool-availability) once they connect.
158* **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](https://code.claude.com/docs/en/agent-sdk/tool-search#configure-tool-search) turns it off, or when you exclude the `ToolSearch` tool, for example through `disallowedTools`.
159
160157### Named servers
161158
162159You name a server by listing any of its tools, such as `mcp__github__list_issues` or `mcp__github__*`, in [`allowedTools`](#allow-mcp-tools) or in a `permissions.allow` rule in the `settings` option. An [`mcp_tool` hook](https://code.claude.com/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.
from line 160
163160
164161### Set the first-turn wait yourself
165162
166To choose the first-turn wait yourself, set `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` in the [`env` option](https://code.claude.com/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`.
163To lengthen or shorten the first-turn wait, set the `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` environment variable in the [`env` option](https://code.claude.com/docs/en/agent-sdk/configuration#set-environment-variables), for example `CLAUDE_CODE_MCP_STARTUP_WAIT_MS: "5000"`. Requires Claude Code v2.1.274 or later.
167164
165The first turn then waits up to that many milliseconds for stdio, HTTP, and SSE servers that are still connecting, wherever you configured them. Set the variable to `0` to skip that wait.
166
168167Three waits apply whatever value you set, including `0`:
169168
170169* **A `permissionPromptToolName` server**: up to `MCP_TIMEOUT`.
171170* **An in-process [SDK server](#sdk-mcp-servers)**: up to `MCP_TIMEOUT` per connect attempt.
172171* **A still-connecting [named server](#named-servers)**: at least up to 2 seconds, so a value below `2000` doesn't shorten its wait.
173
174Set 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.
175172
176173### Make startup wait for servers
177174
No line in this hunk matches that.