CLAUDE_CODE_MCP_TOOL_DISCOVERY
Updated by Alex Sorokoletov
CLAUDE_CODE_MCP_TOOL_DISCOVERY is a Claude Code environment variable: Controls MCP tool discovery. When on, a qualifying MCP server's tools are routed through tool-search rather than loaded; it applies to stdio, SSE, HTTP, and WebSocket servers that are not marked always-load. When unset, a default decides. Added in v2.1.333 and still present in v2.1.333. It is not in the official reference.
| Status | Present in v2.1.333 |
|---|---|
| Added | Added in v2.1.333 |
| Category | MCP |
| Official docs | Not listed |
How to set it
For one session, export it in the shell that starts Claude Code:
export CLAUDE_CODE_MCP_TOOL_DISCOVERY=<value>
claudeTo apply it to every session, add it to the env object of a settings file:
// ~/.claude/settings.json
{
"env": {
"CLAUDE_CODE_MCP_TOOL_DISCOVERY": "<value>"
}
}Release notes that mention it
- Claude Code Version Tracker: Undocumented Env Vars, Feature Gates & Models
- claude-code-env-vars-v2-1-333
Related variables
CLAUDE_CODE_MCP_APPS_NO_TOOL_ROUTE: When true, adds the header X-MCP-Features set to mcp_apps_disable_form_deferral on MCP server requests that do not already send that header.CLAUDE_CODE_MCP_SERVE_TOOL_OUTPUT: When true, enables the experimental MCP serve tool-output path, which validates and attaches tool deny rules; off otherwise.MCP_DISCOVERY_CACHEMCP_DISCOVERY_CACHE_MAX_STALE_SMCP_DISCOVERY_CACHE_STRIKES: Overrides the strike count that governs the MCP discovery cache (used with MCP_DISCOVERY_CACHE_TTL_S and MCP_DISCOVERY_CACHE_MAX_STALE_S).MCP_DISCOVERY_CACHE_TTL_SCLAUDE_CODE_WEBFETCH_MCP_TOOLCLAUDE_CODE_ARTIFACT_MCP: Enables MCP runtime-capability support for artifacts; on by default.
Frequently asked questions
What does CLAUDE_CODE_MCP_TOOL_DISCOVERY do?
Controls MCP tool discovery. When on, a qualifying MCP server's tools are routed through tool-search rather than loaded; it applies to stdio, SSE, HTTP, and WebSocket servers that are not marked always-load. When unset, a default decides.
Which Claude Code version has CLAUDE_CODE_MCP_TOOL_DISCOVERY?
Added in v2.1.333 and still present in v2.1.333.
How do I set CLAUDE_CODE_MCP_TOOL_DISCOVERY?
Export it before starting Claude Code (export CLAUDE_CODE_MCP_TOOL_DISCOVERY=value), or add it to the "env" object in ~/.claude/settings.json to apply it to every session.
All variables, searchable: Claude Code environment variables.