MCP Env Vars
These env vars change how Claude Code starts, times out, and limits MCP servers.
Set them in the shell or in the env key of a settings file.
For example, MCP_TIMEOUT=30000 gives a server 30 seconds to start.
Export the variable, or add it to env in a settings file. Some are switches, such as ENABLE_CLAUDEAI_MCP_SERVERS and MCP_CONNECTION_NONBLOCKING.
Documented Variables
Source: Connect Claude Code to Tools via MCP, Environment Variables, and Settings Reference. All env vars of Claude Code are listed on Plugin and MCP Env Vars and the other env var pages.
| Variable | Status | What It Does | How It Works |
|---|---|---|---|
MCP_ | Documented | Startup timeout of one server. | Milliseconds. Default 30000. |
MCP_ | Documented | Timeout of one tool call. | Milliseconds. Default 100000000 (about 28 hours). Values below 1000 become 1 s. The per-server timeout wins. Remote servers also have a 60 s per-request timer. |
CLAUDE_ | Documented | Idle timeout of a call. | Milliseconds. Defaults: 300000 (remote) and 1800000 (stdio). 0 turns it off. |
MCP_ | Documented | Wait during blocking startup. | Milliseconds. Default 5000. Applies with MCP_ or always. |
MCP_ | Documented | Sets whether startup waits for servers. | Startup does not wait by default. 0 waits for servers before the first query. always servers still wait. |
MCP_ | Documented | Sets how many local servers connect at once. | Default 3 (stdio). |
MCP_ | Documented | Sets how many remote servers connect at once. | Default 20 (http, sse). |
CLAUDE_ | Documented | Sets the first-turn wait in non-interactive mode. | Milliseconds. 0 skips the wait. 2. and later. |
MAX_ | Documented | Token limit of a result. | Default 25000. The warning at 10000 is fixed. |
CLAUDE_ | Documented | Length limit of descriptions and instructions. | Replaces both defaults (4096 and 16384). 2. and later. |
CLAUDE_ | Documented | Delay before a call moves to the background. | Default 120000. 0 turns it off. 2. and later. |
CLAUDE_ | Documented | Turns off all background tasks. | 1 also turns off MCP auto background. |
CLAUDE_ | Documented | Allows auto background in -. | Set to 1. |
CLAUDE_ | Documented | Gives stdio servers a minimal env. | 1 gives only a safe baseline plus the server env. |
ENABLE_ | Documented | Sets the tool search mode. | Not set, true, auto, auto:, or false. See MCP Runtime. |
CLAUDE_ | Documented | Strips beta fields. | Keeps tool search off. Managed settings can keep it on (2. and later). |
ENABLE_ | Documented | Controls the fetch of connectors. | false stops the fetch. |
MCP_ | Documented | Turns the discovery cache on or off. | 1 on, 0 off. Off by default unless a rollout enables it. |
MCP_ | Documented | Sets entry age without a refresh. | Default 900. |
MCP_ | Documented | Sets the maximum entry age. | Default 14400, capped at 7 days. |
MCP_ | Documented | Sets failed refreshes before an entry is discarded. | Default 1. |
MCP_ | Documented | Pins the client runtime. | v1 or v2. Read once per process. 2. and later. |
MCP_ | Documented | Probes for revision 2026-07-28. | auto or legacy. v2 runtime only. |
MCP_ | Documented | Gives the OAuth client secret. | Skips the prompt of --. |
MCP_ | Documented | Fixes the OAuth callback port. | Same as --. |
CLAUDE_ | Documented | Drops the name prefix. | 1 skips mcp__ for SDK servers. |
CLAUDE_ | Documented | Gives the path of the delivered server file. | Read in remote sessions as a copy of -- with scope dynamic. |
Variables Claude Code Sets for Servers
Claude Code puts these in the env of a stdio server or a headersHelper.
| Variable | Status | What It Does | How It Works |
|---|---|---|---|
CLAUDE_ | Documented | Gives the project root. | Set in a stdio server env. |
CLAUDE_, CLAUDECODE | Documented | Mark the session. | Set for stdio servers. The session ID stays as it was at spawn. |
CLAUDE_ | Documented | Strips credentials. | Also applies to stdio servers. You set it. |
CLAUDE_, CLAUDE_ | Documented | Tell a headers the server. | Set for the helper only. |
Undocumented Variables
Only the program shows these. They can change without notice.
| Variable | Status | What It Does | How It Works |
|---|---|---|---|
ENABLE_ | Undocumented | Switch for result files. | false truncates instead of saving a file. |
CLAUDE_ | Undocumented | Declares MCP Apps support. | true adds the io. extension to the client capabilities. |
CLAUDE_ | Undocumented | Skips local plugin servers. | Only sse, http, and ws servers load while it is set. |
CLAUDE_ | Undocumented | Skips MCPB sources of plugins. | The log says Skipping MCPB source. |
CLAUDE_ | Undocumented | Skips plugin servers. | The log says (CLAUDE_. |
CLAUDE_ | Undocumented | Exempts plugin servers from the skip. | The log says exempted via. |
CLAUDE_ | Undocumented | Adds a refresh tool. | Adds one more tool to the tool list when set. |
MCP_ | Undocumented | Picks the truncation prompt. | legacy selects the old prompt. Any other value selects the new one. Not set follows a flag. |
MCP_ | Undocumented | Overrides the CIMD URL. | Used as the OAuth client metadata URL. |
CLAUDE_ | Undocumented | Timeout of the plugin MCP sync. | Default 10000 ms. |
CLAUDE_ | Undocumented | First-turn wait for connectors. | Used with an sdk session. Capped at 2147483647. |
CLAUDE_, CLAUDE_ | Undocumented | Name servers to wait for. | Read for a remote worker. |
CLAUDE_ | Undocumented | Sets the memory cap class of MCP processes. | Linked to the Linux tool memory cap. none is accepted. |
CLAUDE_ | Undocumented | Lists MCP tool names. | Comma-separated. A turn that ends with these tool results is checked. |
CLAUDE_ | Undocumented | Stops SDK manifest capture. | Sets capture to false. |
CLAUDE_ | Undocumented | Marks a bridge MCP carrier. | 1 means child. Another value means descendant. |
CLAUDE_ | Gated | Turns XAA on. | 1. See MCP Authentication. |
MCP_ | Gated | Gives the IdP client secret for XAA. | Read by claude mcp xaa setup --. |
Example
Slow server, big results, no connector fetch
export MCP_TIMEOUT=60000
export MCP_TOOL_TIMEOUT=300000
export MAX_MCP_OUTPUT_TOKENS=50000
export ENABLE_CLAUDEAI_MCP_SERVERS=false
claude
The same in settings
{ "env": { "MCP_TIMEOUT": "60000", "MAX_MCP_OUTPUT_TOKENS": "50000" } }
How It Works
Related Pages
- MCP Runtime
- MCP Authentication
- Plugin Loading for plugin env vars