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
Each name links to its row on the env var pages, which hold the status, the values, the defaults, and the notes. Source: Connect Claude Code to Tools via MCP, Environment Variables, and Settings Reference. Plugin and MCP Env Vars and the other env var pages list all env vars of Claude Code.
MCP_TIMEOUT: Startup timeout of one server.MCP_TOOL_TIMEOUT: Timeout of one tool call.CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT: Idle timeout of a call.MCP_CONNECT_TIMEOUT_MS: Wait during blocking startup.MCP_CONNECTION_NONBLOCKING: Sets whether startup waits for servers.MCP_SERVER_CONNECTION_BATCH_SIZE: Sets how many local servers connect at once.MCP_REMOTE_SERVER_CONNECTION_BATCH_SIZE: Sets how many remote servers connect at once.CLAUDE_CODE_MCP_STARTUP_WAIT_MS: Sets the first-turn wait in non-interactive mode.MAX_MCP_OUTPUT_TOKENS: Token limit of a result.CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH: Length limit of descriptions and instructions.CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS: Delay before a call moves to the background.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: Turns off all background tasks.CLAUDE_AUTO_BACKGROUND_TASKS: Allows auto background in-p.CLAUDE_CODE_MCP_ALLOWLIST_ENV: Gives stdio servers a minimal env.ENABLE_TOOL_SEARCH: Sets the tool search mode. See MCP Runtime.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: Strips beta fields.ENABLE_CLAUDEAI_MCP_SERVERS: Controls the fetch of connectors.MCP_DISCOVERY_CACHE: Turns the discovery cache on or off.MCP_DISCOVERY_CACHE_TTL_S: Sets entry age without a refresh.MCP_DISCOVERY_CACHE_MAX_STALE_S: Sets the maximum entry age.MCP_DISCOVERY_CACHE_STRIKES: Sets failed refreshes before Claude Code discards an entry.MCP_SDK_GENERATION: Pins the client runtime.MCP_PROTOCOL_NEGOTIATION: Probes for revision 2026-07-28.MCP_CLIENT_SECRET: Gives the OAuth client secret.MCP_OAUTH_CALLBACK_PORT: Fixes the OAuth callback port.CLAUDE_AGENT_SDK_MCP_NO_PREFIX: Drops the name prefix.CLAUDE_CODE_REMOTE_MCP_CONFIG: Gives the path of the delivered server file.
Variables Claude Code Sets for Servers
Claude Code puts these in the env of a stdio server or a headersHelper.
CLAUDE_PROJECT_DIR: Gives the project root.CLAUDE_CODE_SESSION_ID,CLAUDECODE: Mark the session.CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: Strips credentials.CLAUDE_CODE_MCP_SERVER_NAME,CLAUDE_CODE_MCP_SERVER_URL: Tell aheadersHelperthe server.
Undocumented Variables
Only the program shows these. They can change without notice.
ENABLE_MCP_LARGE_OUTPUT_FILES: Switch for result files.CLAUDE_CODE_MCP_APPS_HOST: Declares MCP Apps support.CLAUDE_CODE_SKIP_PLUGIN_LOCAL_MCP_SERVERS: Skips local plugin servers.CLAUDE_CODE_SKIP_PLUGIN_MCP_BUNDLES: Skips MCPB sources of plugins.CLAUDE_CODE_SKIP_PLUGIN_MCP_SERVERS: Skips plugin servers.CLAUDE_CODE_SKIP_PLUGIN_MCP_SERVERS_EXCEPT: Exempts plugin servers from the skip.CLAUDE_CODE_ENABLE_REFRESH_MCP_TOOLS: Adds a refresh tool.MCP_TRUNCATION_PROMPT_OVERRIDE: Picks the truncation prompt.MCP_OAUTH_CLIENT_METADATA_URL: Overrides the CIMD URL.CLAUDE_CODE_SYNC_PLUGINS_MCP_TIMEOUT_MS: Timeout of the plugin MCP sync.CLAUDE_CODE_MCP_CONNECTOR_PREWAIT_MS: First-turn wait for connectors.CLAUDE_CODE_MCP_PREWAIT_SERVERS,CLAUDE_CODE_MCP_PREWAIT_SERVERS_MS: Name servers to wait for.CLAUDE_CODE_MCP_MEMORY_CGROUP: Sets the memory cap class of MCP processes.CLAUDE_CODE_TERMINAL_MCP_TOOLS: Lists MCP tool names.CLAUDE_AGENT_SDK_DISABLE_MCP_MANIFESTS: Stops SDK manifest capture.CLAUDE_CODE_BRIDGE_MCP_CARRIER: Marks a bridge MCP carrier.CLAUDE_CODE_ENABLE_XAA: Turns XAA on. See MCP Authentication.MCP_XAA_IDP_CLIENT_SECRET: Gives the IdP client secret for XAA.
Example
export MCP_TIMEOUT=60000
export MCP_TOOL_TIMEOUT=300000
export MAX_MCP_OUTPUT_TOKENS=50000
export ENABLE_CLAUDEAI_MCP_SERVERS=false
claude
{ "env": { "MCP_TIMEOUT": "60000", "MAX_MCP_OUTPUT_TOKENS": "50000" } }
How It Works
Related Pages
- MCP Runtime
- MCP Authentication
- Plugin Loading for plugin env vars