{"parentUuid":null,"isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":"I'm registering a local stdio MCP server for Claude Code (CLI) programmatically by writing config files (not via `claude mcp add`). Constraints: CLAUDE_CONFIG_DIR is set to a per-\"pool\" directory; I want the MCP server available to ALL projects that run with that CLAUDE_CONFIG_DIR, and I want its single tool pre-approved so no permission prompt appears. The server is launched as `/abs/path/to/app --mcp-panel` (a stdio JSON-RPC server), server name `aicontrol`, tool name `write_panel`.\n\nAnswer precisely, with exact file paths, JSON keys, and current syntax:\n\n1. To register a stdio MCP server at USER/GLOBAL scope by writing a file (so it applies to every project), what exact file and JSON structure do I write? Is it `$CLAUDE_CONFIG_DIR/settings.json` with an `mcpServers` key, or a separate file (e.g. `~/.claude.json`, or `.mcp.json`)? Does Claude Code read `mcpServers` from settings.json, or only from `.mcp.json` / the `claude mcp add` store? Give the exact JSON snippet for a stdio server with `command` and `args`.\n\n2. If the server is defined in a project `.mcp.json`, does it require `enabledMcpjsonServers` (or an approval) in settings to be trusted/auto-enabled without an interactive \"trust this MCP server?\" prompt? What's the exact key/value to auto-approve it?\n\n3. What is the EXACT `permissions.allow` string to pre-authorize calling the tool without a prompt? Confirm the name-mangling: server `aicontrol` + tool `write_panel` → is it `mcp__aicontrol__write_panel`? Can I also allow all tools of the server with `mcp__aicontrol`?\n\n4. Does the stdio MCP server child process inherit the environment of the `claude` process (I need an env var `AI_CONTROL_PANEL` that claude has to be visible to the server)? Any config needed to pass env through, or is it inherited by default? Can I also set `env` in the server config?\n\n5. Anything that differs by Claude Code version worth noting.\n\nBe concrete — I'm writing these files from Rust, so I need the exact schema."},"uuid":"5a7d465a-6844-4b8a-900d-11958a629a22","timestamp":"2026-07-11T09:37:39.270Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"5a7d465a-6844-4b8a-900d-11958a629a22","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3bxVoaxDEJ6G9weUKE","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"EuMJCpMBCA8YAipAcWlBmcsMMWiIEvYtV16CWmTQc7+1tAQd14BduT26CfU9Sk1SLUmJm3+Ese0SRGzq1JPVnrfjVPPNUSWQdGEZaDIZY2xhdWRlLWhhaWt1LTQtNS0yMDI1MTAwMTgAQgh0aGlua2luZ1okNGJkZDE1Y2MtNDcxZS00ZTU2LWJhMWEtM2QzZDViNGYwMTdjEgxNT0OwkFnucocJeTUaDJrSWwS0qIudgkK2OyIwLonSEH/GQSyrqJeh/SRdab2yX9yG272W1uac0KhdIh0EOFXnEyqmXIdhTXhjwgGHKvwHw3I8ZPkf9iZl7k8GGojNVB+Ggyimve5onkYAVZfJwxJVvS5sfn3ta5peMKZ3Cb899VLm54PGy9s5ED4FTqFGbfdfZLEpl0KEA3jbcyvivxSLZ6QxCPsuH46vLHotmZKNtl6NPOyDtdhp16X3WB4IiqR9qylhD4wOYzTrbNme7AdAghL8Xynys320SOGupcVHlmf/kp9t2WQWtUf+UcOg2tuBHJjSvxjWYfkLNJsW4D31vi0SJluW3R6aJwY/G1oLjkys5qLMWMBtlrKVzyuhzhO/6OS1jLpOaRzlRyr8A+X2pnoBk3toY0khQk0T+LtgfjuO32VLH3RgkXpy+uE7xbCDGyVDUorbh7/CAbX6zzqzXpE0aO99b144ep6Kj+/lcb5RO8DCvxDYBg+pbST3hNmlvc7a4QrnrREq7rUX6Z1KyaD2xv3w+dPnerws9tcJUWIO/P314UrN4edEMc76DwK/VYC3otPkxcdqLIjen07APvq0HX+ghYC6GjNBkus5ukpve54/7Ux94yJH3EF8rkTMvvWIh/3uZ/iPI78JEhZf43ueirkgJ5FLJ0ibLS+TubhKX++DVzzRyHTw2sENXtSlKTCg2Lr9T/o41XM6NhqCckovKb1fJ8kuhri8whPkI6HYpOg+WbUVfc/gI6BINW6d0llNniPfvbiXPTL3e7PlSB0yVPGvmewmfld2aDznhKaNpZiOZ94Z6NdTxIQcZFdmC8n9jYbL0YUqvStzSAOFniH34ICcqpQuiQXTdJSeWdNRp1zpwZeZopfD0i4oLIqmxOgRWbSGG9vRVOoRF7sQBICwMJMihAfCIX9wj6KDoaTcL7NW7DV5JqxHbGLy6QHCDfMznoVncJdJNp/CewGXLaS53FYbIF7lUtfZGOPx/yK/vS8ZKzrlYbCq3JNIWV9dnlS1XSnU2+/K/qB3ceNcXNzpymWzCFEG0roCnQGnFDvvjjCIfa2UIhyxNNjiTWH3EAqtDyYx/WkEFyu0Z+iSM0L2xAE7Kihr9uRPz1L6EouPExccnL6yllqAvxvprXx8iE0F896OXVjs5qf19/8/2cb47PSvRE7UBg43TP/5cbLLET5+4xRrfqY2DU8Fqs1hBHC2hs81NmhaBf3QhnqvDOCUy3JqWGduKxF6PrSplUSJeW/g7DSFlXzPtzaHTGOxPLJYBjAiWbeOdDHImpby+okV/ifGP0xwCfOb8oJFhmrpDigFfyaFCcoFYse4M2Vm6C2LEaHqV0mlgHvET0hmaPecnx7wB5cvBddcr3MAbITIJ8/T5t2FEK7aICnnew+nDdl6nq8RFHUDmwZq3D4b3S52P3IFbbw8u+58euTs2TowuZqsKrhM0emwGAE="}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":10,"cache_creation_input_tokens":13543,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":13543,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3bwiBUJB1bLEQbzG6H","attributionAgent":"claude-code-guide","type":"assistant","uuid":"9e28aeba-e005-46ec-a694-50ba74129098","timestamp":"2026-07-11T09:37:42.930Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"9e28aeba-e005-46ec-a694-50ba74129098","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3bxVoaxDEJ6G9weUKE","type":"message","role":"assistant","content":[{"type":"text","text":"I'll fetch the Claude Code documentation to get the exact current schema for MCP server registration and permissions."}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":10,"cache_creation_input_tokens":13543,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":13543,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3bwiBUJB1bLEQbzG6H","attributionAgent":"claude-code-guide","type":"assistant","uuid":"9cc82caf-88d5-43fa-a5de-5311fa6c3198","timestamp":"2026-07-11T09:37:43.386Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"9cc82caf-88d5-43fa-a5de-5311fa6c3198","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3bxVoaxDEJ6G9weUKE","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_016vBhZH2Fv1yajutgvEDBg3","name":"WebFetch","input":{"url":"https://code.claude.com/docs/en/claude_code_docs_map.md","prompt":"MCP server configuration, stdio server, .mcp.json, settings.json, registration"},"caller":{"type":"direct"}}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":10,"cache_creation_input_tokens":13543,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":13543,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3bwiBUJB1bLEQbzG6H","attributionAgent":"claude-code-guide","type":"assistant","uuid":"f7bd189c-ad93-4455-a892-6aa9e2006d05","timestamp":"2026-07-11T09:37:44.300Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"f7bd189c-ad93-4455-a892-6aa9e2006d05","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3bxVoaxDEJ6G9weUKE","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_01BodXK4hRK9wTQMTffYCrew","name":"WebFetch","input":{"url":"https://code.claude.com/docs/en/getting-started/mcp-servers.md","prompt":"stdio MCP server registration JSON structure settings.json .mcp.json"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":10,"cache_creation_input_tokens":13543,"cache_read_input_tokens":0,"output_tokens":436,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":13543},"inference_geo":"not_available","iterations":[{"input_tokens":10,"output_tokens":436,"cache_read_input_tokens":0,"cache_creation_input_tokens":13543,"cache_creation":{"ephemeral_5m_input_tokens":13543,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3bwiBUJB1bLEQbzG6H","attributionAgent":"claude-code-guide","type":"assistant","uuid":"f3f5335c-f42e-4880-8a8f-1110e38b5b5e","timestamp":"2026-07-11T09:37:44.887Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"f7bd189c-ad93-4455-a892-6aa9e2006d05","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_016vBhZH2Fv1yajutgvEDBg3","type":"tool_result","content":"<persisted-output>\nOutput too large (96.9KB). Full output saved to: /Users/marcus.hinz/.config/ai-control/pools/private/projects/-Users-marcus-hinz-claude-projects-ai-control/f7704328-4eb4-4f0f-bf42-da68abab401d/tool-results/toolu_016vBhZH2Fv1yajutgvEDBg3.txt\n\nPreview (first 2KB):\n> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Claude code docs map\n\n# Claude Code Documentation Map\n\nThis is a comprehensive map of all Claude Code documentation pages with their headings, designed for easy navigation by LLMs.\n\n> **Note:** This file is auto-generated by GitHub Actions. Do not edit manually.\n> Last updated: 2026-07-11 03:53:52 UTC\n\n## Document Structure\n\nThis map uses a hierarchical structure:\n\n* **##** marks documentation groups (e.g., 'Getting started')\n* **###** marks individual documentation pages\n* **Nested bullets** show the heading structure within each page\n* Each page title links to the full documentation\n\n## Getting started\n\n### [overview](https://code.claude.com/docs/en/overview.md)\n\n* Get started\n* What you can do\n* Use Claude Code everywhere\n* Next steps\n\n### [quickstart](https://code.claude.com/docs/en/quickstart.md)\n\n* Before you begin\n* Step 1: Install Claude Code\n* Step 2: Log in to your account\n* Step 3: Start your first session\n* Step 4: Ask your first question\n* Step 5: Make your first code change\n* Step 6: Use Git with Claude Code\n* Step 7: Fix a bug or add a feature\n* Step 8: Test out other common workflows\n* Essential commands\n* Pro tips for beginners\n* What's next?\n* Getting help\n\n### [changelog](https://code.claude.com/docs/en/changelog.md)\n\n* (No headings found)\n\n## Core concepts\n\n### [how-claude-code-works](https://code.claude.com/docs/en/how-claude-code-works.md)\n\n* The agentic loop\n  * Models\n  * Tools\n* What Claude can access\n* Environments and interfaces\n  * Execution environments\n  * Interfaces\n* Work with sessions\n  * Work across branches\n  * Resume or fork sessions\n  * The context window\n    * When context fills up\n    * Manage context with skills and subagents\n* Stay safe with checkpoints and permissions\n  * Undo changes with checkpoints\n  * Control what Claude can do\n...\n</persisted-output>"}]},"uuid":"7f399b5c-e560-4ded-abfa-013951805850","timestamp":"2026-07-11T09:37:44.985Z","toolUseResult":{"bytes":99186,"code":200,"codeText":"OK","result":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Claude code docs map\n\n# Claude Code Documentation Map\n\nThis is a comprehensive map of all Claude Code documentation pages with their headings, designed for easy navigation by LLMs.\n\n> **Note:** This file is auto-generated by GitHub Actions. Do not edit manually.\n> Last updated: 2026-07-11 03:53:52 UTC\n\n## Document Structure\n\nThis map uses a hierarchical structure:\n\n* **##** marks documentation groups (e.g., 'Getting started')\n* **###** marks individual documentation pages\n* **Nested bullets** show the heading structure within each page\n* Each page title links to the full documentation\n\n## Getting started\n\n### [overview](https://code.claude.com/docs/en/overview.md)\n\n* Get started\n* What you can do\n* Use Claude Code everywhere\n* Next steps\n\n### [quickstart](https://code.claude.com/docs/en/quickstart.md)\n\n* Before you begin\n* Step 1: Install Claude Code\n* Step 2: Log in to your account\n* Step 3: Start your first session\n* Step 4: Ask your first question\n* Step 5: Make your first code change\n* Step 6: Use Git with Claude Code\n* Step 7: Fix a bug or add a feature\n* Step 8: Test out other common workflows\n* Essential commands\n* Pro tips for beginners\n* What's next?\n* Getting help\n\n### [changelog](https://code.claude.com/docs/en/changelog.md)\n\n* (No headings found)\n\n## Core concepts\n\n### [how-claude-code-works](https://code.claude.com/docs/en/how-claude-code-works.md)\n\n* The agentic loop\n  * Models\n  * Tools\n* What Claude can access\n* Environments and interfaces\n  * Execution environments\n  * Interfaces\n* Work with sessions\n  * Work across branches\n  * Resume or fork sessions\n  * The context window\n    * When context fills up\n    * Manage context with skills and subagents\n* Stay safe with checkpoints and permissions\n  * Undo changes with checkpoints\n  * Control what Claude can do\n* Work effectively with Claude Code\n  * Ask Claude Code for help\n  * It's a conversation\n    * Interrupt and steer\n  * Be specific upfront\n  * Give Claude something to verify against\n  * Explore before implementing\n  * Delegate, don't dictate\n* What's next\n\n### [features-overview](https://code.claude.com/docs/en/features-overview.md)\n\n* Overview\n* Match features to your goal\n  * Build your setup over time\n  * Compare similar features\n  * Understand how features layer\n  * Combine features\n* Understand context costs\n  * Context cost by feature\n  * Understand how features load\n* Learn more\n\n### [claude-directory](https://code.claude.com/docs/en/claude-directory.md)\n\n* Explore the directory\n* What's not shown\n* Choose the right file\n* File reference\n* Troubleshoot configuration\n* Application data\n  * Cleaned up automatically\n  * Kept until you delete them\n  * Plaintext storage\n  * Clear local data\n* Related resources\n\n### [context-window](https://code.claude.com/docs/en/context-window.md)\n\n* What the timeline shows\n* What survives compaction\n* When your context fills up\n* Check your own session\n* Related resources\n\n### [prompt-caching](https://code.claude.com/docs/en/prompt-caching.md)\n\n* How the cache is organized\n  * Where the cache lives\n* Actions that invalidate the cache\n  * Switching models\n  * Changing effort level\n  * Turning on fast mode\n  * Connecting or disconnecting an MCP server\n  * Enabling or disabling a plugin\n  * Denying an entire tool\n  * Compacting the conversation\n  * Upgrading Claude Code\n* Actions that keep the cache\n  * Editing files in your repository\n  * Editing CLAUDE.md mid-session\n  * Changing output style\n  * Changing permission mode\n  * Invoking skills and commands\n  * Running `/recap`\n  * Rewinding the conversation\n* Cache lifetime\n  * On a Claude subscription\n  * On an API key or third-party provider\n  * Override the TTL\n* Cache scope\n* Check cache performance\n* Subagents and the cache\n* Disable prompt caching\n* Related resources\n\n## Use Claude Code\n\n### [memory](https://code.claude.com/docs/en/memory.md)\n\n* CLAUDE.md vs auto memory\n* CLAUDE.md files\n  * When to add to CLAUDE.md\n  * Choose where to put CLAUDE.md files\n  * Set up a project CLAUDE.md\n  * Write effective instructions\n  * Import additional files\n  * AGENTS.md\n  * How CLAUDE.md files load\n    * Load from additional directories\n  * Organize rules with `.claude/rules/`\n    * Set up rules\n    * Path-specific rules\n    * Share rules across projects with symlinks\n    * User-level rules\n  * Manage CLAUDE.md for large teams\n    * Deploy organization-wide CLAUDE.md\n    * Exclude specific CLAUDE.md files\n* Auto memory\n  * Enable or disable auto memory\n  * Storage location\n  * How it works\n  * Audit and edit your memory\n* View and edit with `/memory`\n* Troubleshoot memory issues\n  * Claude isn't following my CLAUDE.md\n  * I don't know what auto memory saved\n  * My CLAUDE.md is too large\n  * Instructions seem lost after `/compact`\n* Related resources\n\n### [permission-modes](https://code.claude.com/docs/en/permission-modes.md)\n\n* Available modes\n* Switch permission modes\n* Auto-approve file edits with acceptEdits mode\n* Analyze before you edit with plan mode\n  * Review and approve a plan\n  * Set plan mode as the default\n* Eliminate permission prompts with auto mode\n  * Enable auto mode on Bedrock, Agent Platform, or Foundry\n  * What the classifier blocks by default\n  * Boundaries you state in conversation\n  * When auto mode falls back\n* Allow only pre-approved tools with dontAsk mode\n* Skip all checks with bypassPermissions mode\n* Protected paths\n* See also\n\n### [sessions](https://code.claude.com/docs/en/sessions.md)\n\n* Resume a session\n  * Where the session picker looks\n* Name your sessions\n* Use the session picker\n* Branch a session\n* Manage context within a session\n* Export and locate session data\n  * Access conversations from scripts\n  * Where transcripts are stored\n* See also\n\n### [common-workflows](https://code.claude.com/docs/en/common-workflows.md)\n\n* Prompt recipes\n  * Understand new codebases\n    * Get a quick codebase overview\n    * Find relevant code\n  * Fix bugs efficiently\n  * Refactor code\n  * Work with tests\n  * Create pull requests\n  * Handle documentation\n  * Work in notes and non-code folders\n  * Work with images\n  * Reference files and directories\n  * Run Claude on a schedule\n  * Ask Claude about its capabilities\n    * Example questions\n* Resume previous conversations\n* Run parallel sessions with worktrees\n* Plan before editing\n* Delegate research to subagents\n* Pipe Claude into scripts\n* Next steps\n\n### [prompt-library](https://code.claude.com/docs/en/prompt-library.md)\n\n* What makes these prompts work\n* Where these come from\n* Related resources\n\n### [best-practices](https://code.claude.com/docs/en/best-practices.md)\n\n* Give Claude a way to verify its work\n* Explore first, then plan, then code\n* Provide specific context in your prompts\n  * Provide rich content\n* Configure your environment\n  * Write an effective CLAUDE.md\n  * Configure permissions\n  * Use CLI tools\n  * Connect MCP servers\n  * Set up hooks\n  * Create skills\n  * Create custom subagents\n  * Install plugins\n* Communicate effectively\n  * Ask codebase questions\n  * Let Claude interview you\n* Manage your session\n  * Course-correct early and often\n  * Manage context aggressively\n  * Use subagents for investigation\n  * Rewind with checkpoints\n  * Resume conversations\n* Automate and scale\n  * Run non-interactive mode\n  * Run multiple Claude sessions\n  * Fan out across files\n  * Run autonomously with auto mode\n  * Add an adversarial review step\n* Avoid common failure patterns\n* Develop your intuition\n* Related resources\n\n### Platforms and integrations > Claude Code on the web\n\n#### [web-quickstart](https://code.claude.com/docs/en/web-quickstart.md)\n\n* How sessions run\n* Compare ways to run Claude Code\n* Connect GitHub and create an environment\n  * Connect from your terminal\n* Start a task\n* Pre-fill sessions\n* Review and iterate\n* Troubleshoot setup\n  * No repositories appear after connecting GitHub\n  * The page only shows a GitHub login button\n  * \"Not available for the selected organization\"\n  * `/web-setup` shows \"No commands match\" or \"Unknown command\"\n  * \"Could not create a cloud environment\" or \"No cloud environment available\" when using `--cloud` or ultraplan\n  * Setup script failed\n  * New sessions hang or time out during setup\n  * Session keeps running after closing the tab\n* Next steps\n\n#### [claude-code-on-the-web](https://code.claude.com/docs/en/claude-code-on-the-web.md)\n\n* GitHub authentication options\n* The cloud environment\n  * What's available in cloud sessions\n  * Installed tools\n  * Work with GitHub issues and pull requests\n  * Link output back to the session\n  * Run tests, start services, and add packages\n  * Resource limits\n  * Configure your environment\n* Setup scripts\n  * Environment caching\n  * Setup scripts vs. SessionStart hooks\n  * Install dependencies with a SessionStart hook\n* Network access\n  * Access levels\n  * Allow specific domains\n  * GitHub proxy\n  * Security proxy\n  * Default allowed domains\n* Move tasks between web and terminal\n  * From terminal to web\n    * Tips for cloud tasks\n    * Send local repositories without GitHub\n  * From web to terminal\n    * Teleport requirements\n    * `--teleport` is unavailable\n* Work with sessions\n  * Manage context\n  * Review changes\n  * Share sessions\n    * Share from an Enterprise or Team account\n    * Share from a Max or Pro account\n  * Archive sessions\n  * Delete sessions\n* Auto-fix pull requests\n  * How Claude responds to PR activity\n* Security and isolation\n* Troubleshooting\n  * Session creation failed\n  * Remote Control session expired or access denied\n  * Environment expired\n* Limitations\n* Related resources\n\n#### [routines](https://code.claude.com/docs/en/routines.md)\n\n* Example use cases\n* Create a routine\n  * Create from the web\n  * Create from the CLI\n* Configure triggers\n  * Add a schedule trigger\n    * Schedule a one-off run\n  * Add an API trigger\n    * Trigger a routine\n    * API reference\n  * Add a GitHub trigger\n    * Supported events\n    * Filter pull requests\n    * How sessions map to events\n* Manage routines\n  * View and interact with runs\n  * Edit and control routines\n  * Repositories and branch permissions\n  * Connectors\n  * Environments and network access\n* Usage and limits\n* Troubleshooting\n  * `/schedule` shows \"No commands match\" or \"Unknown command\"\n  * \"Routines are disabled by your organization's policy\"\n* Related resources\n\n#### [ultraplan](https://code.claude.com/docs/en/ultraplan.md)\n\n* Launch ultraplan from the CLI\n* Review and revise the plan in your browser\n* Choose where to execute\n  * Execute on the web\n  * Send the plan back to your terminal\n* Related resources\n\n#### [ultrareview](https://code.claude.com/docs/en/ultrareview.md)\n\n* Run ultrareview from the CLI\n* Pricing and free runs\n* Track a running review\n* Run ultrareview non-interactively\n* How ultrareview compares to /code-review and /review\n* Related resources\n\n### Platforms and integrations > Claude Code on desktop\n\n#### [desktop-quickstart](https://code.claude.com/docs/en/desktop-quickstart.md)\n\n* Install\n* Start your first session\n* Now what?\n* Coming from the CLI?\n* What's next\n\n#### [desktop](https://code.claude.com/docs/en/desktop.md)\n\n* Start a session\n* Work with code\n  * Use the prompt box\n  * Add files and context to prompts\n  * Choose a permission mode\n  * Preview your app\n  * Browse external sites\n    * Approve Claude's actions on a site\n    * Choose between the Browser and the Chrome extension\n    * Restrict external browsing for your organization\n  * Review changes with diff view\n  * Review your code\n  * Monitor pull request status\n* Arrange your workspace\n  * Run commands in the terminal\n  * Open and edit files\n  * Open files in other apps\n  * Switch view modes\n  * Keyboard shortcuts\n  * Check usage\n* Let Claude use your computer\n  * When computer use applies\n  * Enable computer use\n  * App permissions\n* Manage sessions\n  * Work in parallel with sessions\n  * Ask a side question without derailing the session\n  * Watch background tasks\n  * Run long-running tasks remotely\n  * Continue in another surface\n  * Sessions from Dispatch\n* Extend Claude Code\n  * Connect external tools\n  * Use skills\n  * Install plugins\n  * Configure preview servers\n    * Auto-verify changes\n    * Configuration fields\n      * When to use `program` vs `runtimeExecutable`\n    * Port conflicts\n    * Examples\n* Environment configuration\n  * Local sessions\n  * Cloud sessions\n  * SSH sessions\n    * Pre-configure SSH connections for your team\n    * Restrict which SSH hosts users can connect to\n* Enterprise configuration\n  * Admin console controls\n  * Managed settings\n  * Device management policies\n  * Authentication and SSO\n  * Data handling\n  * Deployment\n* Coming from the CLI?\n  * CLI flag equivalents\n  * Shared configuration\n  * Feature comparison\n  * What's not available in Desktop\n* Troubleshooting\n  * Check your version\n  * 403 or authentication errors in the Code tab\n  * Blank or stuck screen on launch\n  * \"Failed to load session\"\n  * Session not finding installed tools\n  * Git and Git LFS errors\n  * MCP servers not working on Windows\n  * App won't quit\n  * Windows-specific issues\n  * \"Branch doesn't exist yet\" when opening in CLI\n  * Still stuck?\n\n#### [desktop-linux](https://code.claude.com/docs/en/desktop-linux.md)\n\n* Requirements\n* Install\n  * Install from a downloaded file\n* Update\n* Uninstall\n* Troubleshoot\n  * Unable to locate package claude-desktop\n* What's not in the Linux beta yet\n\n#### [desktop-scheduled-tasks](https://code.claude.com/docs/en/desktop-scheduled-tasks.md)\n\n* Compare scheduling options\n* Create a scheduled task\n* Schedule options\n* How scheduled tasks run\n* Missed runs\n* Permissions for scheduled tasks\n* Manage scheduled tasks\n* Related resources\n\n### Platforms and integrations > Code review & CI/CD\n\n#### [security-guidance](https://code.claude.com/docs/en/security-guidance.md)\n\n* Prerequisites\n* Install the plugin\n  * Enable in cloud sessions and shared repositories\n* What the plugin checks\n  * On each file edit\n  * At the end of each turn\n  * On each commit or push Claude makes\n  * Review independence and limits\n* Add your own rules\n  * Add guidance for the model-backed reviews\n  * Add custom per-edit patterns\n  * Rule file lookup locations\n* Usage cost\n* Disable or uninstall\n* How the plugin integrates with Claude Code\n* How this fits with other security tools\n* Troubleshooting\n* Related resources\n\n#### [code-review](https://code.claude.com/docs/en/code-review.md)\n\n* How reviews work\n  * Severity levels\n  * Rate and reply to findings\n  * Check run output\n  * What Code Review checks\n* Set up Code Review\n* Manually trigger reviews\n* Customize reviews\n  * CLAUDE.md\n  * REVIEW\\.md\n    * What you can tune\n    * Example\n    * Keep it focused\n* View usage\n* Pricing\n* Troubleshooting\n  * Retrigger a failed or timed-out review\n  * Review didn't run and the PR shows a spend-cap message\n  * Find issues that aren't showing as inline comments\n* Review a diff locally\n* Related resources\n\n#### [github-actions](https://code.claude.com/docs/en/github-actions.md)\n\n* Why use Claude Code GitHub Actions?\n* What can Claude do?\n  * Claude Code Action\n* Setup\n* Quick setup\n* Manual setup\n* Upgrading from Beta\n  * Essential changes\n  * Breaking Changes Reference\n  * Before and After Example\n* Example use cases\n  * Basic workflow\n  * Using skills\n  * Custom automation with prompts\n  * Common use cases\n* Best practices\n  * CLAUDE.md configuration\n  * Security considerations\n  * Optimizing performance\n  * CI costs\n* Configuration examples\n* Using with Amazon Bedrock and Google Cloud\n  * Prerequisites\n    * For Google Cloud's Agent Platform:\n    * For Amazon Bedrock:\n* Troubleshooting\n  * Claude not responding to @claude commands\n  * CI not running on Claude's commits\n  * Authentication errors\n* Advanced configuration\n  * Action parameters\n    * Pass CLI arguments\n  * Alternative integration methods\n  * Customizing Claude's behavior\n\n#### [github-enterprise-server](https://code.claude.com/docs/en/github-enterprise-server.md)\n\n* What works with GitHub Enterprise Server\n* Admin setup\n  * GitHub App permissions\n  * Manual setup\n  * Network requirements\n* Developer workflow\n  * Teleport sessions to your terminal\n* Plugin marketplaces on GHES\n  * Add a GHES marketplace\n  * Pre-register GHES marketplaces with managed settings\n  * Allowlist GHES marketplaces in managed settings\n* Limitations\n* Troubleshooting\n  * Web session fails to clone repository\n  * Marketplace add fails with a policy error\n  * Marketplace add on claude.ai fails with a GitHub access error\n  * GHES instance not reachable\n* Related resources\n\n#### [gitlab-ci-cd](https://code.claude.com/docs/en/gitlab-ci-cd.md)\n\n* Why use Claude Code with GitLab?\n* How it works\n* What can Claude do?\n* Setup\n  * Quick setup\n  * Manual setup (recommended for production)\n* Example use cases\n  * Turn issues into MRs\n  * Get implementation help\n  * Fix bugs quickly\n* Using with Amazon Bedrock and Google Cloud\n* Configuration examples\n  * Basic .gitlab-ci.yml (Claude API)\n  * Amazon Bedrock job example (OIDC)\n  * Agent Platform job example (Workload Identity Federation)\n* Best practices\n  * CLAUDE.md configuration\n  * Security considerations\n  * Optimizing performance\n  * CI costs\n* Security and governance\n* Troubleshooting\n  * Claude not responding to @claude commands\n  * Job can't write comments or open MRs\n  * Authentication errors\n* Advanced configuration\n  * Common parameters and variables\n  * Customizing Claude's behavior\n\n## Platforms and integrations\n\n### [platforms](https://code.claude.com/docs/en/platforms.md)\n\n* Where to run Claude Code\n* Connect your tools\n* Work when you are away from your terminal\n* Related resources\n  * Platforms\n  * Integrations\n  * Remote access\n\n### [remote-control](https://code.claude.com/docs/en/remote-control.md)\n\n* Requirements\n* Start a Remote Control session\n  * Check connection status\n  * Connect from another device\n  * Enable Remote Control for all sessions\n* Connection and security\n* Trusted Devices\n  * Enable Trusted Devices for your organization\n  * What members see\n  * Manage enrolled devices\n* Remote Control vs Claude Code on the web\n* Mobile push notifications\n* Limitations\n* Troubleshooting\n  * \"Remote Control requires a claude.ai subscription\"\n  * \"Remote Control requires a full-scope login token\"\n  * \"Unable to determine your organization for Remote Control eligibility\"\n  * \"Remote Control is not yet enabled for your account\"\n  * \"Couldn't verify Remote Control eligibility\"\n  * \"Remote Control is only available when using Claude via api.anthropic.com\"\n  * \"Remote Control is disabled by your organization's policy\"\n  * \"Remote credentials fetch failed\"\n  * \"Couldn't reconnect to your Remote Control session\"\n  * \"Your organization requires Trusted Devices for Remote Control, but this device is not enrolled\"\n  * \"session expired for trusted-device check\"\n* Choose the right approach\n* Related resources\n\n### [chrome](https://code.claude.com/docs/en/chrome.md)\n\n* Capabilities\n* Prerequisites\n* Get started in the CLI\n  * Enable Chrome by default\n  * Manage site permissions\n  * Browser tools in plan mode\n* Example workflows\n  * Test a local web application\n  * Debug with console logs\n  * Automate form filling\n  * Draft content in Google Docs\n  * Extract data from web pages\n  * Run multi-site workflows\n  * Record a demo GIF\n* Troubleshooting\n  * Extension not detected\n  * Browser not responding\n  * Connection drops during long sessions\n  * Windows-specific issues\n  * Common error messages\n* See also\n\n### [computer-use](https://code.claude.com/docs/en/computer-use.md)\n\n* What you can do with computer use\n* When computer use applies\n* Enable computer use\n* Approve apps per session\n* How Claude works on your screen\n  * One session at a time\n  * Apps are hidden while Claude works\n  * Screenshots are downscaled automatically\n  * Stop at any time\n* Safety and the trust boundary\n* Example workflows\n  * Validate a native build\n  * Reproduce a layout bug\n  * Test a simulator flow\n* Differences from the Desktop app\n* Troubleshooting\n  * \"Computer use is in use by another Claude session\"\n  * macOS permissions prompt keeps reappearing\n  * `computer-use` doesn't appear in `/mcp`\n* See also\n\n### [vs-code](https://code.claude.com/docs/en/vs-code.md)\n\n* Prerequisites\n* Install the extension\n* Get started\n* Use the prompt box\n  * Reference files and folders\n  * Resume past conversations\n  * Resume cloud sessions from Claude.ai\n  * Check account and usage\n* Customize your workflow\n  * Choose where Claude lives\n  * Run multiple conversations\n  * Switch to terminal mode\n* Manage plugins\n  * Install plugins\n  * Manage marketplaces\n* Automate browser tasks with Chrome\n* VS Code commands and shortcuts\n  * Launch a VS Code tab from other tools\n* Configure settings\n  * Extension settings\n* VS Code extension vs. Claude Code CLI\n  * Rewind with checkpoints\n  * Run CLI in VS Code\n  * Switch between extension and CLI\n  * Include terminal output in prompts\n  * Monitor background processes\n  * Connect to external tools with MCP\n* Work with git\n  * Create commits and pull requests\n  * Use git worktrees for parallel tasks\n* Use third-party providers\n* Security and privacy\n  * The built-in IDE MCP server\n* Fix common issues\n  * Extension won't install\n  * Spark icon not visible\n  * Cmd+Esc does nothing on macOS\n  * Claude Code never responds\n* Uninstall the extension\n* Next steps\n\n### [jetbrains](https://code.claude.com/docs/en/jetbrains.md)\n\n* Supported IDEs\n* Features\n* Installation\n* Usage\n  * From your IDE\n  * From external terminals\n* Configuration\n  * Claude Code settings\n  * Plugin settings\n    * General settings\n    * ESC key configuration\n* Special configurations\n  * Remote development\n  * WSL configuration\n    * Allow WSL2 traffic through Windows Firewall\n    * Switch WSL2 to mirrored networking\n* Troubleshooting\n  * Plugin not working\n  * IDE not detected\n  * Command not found\n* Security considerations\n\n### [slack](https://code.claude.com/docs/en/slack.md)\n\n* Use cases\n* Prerequisites\n* Setting up Claude Code in Slack\n* How it works\n  * Automatic detection\n  * Context gathering\n  * Session flow\n* User interface elements\n  * App Home\n  * Message actions\n  * Repository selection\n* Access and permissions\n  * User-level access\n  * Workspace-level access\n  * Channel-based access control\n* What's accessible where\n* Best practices\n  * Writing effective requests\n  * When to use Slack vs. web\n* Troubleshooting\n  * \"Claude Code is not enabled for your account\"\n  * Sessions not starting\n  * Repository not showing\n  * Wrong repository selected\n  * Authentication errors\n  * Session expiration\n* Current limitations\n* Related resources\n\n## Agents and parallel work\n\n### [agents](https://code.claude.com/docs/en/agents.md)\n\n* Choose an approach\n* Check on running work\n* Learn more\n\n### [sub-agents](https://code.claude.com/docs/en/sub-agents.md)\n\n* Built-in subagents\n* Quickstart: create your first subagent\n* Configure subagents\n  * Choose the subagent scope\n  * Write subagent files\n    * Supported frontmatter fields\n  * Choose a model\n  * Control subagent capabilities\n    * Available tools\n    * Restrict which subagents can be spawned\n    * Scope MCP servers to a subagent\n    * Permission modes\n    * Preload skills into subagents\n    * Enable persistent memory\n      * Persistent memory tips\n    * Conditional rules with hooks\n    * Disable specific subagents\n  * Define hooks for subagents\n    * Hooks in subagent frontmatter\n    * Project-level hooks for subagent events\n* Work with subagents\n  * Understand automatic delegation\n  * Invoke subagents explicitly\n  * Run subagents in foreground or background\n  * API errors in subagents\n  * Common patterns\n    * Isolate high-volume operations\n    * Run parallel research\n    * Chain subagents\n  * Choose between subagents and main conversation\n  * Spawn nested subagents\n  * Manage subagent context\n    * What loads at startup\n    * Resume subagents\n    * Auto-compaction\n* Fork the current conversation\n  * Observe and steer running forks\n  * How forks differ from named subagents\n  * Limitations\n* Example subagents\n  * Code reviewer\n  * Debugger\n  * Data scientist\n  * Database query validator\n* Next steps\n\n### [agent-view](https://code.claude.com/docs/en/agent-view.md)\n\n* Quick start\n* Monitor sessions with agent view\n  * Read session state\n  * Row summaries\n  * Pull request status\n  * Peek and reply\n  * Attach to a session\n  * Organize the list\n  * Filter sessions\n  * Keyboard shortcuts\n* Dispatch new agents\n  * From agent view\n    * Dispatch to a specific directory\n  * From inside a session\n  * From your shell\n    * Run a shell command\n  * How file edits are isolated\n  * Set the model\n  * Permission mode, model, and effort\n  * Settings, plugins, and MCP servers\n* Manage sessions from the shell\n* How background sessions are hosted\n  * The supervisor process\n  * Where state is stored\n  * Turn off agent view\n* Troubleshooting\n  * `claude agents` lists subagents instead of opening agent view\n  * Agent view opens with no sessions\n  * Backgrounding shows a `Background this session?` dialog\n  * Prompt rejected as too short\n  * Sessions show as failed after shutdown\n  * Opening a session says the conversation is already open\n  * A session fails before starting with a `possibly low memory` note\n  * Agent view says the background service did not respond\n  * Dispatch fails with `Could not resolve authentication method`\n  * Background sessions can't read Desktop, Documents, or Downloads on macOS\n  * Background sessions can't reach local-network hosts on macOS\n  * A session is slow to respond after attaching\n  * `.claude/worktrees/` is filling up\n* Limitations\n* Related resources\n* Version history\n\n### [agent-teams](https://code.claude.com/docs/en/agent-teams.md)\n\n* When to use agent teams\n  * Compare with subagents\n* Enable agent teams\n* Start your first agent team\n* Control your agent team\n  * Choose a display mode\n  * Specify teammates and models\n  * Require plan approval for teammates\n  * Talk to teammates directly\n  * Assign and claim tasks\n  * Shut down teammates\n  * Enforce quality gates with hooks\n* How agent teams work\n  * How Claude starts agent teams\n  * Architecture\n  * Use subagent definitions for teammates\n  * Permissions\n  * Context and communication\n  * Token usage\n* Use case examples\n  * Run a parallel code review\n  * Investigate with competing hypotheses\n* Best practices\n  * Give teammates enough context\n  * Choose an appropriate team size\n  * Size tasks appropriately\n  * Wait for teammates to finish\n  * Start with research and review\n  * Avoid file conflicts\n  * Monitor and steer\n* Troubleshooting\n  * Teammates not appearing\n  * Too many permission prompts\n  * Teammates stopping on errors\n  * Lead shuts down before work is done\n  * Orphaned tmux sessions\n* Limitations\n* Next steps\n\n### [workflows](https://code.claude.com/docs/en/workflows.md)\n\n* When to use a workflow\n* Run a bundled workflow\n  * Bundled workflows\n  * Watch the run\n* Have Claude write a workflow\n  * Ask for a workflow in your prompt\n  * Let Claude decide with ultracode\n  * Approve the plan before it runs\n  * Save the workflow for reuse\n  * Pass input to a saved workflow\n* Example workflow prompts\n  * Audit many files for the same issue\n  * Keep fixing until a check passes\n  * Migrate many files in parallel\n  * Review every changed file and write one summary\n  * Research a topic across many sources\n  * Find issues until the list stops growing\n  * What the saved script looks like\n* How a workflow runs\n  * Behavior and limits\n* Manage runs\n  * Resume after a pause\n  * Cost\n  * Set a size guideline\n  * Turn workflows off\n* Related resources\n\n### [worktrees](https://code.claude.com/docs/en/worktrees.md)\n\n* Start Claude in a worktree\n  * Choose the base branch\n* Copy gitignored files into worktrees\n* Isolate subagents with worktrees\n* Clean up worktrees\n* Manage worktrees manually\n* Non-git version control\n* See also\n\n## MCP\n\n### [mcp-quickstart](https://code.claude.com/docs/en/mcp-quickstart.md)\n\n* Before you begin\n* Add and verify a server\n* Where servers are saved\n  * Find your configuration on disk\n* Change server scope\n  * Use a server in all your projects\n  * Share a server with your team\n* Additional MCP server examples\n  * Add a local server\n  * Connect a server that requires sign-in\n* Edit .mcp.json directly\n* Connect from other surfaces\n* Troubleshooting\n* Next steps\n\n### [mcp](https://code.claude.com/docs/en/mcp.md)\n\n* What you can do with MCP\n* Find and build MCP servers\n* Installing MCP servers\n  * Option 1: Add a remote HTTP server\n  * Option 2: Add a remote SSE server\n  * Option 3: Add a local stdio server\n  * Option 4: Add a remote WebSocket server\n  * Managing your servers\n  * Dynamic tool updates\n  * Automatic reconnection\n  * Push messages with channels\n  * Plugin-provided MCP servers\n* MCP installation scopes\n  * Local scope\n  * Project scope\n  * User scope\n  * Scope hierarchy and precedence\n  * Environment variable expansion in `.mcp.json`\n* Practical examples\n  * Example: Monitor errors with Sentry\n  * Example: Connect to GitHub for code reviews\n  * Example: Query your PostgreSQL database\n* Authenticate with remote MCP servers\n  * Authenticate from the command line\n  * Use a fixed OAuth callback port\n  * Use pre-configured OAuth credentials\n  * Override OAuth metadata discovery\n  * Restrict OAuth scopes\n  * Use dynamic headers for custom authentication\n* Add MCP servers from JSON configuration\n* Import MCP servers from Claude Desktop\n* Use MCP servers from claude.ai\n  * Disable claude.ai connectors\n* Use Claude Code as an MCP server\n* MCP output limits and warnings\n  * Raise the limit for a specific tool\n* Tool input schemas with a root-level combinator\n* Require approval for a specific tool\n* Respond to MCP elicitation requests\n* Use MCP resources\n  * Reference MCP resources\n* Scale with MCP tool search\n  * How it works\n  * For MCP server authors\n  * Configure tool search\n  * Exempt a server from deferral\n* Use MCP prompts as commands\n  * Execute MCP prompts\n* Managed MCP configuration\n\n## Skills\n\n### [skills](https://code.claude.com/docs/en/skills.md)\n\n* Bundled skills\n  * Run and verify your app\n* Getting started\n  * Create your first skill\n  * Where skills live\n    * Live change detection\n    * Automatic discovery from parent and nested directories\n    * Skills from additional directories\n* Configure skills\n  * Types of skill content\n  * Frontmatter reference\n    * How a skill gets its command name\n    * Available string substitutions\n  * Add supporting files\n  * Control who invokes a skill\n  * Skill content lifecycle\n  * Pre-approve tools for a skill\n  * Pass arguments to skills\n* Advanced patterns\n  * Inject dynamic context\n  * Run skills in a subagent\n    * Example: Research skill using Explore agent\n  * Restrict Claude's skill access\n  * Override skill visibility from settings\n* Evaluate and iterate on a skill\n  * Run evals with skill-creator\n* Share skills\n  * Generate visual output\n* Troubleshooting\n  * Skill not triggering\n  * Skill triggers too often\n  * Skill descriptions are cut short\n* Related resources\n\n## Plugins\n\n### [discover-plugins](https://code.claude.com/docs/en/discover-plugins.md)\n\n* How marketplaces work\n* Official Anthropic marketplace\n  * Code intelligence\n    * What Claude gains from code intelligence plugins\n  * External integrations\n  * Automatic security review\n  * Development workflows\n  * Output styles\n* Community marketplace\n* Try it: add the demo marketplace\n* Add marketplaces\n  * Add from GitHub\n  * Add from other Git hosts\n  * Add from local paths\n  * Add from remote URLs\n* Install plugins\n* Manage installed plugins\n  * Apply plugin changes without restarting\n* Manage marketplaces\n  * Use the interactive interface\n  * Use CLI commands\n  * Configure auto-updates\n* Configure team marketplaces\n* Security\n* Troubleshooting\n  * /plugin command not recognized\n  * Common issues\n  * Code intelligence issues\n* Next steps\n\n### [plugins](https://code.claude.com/docs/en/plugins.md)\n\n* When to use plugins vs standalone configuration\n* Quickstart\n  * Prerequisites\n  * Create your first plugin\n* Develop a plugin in your skills directory\n* Plugin structure overview\n* Develop more complex plugins\n  * Add Skills to your plugin\n  * Add LSP servers to your plugin\n  * Add background monitors to your plugin\n  * Ship default settings with your plugin\n  * Organize complex plugins\n  * Test your plugins locally\n  * Debug plugin issues\n  * Share your plugins\n  * Submit your plugin to the community marketplace\n* Convert existing configurations to plugins\n  * Migration steps\n  * What changes when migrating\n* Next steps\n  * For plugin users\n  * For plugin developers\n\n## Artifacts\n\n### [artifacts](https://code.claude.com/docs/en/artifacts.md)\n\n* When to use an artifact\n  * What an artifact is not\n* Create an artifact\n* Update an artifact\n* Share an artifact\n* What you can build\n  * Walk through a change\n  * Compare alternatives\n  * Tune with interactive controls\n  * Bring the result back to your session\n  * Track work in progress\n* Improve the visual design\n* Page constraints\n* Availability\n* Disable artifacts\n* Manage artifacts for your organization\n  * Enable or disable artifacts\n  * Set a retention policy\n  * Review the audit log\n  * Allowlist the viewer domain\n  * List and delete artifacts with the Compliance API\n* Related resources\n\n## Automation\n\n### [hooks-guide](https://code.claude.com/docs/en/hooks-guide.md)\n\n* Set up your first hook\n* What you can automate\n  * Get notified when Claude needs input\n  * Auto-format code after edits\n  * Block edits to protected files\n  * Re-inject context after compaction\n  * Audit configuration changes\n  * Reload environment when directory or files change\n  * Auto-approve specific permission prompts\n* How hooks work\n  * Combine results from multiple hooks\n  * Read input and return output\n    * Hook input\n    * Hook output\n    * Structured JSON output\n  * Filter hooks with matchers\n    * Filter by tool name and arguments with the `if` field\n  * Configure hook location\n* Prompt-based hooks\n* Agent-based hooks\n* HTTP hooks\n* Limitations and troubleshooting\n  * Limitations\n  * Hooks and permission modes\n  * Hook not firing\n  * Hook error in output\n  * `/hooks` shows no hooks configured\n  * Stop hook hits the block cap\n  * JSON validation failed\n  * Debug techniques\n* Learn more\n\n### [channels](https://code.claude.com/docs/en/channels.md)\n\n* Supported channels\n* Quickstart\n* Security\n* Enterprise controls\n  * Enable channels for your organization\n  * Restrict which channel plugins can run\n* Research preview\n* How channels compare\n* Next steps\n\n### [scheduled-tasks](https://code.claude.com/docs/en/scheduled-tasks.md)\n\n* Compare scheduling options\n* Run a prompt repeatedly with /loop\n  * Run on a fixed interval\n  * Let Claude choose the interval\n  * Run the built-in maintenance prompt\n  * Customize the default prompt with loop.md\n  * Stop a loop\n* Set a one-time reminder\n* Manage scheduled tasks\n* How scheduled tasks run\n  * Jitter\n  * Seven-day expiry\n* Cron expression reference\n* Disable scheduled tasks\n* Limitations\n\n### [goal](https://code.claude.com/docs/en/goal.md)\n\n* Compare ways to keep a session running\n* Use `/goal`\n  * Set a goal\n  * Write an effective condition\n  * Check status\n  * Clear a goal\n  * Resume with an active goal\n  * Run non-interactively\n* How evaluation works\n* Requirements\n* See also\n\n### [headless](https://code.claude.com/docs/en/headless.md)\n\n* Basic usage\n  * Start faster with bare mode\n  * Background tasks at exit\n* Examples\n  * Pipe data through Claude\n  * Add Claude to a build script\n  * Get structured output\n  * Stream responses\n  * Auto-approve tools\n  * Create a commit\n  * Customize the system prompt\n  * Continue conversations\n* Next steps\n\n### [deep-links](https://code.claude.com/docs/en/deep-links.md)\n\n* How it works\n  * What a launched session shows\n* Build a link\n  * Choose between `cwd` and `repo`\n* Examples\n  * Embed a link in a runbook\n  * Open a link from the shell\n* Registration and supported platforms\n* Open a VS Code tab instead of a terminal\n* Troubleshooting\n  * Clicking the link does nothing\n  * The link renders as plain text instead of being clickable\n  * The session opens in my home directory instead of the repo\n  * The link opens the wrong terminal\n* Learn more\n\n## Guides\n\n### [large-codebases](https://code.claude.com/docs/en/large-codebases.md)\n\n* What this guide covers\n  * Settings on this page\n  * The example monorepo\n* Choose where to start Claude\n* Layer CLAUDE.md files by directory\n  * Choose between per-directory CLAUDE.md and path-scoped rules\n  * Exclude irrelevant CLAUDE.md files\n* Reduce what Claude reads\n  * Block reads of generated and vendored code\n  * Reduce file reads with code intelligence\n* Scope worktrees and file access\n  * Check out only the directories you need\n  * Grant access across packages or repositories\n* Add per-directory skills\n  * Keep skills discoverable\n* Centralize conventions when layering stops scaling\n  * Recommend the right plugin at session start\n* Put it together\n* Scope and plan changes that span packages\n* Next steps\n\n## Troubleshooting\n\n### [troubleshoot-install](https://code.claude.com/docs/en/troubleshoot-install.md)\n\n* Find your error\n* Run diagnostic checks\n  * Check network connectivity\n  * Verify your PATH\n  * Check for conflicting installations\n  * Check directory permissions\n  * Verify the binary works\n* Common installation issues\n  * Install script returns HTML instead of a shell script\n  * `command not found: claude` after installation\n  * `curl: (56) Failure writing output to destination`\n  * Homebrew cask unavailable or outdated\n  * TLS or SSL connection errors\n  * `Failed to fetch version from downloads.claude.ai`\n  * Wrong install command on Windows\n  * `The process cannot access the file` during Windows install\n  * Install killed on low-memory Linux servers\n  * Install hangs in Docker\n  * Claude Desktop overrides the `claude` command on Windows\n  * Claude Code on Windows requires either Git for Windows (for bash) or PowerShell\n  * Claude Code does not support 32-bit Windows\n  * Linux musl or glibc binary mismatch\n  * `Illegal instruction`\n  * `dyld: cannot load` on macOS\n  * `Exec format error` on WSL1\n  * npm install errors in WSL\n  * Permission errors during installation\n  * Native binary not found after npm install\n* Login and authentication\n  * Reset your login\n  * OAuth error: Invalid code\n  * 403 Forbidden after login\n  * This organization has been disabled with an active subscription\n  * OAuth login fails in WSL2, SSH, or containers\n  * Not logged in or token expired\n  * Bedrock, Agent Platform, or Foundry credentials not loading\n* Still stuck\n\n### [troubleshooting](https://code.claude.com/docs/en/troubleshooting.md)\n\n* Performance and stability\n  * High CPU or memory usage\n  * Auto-compaction stops with a thrashing error\n  * Command hangs or freezes\n  * Garbled or corrupted text in an editor's integrated terminal\n  * Search and discovery issues\n  * Slow or incomplete search results on WSL\n* Get more help\n\n### [debug-your-config](https://code.claude.com/docs/en/debug-your-config.md)\n\n* See what loaded into context\n* Check resolved settings\n* Check MCP servers\n* Check hooks\n* Test against a clean configuration\n* Check common causes\n* Related resources\n\n### [errors](https://code.claude.com/docs/en/errors.md)\n\n* Find your error\n* Automatic retries\n* Server errors\n  * API Error: 500 Internal server error\n  * API Error: Repeated 529 Overloaded errors\n  * Request timed out\n  * The response above may be incomplete\n  * Auto mode cannot determine the safety of an action\n  * Agent terminated early due to an API error\n* Usage limits\n  * You've hit your session limit\n  * Usage credits required for 1M context\n  * Server is temporarily limiting requests\n  * Request rejected (429)\n  * Credit balance is too low\n* Authentication errors\n  * Not logged in\n  * Could not resolve authentication method\n  * Invalid API key\n  * This organization has been disabled\n  * Your organization has disabled API key authentication\n  * Your organization has disabled Claude subscription access\n  * Routines are disabled by your organization's policy\n  * Remote Control requires the Anthropic API\n  * OAuth token revoked or expired\n  * OAuth scope requirement\n  * AWS credentials expired or invalid\n  * AWS authentication failed\n* Network and connection errors\n  * Unable to connect to API\n  * SSL certificate errors\n  * Host not allowed in a cloud session\n  * Couldn't reconnect to your Remote Control session\n* Request errors\n  * Prompt is too long\n  * Error during compaction: Conversation too long\n  * Request too large\n  * Image was too large\n  * Unable to resize image\n  * PDF errors\n  * Extra inputs are not permitted\n  * There's an issue with the selected model\n  * Model is not a recognized model id\n  * Claude Opus is not available with the Claude Pro plan\n  * Model is restricted by your organization's settings\n  * thinking.type.enabled is not supported for this model\n  * Thinking budget exceeds output limit\n  * Tool use or thinking block mismatch\n  * Usage Policy refusal\n  * Safety measures flagged a cybersecurity topic\n* Installation errors\n  * Installation was killed before it could finish\n  * The connection dropped while downloading the update\n* Command-line errors\n  * Conflict between --bg and --print\n  * The --json-schema value is not a valid JSON Schema\n  * Could not import a server from Claude Desktop\n* Plugin errors\n  * Marketplace is registered from an untrusted source\n* Configuration warnings\n  * Workspace has not been trusted\n* Responses seem lower quality than usual\n* Report an error\n\n## Setup and access\n\n### [admin-setup](https://code.claude.com/docs/en/admin-setup.md)\n\n* Choose your API provider\n* Decide how settings reach devices\n* Decide what to enforce\n* Set up usage visibility\n* Review data handling\n* Verify and onboard\n* Next steps\n\n### [setup](https://code.claude.com/docs/en/setup.md)\n\n* System requirements\n  * Additional dependencies\n* Install Claude Code\n  * Set up on Windows\n  * Alpine Linux and musl-based distributions\n* Verify your installation\n* Authenticate\n* Update Claude Code\n  * Auto-updates\n  * Configure release channel\n  * Pin a minimum version\n  * Disable auto-updates\n  * Update manually\n* Advanced installation options\n  * Install a specific version\n  * Install with Linux package managers\n  * Install with npm\n  * Binary integrity and code signing\n    * Verify the manifest signature\n    * Platform code signatures\n* Uninstall Claude Code\n  * Native installation\n  * Homebrew installation\n  * WinGet installation\n  * apt / dnf / apk\n  * npm\n  * Remove configuration files\n\n### [authentication](https://code.claude.com/docs/en/authentication.md)\n\n* Log in to Claude Code\n* Set up team authentication\n  * Claude for Teams or Enterprise\n  * Claude Console authentication\n  * Cloud provider authentication\n* Credential management\n  * Renew an expiring login\n  * Authentication precedence\n  * Generate a long-lived token\n\n### [server-managed-settings](https://code.claude.com/docs/en/server-managed-settings.md)\n\n* Requirements\n* Choose between server-managed and endpoint-managed settings\n* Configure server-managed settings\n  * Verify settings delivery\n  * Access control\n  * Managed-only settings\n  * Current limitations\n* Settings delivery\n  * Settings precedence\n  * Fetch and caching behavior\n  * Invalid entries in delivered settings\n  * Enforce fail-closed startup\n  * Security approval dialogs\n* Platform availability\n* Audit logging\n* Security considerations\n* See also\n\n### [managed-mcp](https://code.claude.com/docs/en/managed-mcp.md)\n\n* Choose a pattern\n* Exclusive control with managed-mcp.json\n  * Authenticate with per-user credentials\n  * Validate the configuration\n  * Disable MCP entirely\n  * Allow claude.ai connectors alongside the managed set\n* Policy-based control with allowlists and denylists\n  * Match servers by URL, command, or name\n  * How a server is evaluated\n  * Example configuration\n  * Restrict the allowlist to managed settings only\n* How restrictions appear to users\n* Monitor MCP usage\n* Configuration summary\n* Related resources\n\n### [auto-mode-config](https://code.claude.com/docs/en/auto-mode-config.md)\n\n* Where the classifier reads configuration\n* Define trusted infrastructure\n* Override the block and allow rules\n* Route all shell commands through the classifier\n* Inspect the defaults and your effective config\n* Review denials\n* See also\n\n## Deployment\n\n### [third-party-integrations](https://code.claude.com/docs/en/third-party-integrations.md)\n\n* Compare deployment options\n* Configure proxies and gateways\n  * Amazon Bedrock\n  * Microsoft Foundry\n  * Google Cloud's Agent Platform\n* Best practices for organizations\n  * Invest in documentation and memory\n  * Simplify deployment\n  * Start with guided usage\n  * Pin model versions for cloud providers\n  * Configure security policies\n  * Leverage MCP for integrations\n* Next steps\n\n### [feature-availability](https://code.claude.com/docs/en/feature-availability.md)\n\n* Availability by model provider\n  * Features available on every provider\n  * Features that require a Claude subscription\n  * CLI capabilities that vary by provider\n  * Admin and analytics\n  * Summary by provider\n* Availability by subscription plan\n* Model availability\n* Related resources\n\n### [amazon-bedrock](https://code.claude.com/docs/en/amazon-bedrock.md)\n\n* Prerequisites\n* Sign in with Bedrock\n* Set up manually\n  * 1. Submit use case details\n  * 2. Configure AWS credentials\n    * Advanced credential configuration\n      * Example configuration\n      * Configuration settings explained\n  * 3. Configure Claude Code\n  * 4. Pin model versions\n    * Map each model version to an inference profile\n* Startup model checks\n* IAM configuration\n* 1M token context window\n* Service tiers\n* AWS Guardrails\n* Use the Mantle endpoint\n  * Enable Mantle\n  * Select a Mantle model\n  * Run Mantle alongside the Invoke API\n  * Route Mantle through a gateway\n  * Mantle environment variables\n* Troubleshooting\n  * Authentication loop with SSO and corporate proxies\n  * Region issues\n  * Zero token counts in /context\n  * Mantle endpoint errors\n* Additional resources\n\n### [claude-platform-on-aws](https://code.claude.com/docs/en/claude-platform-on-aws.md)\n\n* Prerequisites\n* Setup\n  * 1. Configure AWS credentials\n  * 2. Configure Claude Code\n  * 3. Pin model versions\n* Use the Agent SDK\n* Route through a corporate proxy\n* Troubleshooting\n  * `403 Forbidden` or `AccessDenied` on every request\n  * Requests fail with a missing-workspace error\n  * Requests still go to `api.anthropic.com`\n* Additional resources\n\n### [google-vertex-ai](https://code.claude.com/docs/en/google-vertex-ai.md)\n\n* Prerequisites\n* Sign in with Agent Platform\n* Region configuration\n* Set up manually\n  * 1. Enable Agent Platform API\n  * 2. Request model access\n  * 3. Configure GCP credentials\n    * Advanced credential configuration\n  * 4. Configure Claude Code\n  * 5. Pin model versions\n* Startup model checks\n* IAM configuration\n* 1M token context window\n* Troubleshooting\n* Additional resources\n\n### [microsoft-foundry](https://code.claude.com/docs/en/microsoft-foundry.md)\n\n* Prerequisites\n* Setup\n  * 1. Provision Microsoft Foundry resource\n  * 2. Configure Azure credentials\n  * 3. Configure Claude Code\n  * 4. Pin model versions\n  * 5. Run Claude Code\n* Azure RBAC configuration\n* Troubleshooting\n* Additional resources\n\n### [network-config](https://code.claude.com/docs/en/network-config.md)\n\n* Proxy configuration\n  * Environment variables\n  * Basic authentication\n* CA certificate store\n* Custom CA certificates\n* mTLS authentication\n* Network access requirements\n* Additional resources\n\n### [devcontainer](https://code.claude.com/docs/en/devcontainer.md)\n\n* Add Claude Code to your dev container\n* Persist authentication and settings across rebuilds\n* Enforce organization policy\n* Restrict network egress\n* Run without permission prompts\n* Try the reference container\n* Next steps\n\n### Gateways > Claude apps gateway\n\n#### [claude-apps-gateway-config](https://code.claude.com/docs/en/claude-apps-gateway-config.md)\n\n* File structure\n* Secret expansion\n* Required sections\n  * `listen`\n  * `oidc`\n  * `session`\n  * `store`\n  * `upstreams`\n    * Anthropic API\n    * Amazon Bedrock\n    * Claude Platform on AWS\n    * Google Cloud Agent Platform\n    * Microsoft Foundry\n    * Multiple upstreams\n* Optional sections\n  * `admin`\n  * `enforcement`\n  * `models`\n  * `managed`\n    * What goes in `cli`\n    * Precedence with other managed sources\n  * `telemetry`\n  * HTTP tuning\n* Complete example\n* Client-side managed settings\n* Related\n\n#### [claude-apps-gateway-spend-limits](https://code.claude.com/docs/en/claude-apps-gateway-spend-limits.md)\n\n* Set a cap\n  * Authenticate to the admin API\n* How enforcement works\n  * Postgres availability\n* Admin API reference\n  * `/effective`\n  * `/audit`\n  * Pagination\n* Data lifecycle\n* Related\n\n#### [claude-apps-gateway-deploy](https://code.claude.com/docs/en/claude-apps-gateway-deploy.md)\n\n* Identity provider setup\n* Deployment\n  * Container image\n  * Kubernetes\n  * Cloud Run\n  * Push the gateway URL to developer machines\n* Operations\n  * Logs\n  * Health\n  * Outage behavior\n  * JWT secret rotation\n  * Postgres\n  * Upgrades\n* Security\n  * Data flow\n  * Threat model summary\n  * User-code brute-force resistance\n  * Compliance posture\n* Troubleshooting\n* Related\n\n#### [claude-apps-gateway-on-gcp](https://code.claude.com/docs/en/claude-apps-gateway-on-gcp.md)\n\n* What you'll build\n* Prerequisites\n* Deploy the gateway\n* Terraform reference\n* Troubleshooting\n* Next steps\n\n### Gateways > Other gateways\n\n#### [llm-gateway-connect](https://code.claude.com/docs/en/llm-gateway-connect.md)\n\n* Check for an existing configuration\n* Configure Claude Code yourself\n  * Set the credential variable\n  * Set the base URL and credential\n    * Set as shell environment variables\n    * Set in a settings file\n  * Verify the connection\n    * Confirm in Claude Code\n  * How the credential variable maps to a header\n  * Conflicts with an existing login\n* Configure each surface\n  * VS Code extension\n  * Desktop app\n  * GitHub Actions\n  * Agent SDK\n  * Slack, web, and Remote Control\n* Additional configuration\n  * Send additional headers\n  * Add gateway models to the model picker\n  * Rotate credentials with apiKeyHelper\n  * Route to a cloud provider through a gateway\n    * Amazon Bedrock\n    * Google Cloud's Agent Platform\n    * Microsoft Foundry\n    * Claude Platform on AWS\n* Troubleshoot gateway errors\n* Related resources\n\n#### [llm-gateway-rollout](https://code.claude.com/docs/en/llm-gateway-rollout.md)\n\n* Prerequisites\n  * Gateway requirements\n* Rollout steps\n  * Confirm the gateway routes your models\n  * Issue developer credentials\n  * Test Claude Code against the gateway\n  * Distribute the configuration\n    * What to distribute\n    * Distribute through managed settings\n    * Hand developers the values to set themselves\n  * Verify the rollout\n* Maintain the gateway\n* Related resources\n\n#### [llm-gateway-protocol](https://code.claude.com/docs/en/llm-gateway-protocol.md)\n\n* API formats\n  * Foundry and Claude Platform on AWS\n  * Optional endpoints and startup traffic\n  * Streaming\n  * Format mismatch with the upstream\n* Request headers\n  * Forward as open lists\n* System prompt attribution block\n* Feature pass-through\n  * Automatic retry and error forwarding\n  * Disable pre-release capabilities\n* Model discovery\n  * When discovery runs\n  * Request and response\n  * Picker entries and caching\n* Related resources\n\n## Gateways\n\n### [gateways](https://code.claude.com/docs/en/gateways.md)\n\n* How a gateway works\n* Choose a gateway\n  * Claude apps gateway\n  * Other gateways\n* Subscriptions and gateways\n* Configure separately from the gateway\n* Next steps\n\n## Usage and costs\n\n### [monitoring-usage](https://code.claude.com/docs/en/monitoring-usage.md)\n\n* Quick start\n* Administrator configuration\n* Configuration details\n  * Common configuration variables\n  * mTLS authentication\n  * Metrics cardinality control\n  * Traces (beta)\n    * Span hierarchy\n    * Span attributes\n  * Dynamic headers\n    * Settings configuration\n    * Script requirements\n    * Refresh behavior\n  * Multi-team organization support\n  * Example configurations\n* Available metrics and events\n  * Standard attributes\n  * Metrics\n  * Metric details\n    * Session counter\n    * Lines of code counter\n    * Pull request counter\n    * Commit counter\n    * Cost counter\n    * Token counter\n    * Code edit tool decision counter\n    * Active time counter\n  * Events\n    * Event correlation attributes\n    * User prompt event\n    * Assistant response event\n    * Tool result event\n    * API request event\n    * API error event\n    * API refusal event\n    * API request body event\n    * API response body event\n    * Tool decision event\n    * Permission mode changed event\n    * Auth event\n    * MCP server connection event\n    * Internal error event\n    * Plugin installed event\n    * Plugin loaded event\n    * Skill activated event\n    * At mention event\n    * API retries exhausted event\n    * Hook registered event\n    * Hook execution start event\n    * Hook execution complete event\n    * Hook plugin metrics event\n    * Compaction event\n    * Feedback survey event\n* Interpret metrics and events data\n  * Usage monitoring\n  * Cost monitoring\n  * Alerting and segmentation\n  * Detect retry exhaustion\n  * Event analysis\n* Audit security events\n  * Attribute actions to users\n  * Audit MCP activity\n  * Map security questions to events\n  * Send events to a SIEM\n* Backend considerations\n  * For metrics\n  * For events/logs\n  * For traces\n* Service information\n* ROI measurement resources\n* Security and privacy\n* Monitor Claude Code on Amazon Bedrock\n\n### [costs](https://code.claude.com/docs/en/costs.md)\n\n* Track your costs\n  * Using the `/usage` command\n* Managing costs for teams\n  * Rate limit recommendations\n  * Agent team token costs\n* Reduce token usage\n  * Manage context proactively\n  * Choose the right model\n  * Reduce MCP server overhead\n  * Install code intelligence plugins for typed languages\n  * Offload processing to hooks and skills\n  * Move instructions from CLAUDE.md to skills\n  * Adjust extended thinking\n  * Delegate verbose operations to subagents\n  * Manage agent team costs\n  * Write specific prompts\n  * Work efficiently on complex tasks\n* Background token usage\n* Understanding changes in Claude Code behavior\n\n### [analytics](https://code.claude.com/docs/en/analytics.md)\n\n* Access analytics for Team and Enterprise\n  * Enable contribution metrics\n  * Review summary metrics\n  * Explore the charts\n    * Track adoption\n    * Measure PRs per user\n    * View pull requests breakdown\n    * Find top contributors\n  * PR attribution\n    * Tagging criteria\n    * Attribution process\n    * Time window\n    * Excluded files\n    * Attribution notes\n  * Get the most from analytics\n    * Monitor adoption\n    * Measure ROI\n    * Identify power users\n    * Access data programmatically\n* Access analytics for API customers\n  * View team insights\n* Related resources\n\n## Plugin distribution\n\n### [plugin-marketplaces](https://code.claude.com/docs/en/plugin-marketplaces.md)\n\n* Overview\n* Walkthrough: create a local marketplace\n* Create the marketplace file\n* Marketplace schema\n  * Required fields\n  * Owner fields\n  * Optional fields\n* Plugin entries\n  * Required fields\n  * Optional plugin fields\n* Plugin sources\n  * Relative paths\n  * GitHub repositories\n  * Git repositories\n  * Git subdirectories\n  * npm packages\n  * Advanced plugin entries\n  * Strict mode\n* Host and distribute marketplaces\n  * Host on GitHub (recommended)\n  * Host on other git services\n  * Private repositories\n  * Test locally before distribution\n  * Require marketplaces for your team\n  * Pre-populate plugins for containers\n  * Managed marketplace restrictions\n    * Common configurations\n    * How restrictions work\n  * Version resolution and release channels\n    * Set up release channels\n      * Example\n      * Assign channels to user groups\n    * Pin dependency versions\n  * Rename or remove a plugin\n* Validation and testing\n* Manage marketplaces from the CLI\n  * Plugin marketplace add\n  * Plugin marketplace list\n  * Plugin marketplace remove\n  * Plugin marketplace update\n* Troubleshooting\n  * Marketplace not loading\n  * Marketplace validation errors\n  * Plugin installation failures\n  * Private repository authentication fails\n  * Marketplace updates fail in offline environments\n  * Git operations time out\n  * Plugins with relative paths fail in URL-based marketplaces\n  * Files not found after installation\n* See also\n\n### [plugin-dependencies](https://code.claude.com/docs/en/plugin-dependencies.md)\n\n* Why constrain dependency versions\n* Declare a dependency with a version constraint\n* Depend on a plugin from another marketplace\n* Tag plugin releases for version resolution\n* How constraints interact\n* Enable or disable a plugin with dependencies\n* Remove orphaned auto-installed dependencies\n* Resolve dependency errors\n* See also\n\n### [plugin-hints](https://code.claude.com/docs/en/plugin-hints.md)\n\n* How it works\n* Emit the hint\n* Choose where to emit\n* What the user sees\n* Hint format\n* Requirements\n* Get your plugin into the official marketplace\n* See also\n\n### [plugin-relevance](https://code.claude.com/docs/en/plugin-relevance.md)\n\n* How it works\n* Add relevance to a plugin entry\n* Field reference\n  * `relevance`\n  * `relevance.signals`\n* Enable suggestions in managed settings\n* What the user sees\n* Validate your marketplace\n* See also\n\n## Security and data\n\n### [security](https://code.claude.com/docs/en/security.md)\n\n* How we approach security\n  * Security foundation\n  * Permission-based architecture\n  * Built-in protections\n  * User responsibility\n* Protect against prompt injection\n  * Core protections\n  * Privacy safeguards\n  * Additional safeguards\n* MCP security\n* IDE security\n* Cloud execution security\n* Security best practices\n  * Working with sensitive code\n  * Team security\n  * Reporting security issues\n* Related resources\n\n### [data-usage](https://code.claude.com/docs/en/data-usage.md)\n\n* Data policies\n  * Data training policy\n  * Development Partner Program\n  * Feedback using the `/feedback` command\n  * Session quality surveys\n  * Data retention\n* Data access\n* Local Claude Code: Data flow and dependencies\n  * Cloud execution: Data flow and dependencies\n* Telemetry services\n* Default behaviors by API provider\n  * WebFetch domain safety check\n\n### [zero-data-retention](https://code.claude.com/docs/en/zero-data-retention.md)\n\n* ZDR scope\n  * What ZDR covers\n  * What ZDR does not cover\n* Features disabled under ZDR\n  * Model availability under ZDR\n* Data retention for policy violations\n* Request ZDR\n\n## Adoption\n\n### [communications-kit](https://code.claude.com/docs/en/communications-kit.md)\n\n* Launch communications\n  * Before you send\n  * The announcement\n  * Executive sponsor variant\n  * Pilot group variant\n  * Champion recruitment DM\n* Tips and tricks campaign\n  * Get started\n  * Project memory\n  * Control and safety\n  * Connect your tools\n  * Automate your workflows\n  * Day-to-day development\n  * Share and scale\n  * Security and admin\n* Quick reference\n  * FAQ responses\n  * Prompt templates\n\n### [champion-kit](https://code.claude.com/docs/en/champion-kit.md)\n\n* The champion role\n  * What this should cost you\n* Share what you discover\n  * What is worth sharing\n  * Where to share it\n  * The format that works\n* Be the person people ask\n  * Answer with a prompt rather than an explanation\n  * Point at the feature rather than the documentation\n  * Questions you are likely to hear\n* Grow the circle\n  * Patterns that tend to work\n  * Thirty-day playbook\n  * When someone wants to go deeper\n* Respond to common concerns\n* Quick-reference sheet\n\n## Settings and permissions\n\n### [settings](https://code.claude.com/docs/en/settings.md)\n\n* Configuration scopes\n  * Available scopes\n  * When to use each scope\n  * How scopes interact\n  * What uses scopes\n* Settings files\n  * When edits take effect\n  * Invalid entries in managed settings\n  * Available settings\n  * Global config settings\n  * Worktree settings\n  * Permission settings\n  * Permission rule syntax\n  * Sandbox settings\n    * Sandbox path prefixes\n  * Attribution settings\n  * File suggestion settings\n  * Footer link badges\n  * Hook configuration\n  * Compute managed settings with a policy helper\n  * Settings precedence\n  * Verify active settings\n  * Key points about the configuration system\n  * System prompt\n  * Exclude sensitive files\n* Subagent configuration\n* Plugin configuration\n  * Plugin settings\n    * `enabledPlugins`\n    * `extraKnownMarketplaces`\n    * `strictKnownMarketplaces`\n    * `strictPluginOnlyCustomization`\n  * Manage plugins\n* Environment variables\n* Tools available to Claude\n* See also\n\n### [permissions](https://code.claude.com/docs/en/permissions.md)\n\n* Permission system\n* Manage permissions\n* Permission modes\n* Permission rule syntax\n  * Match all uses of a tool\n  * Use specifiers for fine-grained control\n  * Match by input parameter\n  * Wildcard patterns\n  * Tool name wildcards\n* Tool-specific permission rules\n  * Bash\n    * Compound commands\n    * Process wrappers\n    * Read-only commands\n  * PowerShell\n  * Read and Edit\n  * WebFetch\n  * MCP\n  * Agent (subagents)\n  * Cd\n* Extend permissions with hooks\n* Working directories\n  * Additional directories grant file access, not configuration\n* How permissions interact with sandboxing\n* Managed settings\n  * Managed-only settings\n* Settings precedence\n* Project allow rules and workspace trust\n* Example configurations\n* See also\n\n### [sandbox-environments](https://code.claude.com/docs/en/sandbox-environments.md)\n\n* Compare sandboxing approaches\n* Choose an approach\n  * How isolation relates to permission modes\n* Sandboxed Bash tool\n* Sandbox runtime\n* Dev containers\n* Custom container\n* Virtual machine\n* Claude Code on the web\n* Enforce isolation across an organization\n* See also\n\n### [sandboxing](https://code.claude.com/docs/en/sandboxing.md)\n\n* Get started\n  * Set up Linux and WSL2\n  * Sandbox modes\n* Configure sandboxing\n  * Protect credentials\n    * Mask environment variables\n* How sandboxing works\n  * Filesystem isolation\n  * Network isolation\n  * OS-level enforcement\n* How sandboxing relates to permissions and permission modes\n  * Permission rules\n  * Permission modes\n* Configure the sandbox for your organization\n  * Enforce sandboxing with managed settings\n  * Keep developers from widening the policy\n  * Custom proxy configuration\n* Troubleshooting\n* Limitations\n  * Security limitations\n  * Platform and tool compatibility\n  * Scope\n* See also\n\n## Model and responses\n\n### [model-config](https://code.claude.com/docs/en/model-config.md)\n\n* Available models\n  * Model aliases\n  * Work with Fable 5\n  * Setting your model\n* Restrict model selection\n  * Surface coverage\n  * Default model behavior\n  * Enforce the allowlist for the Default model\n  * Control the model users run on\n  * Merge behavior\n  * Mantle model IDs\n  * Organization model restrictions\n* Organization default model\n* Organization effort limits\n* Special model behavior\n  * `default` model setting\n  * `opusplan` model setting\n  * Fallback model chains\n  * Automatic model fallback\n    * Check what triggered fallback\n    * Ask before switching\n    * Enable fallback on Bedrock, Agent Platform, and Foundry\n    * Security research and biology workloads\n  * Adjust effort level\n    * Choose an effort level\n    * Use ultrathink for one-off deep reasoning\n    * Set the effort level\n    * Adaptive reasoning and fixed thinking budgets\n  * Extended thinking\n  * Extended context\n    * Sonnet 5 context window\n* Checking your current model\n* Add a custom model option\n* Environment variables\n  * Pin models for third-party deployments\n  * Customize pinned model display and capabilities\n  * Override model IDs per version\n  * Prompt caching configuration\n\n### [fast-mode](https://code.claude.com/docs/en/fast-mode.md)\n\n* Toggle fast mode\n* Understand the cost tradeoff\n* Decide when to use fast mode\n  * Fast mode vs effort level\n* Requirements\n  * Enable fast mode for your organization\n  * Require per-session opt-in\n* Handle rate limits\n* Research preview\n* See also\n\n### [advisor](https://code.claude.com/docs/en/advisor.md)\n\n* When to use the advisor\n* Enable the advisor\n  * Use the `/advisor` command\n  * Set `advisorModel` in settings\n  * Use the `--advisor` flag\n* Choose an advisor model\n  * Common model pairings\n* When Claude consults the advisor\n* What you see during a session\n* Cost\n* Impact on prompt caching\n* Requirements\n* Turn the advisor off\n* Compare with related features\n* See also\n\n### [output-styles](https://code.claude.com/docs/en/output-styles.md)\n\n* Built-in output styles\n* Change your output style\n* Create a custom output style\n  * Frontmatter\n* How output styles work\n* Comparisons to related features\n* Related resources\n\n## Interface\n\n### [terminal-config](https://code.claude.com/docs/en/terminal-config.md)\n\n* Enter multiline prompts\n* Enable Option key shortcuts on macOS\n* Get a terminal bell or notification\n  * Play a sound with a Notification hook\n* Configure tmux\n* Match the color theme\n  * Create a custom theme\n    * Text and accent colors\n    * Status colors\n    * Input box and mode indicators\n    * Diff rendering\n    * Fullscreen mode\n    * Usage meter and speaker labels\n    * Shimmer variants and subagent colors\n* Switch to fullscreen rendering\n* Paste large content\n* Edit prompts with Vim keybindings\n* Related resources\n\n### [fullscreen](https://code.claude.com/docs/en/fullscreen.md)\n\n* Enable fullscreen rendering\n* What changes\n* Use the mouse\n* Scroll the conversation\n  * Auto-follow\n  * Mouse wheel scrolling\n  * Scroll in the JetBrains IDE terminal\n* Search and review the conversation\n* Clear the conversation\n* Use with tmux\n* Keep native text selection\n* Research preview\n\n### [voice-dictation](https://code.claude.com/docs/en/voice-dictation.md)\n\n* Requirements\n* Enable voice dictation\n* Hold to record\n* Tap to record and send\n* Change the dictation language\n* Rebind the dictation key\n* Troubleshooting\n  * Terminal not listed in macOS Microphone settings\n* See also\n\n### [statusline](https://code.claude.com/docs/en/statusline.md)\n\n* Set up a status line\n  * Use the /statusline command\n  * Manually configure a status line\n  * Disable the status line\n* Build a status line step by step\n* How status lines work\n* Available data\n  * Context window fields\n* Examples\n  * Context window usage\n  * Git status with colors\n  * Cost and duration tracking\n  * Display multiple lines\n  * Clickable links\n  * Rate limit usage\n  * Cache expensive operations\n  * Windows configuration\n* Subagent status lines\n* Tips\n* Troubleshooting\n\n### [keybindings](https://code.claude.com/docs/en/keybindings.md)\n\n* Configuration file\n* Contexts\n* Available actions\n  * App actions\n  * History actions\n  * Chat actions\n  * Autocomplete actions\n  * Confirmation actions\n  * Permission actions\n  * Transcript actions\n  * History search actions\n  * Task actions\n  * Theme actions\n  * Help actions\n  * Tabs actions\n  * Attachments actions\n  * Footer actions\n  * Message selector actions\n  * Diff actions\n  * Model picker actions\n  * Select actions\n  * Plugin actions\n  * Settings actions\n  * Voice actions\n  * Scroll actions\n* Keystroke syntax\n  * Modifiers\n  * Uppercase letters\n  * Chords\n  * Special keys\n* Unbind default shortcuts\n* Reserved shortcuts\n* Terminal conflicts\n* Vim mode interaction\n* Validation\n\n## Reference\n\n### [cli-reference](https://code.claude.com/docs/en/cli-reference.md)\n\n* CLI commands\n* CLI flags\n  * System prompt flags\n* See also\n\n### [commands](https://code.claude.com/docs/en/commands.md)\n\n* Commands across a typical workflow\n* All commands\n* MCP prompts\n* See also\n\n### [env-vars](https://code.claude.com/docs/en/env-vars.md)\n\n* Set environment variables\n  * In your shell\n  * In settings files\n* Precedence\n* Variables\n* See also\n\n### [tools-reference](https://code.claude.com/docs/en/tools-reference.md)\n\n* Configure tools with permission rules and hooks\n* Agent tool behavior\n* Bash tool behavior\n* Edit tool behavior\n* Glob tool behavior\n* Grep tool behavior\n* LSP tool behavior\n* Monitor tool\n  * WebSocket source\n* NotebookEdit tool behavior\n* PowerShell tool\n  * Enable the PowerShell tool\n  * Shell selection in settings, hooks, and skills\n  * Preview limitations\n* Read tool behavior\n* WebFetch tool behavior\n* WebSearch tool behavior\n* Write tool behavior\n* Check which tools are available\n* See also\n\n### [interactive-mode](https://code.claude.com/docs/en/interactive-mode.md)\n\n* Keyboard shortcuts\n  * General controls\n  * Text editing\n  * Theme and display\n  * Multiline input\n  * Quick commands\n  * Transcript viewer\n  * Voice input\n* Commands\n* Vim editor mode\n  * Mode switching\n  * Navigation (NORMAL mode)\n  * Editing (NORMAL mode)\n  * Text objects (NORMAL mode)\n  * Visual mode\n* Command history\n  * Reverse search with Ctrl+R\n* Background Bash commands\n  * How backgrounding works\n  * Shell mode with `!` prefix\n* Prompt suggestions\n* Side questions with /btw\n* Task list\n* Session recap\n* PR review status\n* See also\n\n### [checkpointing](https://code.claude.com/docs/en/checkpointing.md)\n\n* How checkpoints work\n  * Automatic tracking\n  * Rewind and summarize\n    * Rewind past a cleared conversation\n    * Restore vs. summarize\n* Common use cases\n* Limitations\n  * Bash command changes not tracked\n  * External changes not tracked\n  * Not a replacement for version control\n* See also\n\n### [hooks](https://code.claude.com/docs/en/hooks.md)\n\n* Hook lifecycle\n  * How a hook resolves\n* Configuration\n  * Hook locations\n  * Matcher patterns\n    * Match MCP tools\n  * Hook handler fields\n    * Common fields\n    * Command hook fields\n      * Exec form and shell form\n    * HTTP hook fields\n    * MCP tool hook fields\n    * Prompt and agent hook fields\n  * Reference scripts by path\n  * Hooks in skills and agents\n  * The `/hooks` menu\n  * Disable or remove hooks\n* Hook input and output\n  * Common input fields\n  * Exit code output\n    * Exit code 2 behavior per event\n  * HTTP response handling\n  * JSON output\n    * Emit terminal notifications\n    * Add context for Claude\n    * Decision control\n* Hook events\n  * SessionStart\n    * SessionStart input\n    * SessionStart decision control\n    * Persist environment variables\n  * Setup\n    * Setup input\n    * Setup decision control\n  * InstructionsLoaded\n    * InstructionsLoaded input\n    * InstructionsLoaded decision control\n  * UserPromptSubmit\n    * UserPromptSubmit input\n    * UserPromptSubmit decision control\n  * UserPromptExpansion\n    * UserPromptExpansion input\n    * UserPromptExpansion decision control\n  * MessageDisplay\n    * MessageDisplay input\n    * MessageDisplay output\n  * PreToolUse\n    * PreToolUse input\n      * Bash\n      * Write\n      * Edit\n      * Read\n      * Glob\n      * Grep\n      * WebFetch\n      * WebSearch\n      * Agent\n      * AskUserQuestion\n      * ExitPlanMode\n    * PreToolUse decision control\n    * Defer a tool call for later\n  * PermissionRequest\n    * PermissionRequest input\n    * PermissionRequest decision control\n    * Permission update entries\n  * PostToolUse\n    * PostToolUse input\n    * PostToolUse decision control\n  * PostToolUseFailure\n    * PostToolUseFailure input\n    * PostToolUseFailure decision control\n  * PostToolBatch\n    * PostToolBatch input\n    * PostToolBatch decision control\n  * PermissionDenied\n    * PermissionDenied input\n    * PermissionDenied decision control\n  * Notification\n    * Notification input\n  * SubagentStart\n    * SubagentStart input\n  * SubagentStop\n    * SubagentStop input\n  * TaskCreated\n    * TaskCreated input\n    * TaskCreated decision control\n  * TaskCompleted\n    * TaskCompleted input\n    * TaskCompleted decision control\n  * Stop\n    * Stop input\n    * Stop decision control\n  * StopFailure\n    * StopFailure input\n  * TeammateIdle\n    * TeammateIdle input\n    * TeammateIdle decision control\n  * ConfigChange\n    * ConfigChange input\n    * ConfigChange decision control\n  * CwdChanged\n    * CwdChanged input\n    * CwdChanged output\n  * FileChanged\n    * FileChanged input\n    * FileChanged output\n  * WorktreeCreate\n    * WorktreeCreate input\n    * WorktreeCreate output\n  * WorktreeRemove\n    * WorktreeRemove input\n  * PreCompact\n    * PreCompact input\n  * PostCompact\n    * PostCompact input\n  * SessionEnd\n    * SessionEnd input\n  * Elicitation\n    * Elicitation input\n    * Elicitation output\n  * ElicitationResult\n    * ElicitationResult input\n    * ElicitationResult output\n* Prompt-based hooks\n  * How prompt-based hooks work\n  * Prompt hook configuration\n  * Response schema\n  * Check multiple conditions before stopping\n* Agent-based hooks\n  * How agent hooks work\n  * Agent hook configuration\n* Run hooks in the background\n  * Configure an async hook\n  * How async hooks execute\n  * Run tests after file changes\n  * Limitations\n* Security considerations\n  * Disclaimer\n  * Security best practices\n* Windows PowerShell tool\n* Debug hooks\n\n### [plugins-reference](https://code.claude.com/docs/en/plugins-reference.md)\n\n* Plugin components reference\n  * Skills\n  * Agents\n  * Hooks\n  * MCP servers\n  * LSP servers\n  * Monitors\n  * Themes\n* Plugin installation scopes\n* Skills-directory plugins\n  * Choose where the plugin loads from\n  * Edit, reload, and disable a skills-directory plugin\n* Plugin manifest schema\n  * Complete schema\n  * Required fields\n  * Unrecognized fields\n  * Metadata fields\n  * Default enablement\n  * Component path fields\n  * Experimental components\n  * User configuration\n  * Channels\n  * Path behavior rules\n  * Environment variables\n    * Persistent data directory\n* Plugin caching and file resolution\n  * Path traversal limitations\n  * Share files within a marketplace with symlinks\n* Plugin directory structure\n  * Standard plugin layout\n  * File locations reference\n* CLI commands reference\n  * plugin init\n  * plugin install\n  * plugin uninstall\n  * plugin prune\n  * plugin enable\n  * plugin disable\n  * plugin update\n  * plugin list\n  * plugin details\n  * plugin tag\n* Debugging and development tools\n  * Debugging commands\n  * Common issues\n  * Example error messages\n  * Hook troubleshooting\n  * MCP server troubleshooting\n  * Directory structure mistakes\n* Distribution and versioning reference\n  * Version management\n* See also\n\n### [channels-reference](https://code.claude.com/docs/en/channels-reference.md)\n\n* Overview\n* What you need\n* Example: build a webhook receiver\n* Test during the research preview\n* Server options\n* Notification format\n* Expose a reply tool\n* Gate inbound messages\n* Relay permission prompts\n  * How relay works\n  * Permission request fields\n  * Add relay to a chat bridge\n  * Full example\n* Package as a plugin\n* See also\n\n## Glossary\n\n### [glossary](https://code.claude.com/docs/en/glossary.md)\n\n* A\n  * Agent teams\n  * Agentic coding\n  * Agentic harness\n  * Agentic loop\n  * Artifact\n  * Auto memory\n  * Auto mode\n* B\n  * Bare mode\n  * Bundled skills\n* C\n  * Channel\n  * Checkpoint\n  * `.claude` directory\n  * CLAUDE.md\n  * Command\n  * Compaction\n  * Context window\n* D\n  * Dispatch\n* E\n  * Effort level\n  * Extended thinking\n* H\n  * Hook\n* M\n  * Managed settings\n  * MCP (Model Context Protocol)\n  * MCP Tool Search\n* N\n  * Non-interactive mode\n* O\n  * Output style\n* P\n  * Permission mode\n  * Permission rule\n  * Plan mode\n  * Plugin\n  * Project trust\n  * Prompt injection\n* R\n  * Remote Control\n  * Rules\n* S\n  * Sandboxing\n  * Session\n  * Settings layers\n  * Skill\n  * Subagent\n  * Surface\n* T\n  * Teleport\n  * Tool\n  * Turn\n* V\n  * Verification loop\n* W\n  * Worktree isolation\n* Deprecated and renamed terms\n\n## Agent SDK\n\n### [overview](https://code.claude.com/docs/en/agent-sdk/overview.md)\n\n* Get started\n* Capabilities\n  * Claude Code features\n* Compare the Agent SDK to other Claude tools\n* Changelog\n* Reporting bugs\n* Branding guidelines\n* License and terms\n* Next steps\n\n### [quickstart](https://code.claude.com/docs/en/agent-sdk/quickstart.md)\n\n* Prerequisites\n* Setup\n* Create a buggy file\n* Build an agent that finds and fixes bugs\n  * Run your agent\n  * Try other prompts\n  * Customize your agent\n* Key concepts\n* Next steps\n\n## Core concepts\n\n### [agent-loop](https://code.claude.com/docs/en/agent-sdk/agent-loop.md)\n\n* The loop at a glance\n* Turns and messages\n* Message types\n  * Handle messages\n* Tool execution\n  * Built-in tools\n  * Tool permissions\n  * Parallel tool execution\n* Control how the loop runs\n  * Turns and budget\n  * Effort level\n  * Permission mode\n  * Model\n* The context window\n  * What consumes context\n  * Automatic compaction\n  * Keep context efficient\n* Sessions and continuity\n* Handle the result\n* Hooks\n* Put it all together\n* Next steps\n\n### [claude-code-features](https://code.claude.com/docs/en/agent-sdk/claude-code-features.md)\n\n* Control filesystem settings with settingSources\n  * What settingSources does not control\n* Project instructions (CLAUDE.md and rules)\n  * CLAUDE.md load locations\n* Skills\n* Hooks\n  * When to use which hook type\n* Choose the right feature\n* Related resources\n\n### [sessions](https://code.claude.com/docs/en/agent-sdk/sessions.md)\n\n* Choose an approach\n  * Continue, resume, and fork\n* Automatic session management\n  * Python: `ClaudeSDKClient`\n  * TypeScript: `continue: true`\n* Use session options with `query()`\n  * Capture the session ID\n  * Resume by ID\n  * Fork to explore alternatives\n* Resume across hosts\n* Related resources\n\n### [session-storage](https://code.claude.com/docs/en/agent-sdk/session-storage.md)\n\n* The `SessionStore` interface\n* Quick start\n* Write your own adapter\n* Reference implementations\n  * Validate your adapter\n* Behavior notes\n  * Dual-write architecture\n  * Mirror writes are best-effort\n  * `getSessionMessages` returns the post-compaction chain\n  * `forkSession` is not a byte copy\n  * Subagent transcripts\n  * Retention\n* Supported on\n* Related resources\n\n## Input and output\n\n### [streaming-vs-single-mode](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md)\n\n* Overview\n* Streaming Input Mode (Recommended)\n  * How It Works\n  * Benefits\n  * Implementation Example\n* Single Message Input\n  * When to Use Single Message Input\n  * Limitations\n  * Implementation Example\n\n### [user-input](https://code.claude.com/docs/en/agent-sdk/user-input.md)\n\n* Detect when Claude needs input\n* Handle tool approval requests\n  * Respond to tool requests\n* Handle clarifying questions\n  * Question format\n    * Option previews (TypeScript)\n  * Response format\n    * Support free-text input\n  * Complete example\n* Limitations\n* Other ways to get user input\n  * Streaming input\n  * Custom tools\n* Related resources\n\n### [streaming-output](https://code.claude.com/docs/en/agent-sdk/streaming-output.md)\n\n* Enable streaming output\n* StreamEvent reference\n* Message flow\n* Stream text responses\n* Stream tool calls\n* Build a streaming UI\n* Known limitations\n* Next steps\n\n### [structured-outputs](https://code.claude.com/docs/en/agent-sdk/structured-outputs.md)\n\n* Why structured outputs?\n* Quick start\n* Type-safe schemas with Zod and Pydantic\n* Output format configuration\n* Example: TODO tracking agent\n* Error handling\n* Related resources\n\n## Extend with tools\n\n### [custom-tools](https://code.claude.com/docs/en/agent-sdk/custom-tools.md)\n\n* Quick reference\n* Create a custom tool\n  * Weather tool example\n  * Call a custom tool\n  * Add more tools\n  * Add tool annotations\n* Control tool access\n  * Tool name format\n  * Configure allowed tools\n* Handle errors\n* Return images and resources\n  * Images\n  * Resources\n* Return structured data\n* Example: unit converter\n* Next steps\n* Related documentation\n\n### [mcp](https://code.claude.com/docs/en/agent-sdk/mcp.md)\n\n* Quickstart\n* Add an MCP server\n  * In code\n  * From a config file\n* Allow MCP tools\n  * Tool naming convention\n  * Auto-approve with allowedTools\n  * Discover available tools\n* Transport types\n  * stdio servers\n  * HTTP/SSE servers\n  * SDK MCP servers\n* MCP tool search\n* Authentication\n  * Pass credentials via environment variables\n  * HTTP headers for remote servers\n  * OAuth2 authentication\n* Examples\n  * List issues from a repository\n  * Query a database\n* Error handling\n* Troubleshooting\n  * Server shows \"failed\" status\n  * Tools not being called\n  * Connection timeouts\n* Related resources\n\n### [tool-search](https://code.claude.com/docs/en/agent-sdk/tool-search.md)\n\n* How tool search works\n* Configure tool search\n* Optimize tool discovery\n* Limits\n* Related documentation\n\n### [subagents](https://code.claude.com/docs/en/agent-sdk/subagents.md)\n\n* Overview\n* Benefits of using subagents\n  * Context isolation\n  * Parallelization\n  * Specialized instructions and knowledge\n  * Tool restrictions\n* Create subagents\n  * Programmatic definition (recommended)\n  * AgentDefinition configuration\n  * Filesystem-based definition (alternative)\n* What subagents inherit\n* Invoke subagents\n  * Automatic invocation\n  * Explicit invocation\n  * Dynamic agent configuration\n* Detect subagent invocation\n* Resume subagents\n* Tool restrictions\n  * Common tool combinations\n* Scale up with dynamic workflows\n* Troubleshooting\n  * Claude not delegating to subagents\n  * Filesystem-based agents not loading\n  * Long prompt failures on Windows\n* Related documentation\n\n## Customize behavior\n\n### [modifying-system-prompts](https://code.claude.com/docs/en/agent-sdk/modifying-system-prompts.md)\n\n* How system prompts work\n  * Decide on a starting point\n* Customize agent behavior\n  * CLAUDE.md files for project-level instructions\n    * Load CLAUDE.md with the SDK\n  * Output styles for persistent configurations\n    * Create an output style\n    * Activate an output style\n  * Append to the `claude_code` preset\n    * Improve prompt caching across users and machines\n  * Custom system prompts\n* Compare the four approaches\n* Use cases and best practices\n  * When to use CLAUDE.md\n  * When to use output styles\n  * When to use `systemPrompt` with append\n  * When to use custom `systemPrompt`\n* Combine approaches\n  * Combine an output style with session-specific additions\n* See also\n\n### [slash-commands](https://code.claude.com/docs/en/agent-sdk/slash-commands.md)\n\n* Discovering Available Slash Commands\n* Sending Slash Commands\n* Common Slash Commands\n  * `/compact` - Compact conversation history\n  * `/clear` - Reset conversation context\n* Creating Custom Slash Commands\n  * File Locations\n  * File Format\n    * Basic Example\n    * With Frontmatter\n  * Using Custom Commands in the SDK\n  * Advanced Features\n    * Arguments and Placeholders\n    * Bash Command Execution\n    * File References\n  * Organization with Namespacing\n  * Practical Examples\n    * Pull Request Review Command\n    * Test Runner Command\n* See Also\n\n### [skills](https://code.claude.com/docs/en/agent-sdk/skills.md)\n\n* Overview\n* How Skills Work with the SDK\n* Using Skills with the SDK\n* Skill Locations\n* Creating Skills\n* Tool Restrictions\n* Discovering Available Skills\n* Testing Skills\n* Troubleshooting\n  * Skills Not Found\n  * Skill Not Being Used\n  * Additional Troubleshooting\n* Related Documentation\n  * Skills Guides\n  * SDK Resources\n\n### [plugins](https://code.claude.com/docs/en/agent-sdk/plugins.md)\n\n* What are plugins?\n* Loading plugins\n  * Path specifications\n* Verifying plugin installation\n* Using plugin skills\n* Complete example\n* Plugin structure reference\n* Common use cases\n  * Development and testing\n  * Project-specific extensions\n  * Multiple plugin sources\n* Troubleshooting\n  * Plugin not loading\n  * Skills not appearing\n  * Path resolution issues\n* See also\n\n## Control and observability\n\n### [permissions](https://code.claude.com/docs/en/agent-sdk/permissions.md)\n\n* How permissions are evaluated\n* Allow and deny rules\n* Permission modes\n  * Available modes\n  * Set permission mode\n  * Mode details\n    * Accept edits mode (`acceptEdits`)\n    * Don't ask mode (`dontAsk`)\n    * Bypass permissions mode (`bypassPermissions`)\n    * Plan mode (`plan`)\n* Related resources\n\n### [hooks](https://code.claude.com/docs/en/agent-sdk/hooks.md)\n\n* How hooks work\n* Available hooks\n* Configure hooks\n  * Matchers\n  * Callback functions\n    * Inputs\n    * Outputs\n    * Asynchronous output\n* Examples\n  * Modify tool input\n  * Add context and block a tool\n  * Auto-approve specific tools\n  * Register multiple hooks\n  * Filter with multi-tool matchers\n  * Track subagent activity\n  * Make HTTP requests from hooks\n  * Forward notifications to Slack\n* Fix common issues\n  * Hook not firing\n  * Matcher not filtering as expected\n  * Hook timeout\n  * Tool blocked unexpectedly\n  * Modified input not applied\n  * Session hooks not available in Python\n  * Subagent permission prompts multiplying\n  * Recursive hook loops with subagents\n  * systemMessage not appearing in output\n* Related resources\n\n### [file-checkpointing](https://code.claude.com/docs/en/agent-sdk/file-checkpointing.md)\n\n* How checkpointing works\n* Implement checkpointing\n* Common patterns\n  * Checkpoint before risky operations\n  * Multiple restore points\n* Try it out\n* Limitations\n* Troubleshooting\n  * Checkpointing options not recognized\n  * User messages don't have UUIDs\n  * \"No file checkpoint found for message\" error\n  * \"File rewinding is not enabled\" error\n  * \"ProcessTransport is not ready for writing\" error\n* Next steps\n\n### [cost-tracking](https://code.claude.com/docs/en/agent-sdk/cost-tracking.md)\n\n* Understand token usage\n* Get the total cost of a query\n* Track per-step and per-model usage\n  * Track per-step usage\n  * Break down usage per model\n* Accumulate costs across multiple calls\n* Handle errors, caching, and token discrepancies\n  * Resolve output token discrepancies\n  * Track costs on failed conversations\n  * Track cache tokens\n  * Extend the prompt cache TTL to one hour\n* Related documentation\n\n### [observability](https://code.claude.com/docs/en/agent-sdk/observability.md)\n\n* How telemetry flows from the SDK\n* Enable telemetry export\n  * Flush telemetry from short-lived calls\n* Read agent traces\n* Link traces to your application\n* Tag telemetry from your agent\n* Attribute actions to your end users\n* Control sensitive data in exports\n* Related documentation\n\n### [todo-tracking](https://code.claude.com/docs/en/agent-sdk/todo-tracking.md)\n\n* Todo Lifecycle\n* When Todos Are Used\n* Examples\n  * Monitoring Todo Changes\n  * Real-time Progress Display\n* Migrate to Task tools\n* Related Documentation\n\n## Deployment\n\n### [hosting](https://code.claude.com/docs/en/agent-sdk/hosting.md)\n\n* The subprocess model\n  * State that lives on local disk\n* Choose a session pattern\n  * Ephemeral sessions\n  * Long-running sessions\n  * Hybrid sessions\n  * Multi-agent container\n* Provision the container\n  * Container-based sandboxing\n  * Runtime dependencies\n  * Resources\n  * Network\n* Handle production concerns\n  * Session and state persistence\n  * Observability\n  * Auth and secrets\n  * Scaling and concurrency\n  * Cost\n  * Multi-tenant isolation\n* Known limitations\n* Next steps\n\n### [secure-deployment](https://code.claude.com/docs/en/agent-sdk/secure-deployment.md)\n\n* Threat model\n* Built-in security features\n* Security principles\n  * Security boundaries\n  * Least privilege\n  * Defense in depth\n* Isolation technologies\n  * Sandbox runtime\n  * Containers\n  * gVisor\n  * Virtual machines\n  * Cloud deployments\n* Credential management\n  * The proxy pattern\n  * Configuring Claude Code to use a proxy\n  * Implementing a proxy\n  * Credentials for other services\n    * Custom tools\n    * Traffic forwarding\n* Filesystem configuration\n  * Read-only code mounting\n  * Writable locations\n* Further reading\n\n## SDK references\n\n### [typescript](https://code.claude.com/docs/en/agent-sdk/typescript.md)\n\n* Installation\n  * Compile to a single executable\n* Functions\n  * `query()`\n    * Parameters\n    * Returns\n  * `startup()`\n    * Parameters\n    * Returns\n    * Example\n  * `tool()`\n    * Parameters\n    * `ToolAnnotations`\n  * `createSdkMcpServer()`\n    * Parameters\n  * `listSessions()`\n    * Parameters\n    * Return type: `SDKSessionInfo`\n    * Example\n  * `getSessionMessages()`\n    * Parameters\n    * Return type: `SessionMessage`\n    * Example\n  * `getSessionInfo()`\n    * Parameters\n  * `renameSession()`\n    * Parameters\n  * `tagSession()`\n    * Parameters\n  * `resolveSettings()`\n    * Parameters\n    * Return type: `ResolvedSettings`\n    * Example\n* Types\n  * `Options`\n    * Handle slow or stalled API responses\n  * `Query` object\n    * Methods\n    * `applyFlagSettings()`\n  * `WarmQuery`\n    * Methods\n  * `SDKControlInitializeResponse`\n  * `SDKControlInterruptResponse`\n  * `AgentDefinition`\n  * `AgentMcpServerSpec`\n  * `SettingSource`\n    * Default behavior\n    * Why use settingSources\n    * Settings precedence\n  * `PermissionMode`\n  * `CanUseTool`\n  * `PermissionResult`\n  * `ToolConfig`\n  * `McpServerConfig`\n    * `McpStdioServerConfig`\n    * `McpSSEServerConfig`\n    * `McpHttpServerConfig`\n    * `McpSdkServerConfigWithInstance`\n    * `McpClaudeAIProxyServerConfig`\n  * `SdkPluginConfig`\n* Message Types\n  * `SDKMessage`\n  * `SDKAssistantMessage`\n  * `SDKUserMessage`\n  * `SDKUserMessageReplay`\n  * `SDKResultMessage`\n  * `SDKSystemMessage`\n  * `SDKPartialAssistantMessage`\n  * `SDKCompactBoundaryMessage`\n  * `SDKInformationalMessage`\n  * `SDKWorkerShuttingDownMessage`\n  * `SDKPluginInstallMessage`\n  * `SDKPermissionDeniedMessage`\n  * `SDKPermissionDenial`\n  * `SDKMessageOrigin`\n* Hook Types\n  * `HookEvent`\n  * `HookCallback`\n  * `HookCallbackMatcher`\n  * `HookInput`\n  * `BaseHookInput`\n    * `PreToolUseHookInput`\n    * `PostToolUseHookInput`\n    * `PostToolUseFailureHookInput`\n    * `PostToolBatchHookInput`\n    * `NotificationHookInput`\n    * `UserPromptSubmitHookInput`\n    * `SessionStartHookInput`\n    * `SessionEndHookInput`\n    * `StopHookInput`\n    * `SubagentStartHookInput`\n    * `SubagentStopHookInput`\n    * `PreCompactHookInput`\n    * `PermissionRequestHookInput`\n    * `SetupHookInput`\n    * `TeammateIdleHookInput`\n    * `TaskCompletedHookInput`\n    * `ConfigChangeHookInput`\n    * `WorktreeCreateHookInput`\n    * `WorktreeRemoveHookInput`\n    * `MessageDisplayHookInput`\n  * `HookJSONOutput`\n    * `AsyncHookJSONOutput`\n    * `SyncHookJSONOutput`\n* Tool Input Types\n  * `ToolInputSchemas`\n  * Agent\n  * AskUserQuestion\n  * Bash\n  * Monitor\n  * TaskOutput\n  * Edit\n  * Read\n  * Write\n  * Glob\n  * Grep\n  * TaskStop\n  * NotebookEdit\n  * WebFetch\n  * WebSearch\n  * Workflow\n  * TodoWrite\n  * TaskCreate\n  * TaskUpdate\n  * TaskGet\n  * TaskList\n  * ExitPlanMode\n  * ListMcpResources\n  * ReadMcpResource\n  * EnterWorktree\n* Tool Output Types\n  * `ToolOutputSchemas`\n  * Agent\n  * AskUserQuestion\n  * Bash\n  * Monitor\n  * Edit\n  * Read\n  * Write\n  * Glob\n  * Grep\n  * TaskStop\n  * NotebookEdit\n  * WebFetch\n  * WebSearch\n  * Workflow\n  * TodoWrite\n  * TaskCreate\n  * TaskUpdate\n  * TaskGet\n  * TaskList\n  * ExitPlanMode\n  * ListMcpResources\n  * ReadMcpResource\n  * EnterWorktree\n* Permission Types\n  * `PermissionUpdate`\n  * `PermissionBehavior`\n  * `PermissionUpdateDestination`\n  * `PermissionRuleValue`\n* Other Types\n  * `ApiKeySource`\n  * `SdkBeta`\n  * `SlashCommand`\n  * `ModelInfo`\n  * `AgentInfo`\n  * `McpServerStatus`\n  * `McpServerStatusConfig`\n  * `AccountInfo`\n  * `ModelUsage`\n  * `ConfigScope`\n  * `NonNullableUsage`\n  * `Usage`\n  * `CallToolResult`\n  * `ThinkingConfig`\n  * `SpawnedProcess`\n  * `SpawnOptions`\n  * `McpSetServersResult`\n  * `RewindFilesResult`\n  * `SDKStatusMessage`\n  * `SDKTaskNotificationMessage`\n  * `SDKToolUseSummaryMessage`\n  * `SDKHookStartedMessage`\n  * `SDKHookProgressMessage`\n  * `SDKHookResponseMessage`\n  * `SDKToolProgressMessage`\n  * `SDKAuthStatusMessage`\n  * `SDKTaskStartedMessage`\n  * `SDKTaskProgressMessage`\n  * `SDKTaskUpdatedMessage`\n  * `SDKBackgroundTasksChangedMessage`\n  * `SDKFilesPersistedEvent`\n  * `SDKRateLimitEvent`\n  * `SDKLocalCommandOutputMessage`\n  * `SDKCommandsChangedMessage`\n  * `SDKPromptSuggestionMessage`\n  * `SDKConversationResetMessage`\n  * `AbortError`\n* Sandbox Configuration\n  * `SandboxSettings`\n    * Example usage\n  * `SandboxNetworkConfig`\n  * `SandboxFilesystemConfig`\n  * Permissions Fallback for Unsandboxed Commands\n* See also\n\n### [typescript-v2-preview](https://code.claude.com/docs/en/agent-sdk/typescript-v2-preview.md)\n\n* Installation\n* Quick start\n  * One-shot prompt\n  * Basic session\n  * Multi-turn conversation\n  * Session resume\n  * Cleanup\n* API reference\n  * `unstable_v2_createSession()`\n  * `unstable_v2_resumeSession()`\n  * `unstable_v2_prompt()`\n  * SDKSession interface\n* Feature availability\n* See also\n\n### [python](https://code.claude.com/docs/en/agent-sdk/python.md)\n\n* Installation\n* Choosing between `query()` and `ClaudeSDKClient`\n  * Quick comparison\n  * When to use `query()` (one-off tasks)\n  * When to use `ClaudeSDKClient` (continuous conversation)\n* Functions\n  * `query()`\n    * Parameters\n    * Returns\n    * Example - With options\n  * `tool()`\n    * Parameters\n    * Input schema options\n    * Returns\n    * Example\n    * `ToolAnnotations`\n  * `create_sdk_mcp_server()`\n    * Parameters\n    * Returns\n    * Example\n  * `list_sessions()`\n    * Parameters\n    * Return type: `SDKSessionInfo`\n    * Example\n  * `get_session_messages()`\n    * Parameters\n    * Return type: `SessionMessage`\n    * Example\n  * `get_session_info()`\n    * Parameters\n    * Example\n  * `rename_session()`\n    * Parameters\n    * Example\n  * `tag_session()`\n    * Parameters\n    * Example\n* Classes\n  * `ClaudeSDKClient`\n    * Key Features\n    * Methods\n    * Context Manager Support\n    * Example - Continuing a conversation\n    * Example - Streaming input with ClaudeSDKClient\n    * Example - Using interrupts\n    * Example - Advanced permission control\n* Types\n  * `SdkMcpTool`\n  * `Transport`\n  * `ClaudeAgentOptions`\n    * Handle slow or stalled API responses\n  * `OutputFormat`\n  * `SystemPromptPreset`\n  * `SystemPromptFile`\n  * `SettingSource`\n    * Default behavior\n    * Why use setting\\_sources\n    * Settings precedence\n  * `AgentDefinition`\n  * `PermissionMode`\n  * `EffortLevel`\n  * `CanUseTool`\n  * `ToolPermissionContext`\n  * `PermissionResult`\n  * `PermissionResultAllow`\n  * `PermissionResultDeny`\n  * `PermissionUpdate`\n  * `PermissionRuleValue`\n  * `ToolsPreset`\n  * `ThinkingConfig`\n  * `SdkBeta`\n  * `McpSdkServerConfig`\n  * `McpServerConfig`\n    * `McpStdioServerConfig`\n    * `McpSSEServerConfig`\n    * `McpHttpServerConfig`\n  * `McpServerStatusConfig`\n  * `McpStatusResponse`\n  * `McpServerStatus`\n  * `SdkPluginConfig`\n* Message Types\n  * `Message`\n  * `UserMessage`\n  * `AssistantMessage`\n  * `AssistantMessageError`\n  * `SystemMessage`\n  * `ResultMessage`\n  * `StreamEvent`\n  * `RateLimitEvent`\n  * `RateLimitInfo`\n  * `TaskStartedMessage`\n  * `TaskUsage`\n  * `TaskProgressMessage`\n  * `TaskNotificationMessage`\n* Content Block Types\n  * `ContentBlock`\n  * `TextBlock`\n  * `ThinkingBlock`\n  * `ToolUseBlock`\n  * `ToolResultBlock`\n* Error Types\n  * `ClaudeSDKError`\n  * `CLINotFoundError`\n  * `CLIConnectionError`\n  * `ProcessError`\n  * `CLIJSONDecodeError`\n* Hook Types\n  * `HookEvent`\n  * `HookCallback`\n  * `HookContext`\n  * `HookMatcher`\n  * `HookInput`\n  * `BaseHookInput`\n  * `PreToolUseHookInput`\n  * `PostToolUseHookInput`\n  * `PostToolUseFailureHookInput`\n  * `UserPromptSubmitHookInput`\n  * `StopHookInput`\n  * `SubagentStopHookInput`\n  * `PreCompactHookInput`\n  * `NotificationHookInput`\n  * `SubagentStartHookInput`\n  * `PermissionRequestHookInput`\n  * `HookJSONOutput`\n    * `SyncHookJSONOutput`\n    * `HookSpecificOutput`\n    * `AsyncHookJSONOutput`\n  * Hook Usage Example\n* Tool Input/Output Types\n  * Agent\n  * AskUserQuestion\n  * Bash\n  * Monitor\n  * Edit\n  * Read\n  * Write\n  * Glob\n  * Grep\n  * NotebookEdit\n  * WebFetch\n  * WebSearch\n  * TodoWrite\n  * TaskCreate\n  * TaskUpdate\n  * TaskGet\n  * TaskList\n  * BashOutput\n  * KillBash\n  * ExitPlanMode\n  * ListMcpResources\n  * ReadMcpResource\n* Advanced Features with ClaudeSDKClient\n  * Building a Continuous Conversation Interface\n  * Using Hooks for Behavior Modification\n  * Real-time Progress Monitoring\n* Example Usage\n  * Basic file operations (using query)\n  * Error handling\n  * Streaming mode with client\n  * Using custom tools with ClaudeSDKClient\n* Sandbox Configuration\n  * `SandboxSettings`\n    * Example usage\n  * `SandboxNetworkConfig`\n  * `SandboxIgnoreViolations`\n  * Permissions Fallback for Unsandboxed Commands\n* See also\n\n### [migration-guide](https://code.claude.com/docs/en/agent-sdk/migration-guide.md)\n\n* Overview\n* What's Changed\n* Migration Steps\n  * For TypeScript/JavaScript Projects\n  * For Python Projects\n* Breaking changes\n  * Python: ClaudeCodeOptions renamed to ClaudeAgentOptions\n  * System prompt no longer default\n  * Settings sources default\n* Why the Rename?\n* Getting Help\n* Next Steps\n\n## What's New\n\n### [index](https://code.claude.com/docs/en/whats-new/index.md)\n\n* (No headings found)\n\n### [2026-w28](https://code.claude.com/docs/en/whats-new/2026-w28.md)\n\n* (No headings found)\n\n### [2026-w27](https://code.claude.com/docs/en/whats-new/2026-w27.md)\n\n* (No headings found)\n\n### [2026-w26](https://code.claude.com/docs/en/whats-new/2026-w26.md)\n\n* (No headings found)\n\n### [2026-w25](https://code.claude.com/docs/en/whats-new/2026-w25.md)\n\n* (No headings found)\n\n### [2026-w24](https://code.claude.com/docs/en/whats-new/2026-w24.md)\n\n* (No headings found)\n\n### [2026-w23](https://code.claude.com/docs/en/whats-new/2026-w23.md)\n\n* (No headings found)\n\n### [2026-w22](https://code.claude.com/docs/en/whats-new/2026-w22.md)\n\n* (No headings found)\n\n### [2026-w21](https://code.claude.com/docs/en/whats-new/2026-w21.md)\n\n* (No headings found)\n\n### [2026-w20](https://code.claude.com/docs/en/whats-new/2026-w20.md)\n\n* (No headings found)\n\n### [2026-w19](https://code.claude.com/docs/en/whats-new/2026-w19.md)\n\n* (No headings found)\n\n### [2026-w18](https://code.claude.com/docs/en/whats-new/2026-w18.md)\n\n* (No headings found)\n\n### [2026-w17](https://code.claude.com/docs/en/whats-new/2026-w17.md)\n\n* (No headings found)\n\n### [2026-w16](https://code.claude.com/docs/en/whats-new/2026-w16.md)\n\n* (No headings found)\n\n### [2026-w15](https://code.claude.com/docs/en/whats-new/2026-w15.md)\n\n* (No headings found)\n\n### [2026-w14](https://code.claude.com/docs/en/whats-new/2026-w14.md)\n\n* (No headings found)\n\n### [2026-w13](https://code.claude.com/docs/en/whats-new/2026-w13.md)\n\n* (No headings found)\n\n## Resources\n\n### [legal-and-compliance](https://code.claude.com/docs/en/legal-and-compliance.md)\n\n* Legal agreements\n  * License\n  * Commercial agreements\n* Compliance\n  * Healthcare compliance (BAA)\n* Usage policy\n  * Acceptable use\n  * Authentication and credential use\n* Security and trust\n  * Trust and safety\n  * Security vulnerability reporting\n","durationMs":675,"url":"https://code.claude.com/docs/en/claude_code_docs_map.md"},"sourceToolAssistantUUID":"f7bd189c-ad93-4455-a892-6aa9e2006d05","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"f3f5335c-f42e-4880-8a8f-1110e38b5b5e","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01BodXK4hRK9wTQMTffYCrew","type":"tool_result","content":"The server returned HTTP 404 Not Found.\n\nThe response body was not retrieved. If this URL requires authentication, use an authenticated tool (e.g. `gh` for GitHub, or an MCP-provided fetch tool) instead of WebFetch."}]},"uuid":"367ad716-308b-47ba-9082-4463c895a44d","timestamp":"2026-07-11T09:37:45.544Z","toolUseResult":{"bytes":0,"code":404,"codeText":"Not Found","result":"The server returned HTTP 404 Not Found.\n\nThe response body was not retrieved. If this URL requires authentication, use an authenticated tool (e.g. `gh` for GitHub, or an MCP-provided fetch tool) instead of WebFetch.","durationMs":653,"url":"https://code.claude.com/docs/en/getting-started/mcp-servers.md"},"sourceToolAssistantUUID":"f3f5335c-f42e-4880-8a8f-1110e38b5b5e","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"367ad716-308b-47ba-9082-4463c895a44d","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3cRLbDr58rZL2cjDGE","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"Ev0DCpMBCA8YAipAn/Y/K3XvrwajI5Sj0iTXI8oB3cJssIXC0uirf9j6h+igx/pZwA0OHiuIiT/BK8BfR3LcQtfeVmmp4BvPDLLC4TIZY2xhdWRlLWhhaWt1LTQtNS0yMDI1MTAwMTgAQgh0aGlua2luZ1okNGJkZDE1Y2MtNDcxZS00ZTU2LWJhMWEtM2QzZDViNGYwMTdjEgzA8yFJK94FIcoESooaDJxXJVjnpInygTopuiIw4gBwtr8WPF2DyyCTKvBDyUd7tPSUj2RvqSkmyyXRF4GfWA23IRB92kg+cQvQObeAKpYCs988VKU668noF6XhaFwm6nkPXy1b5bjDsa93bEcroPpR+TtPbwWWSppJq0fiajv7dViccvpcfzO2XId695c7Q9vfeOyQ5mezGlTHmgCbTvsVaFpXo8W2LNs3Ss7II2QwFgxebWRla/mQR05wUnZwB7OUi0lTTZmaSMBeztyc+Mi0aRIiTXhrqSy7az4aOCzL01uR7Z3xrpr+JLMzQ/54cT0fQX2Vt5dUpqKnYXPTwtdBTy/YultS05ViaSs1I1BBFN9Y3OLRoJo1/YngpgAOduSltNB0JxBYAPA7ODm0ZOxovAZwp4BAMVRmIolpIGZzCor+9E72LHtuoYGbQmbKJDEzSduEhdOVsz93g0fDf225+ac1jmcYAQ=="}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":1224,"cache_read_input_tokens":13543,"cache_creation":{"ephemeral_5m_input_tokens":1224,"ephemeral_1h_input_tokens":0},"output_tokens":2,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3cQ8AXAhHhyW797yeJ","attributionAgent":"claude-code-guide","type":"assistant","uuid":"96623dd4-b839-4d11-b99a-e41078917b12","timestamp":"2026-07-11T09:37:47.695Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"96623dd4-b839-4d11-b99a-e41078917b12","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3cRLbDr58rZL2cjDGE","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_016BLNbKCjcfgjTCeL2NQ1sY","name":"WebFetch","input":{"url":"https://code.claude.com/docs/llms.txt","prompt":"MCP server configuration stdio JSON settings .mcp.json"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":1224,"cache_read_input_tokens":13543,"output_tokens":168,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":1224},"inference_geo":"not_available","iterations":[{"input_tokens":8,"output_tokens":168,"cache_read_input_tokens":13543,"cache_creation_input_tokens":1224,"cache_creation":{"ephemeral_5m_input_tokens":1224,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3cQ8AXAhHhyW797yeJ","attributionAgent":"claude-code-guide","type":"assistant","uuid":"35cc9ecb-6404-4ad0-a657-57b2424960cd","timestamp":"2026-07-11T09:37:48.158Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"35cc9ecb-6404-4ad0-a657-57b2424960cd","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_016BLNbKCjcfgjTCeL2NQ1sY","type":"tool_result","content":"# MCP Server Configuration for Claude Code\n\nBased on the Claude Code documentation, here's how to configure MCP (Model Context Protocol) servers:\n\n## Configuration Location\n\nMCP server configurations are stored in the `.claude` directory (your project's `.claude/` or home `~/.claude/` directory).\n\n## Key Configuration File\n\nThe primary configuration file is **`.mcp.json`** (or settings in `settings.json`), which uses **stdio** transport for MCP server communication.\n\n## Related Documentation\n\nFor comprehensive MCP setup and configuration, refer to:\n\n- **[Connect to MCP servers](https://code.claude.com/docs/en/mcp-quickstart.md)** - Quick start guide to add an MCP server, verify the connection, and find the configuration on disk\n\n- **[Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp.md)** - Learn how to connect Claude Code to your tools with the Model Context Protocol\n\n- **[Connect to external tools with MCP](https://code.claude.com/docs/en/agent-sdk/mcp.md)** (Agent SDK) - Configure MCP servers to extend your agent with external tools, covering transport types, tool search for large tool sets, authentication, and error handling\n\n- **[Control MCP server access for your organization](https://code.claude.com/docs/en/managed-mcp.md)** - Restrict which MCP servers users can add or connect to with managed configuration files, allowlists, and denylists\n\n## Debugging\n\nUse the `/mcp` command in Claude Code to inspect which MCP servers are loaded and diagnose configuration issues."}]},"uuid":"ceaa861f-97d5-4ce8-b7fe-33024532ac4c","timestamp":"2026-07-11T09:37:54.327Z","toolUseResult":{"bytes":36627,"code":200,"codeText":"OK","result":"# MCP Server Configuration for Claude Code\n\nBased on the Claude Code documentation, here's how to configure MCP (Model Context Protocol) servers:\n\n## Configuration Location\n\nMCP server configurations are stored in the `.claude` directory (your project's `.claude/` or home `~/.claude/` directory).\n\n## Key Configuration File\n\nThe primary configuration file is **`.mcp.json`** (or settings in `settings.json`), which uses **stdio** transport for MCP server communication.\n\n## Related Documentation\n\nFor comprehensive MCP setup and configuration, refer to:\n\n- **[Connect to MCP servers](https://code.claude.com/docs/en/mcp-quickstart.md)** - Quick start guide to add an MCP server, verify the connection, and find the configuration on disk\n\n- **[Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp.md)** - Learn how to connect Claude Code to your tools with the Model Context Protocol\n\n- **[Connect to external tools with MCP](https://code.claude.com/docs/en/agent-sdk/mcp.md)** (Agent SDK) - Configure MCP servers to extend your agent with external tools, covering transport types, tool search for large tool sets, authentication, and error handling\n\n- **[Control MCP server access for your organization](https://code.claude.com/docs/en/managed-mcp.md)** - Restrict which MCP servers users can add or connect to with managed configuration files, allowlists, and denylists\n\n## Debugging\n\nUse the `/mcp` command in Claude Code to inspect which MCP servers are loaded and diagnose configuration issues.","durationMs":6163,"url":"https://code.claude.com/docs/llms.txt"},"sourceToolAssistantUUID":"35cc9ecb-6404-4ad0-a657-57b2424960cd","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"ceaa861f-97d5-4ce8-b7fe-33024532ac4c","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3d51W8i2vXm896yhn1","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"EvcCCpMBCA8YAipAozZt+77cQYbwak9OBaS23ooKkn3dP6D0NZWNM4iFQryyKSzv01fxQxFmKLQukJ3j+B1nILMEslRTuLw/W0wwTzIZY2xhdWRlLWhhaWt1LTQtNS0yMDI1MTAwMTgAQgh0aGlua2luZ1okNGJkZDE1Y2MtNDcxZS00ZTU2LWJhMWEtM2QzZDViNGYwMTdjEgxJwhnZoaiqepW6wYAaDMTfKHvfEhPqyEYrNyIwuMSPSoO9zBfBmqF1K0iailClMV+x6GnZ2Ik0QfBPMO3lNyuwjv7CokwrY+8AGuB5KpAByeoPVNMcdO0sRcpSvdKL/uLTXvlm6Eu/y8HnNuPkQM7RTnQaCa7Y5vJhnHmbeerH1QdyoRa9zCLUgwWC5q7kKAwRTRUOQj5UV7B93DMKY8w4wTj4xsD35Q3emyiMTBsb3kj9NksN07XhB5lIn6h/ITOL71tyq6f6QLeHLVZhjwjKoNJ/yZcR87Z0Wq0q032QGAE="}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":560,"cache_read_input_tokens":14767,"cache_creation":{"ephemeral_5m_input_tokens":560,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3d3j73SxrMcaPKGjnS","attributionAgent":"claude-code-guide","type":"assistant","uuid":"8d446f9c-4182-4b96-9cbb-825ef7427ad5","timestamp":"2026-07-11T09:37:56.166Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"8d446f9c-4182-4b96-9cbb-825ef7427ad5","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3d51W8i2vXm896yhn1","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_01TCqxYeBrnGYwN9gqBcUTV4","name":"WebFetch","input":{"url":"https://code.claude.com/docs/en/mcp.md","prompt":"stdio MCP server configuration JSON schema settings.json .mcp.json command args env permission"},"caller":{"type":"direct"}}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":560,"cache_read_input_tokens":14767,"cache_creation":{"ephemeral_5m_input_tokens":560,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3d3j73SxrMcaPKGjnS","attributionAgent":"claude-code-guide","type":"assistant","uuid":"c2d32dce-9a41-4eb1-9d6c-0cbe73f504b2","timestamp":"2026-07-11T09:37:56.833Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"c2d32dce-9a41-4eb1-9d6c-0cbe73f504b2","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3d51W8i2vXm896yhn1","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_019TS8FaqjikwugUWFsr26in","name":"WebFetch","input":{"url":"https://code.claude.com/docs/en/mcp-quickstart.md","prompt":"stdio server JSON configuration .mcp.json settings.json structure"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":560,"cache_read_input_tokens":14767,"output_tokens":221,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":560},"inference_geo":"not_available","iterations":[{"input_tokens":8,"output_tokens":221,"cache_read_input_tokens":14767,"cache_creation_input_tokens":560,"cache_creation":{"ephemeral_5m_input_tokens":560,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3d3j73SxrMcaPKGjnS","attributionAgent":"claude-code-guide","type":"assistant","uuid":"484f5919-e5d4-4794-ab5a-4b7ca7840a0b","timestamp":"2026-07-11T09:37:57.426Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"484f5919-e5d4-4794-ab5a-4b7ca7840a0b","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_019TS8FaqjikwugUWFsr26in","type":"tool_result","content":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect to MCP servers\n\n> Add an MCP server to Claude Code, verify the connection, and find the configuration on disk.\n\nThe [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) lets Claude Code use tools beyond its built-in set, such as searching an issue tracker, querying a database, or controlling a web browser. These tools come from MCP servers, which run on your machine or as hosted services.\n\nThis guide walks you through connecting one MCP server end to end with the Claude Code CLI. By the end, you'll have a server connected and responding, know where its configuration lives on disk, and know how to fix the most common connection errors.\n\n<Note>\n  You can also add MCP servers from other surfaces, including the desktop app, VS Code, and the web. See [Connect from other surfaces](#connect-from-other-surfaces).\n</Note>\n\nFor every way to connect and configure MCP servers in Claude Code, see the [MCP reference](/en/mcp).\n\n## Before you begin\n\nMake sure you have:\n\n* [Claude Code installed](/en/quickstart) and authenticated\n* A terminal open in a project directory. Any directory works, including an empty one.\n\n## Add and verify a server\n\nThe example below connects to the [Claude Code documentation MCP server](https://code.claude.com/docs/mcp), a hosted server with full-text search over the Claude Code docs. It doesn't require authentication or any special configuration, so it works well as a first server to test the setup flow with.\n\nThe steps are the same for any server: add it, check the connection status, then use it in a session, with an optional cleanup step at the end. Some servers add a step, like a browser sign-in, shown in [Additional MCP server examples](#additional-mcp-server-examples). For more servers to connect, browse the [Anthropic Directory](/en/mcp#find-and-build-mcp-servers).\n\n<Steps>\n  <Step title=\"Add the MCP server\">\n    Register the server with Claude Code. Run this in your terminal, not inside a `claude` session: you're configuring the server before starting a conversation.\n\n    ```bash theme={null}\n    claude mcp add --transport http claude-code-docs https://code.claude.com/docs/mcp\n    ```\n\n    The parts of the command:\n\n    * `claude mcp add`: registers a server with Claude Code.\n    * `--transport http`: the server is hosted at a URL rather than run as a local process.\n    * `claude-code-docs`: a name you make up. Calling the same server `docs` would work identically. Claude Code uses whatever name you pick to label the server's tools in Claude's output and to refer to the server in commands like `claude mcp remove`.\n    * `https://code.claude.com/docs/mcp`: the URL where the server is hosted.\n\n    The command prints a confirmation like `Added HTTP MCP server claude-code-docs with URL: https://code.claude.com/docs/mcp to local config`. The `local config` part means the server is registered to you, in this project: if you start Claude Code in a different project, this server isn't active there. To register a server once for all your projects, add it at user scope, covered in [Change server scope](#change-server-scope).\n  </Step>\n\n  <Step title=\"Check the connection status\">\n    Confirm the server appears in your server list and check its status:\n\n    ```bash theme={null}\n    claude mcp list\n    ```\n\n    The server appears with a status indicator:\n\n    | Status                             | Meaning                                                                                                                                                                       |\n    | :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n    | `✓ Connected`                      | Ready to use. This is what you should see for `claude-code-docs`                                                                                                              |\n    | `! Connected · tools fetch failed` | The server connected but couldn't list its tools. Run `claude mcp get <name>` for the error detail                                                                            |\n    | `! Needs authentication`           | The server is reachable but needs a browser sign-in, or a token passed with `--header`. See [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in) |\n    | `✗ Failed to connect`              | Server didn't respond. See [Troubleshooting](#troubleshooting)                                                                                                                |\n    | `✗ Connection error`               | The connection attempt threw an error. See [Troubleshooting](#troubleshooting)                                                                                                |\n    | `⏸ Pending approval`               | A project-scoped server you haven't approved yet. See [Edit .mcp.json directly](#edit-mcp-json-directly)                                                                      |\n  </Step>\n\n  <Step title=\"Use the server\">\n    Start a session and ask Claude to use the new server by name:\n\n    ```bash theme={null}\n    claude\n    ```\n\n    ```text theme={null}\n    Use the claude-code-docs server to look up what MCP_TIMEOUT does\n    ```\n\n    <Info>\n      You don't normally need to name a server in your prompt, since Claude chooses relevant tools on its own. Naming it here guarantees the demonstration goes through the new server rather than another tool, such as web fetch, that could answer the same question.\n    </Info>\n\n    The first time Claude calls the server, it asks for permission to use the new tool. Approve it to continue. The tool call in Claude's output is labeled with the server name, which is how you confirm the answer came from the MCP server rather than Claude's built-in knowledge.\n  </Step>\n\n  <Step title=\"Remove the server\">\n    This step is optional. When you're done experimenting, you can remove the server:\n\n    ```bash theme={null}\n    claude mcp remove claude-code-docs\n    ```\n\n    <Note>\n      Each connected server takes some space in [Claude's context window](/en/how-claude-code-works#the-context-window) because its tool names and server instructions load into every session. Removing servers you no longer use keeps that space free.\n    </Note>\n  </Step>\n</Steps>\n\n## Where servers are saved\n\nThe `claude mcp add` command writes the server's details to a configuration file. By default it registers the server at `local` scope: private to you, active only in the current project. Pass `--scope user` to register it once for all your projects, or `--scope project` to share it with teammates. [Change server scope](#change-server-scope) walks through both.\n\n<Note>\n  `claude mcp add` works the same in every shell, including PowerShell and Command Prompt. Inside a `claude` session, use the `/mcp` command to check and manage servers you've already added.\n</Note>\n\nThere are other ways to add a server, each covered later on this page:\n\n* [Add a local server](#add-a-local-server): run a program on your machine instead of connecting to a URL.\n* [Edit `.mcp.json` directly](#edit-mcp-json-directly): write the JSON entry yourself instead of using the command.\n* [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in): add a hosted server that needs a browser sign-in before its tools work.\n\n### Find your configuration on disk\n\nThe `claude mcp add` command writes the server to one of three scopes, stored across two files, depending on the `--scope` flag. You don't need to edit these files directly, but knowing where they are helps with debugging and version control.\n\n| Scope     | File                                                   | Available to                             |\n| :-------- | :----------------------------------------------------- | :--------------------------------------- |\n| `local`   | `~/.claude.json`, under the entry for this project     | Only you, only this project. The default |\n| `project` | `.mcp.json` in your project root                       | Everyone who clones the project          |\n| `user`    | `~/.claude.json`, under the top-level `mcpServers` key | Only you, all projects                   |\n\nOn Windows, `~/.claude.json` resolves to `%USERPROFILE%\\.claude.json`, typically `C:\\Users\\YourName\\.claude.json`. If you've set [`CLAUDE_CONFIG_DIR`](/en/env-vars), Claude Code reads `.claude.json` from inside that directory instead.\n\nRun `claude mcp get claude-code-docs` to see which scope holds a server's definition. For how the scopes interact when the same server is defined in more than one, see [MCP installation scopes](/en/mcp#mcp-installation-scopes).\n\n## Change server scope\n\nA server's scope is fixed when you add it, so changing scope means removing the entry and re-adding it at the new one. Both cases below start by removing the local entry from the first walkthrough, so the server has only one definition. If you already removed it at the end of that walkthrough, skip this command:\n\n```bash theme={null}\nclaude mcp remove claude-code-docs --scope local\n```\n\n### Use a server in all your projects\n\nRe-add the server at `user` scope to make it active in every project you open, still private to you:\n\n```bash theme={null}\nclaude mcp add --scope user --transport http claude-code-docs https://code.claude.com/docs/mcp\n```\n\n### Share a server with your team\n\nRe-add the server at `project` scope, which writes to `.mcp.json` in the project root:\n\n```bash theme={null}\nclaude mcp add --scope project --transport http claude-code-docs https://code.claude.com/docs/mcp\n```\n\nCommit `.mcp.json` to version control. Teammates who clone the repository and start Claude Code see a prompt to approve the server, then it connects for them too.\n\n## Additional MCP server examples\n\nThe first walkthrough used a hosted server that connects without any sign-in. The examples below cover the other two common shapes, with the same add, check, use flow.\n\n### Add a local server\n\nA local stdio server is a program Claude Code starts as a subprocess on your machine, rather than a service it reaches over a URL. Use one for tools that need access to local resources like a browser, your filesystem, or a database socket.\n\nThe [Playwright MCP server](https://github.com/microsoft/playwright-mcp) is a good one to try: it gives Claude a browser it can navigate, click, and read, and it needs no account. It runs through `npx`, so it requires [Node.js](https://nodejs.org/en/download) 18 or later.\n\n<Steps>\n  <Step title=\"Add the Playwright server\">\n    Register the server with the command Claude Code should run to start it:\n\n    ```bash theme={null}\n    claude mcp add playwright -- npx -y @playwright/mcp@latest\n    ```\n\n    This command differs from the hosted example in three ways:\n\n    * There's no `--transport` flag, because local servers use the default `stdio` transport.\n    * Everything after the `--` separator is the command Claude Code runs to start the server.\n    * `-y` tells `npx` to install the package without prompting.\n\n    Playwright drives whichever Chrome is already installed on your machine. To use a different browser, append `--browser` with the browser name, for example `--browser firefox`, after `@playwright/mcp@latest`.\n  </Step>\n\n  <Step title=\"Check the connection\">\n    The `Added` confirmation means the entry was saved, not that the command runs. Check the connection:\n\n    ```bash theme={null}\n    claude mcp list\n    ```\n\n    The first check can show `✗ Failed to connect` while `npx` downloads the package, so wait a moment and run it again.\n  </Step>\n\n  <Step title=\"Use the browser\">\n    Give Claude a task that needs the browser:\n\n    ```text theme={null}\n    Use playwright to open https://example.com and tell me the page title\n    ```\n\n    A browser window opens so you can watch it work, and the tool calls in Claude's output are labeled with the `playwright` server name and the action, like `browser_navigate`.\n\n    Try pointing it at your local dev server to check that a page still renders after a change, or have it walk through a bug report step by step.\n  </Step>\n</Steps>\n\n### Connect a server that requires sign-in\n\nHosted services like Sentry, Linear, and Notion run their MCP servers behind OAuth: you add the server's URL, then sign in through your browser.\n\nThe steps below use Sentry as the example. To connect a different service, substitute its URL, which you can find in the [Anthropic Directory](/en/mcp#find-and-build-mcp-servers) or the service's documentation.\n\n<Steps>\n  <Step title=\"Add the server\">\n    The `add` command is the same as for the docs server, with Sentry's URL:\n\n    ```bash theme={null}\n    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n    ```\n\n    After adding, `claude mcp list` shows the server with `! Needs authentication`. That's expected: the next step completes the sign-in.\n  </Step>\n\n  <Step title=\"Authenticate in your browser\">\n    Start a Claude Code session and open the MCP panel:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Select `sentry` from the list, press Enter, and choose `Authenticate`. Your browser opens to Sentry's sign-in page. Approve the connection there.\n\n    Back in Claude Code, the server's status changes to connected. If sign-in fails or the browser doesn't open, see [Troubleshooting](#troubleshooting).\n  </Step>\n\n  <Step title=\"Use the server\">\n    Ask Claude something that needs the service, like `What Sentry projects do I have access to?`, and look for tool calls labeled with the `sentry` server name in its output.\n  </Step>\n</Steps>\n\nServers that authenticate with a static token instead of OAuth take the token at add time with `--header \"Authorization: Bearer <token>\"`. See the [GitHub example](/en/mcp#example-connect-to-github-for-code-reviews) for a worked version.\n\n## Edit .mcp.json directly\n\nEvery file in the [scope table](#find-your-configuration-on-disk) uses the same JSON format for server entries. This section edits `.mcp.json`, the project-scope file. It's the one most worth writing by hand because it's checked into the repository, where it doubles as configuration-as-code for your team.\n\nCreate `.mcp.json` in your project root. The example below defines both servers from this guide, the hosted docs server reached over HTTP and the Playwright server as a local `stdio` process:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"claude-code-docs\": {\n      \"type\": \"http\",\n      \"url\": \"https://code.claude.com/docs/mcp\"\n    },\n    \"playwright\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@playwright/mcp@latest\"]\n    }\n  }\n}\n```\n\nThe fields differ by server type:\n\n* For HTTP servers, `url` is the endpoint Claude Code connects to.\n* For stdio servers, `command` and `args` are the program it runs.\n\nAfter saving the file, start a new Claude Code session in the project. Claude Code reads `.mcp.json` at startup.\n\nThe first time Claude Code sees a project-scoped server, it asks you to approve it. The prompt exists so a repository you clone can't launch processes on your machine without your consent. Approve the prompt, or run `/mcp` to approve later if you missed it.\n\nOnce you've approved, run `/mcp` and check that the servers show as connected. If one shows an error instead, see [Troubleshooting](#troubleshooting).\n\n## Connect from other surfaces\n\nThis guide uses the `claude mcp` CLI commands, but every Claude Code surface can connect to MCP servers:\n\n* **Claude Code desktop app**: add servers through the [Connectors UI](/en/desktop#connect-external-tools).\n* **Claude Desktop chat app**: a separate app from Claude Code. To copy servers from its `claude_desktop_config.json` into the CLI, run `claude mcp add-from-claude-desktop` on macOS or WSL.\n* **VS Code**: see [Connect to external tools with MCP](/en/vs-code#connect-to-external-tools-with-mcp).\n* **Claude Code on the web**: reads `.mcp.json` from your repository. See [Edit .mcp.json directly](#edit-mcp-json-directly).\n* **Claude.ai**: connectors you add at [claude.ai/customize/connectors](https://claude.ai/customize/connectors) load automatically in the CLI when you sign in with that account. See [Use MCP servers from Claude.ai](/en/mcp#use-mcp-servers-from-claude-ai).\n\n## Troubleshooting\n\nIf a server doesn't connect, check its status with `/mcp` inside a session or `claude mcp list` from your shell, then match the symptom below. The `/mcp` panel also lets you reconnect or authenticate without leaving the session.\n\n<AccordionGroup>\n  <Accordion title=\"/mcp shows No MCP servers configured\">\n    Claude Code didn't find any servers for the current directory. The most common causes:\n\n    * You ran `claude mcp add` from a different project. Local-scoped servers are tied to the project where you added them: the repository root, or the exact directory if you weren't in a git repository. Re-add the server from the project you're in now, or add it with `--scope user` so it isn't tied to a project.\n    * You edited a configuration file at the wrong path. The correct files are `~/.claude.json` and `<project>/.mcp.json`. Claude Code doesn't read paths such as `~/.claude/.mcp.json`, `~/.claude/config/mcp.json`, `~/.claude/mcp.json`, or `%APPDATA%\\Claude\\mcp.json`. For user-scoped servers, run `claude mcp add --scope user`, which writes to the `mcpServers` key in `~/.claude.json`; for project-scoped servers, edit `.mcp.json` at the project root.\n  </Accordion>\n\n  <Accordion title=\"Status shows Failed to connect or Connection error\">\n    Both statuses mean the server didn't start or the URL didn't respond. They can also appear for HTTP servers that expect a token rather than the browser sign-in covered in [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in).\n\n    As of v2.1.191, an HTTP server that returns `404 Not Found` shows `MCP endpoint not found at <url>. Check the URL in your MCP config.` when you select the server in `/mcp`, with the URL Claude Code tried. Earlier versions show a generic `Error POSTing to endpoint` message without the URL. Compare the URL to the server's documented MCP endpoint path, then run `claude mcp remove <name>` and re-add with the correct URL.\n\n    For HTTP servers, confirm the URL is reachable from your machine:\n\n    ```bash theme={null}\n    curl -I https://mcp.sentry.dev/mcp\n    ```\n\n    In PowerShell, use `curl.exe` instead of `curl` so the request goes to the real curl binary rather than the `Invoke-WebRequest` alias.\n\n    The response tells you which kind of problem you have:\n\n    * A `404` or `405`: the server is up. Many MCP endpoints answer only POST requests, so this still confirms the URL is reachable from your machine.\n    * A `401` or `403`: the server is up and you need to authenticate. Use the browser sign-in in [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in), or for servers that take a token instead, like GitHub's, pass it with `--header \"Authorization: Bearer <token>\"` on the `claude mcp add` command.\n    * No response at all: check the URL and your network.\n\n    For stdio servers, run the configured command directly in your terminal to see the underlying error. For the Playwright server from this guide, run:\n\n    ```bash theme={null}\n    npx -y @playwright/mcp@latest\n    ```\n\n    What happens next tells you where the problem is:\n\n    * The command starts and waits for input: the server itself works. Run `claude mcp get <name>` and confirm the command shown there matches what you just ran. If the command shown differs from what you typed, you likely omitted the `--` separator before the server command. Remove the server and re-add it with `--` in place. If you wrote `.mcp.json` by hand, check its syntax and location.\n    * The command errors: the message names what's missing, such as Node.js or a browser.\n  </Accordion>\n\n  <Accordion title=\"Connection timed out at startup\">\n    The server took longer than the default 30-second startup timeout. A stdio server's first run can be slow while `npx` downloads the package. Increase the limit with the [`MCP_TIMEOUT`](/en/env-vars) environment variable, in milliseconds:\n\n    ```bash theme={null}\n    MCP_TIMEOUT=60000 claude\n    ```\n\n    In PowerShell, set the variable before the command on the same line:\n\n    ```powershell theme={null}\n    $env:MCP_TIMEOUT = \"60000\"; claude\n    ```\n  </Accordion>\n\n  <Accordion title=\"Server already exists\">\n    You've already added a server with that name at the same scope. Either remove the existing entry first or choose a different name:\n\n    ```bash theme={null}\n    claude mcp remove claude-code-docs\n    ```\n\n    If the name exists at more than one scope, `remove` reports `exists in multiple scopes`. Pass `--scope` to choose which copy to delete, for example `claude mcp remove claude-code-docs --scope local`.\n  </Accordion>\n\n  <Accordion title=\"Server connects but no tools appear\">\n    Run `/mcp` inside a session and select the server to see its tool list. If the list is empty, the server started but didn't register any tools, which usually means it's missing a required environment variable such as an API key.\n\n    Pass the variable with `--env KEY=value` on `claude mcp add`, or in the `env` field of the server's `.mcp.json` entry. The server's documentation lists the variables it needs.\n  </Accordion>\n\n  <Accordion title=\"Changes to .mcp.json don't take effect\">\n    Claude Code reads `.mcp.json` at session start. Exit and restart the session after editing the file.\n\n    If your servers still don't appear, run `/mcp` and look for a parse warning. Claude Code skips malformed entries and shows the offending field there.\n\n    If you previously rejected the server when prompted, reset project approvals:\n\n    ```bash theme={null}\n    claude mcp reset-project-choices\n    ```\n  </Accordion>\n\n  <Accordion title=\"OAuth sign-in fails or browser doesn't open\">\n    Run `/mcp`, select the server, and choose `Authenticate` again. If the browser doesn't open automatically, copy the URL shown in the terminal and open it manually. See [Authenticate with remote MCP servers](/en/mcp#authenticate-with-remote-mcp-servers) for fixed callback ports and pre-configured credentials.\n  </Accordion>\n</AccordionGroup>\n\n## Next steps\n\nWith one server connected, explore the rest of what MCP enables:\n\n* [Find more MCP servers](/en/mcp#find-and-build-mcp-servers) in the Anthropic Directory\n* [Share servers with your team](/en/mcp#mcp-installation-scopes) using installation scopes\n* [Manage MCP access for an organization](/en/managed-mcp) with managed settings and policy controls\n* [Reference MCP resources](/en/mcp#use-mcp-resources) in prompts with @ mentions\n* [Run MCP prompts as commands](/en/mcp#use-mcp-prompts-as-commands) from the `/` menu\n* [Build your own server](https://modelcontextprotocol.io/quickstart/server) with the MCP SDK\n"}]},"uuid":"254ad796-84ec-48f9-97d2-182197ce7bdc","timestamp":"2026-07-11T09:37:57.764Z","toolUseResult":{"bytes":23226,"code":200,"codeText":"OK","result":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect to MCP servers\n\n> Add an MCP server to Claude Code, verify the connection, and find the configuration on disk.\n\nThe [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) lets Claude Code use tools beyond its built-in set, such as searching an issue tracker, querying a database, or controlling a web browser. These tools come from MCP servers, which run on your machine or as hosted services.\n\nThis guide walks you through connecting one MCP server end to end with the Claude Code CLI. By the end, you'll have a server connected and responding, know where its configuration lives on disk, and know how to fix the most common connection errors.\n\n<Note>\n  You can also add MCP servers from other surfaces, including the desktop app, VS Code, and the web. See [Connect from other surfaces](#connect-from-other-surfaces).\n</Note>\n\nFor every way to connect and configure MCP servers in Claude Code, see the [MCP reference](/en/mcp).\n\n## Before you begin\n\nMake sure you have:\n\n* [Claude Code installed](/en/quickstart) and authenticated\n* A terminal open in a project directory. Any directory works, including an empty one.\n\n## Add and verify a server\n\nThe example below connects to the [Claude Code documentation MCP server](https://code.claude.com/docs/mcp), a hosted server with full-text search over the Claude Code docs. It doesn't require authentication or any special configuration, so it works well as a first server to test the setup flow with.\n\nThe steps are the same for any server: add it, check the connection status, then use it in a session, with an optional cleanup step at the end. Some servers add a step, like a browser sign-in, shown in [Additional MCP server examples](#additional-mcp-server-examples). For more servers to connect, browse the [Anthropic Directory](/en/mcp#find-and-build-mcp-servers).\n\n<Steps>\n  <Step title=\"Add the MCP server\">\n    Register the server with Claude Code. Run this in your terminal, not inside a `claude` session: you're configuring the server before starting a conversation.\n\n    ```bash theme={null}\n    claude mcp add --transport http claude-code-docs https://code.claude.com/docs/mcp\n    ```\n\n    The parts of the command:\n\n    * `claude mcp add`: registers a server with Claude Code.\n    * `--transport http`: the server is hosted at a URL rather than run as a local process.\n    * `claude-code-docs`: a name you make up. Calling the same server `docs` would work identically. Claude Code uses whatever name you pick to label the server's tools in Claude's output and to refer to the server in commands like `claude mcp remove`.\n    * `https://code.claude.com/docs/mcp`: the URL where the server is hosted.\n\n    The command prints a confirmation like `Added HTTP MCP server claude-code-docs with URL: https://code.claude.com/docs/mcp to local config`. The `local config` part means the server is registered to you, in this project: if you start Claude Code in a different project, this server isn't active there. To register a server once for all your projects, add it at user scope, covered in [Change server scope](#change-server-scope).\n  </Step>\n\n  <Step title=\"Check the connection status\">\n    Confirm the server appears in your server list and check its status:\n\n    ```bash theme={null}\n    claude mcp list\n    ```\n\n    The server appears with a status indicator:\n\n    | Status                             | Meaning                                                                                                                                                                       |\n    | :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n    | `✓ Connected`                      | Ready to use. This is what you should see for `claude-code-docs`                                                                                                              |\n    | `! Connected · tools fetch failed` | The server connected but couldn't list its tools. Run `claude mcp get <name>` for the error detail                                                                            |\n    | `! Needs authentication`           | The server is reachable but needs a browser sign-in, or a token passed with `--header`. See [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in) |\n    | `✗ Failed to connect`              | Server didn't respond. See [Troubleshooting](#troubleshooting)                                                                                                                |\n    | `✗ Connection error`               | The connection attempt threw an error. See [Troubleshooting](#troubleshooting)                                                                                                |\n    | `⏸ Pending approval`               | A project-scoped server you haven't approved yet. See [Edit .mcp.json directly](#edit-mcp-json-directly)                                                                      |\n  </Step>\n\n  <Step title=\"Use the server\">\n    Start a session and ask Claude to use the new server by name:\n\n    ```bash theme={null}\n    claude\n    ```\n\n    ```text theme={null}\n    Use the claude-code-docs server to look up what MCP_TIMEOUT does\n    ```\n\n    <Info>\n      You don't normally need to name a server in your prompt, since Claude chooses relevant tools on its own. Naming it here guarantees the demonstration goes through the new server rather than another tool, such as web fetch, that could answer the same question.\n    </Info>\n\n    The first time Claude calls the server, it asks for permission to use the new tool. Approve it to continue. The tool call in Claude's output is labeled with the server name, which is how you confirm the answer came from the MCP server rather than Claude's built-in knowledge.\n  </Step>\n\n  <Step title=\"Remove the server\">\n    This step is optional. When you're done experimenting, you can remove the server:\n\n    ```bash theme={null}\n    claude mcp remove claude-code-docs\n    ```\n\n    <Note>\n      Each connected server takes some space in [Claude's context window](/en/how-claude-code-works#the-context-window) because its tool names and server instructions load into every session. Removing servers you no longer use keeps that space free.\n    </Note>\n  </Step>\n</Steps>\n\n## Where servers are saved\n\nThe `claude mcp add` command writes the server's details to a configuration file. By default it registers the server at `local` scope: private to you, active only in the current project. Pass `--scope user` to register it once for all your projects, or `--scope project` to share it with teammates. [Change server scope](#change-server-scope) walks through both.\n\n<Note>\n  `claude mcp add` works the same in every shell, including PowerShell and Command Prompt. Inside a `claude` session, use the `/mcp` command to check and manage servers you've already added.\n</Note>\n\nThere are other ways to add a server, each covered later on this page:\n\n* [Add a local server](#add-a-local-server): run a program on your machine instead of connecting to a URL.\n* [Edit `.mcp.json` directly](#edit-mcp-json-directly): write the JSON entry yourself instead of using the command.\n* [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in): add a hosted server that needs a browser sign-in before its tools work.\n\n### Find your configuration on disk\n\nThe `claude mcp add` command writes the server to one of three scopes, stored across two files, depending on the `--scope` flag. You don't need to edit these files directly, but knowing where they are helps with debugging and version control.\n\n| Scope     | File                                                   | Available to                             |\n| :-------- | :----------------------------------------------------- | :--------------------------------------- |\n| `local`   | `~/.claude.json`, under the entry for this project     | Only you, only this project. The default |\n| `project` | `.mcp.json` in your project root                       | Everyone who clones the project          |\n| `user`    | `~/.claude.json`, under the top-level `mcpServers` key | Only you, all projects                   |\n\nOn Windows, `~/.claude.json` resolves to `%USERPROFILE%\\.claude.json`, typically `C:\\Users\\YourName\\.claude.json`. If you've set [`CLAUDE_CONFIG_DIR`](/en/env-vars), Claude Code reads `.claude.json` from inside that directory instead.\n\nRun `claude mcp get claude-code-docs` to see which scope holds a server's definition. For how the scopes interact when the same server is defined in more than one, see [MCP installation scopes](/en/mcp#mcp-installation-scopes).\n\n## Change server scope\n\nA server's scope is fixed when you add it, so changing scope means removing the entry and re-adding it at the new one. Both cases below start by removing the local entry from the first walkthrough, so the server has only one definition. If you already removed it at the end of that walkthrough, skip this command:\n\n```bash theme={null}\nclaude mcp remove claude-code-docs --scope local\n```\n\n### Use a server in all your projects\n\nRe-add the server at `user` scope to make it active in every project you open, still private to you:\n\n```bash theme={null}\nclaude mcp add --scope user --transport http claude-code-docs https://code.claude.com/docs/mcp\n```\n\n### Share a server with your team\n\nRe-add the server at `project` scope, which writes to `.mcp.json` in the project root:\n\n```bash theme={null}\nclaude mcp add --scope project --transport http claude-code-docs https://code.claude.com/docs/mcp\n```\n\nCommit `.mcp.json` to version control. Teammates who clone the repository and start Claude Code see a prompt to approve the server, then it connects for them too.\n\n## Additional MCP server examples\n\nThe first walkthrough used a hosted server that connects without any sign-in. The examples below cover the other two common shapes, with the same add, check, use flow.\n\n### Add a local server\n\nA local stdio server is a program Claude Code starts as a subprocess on your machine, rather than a service it reaches over a URL. Use one for tools that need access to local resources like a browser, your filesystem, or a database socket.\n\nThe [Playwright MCP server](https://github.com/microsoft/playwright-mcp) is a good one to try: it gives Claude a browser it can navigate, click, and read, and it needs no account. It runs through `npx`, so it requires [Node.js](https://nodejs.org/en/download) 18 or later.\n\n<Steps>\n  <Step title=\"Add the Playwright server\">\n    Register the server with the command Claude Code should run to start it:\n\n    ```bash theme={null}\n    claude mcp add playwright -- npx -y @playwright/mcp@latest\n    ```\n\n    This command differs from the hosted example in three ways:\n\n    * There's no `--transport` flag, because local servers use the default `stdio` transport.\n    * Everything after the `--` separator is the command Claude Code runs to start the server.\n    * `-y` tells `npx` to install the package without prompting.\n\n    Playwright drives whichever Chrome is already installed on your machine. To use a different browser, append `--browser` with the browser name, for example `--browser firefox`, after `@playwright/mcp@latest`.\n  </Step>\n\n  <Step title=\"Check the connection\">\n    The `Added` confirmation means the entry was saved, not that the command runs. Check the connection:\n\n    ```bash theme={null}\n    claude mcp list\n    ```\n\n    The first check can show `✗ Failed to connect` while `npx` downloads the package, so wait a moment and run it again.\n  </Step>\n\n  <Step title=\"Use the browser\">\n    Give Claude a task that needs the browser:\n\n    ```text theme={null}\n    Use playwright to open https://example.com and tell me the page title\n    ```\n\n    A browser window opens so you can watch it work, and the tool calls in Claude's output are labeled with the `playwright` server name and the action, like `browser_navigate`.\n\n    Try pointing it at your local dev server to check that a page still renders after a change, or have it walk through a bug report step by step.\n  </Step>\n</Steps>\n\n### Connect a server that requires sign-in\n\nHosted services like Sentry, Linear, and Notion run their MCP servers behind OAuth: you add the server's URL, then sign in through your browser.\n\nThe steps below use Sentry as the example. To connect a different service, substitute its URL, which you can find in the [Anthropic Directory](/en/mcp#find-and-build-mcp-servers) or the service's documentation.\n\n<Steps>\n  <Step title=\"Add the server\">\n    The `add` command is the same as for the docs server, with Sentry's URL:\n\n    ```bash theme={null}\n    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n    ```\n\n    After adding, `claude mcp list` shows the server with `! Needs authentication`. That's expected: the next step completes the sign-in.\n  </Step>\n\n  <Step title=\"Authenticate in your browser\">\n    Start a Claude Code session and open the MCP panel:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Select `sentry` from the list, press Enter, and choose `Authenticate`. Your browser opens to Sentry's sign-in page. Approve the connection there.\n\n    Back in Claude Code, the server's status changes to connected. If sign-in fails or the browser doesn't open, see [Troubleshooting](#troubleshooting).\n  </Step>\n\n  <Step title=\"Use the server\">\n    Ask Claude something that needs the service, like `What Sentry projects do I have access to?`, and look for tool calls labeled with the `sentry` server name in its output.\n  </Step>\n</Steps>\n\nServers that authenticate with a static token instead of OAuth take the token at add time with `--header \"Authorization: Bearer <token>\"`. See the [GitHub example](/en/mcp#example-connect-to-github-for-code-reviews) for a worked version.\n\n## Edit .mcp.json directly\n\nEvery file in the [scope table](#find-your-configuration-on-disk) uses the same JSON format for server entries. This section edits `.mcp.json`, the project-scope file. It's the one most worth writing by hand because it's checked into the repository, where it doubles as configuration-as-code for your team.\n\nCreate `.mcp.json` in your project root. The example below defines both servers from this guide, the hosted docs server reached over HTTP and the Playwright server as a local `stdio` process:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"claude-code-docs\": {\n      \"type\": \"http\",\n      \"url\": \"https://code.claude.com/docs/mcp\"\n    },\n    \"playwright\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@playwright/mcp@latest\"]\n    }\n  }\n}\n```\n\nThe fields differ by server type:\n\n* For HTTP servers, `url` is the endpoint Claude Code connects to.\n* For stdio servers, `command` and `args` are the program it runs.\n\nAfter saving the file, start a new Claude Code session in the project. Claude Code reads `.mcp.json` at startup.\n\nThe first time Claude Code sees a project-scoped server, it asks you to approve it. The prompt exists so a repository you clone can't launch processes on your machine without your consent. Approve the prompt, or run `/mcp` to approve later if you missed it.\n\nOnce you've approved, run `/mcp` and check that the servers show as connected. If one shows an error instead, see [Troubleshooting](#troubleshooting).\n\n## Connect from other surfaces\n\nThis guide uses the `claude mcp` CLI commands, but every Claude Code surface can connect to MCP servers:\n\n* **Claude Code desktop app**: add servers through the [Connectors UI](/en/desktop#connect-external-tools).\n* **Claude Desktop chat app**: a separate app from Claude Code. To copy servers from its `claude_desktop_config.json` into the CLI, run `claude mcp add-from-claude-desktop` on macOS or WSL.\n* **VS Code**: see [Connect to external tools with MCP](/en/vs-code#connect-to-external-tools-with-mcp).\n* **Claude Code on the web**: reads `.mcp.json` from your repository. See [Edit .mcp.json directly](#edit-mcp-json-directly).\n* **Claude.ai**: connectors you add at [claude.ai/customize/connectors](https://claude.ai/customize/connectors) load automatically in the CLI when you sign in with that account. See [Use MCP servers from Claude.ai](/en/mcp#use-mcp-servers-from-claude-ai).\n\n## Troubleshooting\n\nIf a server doesn't connect, check its status with `/mcp` inside a session or `claude mcp list` from your shell, then match the symptom below. The `/mcp` panel also lets you reconnect or authenticate without leaving the session.\n\n<AccordionGroup>\n  <Accordion title=\"/mcp shows No MCP servers configured\">\n    Claude Code didn't find any servers for the current directory. The most common causes:\n\n    * You ran `claude mcp add` from a different project. Local-scoped servers are tied to the project where you added them: the repository root, or the exact directory if you weren't in a git repository. Re-add the server from the project you're in now, or add it with `--scope user` so it isn't tied to a project.\n    * You edited a configuration file at the wrong path. The correct files are `~/.claude.json` and `<project>/.mcp.json`. Claude Code doesn't read paths such as `~/.claude/.mcp.json`, `~/.claude/config/mcp.json`, `~/.claude/mcp.json`, or `%APPDATA%\\Claude\\mcp.json`. For user-scoped servers, run `claude mcp add --scope user`, which writes to the `mcpServers` key in `~/.claude.json`; for project-scoped servers, edit `.mcp.json` at the project root.\n  </Accordion>\n\n  <Accordion title=\"Status shows Failed to connect or Connection error\">\n    Both statuses mean the server didn't start or the URL didn't respond. They can also appear for HTTP servers that expect a token rather than the browser sign-in covered in [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in).\n\n    As of v2.1.191, an HTTP server that returns `404 Not Found` shows `MCP endpoint not found at <url>. Check the URL in your MCP config.` when you select the server in `/mcp`, with the URL Claude Code tried. Earlier versions show a generic `Error POSTing to endpoint` message without the URL. Compare the URL to the server's documented MCP endpoint path, then run `claude mcp remove <name>` and re-add with the correct URL.\n\n    For HTTP servers, confirm the URL is reachable from your machine:\n\n    ```bash theme={null}\n    curl -I https://mcp.sentry.dev/mcp\n    ```\n\n    In PowerShell, use `curl.exe` instead of `curl` so the request goes to the real curl binary rather than the `Invoke-WebRequest` alias.\n\n    The response tells you which kind of problem you have:\n\n    * A `404` or `405`: the server is up. Many MCP endpoints answer only POST requests, so this still confirms the URL is reachable from your machine.\n    * A `401` or `403`: the server is up and you need to authenticate. Use the browser sign-in in [Connect a server that requires sign-in](#connect-a-server-that-requires-sign-in), or for servers that take a token instead, like GitHub's, pass it with `--header \"Authorization: Bearer <token>\"` on the `claude mcp add` command.\n    * No response at all: check the URL and your network.\n\n    For stdio servers, run the configured command directly in your terminal to see the underlying error. For the Playwright server from this guide, run:\n\n    ```bash theme={null}\n    npx -y @playwright/mcp@latest\n    ```\n\n    What happens next tells you where the problem is:\n\n    * The command starts and waits for input: the server itself works. Run `claude mcp get <name>` and confirm the command shown there matches what you just ran. If the command shown differs from what you typed, you likely omitted the `--` separator before the server command. Remove the server and re-add it with `--` in place. If you wrote `.mcp.json` by hand, check its syntax and location.\n    * The command errors: the message names what's missing, such as Node.js or a browser.\n  </Accordion>\n\n  <Accordion title=\"Connection timed out at startup\">\n    The server took longer than the default 30-second startup timeout. A stdio server's first run can be slow while `npx` downloads the package. Increase the limit with the [`MCP_TIMEOUT`](/en/env-vars) environment variable, in milliseconds:\n\n    ```bash theme={null}\n    MCP_TIMEOUT=60000 claude\n    ```\n\n    In PowerShell, set the variable before the command on the same line:\n\n    ```powershell theme={null}\n    $env:MCP_TIMEOUT = \"60000\"; claude\n    ```\n  </Accordion>\n\n  <Accordion title=\"Server already exists\">\n    You've already added a server with that name at the same scope. Either remove the existing entry first or choose a different name:\n\n    ```bash theme={null}\n    claude mcp remove claude-code-docs\n    ```\n\n    If the name exists at more than one scope, `remove` reports `exists in multiple scopes`. Pass `--scope` to choose which copy to delete, for example `claude mcp remove claude-code-docs --scope local`.\n  </Accordion>\n\n  <Accordion title=\"Server connects but no tools appear\">\n    Run `/mcp` inside a session and select the server to see its tool list. If the list is empty, the server started but didn't register any tools, which usually means it's missing a required environment variable such as an API key.\n\n    Pass the variable with `--env KEY=value` on `claude mcp add`, or in the `env` field of the server's `.mcp.json` entry. The server's documentation lists the variables it needs.\n  </Accordion>\n\n  <Accordion title=\"Changes to .mcp.json don't take effect\">\n    Claude Code reads `.mcp.json` at session start. Exit and restart the session after editing the file.\n\n    If your servers still don't appear, run `/mcp` and look for a parse warning. Claude Code skips malformed entries and shows the offending field there.\n\n    If you previously rejected the server when prompted, reset project approvals:\n\n    ```bash theme={null}\n    claude mcp reset-project-choices\n    ```\n  </Accordion>\n\n  <Accordion title=\"OAuth sign-in fails or browser doesn't open\">\n    Run `/mcp`, select the server, and choose `Authenticate` again. If the browser doesn't open automatically, copy the URL shown in the terminal and open it manually. See [Authenticate with remote MCP servers](/en/mcp#authenticate-with-remote-mcp-servers) for fixed callback ports and pre-configured credentials.\n  </Accordion>\n</AccordionGroup>\n\n## Next steps\n\nWith one server connected, explore the rest of what MCP enables:\n\n* [Find more MCP servers](/en/mcp#find-and-build-mcp-servers) in the Anthropic Directory\n* [Share servers with your team](/en/mcp#mcp-installation-scopes) using installation scopes\n* [Manage MCP access for an organization](/en/managed-mcp) with managed settings and policy controls\n* [Reference MCP resources](/en/mcp#use-mcp-resources) in prompts with @ mentions\n* [Run MCP prompts as commands](/en/mcp#use-mcp-prompts-as-commands) from the `/` menu\n* [Build your own server](https://modelcontextprotocol.io/quickstart/server) with the MCP SDK\n","durationMs":330,"url":"https://code.claude.com/docs/en/mcp-quickstart.md"},"sourceToolAssistantUUID":"484f5919-e5d4-4794-ab5a-4b7ca7840a0b","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"c2d32dce-9a41-4eb1-9d6c-0cbe73f504b2","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01TCqxYeBrnGYwN9gqBcUTV4","type":"tool_result","content":"<persisted-output>\nOutput too large (63.7KB). Full output saved to: /Users/marcus.hinz/.config/ai-control/pools/private/projects/-Users-marcus-hinz-claude-projects-ai-control/f7704328-4eb4-4f0f-bf42-da68abab401d/tool-results/toolu_01TCqxYeBrnGYwN9gqBcUTV4.txt\n\nPreview (first 2KB):\n> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect Claude Code to tools via MCP\n\n> Learn how to connect Claude Code to your tools with the Model Context Protocol.\n\nClaude 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.\n\nConnect 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.\n\nIf you're connecting your first server, start with the [MCP quickstart](/en/mcp-quickstart) for a step-by-step walkthrough. This page is the full reference.\n\n## What you can do with MCP\n\nWith MCP servers connected, you can ask Claude Code to:\n\n* **Implement features from issue trackers**: \"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.\"\n* **Analyze monitoring data**: \"Check Sentry and Statsig to check the usage of the feature described in ENG-4521.\"\n* **Query databases**: \"Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.\"\n* **Integrate designs**: \"Update our standard email template based on the new Figma designs that were posted in Slack\"\n* **Automate workflows**: \"Create Gmail drafts inviting these 10 users to a feedback session about the new feature.\"\n* **React to external events**: an MCP server can also act as a [channel](/en/channels) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you're away.\n\n## Find and build MCP servers\n\n...\n</persisted-output>"}]},"uuid":"f5577080-af97-4728-a7fb-aaa78cc373cf","timestamp":"2026-07-11T09:37:58.182Z","toolUseResult":{"bytes":65223,"code":200,"codeText":"OK","result":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect Claude Code to tools via MCP\n\n> Learn how to connect Claude Code to your tools with the Model Context Protocol.\n\nClaude 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.\n\nConnect 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.\n\nIf you're connecting your first server, start with the [MCP quickstart](/en/mcp-quickstart) for a step-by-step walkthrough. This page is the full reference.\n\n## What you can do with MCP\n\nWith MCP servers connected, you can ask Claude Code to:\n\n* **Implement features from issue trackers**: \"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.\"\n* **Analyze monitoring data**: \"Check Sentry and Statsig to check the usage of the feature described in ENG-4521.\"\n* **Query databases**: \"Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.\"\n* **Integrate designs**: \"Update our standard email template based on the new Figma designs that were posted in Slack\"\n* **Automate workflows**: \"Create Gmail drafts inviting these 10 users to a feedback session about the new feature.\"\n* **React to external events**: an MCP server can also act as a [channel](/en/channels) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you're away.\n\n## Find and build MCP servers\n\nBrowse 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`.\n\n<Warning>\n  Verify you trust each server before connecting it. Servers that fetch external content can expose you to [prompt injection risk](/en/security#protect-against-prompt-injection).\n</Warning>\n\nTo 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.\n\nYou 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).\n\n<Steps>\n  <Step title=\"Install the plugin\">\n    In a Claude Code session, run:\n\n    ```\n    /plugin install mcp-server-dev@claude-plugins-official\n    ```\n\n    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.\n  </Step>\n\n  <Step title=\"Run the build skill\">\n    ```\n    /mcp-server-dev:build-mcp-server\n    ```\n\n    Claude asks about your use case and scaffolds a remote HTTP or local stdio server.\n  </Step>\n</Steps>\n\n## Installing MCP servers\n\nMCP servers can be configured in several ways depending on your needs:\n\n### Option 1: Add a remote HTTP server\n\nHTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add --transport http <name> <url>\n\n# Real example: Connect to Notion\nclaude mcp add --transport http notion https://mcp.notion.com/mcp\n\n# Example with Bearer token\nclaude mcp add --transport http secure-api https://api.example.com/mcp \\\n  --header \"Authorization: Bearer your-token\"\n```\n\nWhen 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.\n\nA 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`.\n\n### Option 2: Add a remote SSE server\n\n<Warning>\n  The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.\n</Warning>\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add --transport sse <name> <url>\n\n# Real example: Connect to Asana\nclaude mcp add --transport sse asana https://mcp.asana.com/sse\n\n# Example with authentication header\nclaude mcp add --transport sse private-api https://api.company.com/sse \\\n  --header \"X-API-Key: your-key-here\"\n```\n\n### Option 3: Add a local stdio server\n\nStdio servers run as local processes on your machine. They're ideal for tools that need direct system access or custom scripts.\n\nClaude 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.\n\n`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](/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`.\n\nThis 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.\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add [options] <name> -- <command> [args...]\n\n# Real example: Add Airtable server\nclaude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \\\n  -- npx -y airtable-mcp-server\n```\n\n<Note>\n  **Important: Separate server arguments with `--`**\n\n  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.\n\n  For example:\n\n  * `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`\n  * `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\n\n  Without `--`, Claude Code would try to parse the server's flags, like `--port` above, as its own options.\n\n  `--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.\n</Note>\n\n### Option 4: Add a remote WebSocket server\n\nWebSocket 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.\n\nConfigure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:\n\n```bash theme={null}\nclaude mcp add-json events-server \\\n  '{\"type\":\"ws\",\"url\":\"wss://mcp.example.com/socket\",\"headers\":{\"Authorization\":\"Bearer YOUR_TOKEN\"}}'\n```\n\nThe `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`](#use-dynamic-headers-for-custom-authentication). The `claude mcp add --transport` flag doesn't accept `ws`.\n\n### Managing your servers\n\nOnce configured, you can manage your MCP servers with these commands:\n\n```bash theme={null}\n# List all configured servers\nclaude mcp list\n\n# Get details for a specific server\nclaude mcp get github\n\n# Remove a server\nclaude mcp remove github\n\n# (within Claude Code) Check server status\n/mcp\n```\n\nProject-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`.\n\nAs 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`](/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.\n\nApprovals from these sources still apply in an untrusted folder:\n\n* your user `~/.claude/settings.json`\n* managed settings\n* settings passed with `--settings`\n* `.claude/settings.local.json`, as long as git doesn't track it\n\nA `disabledMcpjsonServers` entry in any settings file still rejects the server.\n\nThe `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools.\n\nIf your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With [tool search](#scale-with-mcp-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.\n\nSome 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.\n\n`Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app's preview pane](/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.\n\n### Dynamic tool updates\n\nClaude 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.\n\n### Automatic reconnection\n\nIf 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.\n\nThe 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.\n\nWhen 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](#scale-with-mcp-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.\n\nAs 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.\n\n### Push messages with channels\n\nAn 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](/en/channels) to use an officially supported channel, or [Channels reference](/en/channels-reference) to build your own.\n\n<Tip>\n  Tips:\n\n  * Use the `-s` or `--scope` flag to specify where the configuration is stored:\n    * `local` (default): available only to you in the current project. Older versions called this scope `project`\n    * `project`: shared with everyone in the project via the `.mcp.json` file\n    * `user`: available to you across all projects. Older versions called this scope `global`\n  * Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)\n  * The `--transport` and `--header` flags also accept `-t` and `-H` short forms\n  * Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)\n  * 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\n  * 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`)\n  * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication\n</Tip>\n\nThe 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. {/* min-version: 2.1.162 */}Before v2.1.162, values below 1000 were floored to one second instead.\n\nA 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.\n\nFor HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum.\n\nA 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. {/* min-version: 2.1.203 */}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](#use-mcp-servers-from-claude-ai) servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout.\n\nSet the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](/en/env-vars) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.\n\n### Plugin-provided MCP servers\n\n[Plugins](/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.\n\n**How plugin MCP servers work**:\n\n* Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`\n* When a plugin is enabled, its MCP servers start automatically\n* Plugin MCP tools appear alongside manually configured MCP tools\n* Plugin servers are managed through plugin installation, not `/mcp` commands\n\n**Example plugin MCP configuration**:\n\nIn `.mcp.json` at plugin root:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"database-tools\": {\n      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/db-server\",\n      \"args\": [\"--config\", \"${CLAUDE_PLUGIN_ROOT}/config.json\"],\n      \"env\": {\n        \"DB_URL\": \"${DB_URL}\"\n      }\n    }\n  }\n}\n```\n\nOr inline in `plugin.json`:\n\n```json theme={null}\n{\n  \"name\": \"my-plugin\",\n  \"mcpServers\": {\n    \"plugin-api\": {\n      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/api-server\",\n      \"args\": [\"--port\", \"8080\"]\n    }\n  }\n}\n```\n\n**Plugin MCP features**:\n\n* **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\n* **Environment variables**: use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](/en/plugins-reference#persistent-data-directory) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root\n* **User environment access**: access to the same environment variables as manually configured servers\n* **Multiple transport types**: support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server\n\n**Viewing plugin MCP servers**:\n\n```bash theme={null}\n# Within Claude Code, see all MCP servers including plugin ones\n/mcp\n```\n\nPlugin servers appear in the list with indicators showing they come from plugins.\n\n**Plugin MCP tool names**:\n\nTools 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:\n\n```\nmcp__plugin_my-plugin_database-tools__query\n```\n\nUse this full name when referencing the tool in [permission rules](/en/permissions), a skill's `allowed-tools` list, a [subagent's `tools` field](/en/sub-agents#available-tools), or a [hook matcher](/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.\n\nThe 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](/en/hooks#mcp-tool-hook-fields).\n\n**Benefits of plugin MCP servers**:\n\n* **Bundled distribution**: tools and servers packaged together\n* **Automatic setup**: no manual MCP configuration needed\n* **Team consistency**: everyone gets the same tools when the plugin is installed\n\nSee the [plugin components reference](/en/plugins-reference#mcp-servers) for details on bundling MCP servers with plugins.\n\n## MCP installation scopes\n\nMCP 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](#managed-mcp-configuration).\n\n| Scope                     | Loads in             | Shared with team         | Stored in                   |\n| ------------------------- | -------------------- | ------------------------ | --------------------------- |\n| [Local](#local-scope)     | Current project only | No                       | `~/.claude.json`            |\n| [Project](#project-scope) | Current project only | Yes, via version control | `.mcp.json` in project root |\n| [User](#user-scope)       | All your projects    | No                       | `~/.claude.json`            |\n\n### Local scope\n\nLocal 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.\n\n<Note>\n  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](/en/settings#settings-files) for details on settings file locations.\n</Note>\n\n```bash theme={null}\n# Add a local-scoped server (default)\nclaude mcp add --transport http stripe https://mcp.stripe.com\n\n# Explicitly specify local scope\nclaude mcp add --transport http stripe --scope local https://mcp.stripe.com\n```\n\nThe 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`:\n\n```json theme={null}\n{\n  \"projects\": {\n    \"/path/to/your/project\": {\n      \"mcpServers\": {\n        \"stripe\": {\n          \"type\": \"http\",\n          \"url\": \"https://mcp.stripe.com\"\n        }\n      }\n    }\n  }\n}\n```\n\n### Project scope\n\nProject-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.\n\n```bash theme={null}\n# Add a project-scoped server\nclaude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp\n```\n\nThe resulting `.mcp.json` file follows a standardized format:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"shared-server\": {\n      \"command\": \"/path/to/server\",\n      \"args\": [],\n      \"env\": {}\n    }\n  }\n}\n```\n\nFor 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.\n\n### User scope\n\nUser-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.\n\n```bash theme={null}\n# Add a user server\nclaude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic\n```\n\n### Scope hierarchy and precedence\n\nWhen 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.\n\n1. Local scope\n2. Project scope\n3. User scope\n4. [Plugin-provided servers](/en/plugins)\n5. [claude.ai connectors](#use-mcp-servers-from-claude-ai)\n\nThe 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.\n\n### Environment variable expansion in `.mcp.json`\n\nClaude 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.\n\n**Supported syntax:**\n\n* `${VAR}`: expands to the value of environment variable `VAR`\n* `${VAR:-default}`: expands to `VAR` if set, otherwise uses `default`\n\n**Expansion locations:**\nEnvironment variables can be expanded in:\n\n* `command`: the server executable path\n* `args`: command-line arguments\n* `env`: environment variables passed to the server\n* `url`: for HTTP server types\n* `headers`: for HTTP server authentication\n\n**Example with variable expansion:**\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"api-server\": {\n      \"type\": \"http\",\n      \"url\": \"${API_BASE_URL:-https://api.example.com}/mcp\",\n      \"headers\": {\n        \"Authorization\": \"Bearer ${API_KEY}\"\n      }\n    }\n  }\n}\n```\n\nIf a required environment variable isn't set and has no default value, Claude Code fails to parse the config.\n\n## Practical examples\n\n### Example: Monitor errors with Sentry\n\n```bash theme={null}\nclaude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n```\n\nAuthenticate with your Sentry account:\n\n```text theme={null}\n/mcp\n```\n\nThen debug production issues:\n\n```text theme={null}\nWhat are the most common errors in the last 24 hours?\n```\n\n```text theme={null}\nShow me the stack trace for error ID abc123\n```\n\n```text theme={null}\nWhich deployment introduced these new errors?\n```\n\n### Example: Connect to GitHub for code reviews\n\nGitHub'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:\n\n```bash theme={null}\nclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ \\\n  --header \"Authorization: Bearer YOUR_GITHUB_PAT\"\n```\n\nThen work with GitHub:\n\n```text theme={null}\nReview PR #456 and suggest improvements\n```\n\n```text theme={null}\nCreate a new issue for the bug we just found\n```\n\n```text theme={null}\nShow me all open PRs assigned to me\n```\n\n### Example: Query your PostgreSQL database\n\n```bash theme={null}\nclaude mcp add --transport stdio db -- npx -y @bytebase/dbhub \\\n  --dsn \"postgresql://readonly:pass@prod.db.com:5432/analytics\"\n```\n\nThen query your database naturally:\n\n```text theme={null}\nWhat's our total revenue this month?\n```\n\n```text theme={null}\nShow me the schema for the orders table\n```\n\n```text theme={null}\nFind customers who haven't made a purchase in 90 days\n```\n\n## Authenticate with remote MCP servers\n\nMany cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections.\n\nClaude 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.\n\nAs 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.\n\nA custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.\n\nAs 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.\n\nIn 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](#scale-with-mcp-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>`.\n\nIf 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.\n\n<Steps>\n  <Step title=\"Add the server that requires authentication\">\n    For example:\n\n    ```bash theme={null}\n    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n    ```\n  </Step>\n\n  <Step title=\"Use the /mcp command within Claude Code\">\n    In Claude Code, use the command:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Then follow the steps in your browser to log in.\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Authentication tokens are stored securely and refreshed automatically\n  * Use \"Clear authentication\" in the `/mcp` menu to revoke access\n  * If your browser doesn't open automatically, copy the provided URL and open it manually\n  * 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\n  * OAuth authentication works with HTTP servers\n</Tip>\n\n### Authenticate from the command line\n\nFrom 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.\n\n```bash theme={null}\nclaude mcp login sentry\n```\n\nTo clear stored credentials later, run `claude mcp logout <name>`.\n\nAs 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.\n\n```bash theme={null}\nclaude mcp login sentry --no-browser\n```\n\n### Use a fixed OAuth callback port\n\nSome 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`.\n\nYou can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).\n\n```bash theme={null}\n# Fixed callback port with dynamic client registration\nclaude mcp add --transport http \\\n  --callback-port 8080 \\\n  my-server https://mcp.example.com/mcp\n```\n\n### Use pre-configured OAuth credentials\n\nSome 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.\n\n<Steps>\n  <Step title=\"Register an OAuth app with the server\">\n    Create an app through the server's developer portal and note your client ID and client secret.\n\n    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.\n  </Step>\n\n  <Step title=\"Add the server with your credentials\">\n    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.\n\n    <Tabs>\n      <Tab title=\"claude mcp add\">\n        Use `--client-id` to pass your app's client ID. The `--client-secret` flag prompts for the secret with masked input:\n\n        ```bash theme={null}\n        claude mcp add --transport http \\\n          --client-id your-client-id --client-secret --callback-port 8080 \\\n          my-server https://mcp.example.com/mcp\n        ```\n      </Tab>\n\n      <Tab title=\"claude mcp add-json\">\n        Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:\n\n        ```bash theme={null}\n        claude mcp add-json my-server \\\n          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' \\\n          --client-secret\n        ```\n      </Tab>\n\n      <Tab title=\"claude mcp add-json (callback port only)\">\n        Use `--callback-port` without a client ID to fix the port while using dynamic client registration:\n\n        ```bash theme={null}\n        claude mcp add-json my-server \\\n          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"callbackPort\":8080}}'\n        ```\n      </Tab>\n\n      <Tab title=\"CI / env var\">\n        Set the secret via environment variable to skip the interactive prompt:\n\n        ```bash theme={null}\n        MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \\\n          --client-id your-client-id --client-secret --callback-port 8080 \\\n          my-server https://mcp.example.com/mcp\n        ```\n      </Tab>\n    </Tabs>\n  </Step>\n\n  <Step title=\"Authenticate in Claude Code\">\n    Run `/mcp` in Claude Code and follow the browser login flow.\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config\n  * If the server uses a public OAuth client with no secret, use only `--client-id` without `--client-secret`\n  * `--callback-port` can be used with or without `--client-id`\n  * These flags only apply to HTTP and SSE transports. They have no effect on stdio servers\n  * Use `claude mcp get <name>` to verify that OAuth credentials are configured for a server\n</Tip>\n\n### Override OAuth metadata discovery\n\nPoint 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`.\n\nSet `authServerMetadataUrl` in the `oauth` object of your server's config in `.mcp.json`:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"my-server\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/mcp\",\n      \"oauth\": {\n        \"authServerMetadataUrl\": \"https://auth.example.com/.well-known/openid-configuration\"\n      }\n    }\n  }\n}\n```\n\nThe 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.\n\n### Restrict OAuth scopes\n\nSet `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.\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"slack\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.slack.com/mcp\",\n      \"oauth\": {\n        \"scopes\": \"channels:read chat:write search:read\"\n      }\n    }\n  }\n}\n```\n\n`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.\n\nAs 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.\n\nIf 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.\n\nIf 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.\n\n### Use dynamic headers for custom authentication\n\nIf 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.\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"internal-api\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.internal.example.com\",\n      \"headersHelper\": \"/opt/bin/get-mcp-auth-headers.sh\"\n    }\n  }\n}\n```\n\nThe command can also be inline:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"internal-api\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.internal.example.com\",\n      \"headersHelper\": \"echo '{\\\"Authorization\\\": \\\"Bearer '\\\"$(get-token)\\\"'\\\"}'\"\n    }\n  }\n}\n```\n\n**Requirements:**\n\n* The command must write a JSON object of string key-value pairs to stdout\n* The command runs in a shell with a 10-second timeout\n* Dynamic headers override any static `headers` with the same name\n\nThe 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.\n\nAs 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.\n\nClaude Code sets these environment variables when executing the helper:\n\n| Variable                      | Value                                                                                                        |\n| :---------------------------- | :----------------------------------------------------------------------------------------------------------- |\n| `CLAUDE_CODE_MCP_SERVER_NAME` | the name of the MCP server                                                                                   |\n| `CLAUDE_CODE_MCP_SERVER_URL`  | the URL of the MCP server                                                                                    |\n| `CLAUDE_PLUGIN_ROOT`          | the plugin's root directory. Set only when a [plugin](/en/plugins-reference#mcp-servers) provides the server |\n\nUse these to write a single helper script that serves multiple MCP servers.\n\nFor 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.\n\n<Note>\n  `headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.\n</Note>\n\n## Add MCP servers from JSON configuration\n\nIf you have a JSON configuration for an MCP server, you can add it directly:\n\n<Steps>\n  <Step title=\"Add an MCP server from JSON\">\n    ```bash theme={null}\n    # Basic syntax\n    claude mcp add-json <name> '<json>'\n\n    # Example: Adding an HTTP server with JSON configuration\n    claude mcp add-json weather-api '{\"type\":\"http\",\"url\":\"https://api.weather.com/mcp\",\"headers\":{\"Authorization\":\"Bearer token\"}}'\n\n    # Example: Adding a stdio server with JSON configuration\n    claude mcp add-json local-weather '{\"type\":\"stdio\",\"command\":\"/path/to/weather-cli\",\"args\":[\"--api-key\",\"abc123\"],\"env\":{\"CACHE_DIR\":\"/tmp\"}}'\n\n    # Example: Adding an HTTP server with pre-configured OAuth credentials\n    claude mcp add-json my-server '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' --client-secret\n    ```\n  </Step>\n\n  <Step title=\"Verify the server was added\">\n    ```bash theme={null}\n    claude mcp get weather-api\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Make sure the JSON is properly escaped in your shell\n  * The JSON must conform to the MCP server configuration schema\n  * You can use `--scope user` to add the server to your user configuration instead of the project-specific one\n</Tip>\n\n## Import MCP servers from Claude Desktop\n\nIf you've already configured MCP servers in Claude Desktop, you can import them:\n\n<Steps>\n  <Step title=\"Import servers from Claude Desktop\">\n    ```bash theme={null}\n    # Basic syntax \n    claude mcp add-from-claude-desktop \n    ```\n  </Step>\n\n  <Step title=\"Select which servers to import\">\n    After running the command, you'll see an interactive dialog that allows you to select which servers you want to import.\n  </Step>\n\n  <Step title=\"Verify the servers were imported\">\n    ```bash theme={null}\n    claude mcp list \n    ```\n  </Step>\n</Steps>\n\nServer 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.\n\n<Tip>\n  Tips:\n\n  * This feature only works on macOS and Windows Subsystem for Linux (WSL)\n  * It reads the Claude Desktop configuration file from its standard location on those platforms\n  * Use the `--scope user` flag to add servers to your user configuration\n  * 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\n  * If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)\n</Tip>\n\n## Use MCP servers from claude.ai\n\nIf 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:\n\n<Steps>\n  <Step title=\"Configure MCP servers in claude.ai\">\n    Add servers at [claude.ai/customize/connectors](https://claude.ai/customize/connectors). On Team and Enterprise plans, only admins can add servers.\n  </Step>\n\n  <Step title=\"Authenticate the MCP server\">\n    Complete any required authentication steps in claude.ai.\n  </Step>\n\n  <Step title=\"View and manage servers in Claude Code\">\n    In Claude Code, use the command:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Servers from claude.ai appear in the list with indicators showing they come from claude.ai.\n  </Step>\n</Steps>\n\nFrom 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.\n\nConnectors from claude.ai are fetched only when your active [authentication method](/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`.\n\nIf `/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.\n\nA server you've added in Claude Code takes [precedence](#scope-hierarchy-and-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.\n\nSome 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.\n\n### Disable claude.ai connectors\n\nTo disable claude.ai MCP servers in Claude Code, set [`disableClaudeAiConnectors`](/en/settings#available-settings) to `true` in any settings scope:\n\n```json theme={null}\n{\n  \"disableClaudeAiConnectors\": true\n}\n```\n\nThis 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.\n\nYou can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:\n\n```bash theme={null}\nENABLE_CLAUDEAI_MCP_SERVERS=false claude\n```\n\nTo block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](/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.\n\n<Note>\n  These client-side settings govern local Claude Code sessions. In [Claude Code on the web](/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.\n</Note>\n\n## Use Claude Code as an MCP server\n\nYou can use Claude Code itself as an MCP server that other applications can connect to:\n\n```bash theme={null}\n# Start Claude as a stdio MCP server\nclaude mcp serve\n```\n\nYou can use this in Claude Desktop by adding this configuration to claude\\_desktop\\_config.json:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"claude-code\": {\n      \"type\": \"stdio\",\n      \"command\": \"claude\",\n      \"args\": [\"mcp\", \"serve\"],\n      \"env\": {}\n    }\n  }\n}\n```\n\n<Warning>\n  **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.\n\n  To find the full path:\n\n  ```bash theme={null}\n  which claude\n  ```\n\n  Then use the full path in your configuration:\n\n  ```json theme={null}\n  {\n    \"mcpServers\": {\n      \"claude-code\": {\n        \"type\": \"stdio\",\n        \"command\": \"/full/path/to/claude\",\n        \"args\": [\"mcp\", \"serve\"],\n        \"env\": {}\n      }\n    }\n  }\n  ```\n\n  Without the correct executable path, you'll encounter errors like `spawn claude ENOENT`.\n</Warning>\n\n<Tip>\n  Tips:\n\n  * The server provides access to Claude's tools like View, Edit, LS, etc.\n  * In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.\n  * 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.\n</Tip>\n\n## MCP output limits and warnings\n\nWhen MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:\n\n* **Output warning threshold**: Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens\n* **Configurable limit**: you can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable\n* **Default limit**: the default maximum is 25,000 tokens\n* **Scope**: the environment variable applies to tools that don't declare their own limit. Tools that set [`anthropic/maxResultSizeChars`](#raise-the-limit-for-a-specific-tool) 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`\n\nTo increase the limit for tools that produce large outputs:\n\n```bash theme={null}\nexport MAX_MCP_OUTPUT_TOKENS=50000\nclaude\n```\n\nThis is particularly useful when working with MCP servers that:\n\n* Query large datasets or databases\n* Generate detailed reports or documentation\n* Process extensive log files or debugging information\n\n### Raise the limit for a specific tool\n\nIf 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.\n\nThis 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.\n\n```json theme={null}\n{\n  \"name\": \"get_schema\",\n  \"description\": \"Returns the full database schema\",\n  \"_meta\": {\n    \"anthropic/maxResultSizeChars\": 200000\n  }\n}\n```\n\nThe 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.\n\n<Warning>\n  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.\n</Warning>\n\n## Tool input schemas with a root-level combinator\n\nSome 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.\n\nAs 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:\n\n* `allOf`: properties from every branch are merged, and each branch's `required` list still applies\n* `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\n\nYour server receives whichever arguments Claude chose, so keep validating the combination server-side.\n\nWhen 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`.\n\n## Require approval for a specific tool\n\nIf 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.\n\nClaude Code shows that tool's permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](/en/permissions#permission-modes), and doesn't offer a \"don't ask again\" option for it. [Allow rules](/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.\n\nThe prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](/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](/en/agent-sdk/permissions) does receive these calls and can approve them, because the SDK host is expected to show them to a user.\n\nUse 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.\n\nThe following `tools/list` entry marks one tool as always requiring approval.\n\n```json theme={null}\n{\n  \"name\": \"grant_access\",\n  \"description\": \"Requests access to a protected resource\",\n  \"_meta\": {\n    \"anthropic/requiresUserInteraction\": true\n  }\n}\n```\n\nThe `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow.\n\nWhen a session is connected to [Remote Control](/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.\n\n## Respond to MCP elicitation requests\n\nMCP 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.\n\nServers can request input in two ways:\n\n* **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.\n* **URL mode**: Claude Code opens a browser URL for authentication or approval. Complete the flow in the browser, then confirm in the CLI.\n\nTo auto-respond to elicitation requests without showing a dialog, use the [`Elicitation` hook](/en/hooks#elicitation).\n\nIf 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.\n\n## Use MCP resources\n\nMCP servers can expose resources that you can reference using @ mentions, similar to how you reference files.\n\n### Reference MCP resources\n\n<Steps>\n  <Step title=\"List available resources\">\n    Type `@` in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu.\n  </Step>\n\n  <Step title=\"Reference a specific resource\">\n    Use the format `@server:protocol://resource/path` to reference a resource:\n\n    ```text theme={null}\n    Can you analyze @github:issue://123 and suggest a fix?\n    ```\n\n    ```text theme={null}\n    Please review the API documentation at @docs:file://api/authentication\n    ```\n  </Step>\n\n  <Step title=\"Multiple resource references\">\n    You can reference multiple resources in a single prompt:\n\n    ```text theme={null}\n    Compare @postgres:schema://users with @docs:file://database/user-model\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Resources are automatically fetched and included as attachments when referenced\n  * Resource paths are fuzzy-searchable in the @ mention autocomplete\n  * Claude Code automatically provides tools to list and read MCP resources when servers support them\n  * Resources can contain any type of content that the MCP server provides (text, JSON, structured data, etc.)\n</Tip>\n\n## Scale with MCP tool search\n\nTool 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.\n\n### How it works\n\nTool 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.\n\nIf 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](#configure-tool-search) for all options.\n\n### For MCP server authors\n\nIf 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](/en/skills) work.\n\nAdd clear, descriptive server instructions that explain:\n\n* What category of tasks your tools handle\n* When Claude should search for your tools\n* Key capabilities your server provides\n\nClaude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.\n\n### Configure tool search\n\nTool 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.\n\nTool 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.\n\nControl tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:\n\n| Value    | Behavior                                                                                                                                                                                                                                                                 |\n| :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| (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                                                                                                       |\n| `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 |\n| `auto`   | Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise                                                                                                                                                                      |\n| `auto:N` | Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%                                                                                                                                                                                |\n| `false`  | All MCP tools loaded upfront, no deferral                                                                                                                                                                                                                                |\n\n```bash theme={null}\n# Use a custom 5% threshold\nENABLE_TOOL_SEARCH=auto:5 claude\n\n# Disable tool search entirely\nENABLE_TOOL_SEARCH=false claude\n```\n\nOr set the value in your [settings.json `env` field](/en/settings#available-settings).\n\nYou can also disable the `ToolSearch` tool specifically:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\"ToolSearch\"]\n  }\n}\n```\n\n### Exempt a server from deferral\n\nIf 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.\n\nThe following `.mcp.json` entry exempts one HTTP server while leaving other servers deferred:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"core-tools\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/mcp\",\n      \"alwaysLoad\": true\n    }\n  }\n}\n```\n\nThe `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.\n\nSetting `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](/en/env-vars), since the tools must be present when the first prompt is built. Other servers continue to connect in the background.\n\n## Use MCP prompts as commands\n\nMCP servers can expose prompts that become available as commands in Claude Code.\n\n### Execute MCP prompts\n\n<Steps>\n  <Step title=\"Discover available prompts\">\n    Type `/` to see all available commands, including those from MCP servers. MCP prompts appear with the format `/mcp__servername__promptname`.\n  </Step>\n\n  <Step title=\"Execute a prompt without arguments\">\n    ```text theme={null}\n    /mcp__github__list_prs\n    ```\n  </Step>\n\n  <Step title=\"Execute a prompt with arguments\">\n    Many prompts accept arguments. Pass them space-separated after the command:\n\n    ```text theme={null}\n    /mcp__github__pr_review 456\n    ```\n\n    ```text theme={null}\n    /mcp__jira__create_issue \"Bug in login flow\" high\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * MCP prompts are dynamically discovered from connected servers\n  * Arguments are parsed based on the prompt's defined parameters\n  * Prompt results are injected directly into the conversation\n  * Server and prompt names are normalized, with spaces converted to underscores\n</Tip>\n\n## Managed MCP configuration\n\nFor organizations that need centralized control over which MCP servers users can connect to, see [Managed MCP configuration](/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.\n","durationMs":1340,"url":"https://code.claude.com/docs/en/mcp.md"},"sourceToolAssistantUUID":"c2d32dce-9a41-4eb1-9d6c-0cbe73f504b2","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"f5577080-af97-4728-a7fb-aaa78cc373cf","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dMNViJcTje1mwRCrE","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"Ep0ECpMBCA8YAipAa/dxrBc4b4MyTLDQWijI+E4dkXLtvixB6KoPI8whQwyaKcJIfHn2tQRGlo6xYHQ6krfEQKNGdcMN3vLrCyg0bTIZY2xhdWRlLWhhaWt1LTQtNS0yMDI1MTAwMTgAQgh0aGlua2luZ1okNGJkZDE1Y2MtNDcxZS00ZTU2LWJhMWEtM2QzZDViNGYwMTdjEgzOGTu8hKoOIVe42BgaDMgAZC71oJeRR+ki9iIw90CyJnTt11Pg5HOHoG3moHU+84BQ2jRq79W3Wzn4P+is8u8f9I7l4gC45Flwph21KrYC8lIt0yFJjgzeOP9cy7E3B6KSVzS1FE+pcdkC3P2w+nUGy8+Epn31YoWZuszBLnJwGJFWTlgwIsxUuSxl7OSaUeZXu5EmRbQfWve1yVPvycJqJTWdgQwkeU7cKYjb1T3eJPofey1AztkKtivQjbWqXXw3GcEkP9sIxvIYbfjgYFuPXI9AM76hahBRZeXyZ9obQR95WRvdLt5za+2u02yoGm0ORKBKupIgJsrgl0HDQGAeS7A8Xdv/MR1oAF2YQD8ddGwZUQoJQL1jtTctmXUI3qeLtT8gVSiEIE5L1niy72/Qn0O/NZ09cRil9kwTiTOE16duNcBc4MxzfK8XGjVi0ZrUzO7p/WGoSmPa7+KAYQCLKiChdj7sn3S/ZrKwIjVVAYEd6/15Ow5ToltJUkVqLHuKU53m/hgB"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":5888,"cache_creation_input_tokens":842,"cache_read_input_tokens":15327,"cache_creation":{"ephemeral_5m_input_tokens":842,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3dLA59QTj82SeP2zkV","attributionAgent":"claude-code-guide","type":"assistant","uuid":"b3bb5089-e2df-42c6-bd23-1a0d87bfd6c6","timestamp":"2026-07-11T09:38:01.539Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"b3bb5089-e2df-42c6-bd23-1a0d87bfd6c6","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dMNViJcTje1mwRCrE","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_01XgSLPyTpP8MwFa36KC235g","name":"WebFetch","input":{"url":"https://code.claude.com/docs/en/mcp.md","prompt":"permissions allow mcp tool names trust approve .mcp.json environment variables env inheritance"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":5888,"cache_creation_input_tokens":842,"cache_read_input_tokens":15327,"output_tokens":176,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":842},"inference_geo":"not_available","iterations":[{"input_tokens":5888,"output_tokens":176,"cache_read_input_tokens":15327,"cache_creation_input_tokens":842,"cache_creation":{"ephemeral_5m_input_tokens":842,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3dLA59QTj82SeP2zkV","attributionAgent":"claude-code-guide","type":"assistant","uuid":"c789b8f7-f588-4f0f-a6f1-d6121efa5169","timestamp":"2026-07-11T09:38:02.070Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"c789b8f7-f588-4f0f-a6f1-d6121efa5169","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01XgSLPyTpP8MwFa36KC235g","type":"tool_result","content":"<persisted-output>\nOutput too large (63.7KB). Full output saved to: /Users/marcus.hinz/.config/ai-control/pools/private/projects/-Users-marcus-hinz-claude-projects-ai-control/f7704328-4eb4-4f0f-bf42-da68abab401d/tool-results/toolu_01XgSLPyTpP8MwFa36KC235g.txt\n\nPreview (first 2KB):\n> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect Claude Code to tools via MCP\n\n> Learn how to connect Claude Code to your tools with the Model Context Protocol.\n\nClaude 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.\n\nConnect 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.\n\nIf you're connecting your first server, start with the [MCP quickstart](/en/mcp-quickstart) for a step-by-step walkthrough. This page is the full reference.\n\n## What you can do with MCP\n\nWith MCP servers connected, you can ask Claude Code to:\n\n* **Implement features from issue trackers**: \"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.\"\n* **Analyze monitoring data**: \"Check Sentry and Statsig to check the usage of the feature described in ENG-4521.\"\n* **Query databases**: \"Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.\"\n* **Integrate designs**: \"Update our standard email template based on the new Figma designs that were posted in Slack\"\n* **Automate workflows**: \"Create Gmail drafts inviting these 10 users to a feedback session about the new feature.\"\n* **React to external events**: an MCP server can also act as a [channel](/en/channels) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you're away.\n\n## Find and build MCP servers\n\n...\n</persisted-output>"}]},"uuid":"64dfd56d-cdb6-4039-99ca-04f1a74578ae","timestamp":"2026-07-11T09:38:02.087Z","toolUseResult":{"bytes":65223,"code":200,"codeText":"OK","result":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect Claude Code to tools via MCP\n\n> Learn how to connect Claude Code to your tools with the Model Context Protocol.\n\nClaude 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.\n\nConnect 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.\n\nIf you're connecting your first server, start with the [MCP quickstart](/en/mcp-quickstart) for a step-by-step walkthrough. This page is the full reference.\n\n## What you can do with MCP\n\nWith MCP servers connected, you can ask Claude Code to:\n\n* **Implement features from issue trackers**: \"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.\"\n* **Analyze monitoring data**: \"Check Sentry and Statsig to check the usage of the feature described in ENG-4521.\"\n* **Query databases**: \"Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.\"\n* **Integrate designs**: \"Update our standard email template based on the new Figma designs that were posted in Slack\"\n* **Automate workflows**: \"Create Gmail drafts inviting these 10 users to a feedback session about the new feature.\"\n* **React to external events**: an MCP server can also act as a [channel](/en/channels) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you're away.\n\n## Find and build MCP servers\n\nBrowse 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`.\n\n<Warning>\n  Verify you trust each server before connecting it. Servers that fetch external content can expose you to [prompt injection risk](/en/security#protect-against-prompt-injection).\n</Warning>\n\nTo 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.\n\nYou 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).\n\n<Steps>\n  <Step title=\"Install the plugin\">\n    In a Claude Code session, run:\n\n    ```\n    /plugin install mcp-server-dev@claude-plugins-official\n    ```\n\n    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.\n  </Step>\n\n  <Step title=\"Run the build skill\">\n    ```\n    /mcp-server-dev:build-mcp-server\n    ```\n\n    Claude asks about your use case and scaffolds a remote HTTP or local stdio server.\n  </Step>\n</Steps>\n\n## Installing MCP servers\n\nMCP servers can be configured in several ways depending on your needs:\n\n### Option 1: Add a remote HTTP server\n\nHTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add --transport http <name> <url>\n\n# Real example: Connect to Notion\nclaude mcp add --transport http notion https://mcp.notion.com/mcp\n\n# Example with Bearer token\nclaude mcp add --transport http secure-api https://api.example.com/mcp \\\n  --header \"Authorization: Bearer your-token\"\n```\n\nWhen 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.\n\nA 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`.\n\n### Option 2: Add a remote SSE server\n\n<Warning>\n  The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.\n</Warning>\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add --transport sse <name> <url>\n\n# Real example: Connect to Asana\nclaude mcp add --transport sse asana https://mcp.asana.com/sse\n\n# Example with authentication header\nclaude mcp add --transport sse private-api https://api.company.com/sse \\\n  --header \"X-API-Key: your-key-here\"\n```\n\n### Option 3: Add a local stdio server\n\nStdio servers run as local processes on your machine. They're ideal for tools that need direct system access or custom scripts.\n\nClaude 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.\n\n`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](/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`.\n\nThis 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.\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add [options] <name> -- <command> [args...]\n\n# Real example: Add Airtable server\nclaude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \\\n  -- npx -y airtable-mcp-server\n```\n\n<Note>\n  **Important: Separate server arguments with `--`**\n\n  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.\n\n  For example:\n\n  * `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`\n  * `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\n\n  Without `--`, Claude Code would try to parse the server's flags, like `--port` above, as its own options.\n\n  `--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.\n</Note>\n\n### Option 4: Add a remote WebSocket server\n\nWebSocket 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.\n\nConfigure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:\n\n```bash theme={null}\nclaude mcp add-json events-server \\\n  '{\"type\":\"ws\",\"url\":\"wss://mcp.example.com/socket\",\"headers\":{\"Authorization\":\"Bearer YOUR_TOKEN\"}}'\n```\n\nThe `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`](#use-dynamic-headers-for-custom-authentication). The `claude mcp add --transport` flag doesn't accept `ws`.\n\n### Managing your servers\n\nOnce configured, you can manage your MCP servers with these commands:\n\n```bash theme={null}\n# List all configured servers\nclaude mcp list\n\n# Get details for a specific server\nclaude mcp get github\n\n# Remove a server\nclaude mcp remove github\n\n# (within Claude Code) Check server status\n/mcp\n```\n\nProject-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`.\n\nAs 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`](/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.\n\nApprovals from these sources still apply in an untrusted folder:\n\n* your user `~/.claude/settings.json`\n* managed settings\n* settings passed with `--settings`\n* `.claude/settings.local.json`, as long as git doesn't track it\n\nA `disabledMcpjsonServers` entry in any settings file still rejects the server.\n\nThe `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools.\n\nIf your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With [tool search](#scale-with-mcp-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.\n\nSome 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.\n\n`Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app's preview pane](/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.\n\n### Dynamic tool updates\n\nClaude 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.\n\n### Automatic reconnection\n\nIf 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.\n\nThe 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.\n\nWhen 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](#scale-with-mcp-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.\n\nAs 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.\n\n### Push messages with channels\n\nAn 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](/en/channels) to use an officially supported channel, or [Channels reference](/en/channels-reference) to build your own.\n\n<Tip>\n  Tips:\n\n  * Use the `-s` or `--scope` flag to specify where the configuration is stored:\n    * `local` (default): available only to you in the current project. Older versions called this scope `project`\n    * `project`: shared with everyone in the project via the `.mcp.json` file\n    * `user`: available to you across all projects. Older versions called this scope `global`\n  * Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)\n  * The `--transport` and `--header` flags also accept `-t` and `-H` short forms\n  * Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)\n  * 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\n  * 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`)\n  * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication\n</Tip>\n\nThe 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. {/* min-version: 2.1.162 */}Before v2.1.162, values below 1000 were floored to one second instead.\n\nA 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.\n\nFor HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum.\n\nA 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. {/* min-version: 2.1.203 */}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](#use-mcp-servers-from-claude-ai) servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout.\n\nSet the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](/en/env-vars) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.\n\n### Plugin-provided MCP servers\n\n[Plugins](/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.\n\n**How plugin MCP servers work**:\n\n* Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`\n* When a plugin is enabled, its MCP servers start automatically\n* Plugin MCP tools appear alongside manually configured MCP tools\n* Plugin servers are managed through plugin installation, not `/mcp` commands\n\n**Example plugin MCP configuration**:\n\nIn `.mcp.json` at plugin root:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"database-tools\": {\n      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/db-server\",\n      \"args\": [\"--config\", \"${CLAUDE_PLUGIN_ROOT}/config.json\"],\n      \"env\": {\n        \"DB_URL\": \"${DB_URL}\"\n      }\n    }\n  }\n}\n```\n\nOr inline in `plugin.json`:\n\n```json theme={null}\n{\n  \"name\": \"my-plugin\",\n  \"mcpServers\": {\n    \"plugin-api\": {\n      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/api-server\",\n      \"args\": [\"--port\", \"8080\"]\n    }\n  }\n}\n```\n\n**Plugin MCP features**:\n\n* **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\n* **Environment variables**: use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](/en/plugins-reference#persistent-data-directory) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root\n* **User environment access**: access to the same environment variables as manually configured servers\n* **Multiple transport types**: support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server\n\n**Viewing plugin MCP servers**:\n\n```bash theme={null}\n# Within Claude Code, see all MCP servers including plugin ones\n/mcp\n```\n\nPlugin servers appear in the list with indicators showing they come from plugins.\n\n**Plugin MCP tool names**:\n\nTools 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:\n\n```\nmcp__plugin_my-plugin_database-tools__query\n```\n\nUse this full name when referencing the tool in [permission rules](/en/permissions), a skill's `allowed-tools` list, a [subagent's `tools` field](/en/sub-agents#available-tools), or a [hook matcher](/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.\n\nThe 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](/en/hooks#mcp-tool-hook-fields).\n\n**Benefits of plugin MCP servers**:\n\n* **Bundled distribution**: tools and servers packaged together\n* **Automatic setup**: no manual MCP configuration needed\n* **Team consistency**: everyone gets the same tools when the plugin is installed\n\nSee the [plugin components reference](/en/plugins-reference#mcp-servers) for details on bundling MCP servers with plugins.\n\n## MCP installation scopes\n\nMCP 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](#managed-mcp-configuration).\n\n| Scope                     | Loads in             | Shared with team         | Stored in                   |\n| ------------------------- | -------------------- | ------------------------ | --------------------------- |\n| [Local](#local-scope)     | Current project only | No                       | `~/.claude.json`            |\n| [Project](#project-scope) | Current project only | Yes, via version control | `.mcp.json` in project root |\n| [User](#user-scope)       | All your projects    | No                       | `~/.claude.json`            |\n\n### Local scope\n\nLocal 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.\n\n<Note>\n  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](/en/settings#settings-files) for details on settings file locations.\n</Note>\n\n```bash theme={null}\n# Add a local-scoped server (default)\nclaude mcp add --transport http stripe https://mcp.stripe.com\n\n# Explicitly specify local scope\nclaude mcp add --transport http stripe --scope local https://mcp.stripe.com\n```\n\nThe 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`:\n\n```json theme={null}\n{\n  \"projects\": {\n    \"/path/to/your/project\": {\n      \"mcpServers\": {\n        \"stripe\": {\n          \"type\": \"http\",\n          \"url\": \"https://mcp.stripe.com\"\n        }\n      }\n    }\n  }\n}\n```\n\n### Project scope\n\nProject-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.\n\n```bash theme={null}\n# Add a project-scoped server\nclaude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp\n```\n\nThe resulting `.mcp.json` file follows a standardized format:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"shared-server\": {\n      \"command\": \"/path/to/server\",\n      \"args\": [],\n      \"env\": {}\n    }\n  }\n}\n```\n\nFor 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.\n\n### User scope\n\nUser-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.\n\n```bash theme={null}\n# Add a user server\nclaude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic\n```\n\n### Scope hierarchy and precedence\n\nWhen 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.\n\n1. Local scope\n2. Project scope\n3. User scope\n4. [Plugin-provided servers](/en/plugins)\n5. [claude.ai connectors](#use-mcp-servers-from-claude-ai)\n\nThe 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.\n\n### Environment variable expansion in `.mcp.json`\n\nClaude 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.\n\n**Supported syntax:**\n\n* `${VAR}`: expands to the value of environment variable `VAR`\n* `${VAR:-default}`: expands to `VAR` if set, otherwise uses `default`\n\n**Expansion locations:**\nEnvironment variables can be expanded in:\n\n* `command`: the server executable path\n* `args`: command-line arguments\n* `env`: environment variables passed to the server\n* `url`: for HTTP server types\n* `headers`: for HTTP server authentication\n\n**Example with variable expansion:**\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"api-server\": {\n      \"type\": \"http\",\n      \"url\": \"${API_BASE_URL:-https://api.example.com}/mcp\",\n      \"headers\": {\n        \"Authorization\": \"Bearer ${API_KEY}\"\n      }\n    }\n  }\n}\n```\n\nIf a required environment variable isn't set and has no default value, Claude Code fails to parse the config.\n\n## Practical examples\n\n### Example: Monitor errors with Sentry\n\n```bash theme={null}\nclaude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n```\n\nAuthenticate with your Sentry account:\n\n```text theme={null}\n/mcp\n```\n\nThen debug production issues:\n\n```text theme={null}\nWhat are the most common errors in the last 24 hours?\n```\n\n```text theme={null}\nShow me the stack trace for error ID abc123\n```\n\n```text theme={null}\nWhich deployment introduced these new errors?\n```\n\n### Example: Connect to GitHub for code reviews\n\nGitHub'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:\n\n```bash theme={null}\nclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ \\\n  --header \"Authorization: Bearer YOUR_GITHUB_PAT\"\n```\n\nThen work with GitHub:\n\n```text theme={null}\nReview PR #456 and suggest improvements\n```\n\n```text theme={null}\nCreate a new issue for the bug we just found\n```\n\n```text theme={null}\nShow me all open PRs assigned to me\n```\n\n### Example: Query your PostgreSQL database\n\n```bash theme={null}\nclaude mcp add --transport stdio db -- npx -y @bytebase/dbhub \\\n  --dsn \"postgresql://readonly:pass@prod.db.com:5432/analytics\"\n```\n\nThen query your database naturally:\n\n```text theme={null}\nWhat's our total revenue this month?\n```\n\n```text theme={null}\nShow me the schema for the orders table\n```\n\n```text theme={null}\nFind customers who haven't made a purchase in 90 days\n```\n\n## Authenticate with remote MCP servers\n\nMany cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections.\n\nClaude 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.\n\nAs 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.\n\nA custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.\n\nAs 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.\n\nIn 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](#scale-with-mcp-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>`.\n\nIf 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.\n\n<Steps>\n  <Step title=\"Add the server that requires authentication\">\n    For example:\n\n    ```bash theme={null}\n    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n    ```\n  </Step>\n\n  <Step title=\"Use the /mcp command within Claude Code\">\n    In Claude Code, use the command:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Then follow the steps in your browser to log in.\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Authentication tokens are stored securely and refreshed automatically\n  * Use \"Clear authentication\" in the `/mcp` menu to revoke access\n  * If your browser doesn't open automatically, copy the provided URL and open it manually\n  * 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\n  * OAuth authentication works with HTTP servers\n</Tip>\n\n### Authenticate from the command line\n\nFrom 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.\n\n```bash theme={null}\nclaude mcp login sentry\n```\n\nTo clear stored credentials later, run `claude mcp logout <name>`.\n\nAs 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.\n\n```bash theme={null}\nclaude mcp login sentry --no-browser\n```\n\n### Use a fixed OAuth callback port\n\nSome 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`.\n\nYou can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).\n\n```bash theme={null}\n# Fixed callback port with dynamic client registration\nclaude mcp add --transport http \\\n  --callback-port 8080 \\\n  my-server https://mcp.example.com/mcp\n```\n\n### Use pre-configured OAuth credentials\n\nSome 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.\n\n<Steps>\n  <Step title=\"Register an OAuth app with the server\">\n    Create an app through the server's developer portal and note your client ID and client secret.\n\n    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.\n  </Step>\n\n  <Step title=\"Add the server with your credentials\">\n    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.\n\n    <Tabs>\n      <Tab title=\"claude mcp add\">\n        Use `--client-id` to pass your app's client ID. The `--client-secret` flag prompts for the secret with masked input:\n\n        ```bash theme={null}\n        claude mcp add --transport http \\\n          --client-id your-client-id --client-secret --callback-port 8080 \\\n          my-server https://mcp.example.com/mcp\n        ```\n      </Tab>\n\n      <Tab title=\"claude mcp add-json\">\n        Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:\n\n        ```bash theme={null}\n        claude mcp add-json my-server \\\n          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' \\\n          --client-secret\n        ```\n      </Tab>\n\n      <Tab title=\"claude mcp add-json (callback port only)\">\n        Use `--callback-port` without a client ID to fix the port while using dynamic client registration:\n\n        ```bash theme={null}\n        claude mcp add-json my-server \\\n          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"callbackPort\":8080}}'\n        ```\n      </Tab>\n\n      <Tab title=\"CI / env var\">\n        Set the secret via environment variable to skip the interactive prompt:\n\n        ```bash theme={null}\n        MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \\\n          --client-id your-client-id --client-secret --callback-port 8080 \\\n          my-server https://mcp.example.com/mcp\n        ```\n      </Tab>\n    </Tabs>\n  </Step>\n\n  <Step title=\"Authenticate in Claude Code\">\n    Run `/mcp` in Claude Code and follow the browser login flow.\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config\n  * If the server uses a public OAuth client with no secret, use only `--client-id` without `--client-secret`\n  * `--callback-port` can be used with or without `--client-id`\n  * These flags only apply to HTTP and SSE transports. They have no effect on stdio servers\n  * Use `claude mcp get <name>` to verify that OAuth credentials are configured for a server\n</Tip>\n\n### Override OAuth metadata discovery\n\nPoint 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`.\n\nSet `authServerMetadataUrl` in the `oauth` object of your server's config in `.mcp.json`:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"my-server\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/mcp\",\n      \"oauth\": {\n        \"authServerMetadataUrl\": \"https://auth.example.com/.well-known/openid-configuration\"\n      }\n    }\n  }\n}\n```\n\nThe 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.\n\n### Restrict OAuth scopes\n\nSet `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.\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"slack\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.slack.com/mcp\",\n      \"oauth\": {\n        \"scopes\": \"channels:read chat:write search:read\"\n      }\n    }\n  }\n}\n```\n\n`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.\n\nAs 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.\n\nIf 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.\n\nIf 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.\n\n### Use dynamic headers for custom authentication\n\nIf 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.\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"internal-api\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.internal.example.com\",\n      \"headersHelper\": \"/opt/bin/get-mcp-auth-headers.sh\"\n    }\n  }\n}\n```\n\nThe command can also be inline:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"internal-api\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.internal.example.com\",\n      \"headersHelper\": \"echo '{\\\"Authorization\\\": \\\"Bearer '\\\"$(get-token)\\\"'\\\"}'\"\n    }\n  }\n}\n```\n\n**Requirements:**\n\n* The command must write a JSON object of string key-value pairs to stdout\n* The command runs in a shell with a 10-second timeout\n* Dynamic headers override any static `headers` with the same name\n\nThe 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.\n\nAs 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.\n\nClaude Code sets these environment variables when executing the helper:\n\n| Variable                      | Value                                                                                                        |\n| :---------------------------- | :----------------------------------------------------------------------------------------------------------- |\n| `CLAUDE_CODE_MCP_SERVER_NAME` | the name of the MCP server                                                                                   |\n| `CLAUDE_CODE_MCP_SERVER_URL`  | the URL of the MCP server                                                                                    |\n| `CLAUDE_PLUGIN_ROOT`          | the plugin's root directory. Set only when a [plugin](/en/plugins-reference#mcp-servers) provides the server |\n\nUse these to write a single helper script that serves multiple MCP servers.\n\nFor 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.\n\n<Note>\n  `headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.\n</Note>\n\n## Add MCP servers from JSON configuration\n\nIf you have a JSON configuration for an MCP server, you can add it directly:\n\n<Steps>\n  <Step title=\"Add an MCP server from JSON\">\n    ```bash theme={null}\n    # Basic syntax\n    claude mcp add-json <name> '<json>'\n\n    # Example: Adding an HTTP server with JSON configuration\n    claude mcp add-json weather-api '{\"type\":\"http\",\"url\":\"https://api.weather.com/mcp\",\"headers\":{\"Authorization\":\"Bearer token\"}}'\n\n    # Example: Adding a stdio server with JSON configuration\n    claude mcp add-json local-weather '{\"type\":\"stdio\",\"command\":\"/path/to/weather-cli\",\"args\":[\"--api-key\",\"abc123\"],\"env\":{\"CACHE_DIR\":\"/tmp\"}}'\n\n    # Example: Adding an HTTP server with pre-configured OAuth credentials\n    claude mcp add-json my-server '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' --client-secret\n    ```\n  </Step>\n\n  <Step title=\"Verify the server was added\">\n    ```bash theme={null}\n    claude mcp get weather-api\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Make sure the JSON is properly escaped in your shell\n  * The JSON must conform to the MCP server configuration schema\n  * You can use `--scope user` to add the server to your user configuration instead of the project-specific one\n</Tip>\n\n## Import MCP servers from Claude Desktop\n\nIf you've already configured MCP servers in Claude Desktop, you can import them:\n\n<Steps>\n  <Step title=\"Import servers from Claude Desktop\">\n    ```bash theme={null}\n    # Basic syntax \n    claude mcp add-from-claude-desktop \n    ```\n  </Step>\n\n  <Step title=\"Select which servers to import\">\n    After running the command, you'll see an interactive dialog that allows you to select which servers you want to import.\n  </Step>\n\n  <Step title=\"Verify the servers were imported\">\n    ```bash theme={null}\n    claude mcp list \n    ```\n  </Step>\n</Steps>\n\nServer 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.\n\n<Tip>\n  Tips:\n\n  * This feature only works on macOS and Windows Subsystem for Linux (WSL)\n  * It reads the Claude Desktop configuration file from its standard location on those platforms\n  * Use the `--scope user` flag to add servers to your user configuration\n  * 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\n  * If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)\n</Tip>\n\n## Use MCP servers from claude.ai\n\nIf 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:\n\n<Steps>\n  <Step title=\"Configure MCP servers in claude.ai\">\n    Add servers at [claude.ai/customize/connectors](https://claude.ai/customize/connectors). On Team and Enterprise plans, only admins can add servers.\n  </Step>\n\n  <Step title=\"Authenticate the MCP server\">\n    Complete any required authentication steps in claude.ai.\n  </Step>\n\n  <Step title=\"View and manage servers in Claude Code\">\n    In Claude Code, use the command:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Servers from claude.ai appear in the list with indicators showing they come from claude.ai.\n  </Step>\n</Steps>\n\nFrom 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.\n\nConnectors from claude.ai are fetched only when your active [authentication method](/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`.\n\nIf `/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.\n\nA server you've added in Claude Code takes [precedence](#scope-hierarchy-and-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.\n\nSome 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.\n\n### Disable claude.ai connectors\n\nTo disable claude.ai MCP servers in Claude Code, set [`disableClaudeAiConnectors`](/en/settings#available-settings) to `true` in any settings scope:\n\n```json theme={null}\n{\n  \"disableClaudeAiConnectors\": true\n}\n```\n\nThis 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.\n\nYou can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:\n\n```bash theme={null}\nENABLE_CLAUDEAI_MCP_SERVERS=false claude\n```\n\nTo block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](/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.\n\n<Note>\n  These client-side settings govern local Claude Code sessions. In [Claude Code on the web](/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.\n</Note>\n\n## Use Claude Code as an MCP server\n\nYou can use Claude Code itself as an MCP server that other applications can connect to:\n\n```bash theme={null}\n# Start Claude as a stdio MCP server\nclaude mcp serve\n```\n\nYou can use this in Claude Desktop by adding this configuration to claude\\_desktop\\_config.json:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"claude-code\": {\n      \"type\": \"stdio\",\n      \"command\": \"claude\",\n      \"args\": [\"mcp\", \"serve\"],\n      \"env\": {}\n    }\n  }\n}\n```\n\n<Warning>\n  **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.\n\n  To find the full path:\n\n  ```bash theme={null}\n  which claude\n  ```\n\n  Then use the full path in your configuration:\n\n  ```json theme={null}\n  {\n    \"mcpServers\": {\n      \"claude-code\": {\n        \"type\": \"stdio\",\n        \"command\": \"/full/path/to/claude\",\n        \"args\": [\"mcp\", \"serve\"],\n        \"env\": {}\n      }\n    }\n  }\n  ```\n\n  Without the correct executable path, you'll encounter errors like `spawn claude ENOENT`.\n</Warning>\n\n<Tip>\n  Tips:\n\n  * The server provides access to Claude's tools like View, Edit, LS, etc.\n  * In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.\n  * 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.\n</Tip>\n\n## MCP output limits and warnings\n\nWhen MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:\n\n* **Output warning threshold**: Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens\n* **Configurable limit**: you can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable\n* **Default limit**: the default maximum is 25,000 tokens\n* **Scope**: the environment variable applies to tools that don't declare their own limit. Tools that set [`anthropic/maxResultSizeChars`](#raise-the-limit-for-a-specific-tool) 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`\n\nTo increase the limit for tools that produce large outputs:\n\n```bash theme={null}\nexport MAX_MCP_OUTPUT_TOKENS=50000\nclaude\n```\n\nThis is particularly useful when working with MCP servers that:\n\n* Query large datasets or databases\n* Generate detailed reports or documentation\n* Process extensive log files or debugging information\n\n### Raise the limit for a specific tool\n\nIf 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.\n\nThis 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.\n\n```json theme={null}\n{\n  \"name\": \"get_schema\",\n  \"description\": \"Returns the full database schema\",\n  \"_meta\": {\n    \"anthropic/maxResultSizeChars\": 200000\n  }\n}\n```\n\nThe 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.\n\n<Warning>\n  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.\n</Warning>\n\n## Tool input schemas with a root-level combinator\n\nSome 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.\n\nAs 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:\n\n* `allOf`: properties from every branch are merged, and each branch's `required` list still applies\n* `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\n\nYour server receives whichever arguments Claude chose, so keep validating the combination server-side.\n\nWhen 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`.\n\n## Require approval for a specific tool\n\nIf 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.\n\nClaude Code shows that tool's permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](/en/permissions#permission-modes), and doesn't offer a \"don't ask again\" option for it. [Allow rules](/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.\n\nThe prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](/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](/en/agent-sdk/permissions) does receive these calls and can approve them, because the SDK host is expected to show them to a user.\n\nUse 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.\n\nThe following `tools/list` entry marks one tool as always requiring approval.\n\n```json theme={null}\n{\n  \"name\": \"grant_access\",\n  \"description\": \"Requests access to a protected resource\",\n  \"_meta\": {\n    \"anthropic/requiresUserInteraction\": true\n  }\n}\n```\n\nThe `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow.\n\nWhen a session is connected to [Remote Control](/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.\n\n## Respond to MCP elicitation requests\n\nMCP 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.\n\nServers can request input in two ways:\n\n* **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.\n* **URL mode**: Claude Code opens a browser URL for authentication or approval. Complete the flow in the browser, then confirm in the CLI.\n\nTo auto-respond to elicitation requests without showing a dialog, use the [`Elicitation` hook](/en/hooks#elicitation).\n\nIf 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.\n\n## Use MCP resources\n\nMCP servers can expose resources that you can reference using @ mentions, similar to how you reference files.\n\n### Reference MCP resources\n\n<Steps>\n  <Step title=\"List available resources\">\n    Type `@` in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu.\n  </Step>\n\n  <Step title=\"Reference a specific resource\">\n    Use the format `@server:protocol://resource/path` to reference a resource:\n\n    ```text theme={null}\n    Can you analyze @github:issue://123 and suggest a fix?\n    ```\n\n    ```text theme={null}\n    Please review the API documentation at @docs:file://api/authentication\n    ```\n  </Step>\n\n  <Step title=\"Multiple resource references\">\n    You can reference multiple resources in a single prompt:\n\n    ```text theme={null}\n    Compare @postgres:schema://users with @docs:file://database/user-model\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Resources are automatically fetched and included as attachments when referenced\n  * Resource paths are fuzzy-searchable in the @ mention autocomplete\n  * Claude Code automatically provides tools to list and read MCP resources when servers support them\n  * Resources can contain any type of content that the MCP server provides (text, JSON, structured data, etc.)\n</Tip>\n\n## Scale with MCP tool search\n\nTool 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.\n\n### How it works\n\nTool 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.\n\nIf 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](#configure-tool-search) for all options.\n\n### For MCP server authors\n\nIf 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](/en/skills) work.\n\nAdd clear, descriptive server instructions that explain:\n\n* What category of tasks your tools handle\n* When Claude should search for your tools\n* Key capabilities your server provides\n\nClaude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.\n\n### Configure tool search\n\nTool 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.\n\nTool 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.\n\nControl tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:\n\n| Value    | Behavior                                                                                                                                                                                                                                                                 |\n| :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| (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                                                                                                       |\n| `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 |\n| `auto`   | Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise                                                                                                                                                                      |\n| `auto:N` | Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%                                                                                                                                                                                |\n| `false`  | All MCP tools loaded upfront, no deferral                                                                                                                                                                                                                                |\n\n```bash theme={null}\n# Use a custom 5% threshold\nENABLE_TOOL_SEARCH=auto:5 claude\n\n# Disable tool search entirely\nENABLE_TOOL_SEARCH=false claude\n```\n\nOr set the value in your [settings.json `env` field](/en/settings#available-settings).\n\nYou can also disable the `ToolSearch` tool specifically:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\"ToolSearch\"]\n  }\n}\n```\n\n### Exempt a server from deferral\n\nIf 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.\n\nThe following `.mcp.json` entry exempts one HTTP server while leaving other servers deferred:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"core-tools\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/mcp\",\n      \"alwaysLoad\": true\n    }\n  }\n}\n```\n\nThe `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.\n\nSetting `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](/en/env-vars), since the tools must be present when the first prompt is built. Other servers continue to connect in the background.\n\n## Use MCP prompts as commands\n\nMCP servers can expose prompts that become available as commands in Claude Code.\n\n### Execute MCP prompts\n\n<Steps>\n  <Step title=\"Discover available prompts\">\n    Type `/` to see all available commands, including those from MCP servers. MCP prompts appear with the format `/mcp__servername__promptname`.\n  </Step>\n\n  <Step title=\"Execute a prompt without arguments\">\n    ```text theme={null}\n    /mcp__github__list_prs\n    ```\n  </Step>\n\n  <Step title=\"Execute a prompt with arguments\">\n    Many prompts accept arguments. Pass them space-separated after the command:\n\n    ```text theme={null}\n    /mcp__github__pr_review 456\n    ```\n\n    ```text theme={null}\n    /mcp__jira__create_issue \"Bug in login flow\" high\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * MCP prompts are dynamically discovered from connected servers\n  * Arguments are parsed based on the prompt's defined parameters\n  * Prompt results are injected directly into the conversation\n  * Server and prompt names are normalized, with spaces converted to underscores\n</Tip>\n\n## Managed MCP configuration\n\nFor organizations that need centralized control over which MCP servers users can connect to, see [Managed MCP configuration](/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.\n","durationMs":0,"url":"https://code.claude.com/docs/en/mcp.md"},"sourceToolAssistantUUID":"c789b8f7-f588-4f0f-a6f1-d6121efa5169","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"64dfd56d-cdb6-4039-99ca-04f1a74578ae","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dfyw2xAia38dXTLgz","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"Eo0DCpMBCA8YAipAh1OZvAzlBkm/37FHa4EIJwfmDN4A08lDomqb7ZMy4AD/oPR07el8xG3udznlf9dpNLaUMbJmMeh51GZK8lVbyzIZY2xhdWRlLWhhaWt1LTQtNS0yMDI1MTAwMTgAQgh0aGlua2luZ1okNGJkZDE1Y2MtNDcxZS00ZTU2LWJhMWEtM2QzZDViNGYwMTdjEgyDhRFwNoF+MKg45/0aDP2aKTM/XQ0Nx5GFjSIw+/zpVv5wcXnTcE64jhA89PH46xud5f8lEVxmYHoRIrRHT8ks/qn7zGo4KsldIQyuKqYBHWgK6eSrrLMXSOo7JZkRKhqrBBi9vnoS9Pdo6U2I7u5F52+zOHAjIX3R6BnhImd2UyKP7HD8Hcv1E+BAv4CYG9bNcu/JV9ce8x/FU/+b0ew4YoIz/7i8OjnoUVVCc/bWljNeAFLkufgPRGHIGHJMpwEtPUWmQJ7wiq2ahXEh5RmnE4kVmbP2JA/AyP/aHMSTffhHEX6eBUY+anRKhFhJJwH1wovqJBgB"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":6657,"cache_read_input_tokens":16169,"cache_creation":{"ephemeral_5m_input_tokens":6657,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3ddFiyi3ZSpxxdF4kA","attributionAgent":"claude-code-guide","type":"assistant","uuid":"8d648c44-c5ee-4027-a1c7-d887be18edd2","timestamp":"2026-07-11T09:38:04.960Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"8d648c44-c5ee-4027-a1c7-d887be18edd2","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dfyw2xAia38dXTLgz","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_01Junztknmnn246JuYdiAykU","name":"Read","input":{"file_path":"/Users/marcus.hinz/.config/ai-control/pools/private/projects/-Users-marcus-hinz-claude-projects-ai-control/f7704328-4eb4-4f0f-bf42-da68abab401d/tool-results/toolu_01TCqxYeBrnGYwN9gqBcUTV4.txt","limit":3000},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":6657,"cache_read_input_tokens":16169,"output_tokens":195,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":6657},"inference_geo":"not_available","iterations":[{"input_tokens":8,"output_tokens":195,"cache_read_input_tokens":16169,"cache_creation_input_tokens":6657,"cache_creation":{"ephemeral_5m_input_tokens":6657,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3ddFiyi3ZSpxxdF4kA","attributionAgent":"claude-code-guide","type":"assistant","uuid":"e201f257-7b9d-427c-810e-582ec111fe65","timestamp":"2026-07-11T09:38:06.123Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"e201f257-7b9d-427c-810e-582ec111fe65","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01Junztknmnn246JuYdiAykU","type":"tool_result","content":"1\t> ## Documentation Index\n2\t> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n3\t> Use this file to discover all available pages before exploring further.\n4\t\n5\t# Connect Claude Code to tools via MCP\n6\t\n7\t> Learn how to connect Claude Code to your tools with the Model Context Protocol.\n8\t\n9\tClaude 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.\n10\t\n11\tConnect 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.\n12\t\n13\tIf you're connecting your first server, start with the [MCP quickstart](/en/mcp-quickstart) for a step-by-step walkthrough. This page is the full reference.\n14\t\n15\t## What you can do with MCP\n16\t\n17\tWith MCP servers connected, you can ask Claude Code to:\n18\t\n19\t* **Implement features from issue trackers**: \"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.\"\n20\t* **Analyze monitoring data**: \"Check Sentry and Statsig to check the usage of the feature described in ENG-4521.\"\n21\t* **Query databases**: \"Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.\"\n22\t* **Integrate designs**: \"Update our standard email template based on the new Figma designs that were posted in Slack\"\n23\t* **Automate workflows**: \"Create Gmail drafts inviting these 10 users to a feedback session about the new feature.\"\n24\t* **React to external events**: an MCP server can also act as a [channel](/en/channels) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you're away.\n25\t\n26\t## Find and build MCP servers\n27\t\n28\tBrowse 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`.\n29\t\n30\t<Warning>\n31\t  Verify you trust each server before connecting it. Servers that fetch external content can expose you to [prompt injection risk](/en/security#protect-against-prompt-injection).\n32\t</Warning>\n33\t\n34\tTo 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.\n35\t\n36\tYou 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).\n37\t\n38\t<Steps>\n39\t  <Step title=\"Install the plugin\">\n40\t    In a Claude Code session, run:\n41\t\n42\t    ```\n43\t    /plugin install mcp-server-dev@claude-plugins-official\n44\t    ```\n45\t\n46\t    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.\n47\t  </Step>\n48\t\n49\t  <Step title=\"Run the build skill\">\n50\t    ```\n51\t    /mcp-server-dev:build-mcp-server\n52\t    ```\n53\t\n54\t    Claude asks about your use case and scaffolds a remote HTTP or local stdio server.\n55\t  </Step>\n56\t</Steps>\n57\t\n58\t## Installing MCP servers\n59\t\n60\tMCP servers can be configured in several ways depending on your needs:\n61\t\n62\t### Option 1: Add a remote HTTP server\n63\t\n64\tHTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.\n65\t\n66\t```bash theme={null}\n67\t# Basic syntax\n68\tclaude mcp add --transport http <name> <url>\n69\t\n70\t# Real example: Connect to Notion\n71\tclaude mcp add --transport http notion https://mcp.notion.com/mcp\n72\t\n73\t# Example with Bearer token\n74\tclaude mcp add --transport http secure-api https://api.example.com/mcp \\\n75\t  --header \"Authorization: Bearer your-token\"\n76\t```\n77\t\n78\tWhen 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.\n79\t\n80\tA 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`.\n81\t\n82\t### Option 2: Add a remote SSE server\n83\t\n84\t<Warning>\n85\t  The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.\n86\t</Warning>\n87\t\n88\t```bash theme={null}\n89\t# Basic syntax\n90\tclaude mcp add --transport sse <name> <url>\n91\t\n92\t# Real example: Connect to Asana\n93\tclaude mcp add --transport sse asana https://mcp.asana.com/sse\n94\t\n95\t# Example with authentication header\n96\tclaude mcp add --transport sse private-api https://api.company.com/sse \\\n97\t  --header \"X-API-Key: your-key-here\"\n98\t```\n99\t\n100\t### Option 3: Add a local stdio server\n101\t\n102\tStdio servers run as local processes on your machine. They're ideal for tools that need direct system access or custom scripts.\n103\t\n104\tClaude 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.\n105\t\n106\t`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](/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`.\n107\t\n108\tThis 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.\n109\t\n110\t```bash theme={null}\n111\t# Basic syntax\n112\tclaude mcp add [options] <name> -- <command> [args...]\n113\t\n114\t# Real example: Add Airtable server\n115\tclaude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \\\n116\t  -- npx -y airtable-mcp-server\n117\t```\n118\t\n119\t<Note>\n120\t  **Important: Separate server arguments with `--`**\n121\t\n122\t  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.\n123\t\n124\t  For example:\n125\t\n126\t  * `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`\n127\t  * `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\n128\t\n129\t  Without `--`, Claude Code would try to parse the server's flags, like `--port` above, as its own options.\n130\t\n131\t  `--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.\n132\t</Note>\n133\t\n134\t### Option 4: Add a remote WebSocket server\n135\t\n136\tWebSocket 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.\n137\t\n138\tConfigure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:\n139\t\n140\t```bash theme={null}\n141\tclaude mcp add-json events-server \\\n142\t  '{\"type\":\"ws\",\"url\":\"wss://mcp.example.com/socket\",\"headers\":{\"Authorization\":\"Bearer YOUR_TOKEN\"}}'\n143\t```\n144\t\n145\tThe `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`](#use-dynamic-headers-for-custom-authentication). The `claude mcp add --transport` flag doesn't accept `ws`.\n146\t\n147\t### Managing your servers\n148\t\n149\tOnce configured, you can manage your MCP servers with these commands:\n150\t\n151\t```bash theme={null}\n152\t# List all configured servers\n153\tclaude mcp list\n154\t\n155\t# Get details for a specific server\n156\tclaude mcp get github\n157\t\n158\t# Remove a server\n159\tclaude mcp remove github\n160\t\n161\t# (within Claude Code) Check server status\n162\t/mcp\n163\t```\n164\t\n165\tProject-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`.\n166\t\n167\tAs 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`](/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.\n168\t\n169\tApprovals from these sources still apply in an untrusted folder:\n170\t\n171\t* your user `~/.claude/settings.json`\n172\t* managed settings\n173\t* settings passed with `--settings`\n174\t* `.claude/settings.local.json`, as long as git doesn't track it\n175\t\n176\tA `disabledMcpjsonServers` entry in any settings file still rejects the server.\n177\t\n178\tThe `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools.\n179\t\n180\tIf your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With [tool search](#scale-with-mcp-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.\n181\t\n182\tSome 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.\n183\t\n184\t`Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app's preview pane](/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.\n185\t\n186\t### Dynamic tool updates\n187\t\n188\tClaude 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.\n189\t\n190\t### Automatic reconnection\n191\t\n192\tIf 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.\n193\t\n194\tThe 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.\n195\t\n196\tWhen 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](#scale-with-mcp-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.\n197\t\n198\tAs 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.\n199\t\n200\t### Push messages with channels\n201\t\n202\tAn 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](/en/channels) to use an officially supported channel, or [Channels reference](/en/channels-reference) to build your own.\n203\t\n204\t<Tip>\n205\t  Tips:\n206\t\n207\t  * Use the `-s` or `--scope` flag to specify where the configuration is stored:\n208\t    * `local` (default): available only to you in the current project. Older versions called this scope `project`\n209\t    * `project`: shared with everyone in the project via the `.mcp.json` file\n210\t    * `user`: available to you across all projects. Older versions called this scope `global`\n211\t  * Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)\n212\t  * The `--transport` and `--header` flags also accept `-t` and `-H` short forms\n213\t  * Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)\n214\t  * 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\n215\t  * 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`)\n216\t  * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication\n217\t</Tip>\n218\t\n219\tThe 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. {/* min-version: 2.1.162 */}Before v2.1.162, values below 1000 were floored to one second instead.\n220\t\n221\tA 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.\n222\t\n223\tFor HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum.\n224\t\n225\tA 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. {/* min-version: 2.1.203 */}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](#use-mcp-servers-from-claude-ai) servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout.\n226\t\n227\tSet the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](/en/env-vars) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.\n228\t\n229\t### Plugin-provided MCP servers\n230\t\n231\t[Plugins](/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.\n232\t\n233\t**How plugin MCP servers work**:\n234\t\n235\t* Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`\n236\t* When a plugin is enabled, its MCP servers start automatically\n237\t* Plugin MCP tools appear alongside manually configured MCP tools\n238\t* Plugin servers are managed through plugin installation, not `/mcp` commands\n239\t\n240\t**Example plugin MCP configuration**:\n241\t\n242\tIn `.mcp.json` at plugin root:\n243\t\n244\t```json theme={null}\n245\t{\n246\t  \"mcpServers\": {\n247\t    \"database-tools\": {\n248\t      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/db-server\",\n249\t      \"args\": [\"--config\", \"${CLAUDE_PLUGIN_ROOT}/config.json\"],\n250\t      \"env\": {\n251\t        \"DB_URL\": \"${DB_URL}\"\n252\t      }\n253\t    }\n254\t  }\n255\t}\n256\t```\n257\t\n258\tOr inline in `plugin.json`:\n259\t\n260\t```json theme={null}\n261\t{\n262\t  \"name\": \"my-plugin\",\n263\t  \"mcpServers\": {\n264\t    \"plugin-api\": {\n265\t      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/api-server\",\n266\t      \"args\": [\"--port\", \"8080\"]\n267\t    }\n268\t  }\n269\t}\n270\t```\n271\t\n272\t**Plugin MCP features**:\n273\t\n274\t* **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\n275\t* **Environment variables**: use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](/en/plugins-reference#persistent-data-directory) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root\n276\t* **User environment access**: access to the same environment variables as manually configured servers\n277\t* **Multiple transport types**: support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server\n278\t\n279\t**Viewing plugin MCP servers**:\n280\t\n281\t```bash theme={null}\n282\t# Within Claude Code, see all MCP servers including plugin ones\n283\t/mcp\n284\t```\n285\t\n286\tPlugin servers appear in the list with indicators showing they come from plugins.\n287\t\n288\t**Plugin MCP tool names**:\n289\t\n290\tTools 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:\n291\t\n292\t```\n293\tmcp__plugin_my-plugin_database-tools__query\n294\t```\n295\t\n296\tUse this full name when referencing the tool in [permission rules](/en/permissions), a skill's `allowed-tools` list, a [subagent's `tools` field](/en/sub-agents#available-tools), or a [hook matcher](/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.\n297\t\n298\tThe 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](/en/hooks#mcp-tool-hook-fields).\n299\t\n300\t**Benefits of plugin MCP servers**:\n301\t\n302\t* **Bundled distribution**: tools and servers packaged together\n303\t* **Automatic setup**: no manual MCP configuration needed\n304\t* **Team consistency**: everyone gets the same tools when the plugin is installed\n305\t\n306\tSee the [plugin components reference](/en/plugins-reference#mcp-servers) for details on bundling MCP servers with plugins.\n307\t\n308\t## MCP installation scopes\n309\t\n310\tMCP 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](#managed-mcp-configuration).\n311\t\n312\t| Scope                     | Loads in             | Shared with team         | Stored in                   |\n313\t| ------------------------- | -------------------- | ------------------------ | --------------------------- |\n314\t| [Local](#local-scope)     | Current project only | No                       | `~/.claude.json`            |\n315\t| [Project](#project-scope) | Current project only | Yes, via version control | `.mcp.json` in project root |\n316\t| [User](#user-scope)       | All your projects    | No                       | `~/.claude.json`            |\n317\t\n318\t### Local scope\n319\t\n320\tLocal 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.\n321\t\n322\t<Note>\n323\t  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](/en/settings#settings-files) for details on settings file locations.\n324\t</Note>\n325\t\n326\t```bash theme={null}\n327\t# Add a local-scoped server (default)\n328\tclaude mcp add --transport http stripe https://mcp.stripe.com\n329\t\n330\t# Explicitly specify local scope\n331\tclaude mcp add --transport http stripe --scope local https://mcp.stripe.com\n332\t```\n333\t\n334\tThe 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`:\n335\t\n336\t```json theme={null}\n337\t{\n338\t  \"projects\": {\n339\t    \"/path/to/your/project\": {\n340\t      \"mcpServers\": {\n341\t        \"stripe\": {\n342\t          \"type\": \"http\",\n343\t          \"url\": \"https://mcp.stripe.com\"\n344\t        }\n345\t      }\n346\t    }\n347\t  }\n348\t}\n349\t```\n350\t\n351\t### Project scope\n352\t\n353\tProject-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.\n354\t\n355\t```bash theme={null}\n356\t# Add a project-scoped server\n357\tclaude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp\n358\t```\n359\t\n360\tThe resulting `.mcp.json` file follows a standardized format:\n361\t\n362\t```json theme={null}\n363\t{\n364\t  \"mcpServers\": {\n365\t    \"shared-server\": {\n366\t      \"command\": \"/path/to/server\",\n367\t      \"args\": [],\n368\t      \"env\": {}\n369\t    }\n370\t  }\n371\t}\n372\t```\n373\t\n374\tFor 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.\n375\t\n376\t### User scope\n377\t\n378\tUser-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.\n379\t\n380\t```bash theme={null}\n381\t# Add a user server\n382\tclaude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic\n383\t```\n384\t\n385\t### Scope hierarchy and precedence\n386\t\n387\tWhen 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.\n388\t\n389\t1. Local scope\n390\t2. Project scope\n391\t3. User scope\n392\t4. [Plugin-provided servers](/en/plugins)\n393\t5. [claude.ai connectors](#use-mcp-servers-from-claude-ai)\n394\t\n395\tThe 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.\n396\t\n397\t### Environment variable expansion in `.mcp.json`\n398\t\n399\tClaude 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.\n400\t\n401\t**Supported syntax:**\n402\t\n403\t* `${VAR}`: expands to the value of environment variable `VAR`\n404\t* `${VAR:-default}`: expands to `VAR` if set, otherwise uses `default`\n405\t\n406\t**Expansion locations:**\n407\tEnvironment variables can be expanded in:\n408\t\n409\t* `command`: the server executable path\n410\t* `args`: command-line arguments\n411\t* `env`: environment variables passed to the server\n412\t* `url`: for HTTP server types\n413\t* `headers`: for HTTP server authentication\n414\t\n415\t**Example with variable expansion:**\n416\t\n417\t```json theme={null}\n418\t{\n419\t  \"mcpServers\": {\n420\t    \"api-server\": {\n421\t      \"type\": \"http\",\n422\t      \"url\": \"${API_BASE_URL:-https://api.example.com}/mcp\",\n423\t      \"headers\": {\n424\t        \"Authorization\": \"Bearer ${API_KEY}\"\n425\t      }\n426\t    }\n427\t  }\n428\t}\n429\t```\n430\t\n431\tIf a required environment variable isn't set and has no default value, Claude Code fails to parse the config.\n432\t\n433\t## Practical examples\n434\t\n435\t### Example: Monitor errors with Sentry\n436\t\n437\t```bash theme={null}\n438\tclaude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n439\t```\n440\t\n441\tAuthenticate with your Sentry account:\n442\t\n443\t```text theme={null}\n444\t/mcp\n445\t```\n446\t\n447\tThen debug production issues:\n448\t\n449\t```text theme={null}\n450\tWhat are the most common errors in the last 24 hours?\n451\t```\n452\t\n453\t```text theme={null}\n454\tShow me the stack trace for error ID abc123\n455\t```\n456\t\n457\t```text theme={null}\n458\tWhich deployment introduced these new errors?\n459\t```\n460\t\n461\t### Example: Connect to GitHub for code reviews\n462\t\n463\tGitHub'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:\n464\t\n465\t```bash theme={null}\n466\tclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ \\\n467\t  --header \"Authorization: Bearer YOUR_GITHUB_PAT\"\n468\t```\n469\t\n470\tThen work with GitHub:\n471\t\n472\t```text theme={null}\n473\tReview PR #456 and suggest improvements\n474\t```\n475\t\n476\t```text theme={null}\n477\tCreate a new issue for the bug we just found\n478\t```\n479\t\n480\t```text theme={null}\n481\tShow me all open PRs assigned to me\n482\t```\n483\t\n484\t### Example: Query your PostgreSQL database\n485\t\n486\t```bash theme={null}\n487\tclaude mcp add --transport stdio db -- npx -y @bytebase/dbhub \\\n488\t  --dsn \"postgresql://readonly:pass@prod.db.com:5432/analytics\"\n489\t```\n490\t\n491\tThen query your database naturally:\n492\t\n493\t```text theme={null}\n494\tWhat's our total revenue this month?\n495\t```\n496\t\n497\t```text theme={null}\n498\tShow me the schema for the orders table\n499\t```\n500\t\n501\t```text theme={null}\n502\tFind customers who haven't made a purchase in 90 days\n503\t```\n504\t\n505\t## Authenticate with remote MCP servers\n506\t\n507\tMany cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections.\n508\t\n509\tClaude 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.\n510\t\n511\tAs 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.\n512\t\n513\tA custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.\n514\t\n515\tAs 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.\n516\t\n517\tIn 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](#scale-with-mcp-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>`.\n518\t\n519\tIf 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.\n520\t\n521\t<Steps>\n522\t  <Step title=\"Add the server that requires authentication\">\n523\t    For example:\n524\t\n525\t    ```bash theme={null}\n526\t    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n527\t    ```\n528\t  </Step>\n529\t\n530\t  <Step title=\"Use the /mcp command within Claude Code\">\n531\t    In Claude Code, use the command:\n532\t\n533\t    ```text theme={null}\n534\t    /mcp\n535\t    ```\n536\t\n537\t    Then follow the steps in your browser to log in.\n538\t  </Step>\n539\t</Steps>\n540\t\n541\t<Tip>\n542\t  Tips:\n543\t\n544\t  * Authentication tokens are stored securely and refreshed automatically\n545\t  * Use \"Clear authentication\" in the `/mcp` menu to revoke access\n546\t  * If your browser doesn't open automatically, copy the provided URL and open it manually\n547\t  * 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\n548\t  * OAuth authentication works with HTTP servers\n549\t</Tip>\n550\t\n551\t### Authenticate from the command line\n552\t\n553\tFrom 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.\n554\t\n555\t```bash theme={null}\n556\tclaude mcp login sentry\n557\t```\n558\t\n559\tTo clear stored credentials later, run `claude mcp logout <name>`.\n560\t\n561\tAs 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.\n562\t\n563\t```bash theme={null}\n564\tclaude mcp login sentry --no-browser\n565\t```\n566\t\n567\t### Use a fixed OAuth callback port\n568\t\n569\tSome 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`.\n570\t\n571\tYou can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).\n572\t\n573\t```bash theme={null}\n574\t# Fixed callback port with dynamic client registration\n575\tclaude mcp add --transport http \\\n576\t  --callback-port 8080 \\\n577\t  my-server https://mcp.example.com/mcp\n578\t```\n579\t\n580\t### Use pre-configured OAuth credentials\n581\t\n582\tSome 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.\n583\t\n584\t<Steps>\n585\t  <Step title=\"Register an OAuth app with the server\">\n586\t    Create an app through the server's developer portal and note your client ID and client secret.\n587\t\n588\t    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.\n589\t  </Step>\n590\t\n591\t  <Step title=\"Add the server with your credentials\">\n592\t    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.\n593\t\n594\t    <Tabs>\n595\t      <Tab title=\"claude mcp add\">\n596\t        Use `--client-id` to pass your app's client ID. The `--client-secret` flag prompts for the secret with masked input:\n597\t\n598\t        ```bash theme={null}\n599\t        claude mcp add --transport http \\\n600\t          --client-id your-client-id --client-secret --callback-port 8080 \\\n601\t          my-server https://mcp.example.com/mcp\n602\t        ```\n603\t      </Tab>\n604\t\n605\t      <Tab title=\"claude mcp add-json\">\n606\t        Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:\n607\t\n608\t        ```bash theme={null}\n609\t        claude mcp add-json my-server \\\n610\t          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' \\\n611\t          --client-secret\n612\t        ```\n613\t      </Tab>\n614\t\n615\t      <Tab title=\"claude mcp add-json (callback port only)\">\n616\t        Use `--callback-port` without a client ID to fix the port while using dynamic client registration:\n617\t\n618\t        ```bash theme={null}\n619\t        claude mcp add-json my-server \\\n620\t          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"callbackPort\":8080}}'\n621\t        ```\n622\t      </Tab>\n623\t\n624\t      <Tab title=\"CI / env var\">\n625\t        Set the secret via environment variable to skip the interactive prompt:\n626\t\n627\t        ```bash theme={null}\n628\t        MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \\\n629\t          --client-id your-client-id --client-secret --callback-port 8080 \\\n630\t          my-server https://mcp.example.com/mcp\n631\t        ```\n632\t      </Tab>\n633\t    </Tabs>\n634\t  </Step>\n635\t\n636\t  <Step title=\"Authenticate in Claude Code\">\n637\t    Run `/mcp` in Claude Code and follow the browser login flow.\n638\t  </Step>\n639\t</Steps>\n640\t\n641\t<Tip>\n642\t  Tips:\n643\t\n644\t  * The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config\n645\t  * If the server uses a public OAuth client with no secret, use only `--client-id` without `--client-secret`\n646\t  * `--callback-port` can be used with or without `--client-id`\n647\t  * These flags only apply to HTTP and SSE transports. They have no effect on stdio servers\n648\t  * Use `claude mcp get <name>` to verify that OAuth credentials are configured for a server\n649\t</Tip>\n650\t\n651\t### Override OAuth metadata discovery\n652\t\n653\tPoint 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`.\n654\t\n655\tSet `authServerMetadataUrl` in the `oauth` object of your server's config in `.mcp.json`:\n656\t\n657\t```json theme={null}\n658\t{\n659\t  \"mcpServers\": {\n660\t    \"my-server\": {\n661\t      \"type\": \"http\",\n662\t      \"url\": \"https://mcp.example.com/mcp\",\n663\t      \"oauth\": {\n664\t        \"authServerMetadataUrl\": \"https://auth.example.com/.well-known/openid-configuration\"\n665\t      }\n666\t    }\n667\t  }\n668\t}\n669\t```\n670\t\n671\tThe 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.\n672\t\n673\t### Restrict OAuth scopes\n674\t\n675\tSet `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.\n676\t\n677\t```json theme={null}\n678\t{\n679\t  \"mcpServers\": {\n680\t    \"slack\": {\n681\t      \"type\": \"http\",\n682\t      \"url\": \"https://mcp.slack.com/mcp\",\n683\t      \"oauth\": {\n684\t        \"scopes\": \"channels:read chat:write search:read\"\n685\t      }\n686\t    }\n687\t  }\n688\t}\n689\t```\n690\t\n691\t`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.\n692\t\n693\tAs 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.\n694\t\n695\tIf 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.\n696\t\n697\tIf 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.\n698\t\n699\t### Use dynamic headers for custom authentication\n700\t\n701\tIf 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.\n702\t\n703\t```json theme={null}\n704\t{\n705\t  \"mcpServers\": {\n706\t    \"internal-api\": {\n707\t      \"type\": \"http\",\n708\t      \"url\": \"https://mcp.internal.example.com\",\n709\t      \"headersHelper\": \"/opt/bin/get-mcp-auth-headers.sh\"\n710\t    }\n711\t  }\n712\t}\n713\t```\n714\t\n715\tThe command can also be inline:\n716\t\n717\t```json theme={null}\n718\t{\n719\t  \"mcpServers\": {\n720\t    \"internal-api\": {\n721\t      \"type\": \"http\",\n722\t      \"url\": \"https://mcp.internal.example.com\",\n723\t      \"headersHelper\": \"echo '{\\\"Authorization\\\": \\\"Bearer '\\\"$(get-token)\\\"'\\\"}'\"\n724\t    }\n725\t  }\n726\t}\n727\t```\n728\t\n729\t**Requirements:**\n730\t\n731\t* The command must write a JSON object of string key-value pairs to stdout\n732\t* The command runs in a shell with a 10-second timeout\n733\t* Dynamic headers override any static `headers` with the same name\n734\t\n735\tThe 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.\n736\t\n737\tAs 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.\n738\t\n739\tClaude Code sets these environment variables when executing the helper:\n740\t\n741\t| Variable                      | Value                                                                                                        |\n742\t| :---------------------------- | :----------------------------------------------------------------------------------------------------------- |\n743\t| `CLAUDE_CODE_MCP_SERVER_NAME` | the name of the MCP server                                                                                   |\n744\t| `CLAUDE_CODE_MCP_SERVER_URL`  | the URL of the MCP server                                                                                    |\n745\t| `CLAUDE_PLUGIN_ROOT`          | the plugin's root directory. Set only when a [plugin](/en/plugins-reference#mcp-servers) provides the server |\n746\t\n747\tUse these to write a single helper script that serves multiple MCP servers.\n748\t\n749\tFor 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.\n750\t\n751\t<Note>\n752\t  `headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.\n753\t</Note>\n754\t\n755\t## Add MCP servers from JSON configuration\n756\t\n757\tIf you have a JSON configuration for an MCP server, you can add it directly:\n758\t\n759\t<Steps>\n760\t  <Step title=\"Add an MCP server from JSON\">\n761\t    ```bash theme={null}\n762\t    # Basic syntax\n763\t    claude mcp add-json <name> '<json>'\n764\t\n765\t    # Example: Adding an HTTP server with JSON configuration\n766\t    claude mcp add-json weather-api '{\"type\":\"http\",\"url\":\"https://api.weather.com/mcp\",\"headers\":{\"Authorization\":\"Bearer token\"}}'\n767\t\n768\t    # Example: Adding a stdio server with JSON configuration\n769\t    claude mcp add-json local-weather '{\"type\":\"stdio\",\"command\":\"/path/to/weather-cli\",\"args\":[\"--api-key\",\"abc123\"],\"env\":{\"CACHE_DIR\":\"/tmp\"}}'\n770\t\n771\t    # Example: Adding an HTTP server with pre-configured OAuth credentials\n772\t    claude mcp add-json my-server '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' --client-secret\n773\t    ```\n774\t  </Step>\n775\t\n776\t  <Step title=\"Verify the server was added\">\n777\t    ```bash theme={null}\n778\t    claude mcp get weather-api\n779\t    ```\n780\t  </Step>\n781\t</Steps>\n782\t\n783\t<Tip>\n784\t  Tips:\n785\t\n786\t  * Make sure the JSON is properly escaped in your shell\n787\t  * The JSON must conform to the MCP server configuration schema\n788\t  * You can use `--scope user` to add the server to your user configuration instead of the project-specific one\n789\t</Tip>\n790\t\n791\t## Import MCP servers from Claude Desktop\n792\t\n793\tIf you've already configured MCP servers in Claude Desktop, you can import them:\n794\t\n795\t<Steps>\n796\t  <Step title=\"Import servers from Claude Desktop\">\n797\t    ```bash theme={null}\n798\t    # Basic syntax \n799\t    claude mcp add-from-claude-desktop \n800\t    ```\n801\t  </Step>\n802\t\n803\t  <Step title=\"Select which servers to import\">\n804\t    After running the command, you'll see an interactive dialog that allows you to select which servers you want to import.\n805\t  </Step>\n806\t\n807\t  <Step title=\"Verify the servers were imported\">\n808\t    ```bash theme={null}\n809\t    claude mcp list \n810\t    ```\n811\t  </Step>\n812\t</Steps>\n813\t\n814\tServer 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.\n815\t\n816\t<Tip>\n817\t  Tips:\n818\t\n819\t  * This feature only works on macOS and Windows Subsystem for Linux (WSL)\n820\t  * It reads the Claude Desktop configuration file from its standard location on those platforms\n821\t  * Use the `--scope user` flag to add servers to your user configuration\n822\t  * 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\n823\t  * If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)\n824\t</Tip>\n825\t\n826\t## Use MCP servers from claude.ai\n827\t\n828\tIf 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:\n829\t\n830\t<Steps>\n831\t  <Step title=\"Configure MCP servers in claude.ai\">\n832\t    Add servers at [claude.ai/customize/connectors](https://claude.ai/customize/connectors). On Team and Enterprise plans, only admins can add servers.\n833\t  </Step>\n834\t\n835\t  <Step title=\"Authenticate the MCP server\">\n836\t    Complete any required authentication steps in claude.ai.\n837\t  </Step>\n838\t\n839\t  <Step title=\"View and manage servers in Claude Code\">\n840\t    In Claude Code, use the command:\n841\t\n842\t    ```text theme={null}\n843\t    /mcp\n844\t    ```\n845\t\n846\t    Servers from claude.ai appear in the list with indicators showing they come from claude.ai.\n847\t  </Step>\n848\t</Steps>\n849\t\n850\tFrom 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.\n851\t\n852\tConnectors from claude.ai are fetched only when your active [authentication method](/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`.\n853\t\n854\tIf `/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.\n855\t\n856\tA server you've added in Claude Code takes [precedence](#scope-hierarchy-and-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.\n857\t\n858\tSome 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.\n859\t\n860\t### Disable claude.ai connectors\n861\t\n862\tTo disable claude.ai MCP servers in Claude Code, set [`disableClaudeAiConnectors`](/en/settings#available-settings) to `true` in any settings scope:\n863\t\n864\t```json theme={null}\n865\t{\n866\t  \"disableClaudeAiConnectors\": true\n867\t}\n868\t```\n869\t\n870\tThis 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.\n871\t\n872\tYou can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:\n873\t\n874\t```bash theme={null}\n875\tENABLE_CLAUDEAI_MCP_SERVERS=false claude\n876\t```\n877\t\n878\tTo block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](/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.\n879\t\n880\t<Note>\n881\t  These client-side settings govern local Claude Code sessions. In [Claude Code on the web](/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.\n882\t</Note>\n883\t\n884\t## Use Claude Code as an MCP server\n885\t\n886\tYou can use Claude Code itself as an MCP server that other applications can connect to:\n887\t\n888\t```bash theme={null}\n889\t# Start Claude as a stdio MCP server\n890\tclaude mcp serve\n891\t```\n892\t\n893\tYou can use this in Claude Desktop by adding this configuration to claude\\_desktop\\_config.json:\n894\t\n895\t```json theme={null}\n896\t{\n897\t  \"mcpServers\": {\n898\t    \"claude-code\": {\n899\t      \"type\": \"stdio\",\n900\t      \"command\": \"claude\",\n901\t      \"args\": [\"mcp\", \"serve\"],\n902\t      \"env\": {}\n903\t    }\n904\t  }\n905\t}\n906\t```\n907\t\n908\t<Warning>\n909\t  **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.\n910\t\n911\t  To find the full path:\n912\t\n913\t  ```bash theme={null}\n914\t  which claude\n915\t  ```\n916\t\n917\t  Then use the full path in your configuration:\n918\t\n919\t  ```json theme={null}\n920\t  {\n921\t    \"mcpServers\": {\n922\t      \"claude-code\": {\n923\t        \"type\": \"stdio\",\n924\t        \"command\": \"/full/path/to/claude\",\n925\t        \"args\": [\"mcp\", \"serve\"],\n926\t        \"env\": {}\n927\t      }\n928\t    }\n929\t  }\n930\t  ```\n931\t\n932\t  Without the correct executable path, you'll encounter errors like `spawn claude ENOENT`.\n933\t</Warning>\n934\t\n935\t<Tip>\n936\t  Tips:\n937\t\n938\t  * The server provides access to Claude's tools like View, Edit, LS, etc.\n939\t  * In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.\n940\t  * 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.\n941\t</Tip>\n942\t\n943\t## MCP output limits and warnings\n944\t\n945\tWhen MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:\n946\t\n947\t* **Output warning threshold**: Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens\n948\t* **Configurable limit**: you can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable\n949\t* **Default limit**: the default maximum is 25,000 tokens\n950\t* **Scope**: the environment variable applies to tools that don't declare their own limit. Tools that set [`anthropic/maxResultSizeChars`](#raise-the-limit-for-a-specific-tool) 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`\n951\t\n952\tTo increase the limit for tools that produce large outputs:\n953\t\n954\t```bash theme={null}\n955\texport MAX_MCP_OUTPUT_TOKENS=50000\n956\tclaude\n957\t```\n958\t\n959\tThis is particularly useful when working with MCP servers that:\n960\t\n961\t* Query large datasets or databases\n962\t* Generate detailed reports or documentation\n963\t* Process extensive log files or debugging information\n964\t\n965\t### Raise the limit for a specific tool\n966\t\n967\tIf 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.\n968\t\n969\tThis 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.\n970\t\n971\t```json theme={null}\n972\t{\n973\t  \"name\": \"get_schema\",\n974\t  \"description\": \"Returns the full database schema\",\n975\t  \"_meta\": {\n976\t    \"anthropic/maxResultSizeChars\": 200000\n977\t  }\n978\t}\n979\t```\n980\t\n981\tThe 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.\n982\t\n983\t<Warning>\n984\t  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.\n985\t</Warning>\n986\t\n987\t## Tool input schemas with a root-level combinator\n988\t\n989\tSome 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.\n990\t\n991\tAs 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:\n992\t\n993\t* `allOf`: properties from every branch are merged, and each branch's `required` list still applies\n994\t* `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\n995\t\n996\tYour server receives whichever arguments Claude chose, so keep validating the combination server-side.\n997\t\n998\tWhen 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`.\n999\t\n1000\t## Require approval for a specific tool\n1001\t\n1002\tIf 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.\n1003\t\n1004\tClaude Code shows that tool's permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](/en/permissions#permission-modes), and doesn't offer a \"don't ask again\" option for it. [Allow rules](/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.\n1005\t\n1006\tThe prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](/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](/en/agent-sdk/permissions) does receive these calls and can approve them, because the SDK host is expected to show them to a user.\n1007\t\n1008\tUse 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.\n1009\t\n1010\tThe following `tools/list` entry marks one tool as always requiring approval.\n1011\t\n1012\t```json theme={null}\n1013\t{\n1014\t  \"name\": \"grant_access\",\n1015\t  \"description\": \"Requests access to a protected resource\",\n1016\t  \"_meta\": {\n1017\t    \"anthropic/requiresUserInteraction\": true\n1018\t  }\n1019\t}\n1020\t```\n1021\t\n1022\tThe `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow.\n1023\t\n1024\tWhen a session is connected to [Remote Control](/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.\n1025\t\n1026\t## Respond to MCP elicitation requests\n1027\t\n1028\tMCP 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.\n1029\t\n1030\tServers can request input in two ways:\n1031\t\n1032\t* **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.\n1033\t* **URL mode**: Claude Code opens a browser URL for authentication or approval. Complete the flow in the browser, then confirm in the CLI.\n1034\t\n1035\tTo auto-respond to elicitation requests without showing a dialog, use the [`Elicitation` hook](/en/hooks#elicitation).\n1036\t\n1037\tIf 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.\n1038\t\n1039\t## Use MCP resources\n1040\t\n1041\tMCP servers can expose resources that you can reference using @ mentions, similar to how you reference files.\n1042\t\n1043\t### Reference MCP resources\n1044\t\n1045\t<Steps>\n1046\t  <Step title=\"List available resources\">\n1047\t    Type `@` in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu.\n1048\t  </Step>\n1049\t\n1050\t  <Step title=\"Reference a specific resource\">\n1051\t    Use the format `@server:protocol://resource/path` to reference a resource:\n1052\t\n1053\t    ```text theme={null}\n1054\t    Can you analyze @github:issue://123 and suggest a fix?\n1055\t    ```\n1056\t\n1057\t    ```text theme={null}\n1058\t    Please review the API documentation at @docs:file://api/authentication\n1059\t    ```\n1060\t  </Step>\n1061\t\n1062\t  <Step title=\"Multiple resource references\">\n1063\t    You can reference multiple resources in a single prompt:\n1064\t\n1065\t    ```text theme={null}\n1066\t    Compare @postgres:schema://users with @docs:file://database/user-model\n1067\t    ```\n1068\t  </Step>\n1069\t</Steps>\n1070\t\n1071\t<Tip>\n1072\t  Tips:\n1073\t\n1074\t  * Resources are automatically fetched and included as attachments when referenced\n1075\t  * Resource paths are fuzzy-searchable in the @ mention autocomplete\n1076\t  * Claude Code automatically provides tools to list and read MCP resources when servers support them\n1077\t  * Resources can contain any type of content that the MCP server provides (text, JSON, structured data, etc.)\n1078\t</Tip>\n1079\t\n1080\t## Scale with MCP tool search\n1081\t\n1082\tTool 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.\n1083\t\n1084\t### How it works\n1085\t\n1086\tTool 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.\n1087\t\n1088\tIf 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](#configure-tool-search) for all options.\n1089\t\n1090\t### For MCP server authors\n1091\t\n1092\tIf 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](/en/skills) work.\n1093\t\n1094\tAdd clear, descriptive server instructions that explain:\n1095\t\n1096\t* What category of tasks your tools handle\n1097\t* When Claude should search for your tools\n1098\t* Key capabilities your server provides\n1099\t\n1100\tClaude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.\n1101\t\n1102\t### Configure tool search\n1103\t\n1104\tTool 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.\n1105\t\n1106\tTool 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.\n1107\t\n1108\tControl tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:\n1109\t\n1110\t| Value    | Behavior                                                                                                                                                                                                                                                                 |\n1111\t| :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n1112\t| (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                                                                                                       |\n1113\t| `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 |\n1114\t| `auto`   | Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise                                                                                                                                                                      |\n1115\t| `auto:N` | Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%                                                                                                                                                                                |\n1116\t| `false`  | All MCP tools loaded upfront, no deferral                                                                                                                                                                                                                                |\n1117\t\n1118\t```bash theme={null}\n1119\t# Use a custom 5% threshold\n1120\tENABLE_TOOL_SEARCH=auto:5 claude\n1121\t\n1122\t# Disable tool search entirely\n1123\tENABLE_TOOL_SEARCH=false claude\n1124\t```\n1125\t\n1126\tOr set the value in your [settings.json `env` field](/en/settings#available-settings).\n1127\t\n1128\tYou can also disable the `ToolSearch` tool specifically:\n1129\t\n1130\t```json theme={null}\n1131\t{\n1132\t  \"permissions\": {\n1133\t    \"deny\": [\"ToolSearch\"]\n1134\t  }\n1135\t}\n1136\t```\n1137\t\n1138\t### Exempt a server from deferral\n1139\t\n1140\tIf 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.\n1141\t\n1142\tThe following `.mcp.json` entry exempts one HTTP server while leaving other servers deferred:\n1143\t\n1144\t```json theme={null}\n1145\t{\n1146\t  \"mcpServers\": {\n1147\t    \"core-tools\": {\n1148\t      \"type\": \"http\",\n1149\t      \"url\": \"https://mcp.example.com/mcp\",\n1150\t      \"alwaysLoad\": true\n1151\t    }\n1152\t  }\n1153\t}\n1154\t```\n1155\t\n1156\tThe `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.\n1157\t\n1158\tSetting `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](/en/env-vars), since the tools must be present when the first prompt is built. Other servers continue to connect in the background.\n1159\t\n1160\t## Use MCP prompts as commands\n1161\t\n1162\tMCP servers can expose prompts that become available as commands in Claude Code.\n1163\t\n1164\t### Execute MCP prompts\n1165\t\n1166\t<Steps>\n1167\t  <Step title=\"Discover available prompts\">\n1168\t    Type `/` to see all available commands, including those from MCP servers. MCP prompts appear with the format `/mcp__servername__promptname`.\n1169\t  </Step>\n1170\t\n1171\t  <Step title=\"Execute a prompt without arguments\">\n1172\t    ```text theme={null}\n1173\t    /mcp__github__list_prs\n1174\t    ```\n1175\t  </Step>\n1176\t\n1177\t  <Step title=\"Execute a prompt with arguments\">\n1178\t    Many prompts accept arguments. Pass them space-separated after the command:\n1179\t\n1180\t    ```text theme={null}\n1181\t    /mcp__github__pr_review 456\n1182\t    ```\n1183\t\n1184\t    ```text theme={null}\n1185\t    /mcp__jira__create_issue \"Bug in login flow\" high\n1186\t    ```\n1187\t  </Step>\n1188\t</Steps>\n1189\t\n1190\t<Tip>\n1191\t  Tips:\n1192\t\n1193\t  * MCP prompts are dynamically discovered from connected servers\n1194\t  * Arguments are parsed based on the prompt's defined parameters\n1195\t  * Prompt results are injected directly into the conversation\n1196\t  * Server and prompt names are normalized, with spaces converted to underscores\n1197\t</Tip>\n1198\t\n1199\t## Managed MCP configuration\n1200\t\n1201\tFor organizations that need centralized control over which MCP servers users can connect to, see [Managed MCP configuration](/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.\n1202\t"}]},"uuid":"28954718-e1f4-4f5e-8ea8-3934b25c5706","timestamp":"2026-07-11T09:38:06.359Z","toolUseResult":{"type":"text","file":{"filePath":"/Users/marcus.hinz/.config/ai-control/pools/private/projects/-Users-marcus-hinz-claude-projects-ai-control/f7704328-4eb4-4f0f-bf42-da68abab401d/tool-results/toolu_01TCqxYeBrnGYwN9gqBcUTV4.txt","content":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Connect Claude Code to tools via MCP\n\n> Learn how to connect Claude Code to your tools with the Model Context Protocol.\n\nClaude 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.\n\nConnect 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.\n\nIf you're connecting your first server, start with the [MCP quickstart](/en/mcp-quickstart) for a step-by-step walkthrough. This page is the full reference.\n\n## What you can do with MCP\n\nWith MCP servers connected, you can ask Claude Code to:\n\n* **Implement features from issue trackers**: \"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub.\"\n* **Analyze monitoring data**: \"Check Sentry and Statsig to check the usage of the feature described in ENG-4521.\"\n* **Query databases**: \"Find emails of 10 random users who used feature ENG-4521, based on our PostgreSQL database.\"\n* **Integrate designs**: \"Update our standard email template based on the new Figma designs that were posted in Slack\"\n* **Automate workflows**: \"Create Gmail drafts inviting these 10 users to a feedback session about the new feature.\"\n* **React to external events**: an MCP server can also act as a [channel](/en/channels) that pushes messages into your session, so Claude reacts to Telegram messages, Discord chats, or webhook events while you're away.\n\n## Find and build MCP servers\n\nBrowse 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`.\n\n<Warning>\n  Verify you trust each server before connecting it. Servers that fetch external content can expose you to [prompt injection risk](/en/security#protect-against-prompt-injection).\n</Warning>\n\nTo 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.\n\nYou 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).\n\n<Steps>\n  <Step title=\"Install the plugin\">\n    In a Claude Code session, run:\n\n    ```\n    /plugin install mcp-server-dev@claude-plugins-official\n    ```\n\n    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.\n  </Step>\n\n  <Step title=\"Run the build skill\">\n    ```\n    /mcp-server-dev:build-mcp-server\n    ```\n\n    Claude asks about your use case and scaffolds a remote HTTP or local stdio server.\n  </Step>\n</Steps>\n\n## Installing MCP servers\n\nMCP servers can be configured in several ways depending on your needs:\n\n### Option 1: Add a remote HTTP server\n\nHTTP servers are the recommended option for connecting to remote MCP servers. This is the most widely supported transport for cloud-based services.\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add --transport http <name> <url>\n\n# Real example: Connect to Notion\nclaude mcp add --transport http notion https://mcp.notion.com/mcp\n\n# Example with Bearer token\nclaude mcp add --transport http secure-api https://api.example.com/mcp \\\n  --header \"Authorization: Bearer your-token\"\n```\n\nWhen 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.\n\nA 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`.\n\n### Option 2: Add a remote SSE server\n\n<Warning>\n  The SSE (Server-Sent Events) transport is deprecated. Use HTTP servers instead, where available.\n</Warning>\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add --transport sse <name> <url>\n\n# Real example: Connect to Asana\nclaude mcp add --transport sse asana https://mcp.asana.com/sse\n\n# Example with authentication header\nclaude mcp add --transport sse private-api https://api.company.com/sse \\\n  --header \"X-API-Key: your-key-here\"\n```\n\n### Option 3: Add a local stdio server\n\nStdio servers run as local processes on your machine. They're ideal for tools that need direct system access or custom scripts.\n\nClaude 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.\n\n`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](/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`.\n\nThis 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.\n\n```bash theme={null}\n# Basic syntax\nclaude mcp add [options] <name> -- <command> [args...]\n\n# Real example: Add Airtable server\nclaude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \\\n  -- npx -y airtable-mcp-server\n```\n\n<Note>\n  **Important: Separate server arguments with `--`**\n\n  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.\n\n  For example:\n\n  * `claude mcp add --transport stdio myserver -- npx server` → runs `npx server`\n  * `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\n\n  Without `--`, Claude Code would try to parse the server's flags, like `--port` above, as its own options.\n\n  `--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.\n</Note>\n\n### Option 4: Add a remote WebSocket server\n\nWebSocket 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.\n\nConfigure WebSocket servers in `.mcp.json` or with `claude mcp add-json`:\n\n```bash theme={null}\nclaude mcp add-json events-server \\\n  '{\"type\":\"ws\",\"url\":\"wss://mcp.example.com/socket\",\"headers\":{\"Authorization\":\"Bearer YOUR_TOKEN\"}}'\n```\n\nThe `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`](#use-dynamic-headers-for-custom-authentication). The `claude mcp add --transport` flag doesn't accept `ws`.\n\n### Managing your servers\n\nOnce configured, you can manage your MCP servers with these commands:\n\n```bash theme={null}\n# List all configured servers\nclaude mcp list\n\n# Get details for a specific server\nclaude mcp get github\n\n# Remove a server\nclaude mcp remove github\n\n# (within Claude Code) Check server status\n/mcp\n```\n\nProject-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`.\n\nAs 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`](/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.\n\nApprovals from these sources still apply in an untrusted folder:\n\n* your user `~/.claude/settings.json`\n* managed settings\n* settings passed with `--settings`\n* `.claude/settings.local.json`, as long as git doesn't track it\n\nA `disabledMcpjsonServers` entry in any settings file still rejects the server.\n\nThe `/mcp` panel shows the tool count next to each connected server and flags servers that advertise the tools capability but expose no tools.\n\nIf your request needs tools from a server that is still connecting in the background, Claude waits for that server before continuing. With [tool search](#scale-with-mcp-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.\n\nSome 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.\n\n`Claude Preview` and `Claude Browser` both name the built-in server that the [Claude Code desktop app's preview pane](/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.\n\n### Dynamic tool updates\n\nClaude 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.\n\n### Automatic reconnection\n\nIf 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.\n\nThe 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.\n\nWhen 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](#scale-with-mcp-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.\n\nAs 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.\n\n### Push messages with channels\n\nAn 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](/en/channels) to use an officially supported channel, or [Channels reference](/en/channels-reference) to build your own.\n\n<Tip>\n  Tips:\n\n  * Use the `-s` or `--scope` flag to specify where the configuration is stored:\n    * `local` (default): available only to you in the current project. Older versions called this scope `project`\n    * `project`: shared with everyone in the project via the `.mcp.json` file\n    * `user`: available to you across all projects. Older versions called this scope `global`\n  * Set environment variables with `-e` or `--env` flags (for example, `-e KEY=value`)\n  * The `--transport` and `--header` flags also accept `-t` and `-H` short forms\n  * Configure MCP server startup timeout using the `MCP_TIMEOUT` environment variable (for example, `MCP_TIMEOUT=10000 claude` sets a 10-second timeout)\n  * 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\n  * 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`)\n  * Use `/mcp` to authenticate with remote servers that require OAuth 2.0 authentication\n</Tip>\n\nThe 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. {/* min-version: 2.1.162 */}Before v2.1.162, values below 1000 were floored to one second instead.\n\nA 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.\n\nFor HTTP and SSE servers, the per-request fetch first-byte budget has a 60-second minimum.\n\nA 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. {/* min-version: 2.1.203 */}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](#use-mcp-servers-from-claude-ai) servers, and to 30 minutes for stdio servers. Before v2.1.203, stdio servers were exempt from the idle timeout.\n\nSet the [`CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT`](/en/env-vars) environment variable in milliseconds to change the idle window, or set it to `0` to disable the check.\n\n### Plugin-provided MCP servers\n\n[Plugins](/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.\n\n**How plugin MCP servers work**:\n\n* Plugins define MCP servers in `.mcp.json` at the plugin root or inline in `plugin.json`\n* When a plugin is enabled, its MCP servers start automatically\n* Plugin MCP tools appear alongside manually configured MCP tools\n* Plugin servers are managed through plugin installation, not `/mcp` commands\n\n**Example plugin MCP configuration**:\n\nIn `.mcp.json` at plugin root:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"database-tools\": {\n      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/db-server\",\n      \"args\": [\"--config\", \"${CLAUDE_PLUGIN_ROOT}/config.json\"],\n      \"env\": {\n        \"DB_URL\": \"${DB_URL}\"\n      }\n    }\n  }\n}\n```\n\nOr inline in `plugin.json`:\n\n```json theme={null}\n{\n  \"name\": \"my-plugin\",\n  \"mcpServers\": {\n    \"plugin-api\": {\n      \"command\": \"${CLAUDE_PLUGIN_ROOT}/servers/api-server\",\n      \"args\": [\"--port\", \"8080\"]\n    }\n  }\n}\n```\n\n**Plugin MCP features**:\n\n* **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\n* **Environment variables**: use `${CLAUDE_PLUGIN_ROOT}` for bundled plugin files, `${CLAUDE_PLUGIN_DATA}` for [persistent state](/en/plugins-reference#persistent-data-directory) that survives plugin updates, and `${CLAUDE_PROJECT_DIR}` for the stable project root\n* **User environment access**: access to the same environment variables as manually configured servers\n* **Multiple transport types**: support for stdio, SSE, HTTP, and WebSocket transports, though transport support may vary by server\n\n**Viewing plugin MCP servers**:\n\n```bash theme={null}\n# Within Claude Code, see all MCP servers including plugin ones\n/mcp\n```\n\nPlugin servers appear in the list with indicators showing they come from plugins.\n\n**Plugin MCP tool names**:\n\nTools 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:\n\n```\nmcp__plugin_my-plugin_database-tools__query\n```\n\nUse this full name when referencing the tool in [permission rules](/en/permissions), a skill's `allowed-tools` list, a [subagent's `tools` field](/en/sub-agents#available-tools), or a [hook matcher](/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.\n\nThe 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](/en/hooks#mcp-tool-hook-fields).\n\n**Benefits of plugin MCP servers**:\n\n* **Bundled distribution**: tools and servers packaged together\n* **Automatic setup**: no manual MCP configuration needed\n* **Team consistency**: everyone gets the same tools when the plugin is installed\n\nSee the [plugin components reference](/en/plugins-reference#mcp-servers) for details on bundling MCP servers with plugins.\n\n## MCP installation scopes\n\nMCP 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](#managed-mcp-configuration).\n\n| Scope                     | Loads in             | Shared with team         | Stored in                   |\n| ------------------------- | -------------------- | ------------------------ | --------------------------- |\n| [Local](#local-scope)     | Current project only | No                       | `~/.claude.json`            |\n| [Project](#project-scope) | Current project only | Yes, via version control | `.mcp.json` in project root |\n| [User](#user-scope)       | All your projects    | No                       | `~/.claude.json`            |\n\n### Local scope\n\nLocal 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.\n\n<Note>\n  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](/en/settings#settings-files) for details on settings file locations.\n</Note>\n\n```bash theme={null}\n# Add a local-scoped server (default)\nclaude mcp add --transport http stripe https://mcp.stripe.com\n\n# Explicitly specify local scope\nclaude mcp add --transport http stripe --scope local https://mcp.stripe.com\n```\n\nThe 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`:\n\n```json theme={null}\n{\n  \"projects\": {\n    \"/path/to/your/project\": {\n      \"mcpServers\": {\n        \"stripe\": {\n          \"type\": \"http\",\n          \"url\": \"https://mcp.stripe.com\"\n        }\n      }\n    }\n  }\n}\n```\n\n### Project scope\n\nProject-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.\n\n```bash theme={null}\n# Add a project-scoped server\nclaude mcp add --transport http paypal --scope project https://mcp.paypal.com/mcp\n```\n\nThe resulting `.mcp.json` file follows a standardized format:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"shared-server\": {\n      \"command\": \"/path/to/server\",\n      \"args\": [],\n      \"env\": {}\n    }\n  }\n}\n```\n\nFor 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.\n\n### User scope\n\nUser-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.\n\n```bash theme={null}\n# Add a user server\nclaude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic\n```\n\n### Scope hierarchy and precedence\n\nWhen 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.\n\n1. Local scope\n2. Project scope\n3. User scope\n4. [Plugin-provided servers](/en/plugins)\n5. [claude.ai connectors](#use-mcp-servers-from-claude-ai)\n\nThe 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.\n\n### Environment variable expansion in `.mcp.json`\n\nClaude 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.\n\n**Supported syntax:**\n\n* `${VAR}`: expands to the value of environment variable `VAR`\n* `${VAR:-default}`: expands to `VAR` if set, otherwise uses `default`\n\n**Expansion locations:**\nEnvironment variables can be expanded in:\n\n* `command`: the server executable path\n* `args`: command-line arguments\n* `env`: environment variables passed to the server\n* `url`: for HTTP server types\n* `headers`: for HTTP server authentication\n\n**Example with variable expansion:**\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"api-server\": {\n      \"type\": \"http\",\n      \"url\": \"${API_BASE_URL:-https://api.example.com}/mcp\",\n      \"headers\": {\n        \"Authorization\": \"Bearer ${API_KEY}\"\n      }\n    }\n  }\n}\n```\n\nIf a required environment variable isn't set and has no default value, Claude Code fails to parse the config.\n\n## Practical examples\n\n### Example: Monitor errors with Sentry\n\n```bash theme={null}\nclaude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n```\n\nAuthenticate with your Sentry account:\n\n```text theme={null}\n/mcp\n```\n\nThen debug production issues:\n\n```text theme={null}\nWhat are the most common errors in the last 24 hours?\n```\n\n```text theme={null}\nShow me the stack trace for error ID abc123\n```\n\n```text theme={null}\nWhich deployment introduced these new errors?\n```\n\n### Example: Connect to GitHub for code reviews\n\nGitHub'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:\n\n```bash theme={null}\nclaude mcp add --transport http github https://api.githubcopilot.com/mcp/ \\\n  --header \"Authorization: Bearer YOUR_GITHUB_PAT\"\n```\n\nThen work with GitHub:\n\n```text theme={null}\nReview PR #456 and suggest improvements\n```\n\n```text theme={null}\nCreate a new issue for the bug we just found\n```\n\n```text theme={null}\nShow me all open PRs assigned to me\n```\n\n### Example: Query your PostgreSQL database\n\n```bash theme={null}\nclaude mcp add --transport stdio db -- npx -y @bytebase/dbhub \\\n  --dsn \"postgresql://readonly:pass@prod.db.com:5432/analytics\"\n```\n\nThen query your database naturally:\n\n```text theme={null}\nWhat's our total revenue this month?\n```\n\n```text theme={null}\nShow me the schema for the orders table\n```\n\n```text theme={null}\nFind customers who haven't made a purchase in 90 days\n```\n\n## Authenticate with remote MCP servers\n\nMany cloud-based MCP servers require authentication. Claude Code supports OAuth 2.0 for secure connections.\n\nClaude 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.\n\nAs 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.\n\nA custom server that returns a `WWW-Authenticate` header pointing to its authorization server gets the same automatic discovery as any other remote server.\n\nAs 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.\n\nIn 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](#scale-with-mcp-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>`.\n\nIf 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.\n\n<Steps>\n  <Step title=\"Add the server that requires authentication\">\n    For example:\n\n    ```bash theme={null}\n    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp\n    ```\n  </Step>\n\n  <Step title=\"Use the /mcp command within Claude Code\">\n    In Claude Code, use the command:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Then follow the steps in your browser to log in.\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Authentication tokens are stored securely and refreshed automatically\n  * Use \"Clear authentication\" in the `/mcp` menu to revoke access\n  * If your browser doesn't open automatically, copy the provided URL and open it manually\n  * 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\n  * OAuth authentication works with HTTP servers\n</Tip>\n\n### Authenticate from the command line\n\nFrom 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.\n\n```bash theme={null}\nclaude mcp login sentry\n```\n\nTo clear stored credentials later, run `claude mcp logout <name>`.\n\nAs 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.\n\n```bash theme={null}\nclaude mcp login sentry --no-browser\n```\n\n### Use a fixed OAuth callback port\n\nSome 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`.\n\nYou can use `--callback-port` on its own (with dynamic client registration) or together with `--client-id` (with pre-configured credentials).\n\n```bash theme={null}\n# Fixed callback port with dynamic client registration\nclaude mcp add --transport http \\\n  --callback-port 8080 \\\n  my-server https://mcp.example.com/mcp\n```\n\n### Use pre-configured OAuth credentials\n\nSome 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.\n\n<Steps>\n  <Step title=\"Register an OAuth app with the server\">\n    Create an app through the server's developer portal and note your client ID and client secret.\n\n    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.\n  </Step>\n\n  <Step title=\"Add the server with your credentials\">\n    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.\n\n    <Tabs>\n      <Tab title=\"claude mcp add\">\n        Use `--client-id` to pass your app's client ID. The `--client-secret` flag prompts for the secret with masked input:\n\n        ```bash theme={null}\n        claude mcp add --transport http \\\n          --client-id your-client-id --client-secret --callback-port 8080 \\\n          my-server https://mcp.example.com/mcp\n        ```\n      </Tab>\n\n      <Tab title=\"claude mcp add-json\">\n        Include the `oauth` object in the JSON config and pass `--client-secret` as a separate flag:\n\n        ```bash theme={null}\n        claude mcp add-json my-server \\\n          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' \\\n          --client-secret\n        ```\n      </Tab>\n\n      <Tab title=\"claude mcp add-json (callback port only)\">\n        Use `--callback-port` without a client ID to fix the port while using dynamic client registration:\n\n        ```bash theme={null}\n        claude mcp add-json my-server \\\n          '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"callbackPort\":8080}}'\n        ```\n      </Tab>\n\n      <Tab title=\"CI / env var\">\n        Set the secret via environment variable to skip the interactive prompt:\n\n        ```bash theme={null}\n        MCP_CLIENT_SECRET=your-secret claude mcp add --transport http \\\n          --client-id your-client-id --client-secret --callback-port 8080 \\\n          my-server https://mcp.example.com/mcp\n        ```\n      </Tab>\n    </Tabs>\n  </Step>\n\n  <Step title=\"Authenticate in Claude Code\">\n    Run `/mcp` in Claude Code and follow the browser login flow.\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * The client secret is stored securely in your system keychain (macOS) or a credentials file, not in your config\n  * If the server uses a public OAuth client with no secret, use only `--client-id` without `--client-secret`\n  * `--callback-port` can be used with or without `--client-id`\n  * These flags only apply to HTTP and SSE transports. They have no effect on stdio servers\n  * Use `claude mcp get <name>` to verify that OAuth credentials are configured for a server\n</Tip>\n\n### Override OAuth metadata discovery\n\nPoint 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`.\n\nSet `authServerMetadataUrl` in the `oauth` object of your server's config in `.mcp.json`:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"my-server\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/mcp\",\n      \"oauth\": {\n        \"authServerMetadataUrl\": \"https://auth.example.com/.well-known/openid-configuration\"\n      }\n    }\n  }\n}\n```\n\nThe 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.\n\n### Restrict OAuth scopes\n\nSet `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.\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"slack\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.slack.com/mcp\",\n      \"oauth\": {\n        \"scopes\": \"channels:read chat:write search:read\"\n      }\n    }\n  }\n}\n```\n\n`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.\n\nAs 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.\n\nIf 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.\n\nIf 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.\n\n### Use dynamic headers for custom authentication\n\nIf 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.\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"internal-api\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.internal.example.com\",\n      \"headersHelper\": \"/opt/bin/get-mcp-auth-headers.sh\"\n    }\n  }\n}\n```\n\nThe command can also be inline:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"internal-api\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.internal.example.com\",\n      \"headersHelper\": \"echo '{\\\"Authorization\\\": \\\"Bearer '\\\"$(get-token)\\\"'\\\"}'\"\n    }\n  }\n}\n```\n\n**Requirements:**\n\n* The command must write a JSON object of string key-value pairs to stdout\n* The command runs in a shell with a 10-second timeout\n* Dynamic headers override any static `headers` with the same name\n\nThe 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.\n\nAs 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.\n\nClaude Code sets these environment variables when executing the helper:\n\n| Variable                      | Value                                                                                                        |\n| :---------------------------- | :----------------------------------------------------------------------------------------------------------- |\n| `CLAUDE_CODE_MCP_SERVER_NAME` | the name of the MCP server                                                                                   |\n| `CLAUDE_CODE_MCP_SERVER_URL`  | the URL of the MCP server                                                                                    |\n| `CLAUDE_PLUGIN_ROOT`          | the plugin's root directory. Set only when a [plugin](/en/plugins-reference#mcp-servers) provides the server |\n\nUse these to write a single helper script that serves multiple MCP servers.\n\nFor 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.\n\n<Note>\n  `headersHelper` executes arbitrary shell commands. When defined at project or local scope, it only runs after you accept the workspace trust dialog.\n</Note>\n\n## Add MCP servers from JSON configuration\n\nIf you have a JSON configuration for an MCP server, you can add it directly:\n\n<Steps>\n  <Step title=\"Add an MCP server from JSON\">\n    ```bash theme={null}\n    # Basic syntax\n    claude mcp add-json <name> '<json>'\n\n    # Example: Adding an HTTP server with JSON configuration\n    claude mcp add-json weather-api '{\"type\":\"http\",\"url\":\"https://api.weather.com/mcp\",\"headers\":{\"Authorization\":\"Bearer token\"}}'\n\n    # Example: Adding a stdio server with JSON configuration\n    claude mcp add-json local-weather '{\"type\":\"stdio\",\"command\":\"/path/to/weather-cli\",\"args\":[\"--api-key\",\"abc123\"],\"env\":{\"CACHE_DIR\":\"/tmp\"}}'\n\n    # Example: Adding an HTTP server with pre-configured OAuth credentials\n    claude mcp add-json my-server '{\"type\":\"http\",\"url\":\"https://mcp.example.com/mcp\",\"oauth\":{\"clientId\":\"your-client-id\",\"callbackPort\":8080}}' --client-secret\n    ```\n  </Step>\n\n  <Step title=\"Verify the server was added\">\n    ```bash theme={null}\n    claude mcp get weather-api\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Make sure the JSON is properly escaped in your shell\n  * The JSON must conform to the MCP server configuration schema\n  * You can use `--scope user` to add the server to your user configuration instead of the project-specific one\n</Tip>\n\n## Import MCP servers from Claude Desktop\n\nIf you've already configured MCP servers in Claude Desktop, you can import them:\n\n<Steps>\n  <Step title=\"Import servers from Claude Desktop\">\n    ```bash theme={null}\n    # Basic syntax \n    claude mcp add-from-claude-desktop \n    ```\n  </Step>\n\n  <Step title=\"Select which servers to import\">\n    After running the command, you'll see an interactive dialog that allows you to select which servers you want to import.\n  </Step>\n\n  <Step title=\"Verify the servers were imported\">\n    ```bash theme={null}\n    claude mcp list \n    ```\n  </Step>\n</Steps>\n\nServer 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.\n\n<Tip>\n  Tips:\n\n  * This feature only works on macOS and Windows Subsystem for Linux (WSL)\n  * It reads the Claude Desktop configuration file from its standard location on those platforms\n  * Use the `--scope user` flag to add servers to your user configuration\n  * 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\n  * If servers with the same names already exist, they get a numerical suffix (for example, `server_1`)\n</Tip>\n\n## Use MCP servers from claude.ai\n\nIf 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:\n\n<Steps>\n  <Step title=\"Configure MCP servers in claude.ai\">\n    Add servers at [claude.ai/customize/connectors](https://claude.ai/customize/connectors). On Team and Enterprise plans, only admins can add servers.\n  </Step>\n\n  <Step title=\"Authenticate the MCP server\">\n    Complete any required authentication steps in claude.ai.\n  </Step>\n\n  <Step title=\"View and manage servers in Claude Code\">\n    In Claude Code, use the command:\n\n    ```text theme={null}\n    /mcp\n    ```\n\n    Servers from claude.ai appear in the list with indicators showing they come from claude.ai.\n  </Step>\n</Steps>\n\nFrom 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.\n\nConnectors from claude.ai are fetched only when your active [authentication method](/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`.\n\nIf `/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.\n\nA server you've added in Claude Code takes [precedence](#scope-hierarchy-and-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.\n\nSome 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.\n\n### Disable claude.ai connectors\n\nTo disable claude.ai MCP servers in Claude Code, set [`disableClaudeAiConnectors`](/en/settings#available-settings) to `true` in any settings scope:\n\n```json theme={null}\n{\n  \"disableClaudeAiConnectors\": true\n}\n```\n\nThis 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.\n\nYou can also set the `ENABLE_CLAUDEAI_MCP_SERVERS` environment variable to `false`, which has the same effect for the current shell session:\n\n```bash theme={null}\nENABLE_CLAUDEAI_MCP_SERVERS=false claude\n```\n\nTo block individual claude.ai connectors instead of all of them, add them to [`deniedMcpServers`](/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.\n\n<Note>\n  These client-side settings govern local Claude Code sessions. In [Claude Code on the web](/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.\n</Note>\n\n## Use Claude Code as an MCP server\n\nYou can use Claude Code itself as an MCP server that other applications can connect to:\n\n```bash theme={null}\n# Start Claude as a stdio MCP server\nclaude mcp serve\n```\n\nYou can use this in Claude Desktop by adding this configuration to claude\\_desktop\\_config.json:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"claude-code\": {\n      \"type\": \"stdio\",\n      \"command\": \"claude\",\n      \"args\": [\"mcp\", \"serve\"],\n      \"env\": {}\n    }\n  }\n}\n```\n\n<Warning>\n  **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.\n\n  To find the full path:\n\n  ```bash theme={null}\n  which claude\n  ```\n\n  Then use the full path in your configuration:\n\n  ```json theme={null}\n  {\n    \"mcpServers\": {\n      \"claude-code\": {\n        \"type\": \"stdio\",\n        \"command\": \"/full/path/to/claude\",\n        \"args\": [\"mcp\", \"serve\"],\n        \"env\": {}\n      }\n    }\n  }\n  ```\n\n  Without the correct executable path, you'll encounter errors like `spawn claude ENOENT`.\n</Warning>\n\n<Tip>\n  Tips:\n\n  * The server provides access to Claude's tools like View, Edit, LS, etc.\n  * In Claude Desktop, try asking Claude to read files in a directory, make edits, and more.\n  * 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.\n</Tip>\n\n## MCP output limits and warnings\n\nWhen MCP tools produce large outputs, Claude Code helps manage the token usage to prevent overwhelming your conversation context:\n\n* **Output warning threshold**: Claude Code displays a warning when any MCP tool output exceeds 10,000 tokens\n* **Configurable limit**: you can adjust the maximum allowed MCP output tokens using the `MAX_MCP_OUTPUT_TOKENS` environment variable\n* **Default limit**: the default maximum is 25,000 tokens\n* **Scope**: the environment variable applies to tools that don't declare their own limit. Tools that set [`anthropic/maxResultSizeChars`](#raise-the-limit-for-a-specific-tool) 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`\n\nTo increase the limit for tools that produce large outputs:\n\n```bash theme={null}\nexport MAX_MCP_OUTPUT_TOKENS=50000\nclaude\n```\n\nThis is particularly useful when working with MCP servers that:\n\n* Query large datasets or databases\n* Generate detailed reports or documentation\n* Process extensive log files or debugging information\n\n### Raise the limit for a specific tool\n\nIf 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.\n\nThis 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.\n\n```json theme={null}\n{\n  \"name\": \"get_schema\",\n  \"description\": \"Returns the full database schema\",\n  \"_meta\": {\n    \"anthropic/maxResultSizeChars\": 200000\n  }\n}\n```\n\nThe 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.\n\n<Warning>\n  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.\n</Warning>\n\n## Tool input schemas with a root-level combinator\n\nSome 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.\n\nAs 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:\n\n* `allOf`: properties from every branch are merged, and each branch's `required` list still applies\n* `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\n\nYour server receives whichever arguments Claude chose, so keep validating the combination server-side.\n\nWhen 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`.\n\n## Require approval for a specific tool\n\nIf 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.\n\nClaude Code shows that tool's permission prompt on every call, even in `acceptEdits`, `auto`, and `bypassPermissions` [permission modes](/en/permissions#permission-modes), and doesn't offer a \"don't ask again\" option for it. [Allow rules](/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.\n\nThe prompt has to reach a person. In non-interactive mode with [`--permission-prompt-tool`](/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](/en/agent-sdk/permissions) does receive these calls and can approve them, because the SDK host is expected to show them to a user.\n\nUse 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.\n\nThe following `tools/list` entry marks one tool as always requiring approval.\n\n```json theme={null}\n{\n  \"name\": \"grant_access\",\n  \"description\": \"Requests access to a protected resource\",\n  \"_meta\": {\n    \"anthropic/requiresUserInteraction\": true\n  }\n}\n```\n\nThe `anthropic/requiresUserInteraction` annotation requires Claude Code v2.1.199 or later. Earlier versions ignore it and apply the standard permission flow.\n\nWhen a session is connected to [Remote Control](/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.\n\n## Respond to MCP elicitation requests\n\nMCP 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.\n\nServers can request input in two ways:\n\n* **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.\n* **URL mode**: Claude Code opens a browser URL for authentication or approval. Complete the flow in the browser, then confirm in the CLI.\n\nTo auto-respond to elicitation requests without showing a dialog, use the [`Elicitation` hook](/en/hooks#elicitation).\n\nIf 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.\n\n## Use MCP resources\n\nMCP servers can expose resources that you can reference using @ mentions, similar to how you reference files.\n\n### Reference MCP resources\n\n<Steps>\n  <Step title=\"List available resources\">\n    Type `@` in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu.\n  </Step>\n\n  <Step title=\"Reference a specific resource\">\n    Use the format `@server:protocol://resource/path` to reference a resource:\n\n    ```text theme={null}\n    Can you analyze @github:issue://123 and suggest a fix?\n    ```\n\n    ```text theme={null}\n    Please review the API documentation at @docs:file://api/authentication\n    ```\n  </Step>\n\n  <Step title=\"Multiple resource references\">\n    You can reference multiple resources in a single prompt:\n\n    ```text theme={null}\n    Compare @postgres:schema://users with @docs:file://database/user-model\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * Resources are automatically fetched and included as attachments when referenced\n  * Resource paths are fuzzy-searchable in the @ mention autocomplete\n  * Claude Code automatically provides tools to list and read MCP resources when servers support them\n  * Resources can contain any type of content that the MCP server provides (text, JSON, structured data, etc.)\n</Tip>\n\n## Scale with MCP tool search\n\nTool 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.\n\n### How it works\n\nTool 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.\n\nIf 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](#configure-tool-search) for all options.\n\n### For MCP server authors\n\nIf 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](/en/skills) work.\n\nAdd clear, descriptive server instructions that explain:\n\n* What category of tasks your tools handle\n* When Claude should search for your tools\n* Key capabilities your server provides\n\nClaude Code truncates tool descriptions and server instructions at 2KB each. Keep them concise to avoid truncation, and put critical details near the start.\n\n### Configure tool search\n\nTool 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.\n\nTool 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.\n\nControl tool search behavior with the `ENABLE_TOOL_SEARCH` environment variable:\n\n| Value    | Behavior                                                                                                                                                                                                                                                                 |\n| :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| (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                                                                                                       |\n| `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 |\n| `auto`   | Threshold mode: tools load upfront if they fit within 10% of the context window, deferred otherwise                                                                                                                                                                      |\n| `auto:N` | Threshold mode with a custom percentage, where `N` is 0-100. For example, `auto:5` for 5%                                                                                                                                                                                |\n| `false`  | All MCP tools loaded upfront, no deferral                                                                                                                                                                                                                                |\n\n```bash theme={null}\n# Use a custom 5% threshold\nENABLE_TOOL_SEARCH=auto:5 claude\n\n# Disable tool search entirely\nENABLE_TOOL_SEARCH=false claude\n```\n\nOr set the value in your [settings.json `env` field](/en/settings#available-settings).\n\nYou can also disable the `ToolSearch` tool specifically:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\"ToolSearch\"]\n  }\n}\n```\n\n### Exempt a server from deferral\n\nIf 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.\n\nThe following `.mcp.json` entry exempts one HTTP server while leaving other servers deferred:\n\n```json theme={null}\n{\n  \"mcpServers\": {\n    \"core-tools\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/mcp\",\n      \"alwaysLoad\": true\n    }\n  }\n}\n```\n\nThe `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.\n\nSetting `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](/en/env-vars), since the tools must be present when the first prompt is built. Other servers continue to connect in the background.\n\n## Use MCP prompts as commands\n\nMCP servers can expose prompts that become available as commands in Claude Code.\n\n### Execute MCP prompts\n\n<Steps>\n  <Step title=\"Discover available prompts\">\n    Type `/` to see all available commands, including those from MCP servers. MCP prompts appear with the format `/mcp__servername__promptname`.\n  </Step>\n\n  <Step title=\"Execute a prompt without arguments\">\n    ```text theme={null}\n    /mcp__github__list_prs\n    ```\n  </Step>\n\n  <Step title=\"Execute a prompt with arguments\">\n    Many prompts accept arguments. Pass them space-separated after the command:\n\n    ```text theme={null}\n    /mcp__github__pr_review 456\n    ```\n\n    ```text theme={null}\n    /mcp__jira__create_issue \"Bug in login flow\" high\n    ```\n  </Step>\n</Steps>\n\n<Tip>\n  Tips:\n\n  * MCP prompts are dynamically discovered from connected servers\n  * Arguments are parsed based on the prompt's defined parameters\n  * Prompt results are injected directly into the conversation\n  * Server and prompt names are normalized, with spaces converted to underscores\n</Tip>\n\n## Managed MCP configuration\n\nFor organizations that need centralized control over which MCP servers users can connect to, see [Managed MCP configuration](/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.\n","numLines":1202,"startLine":1,"totalLines":1202}},"sourceToolAssistantUUID":"e201f257-7b9d-427c-810e-582ec111fe65","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"28954718-e1f4-4f5e-8ea8-3934b25c5706","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dx73fMJjLAH7WVWVs","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"[encoded data, 5244 characters]"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":19519,"cache_read_input_tokens":22826,"cache_creation":{"ephemeral_5m_input_tokens":19519,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3dwBjUzCX6JoT4b5cN","attributionAgent":"claude-code-guide","type":"assistant","uuid":"8404a725-dd08-4519-94e1-5e20d91fb707","timestamp":"2026-07-11T09:38:20.768Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"8404a725-dd08-4519-94e1-5e20d91fb707","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dx73fMJjLAH7WVWVs","type":"message","role":"assistant","content":[{"type":"text","text":"Let me fetch the permissions documentation to confirm the exact syntax for MCP tool authorization:"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":19519,"cache_read_input_tokens":22826,"cache_creation":{"ephemeral_5m_input_tokens":19519,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3dwBjUzCX6JoT4b5cN","attributionAgent":"claude-code-guide","type":"assistant","uuid":"3f2532ae-7090-4807-96ef-1afb18176842","timestamp":"2026-07-11T09:38:21.185Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"3f2532ae-7090-4807-96ef-1afb18176842","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3dx73fMJjLAH7WVWVs","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_01Grun9Ff4NQ45yK7mubMxDt","name":"WebFetch","input":{"url":"https://code.claude.com/docs/en/permissions.md","prompt":"mcp tool permission rule syntax mcp__ allow"},"caller":{"type":"direct"}}],"stop_reason":"tool_use","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":19519,"cache_read_input_tokens":22826,"output_tokens":1137,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":19519},"inference_geo":"not_available","iterations":[{"input_tokens":8,"output_tokens":1137,"cache_read_input_tokens":22826,"cache_creation_input_tokens":19519,"cache_creation":{"ephemeral_5m_input_tokens":19519,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3dwBjUzCX6JoT4b5cN","attributionAgent":"claude-code-guide","type":"assistant","uuid":"e2b5046a-dbed-4ebf-bad9-862bb22325bc","timestamp":"2026-07-11T09:38:21.780Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"e2b5046a-dbed-4ebf-bad9-862bb22325bc","isSidechain":true,"promptId":"e9213d37-b458-42fc-8e21-e84d78e1de36","agentId":"aa6395b4c140e1c9d","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01Grun9Ff4NQ45yK7mubMxDt","type":"tool_result","content":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Configure permissions\n\n> Control what Claude Code can access and do with fine-grained permission rules, modes, and managed policies.\n\nClaude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it can't. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers.\n\n## Permission system\n\nClaude Code uses a tiered permission system to balance power and safety:\n\n| Tool type         | Example          | Approval required                                                                   | \"Yes, don't ask again\" behavior               |\n| :---------------- | :--------------- | :---------------------------------------------------------------------------------- | :-------------------------------------------- |\n| Read-only         | File reads, Grep | No, within the [working directory and additional directories](#working-directories) | N/A                                           |\n| Bash commands     | Shell execution  | Yes, except a built-in set of [read-only commands](#read-only-commands)             | Permanently per project directory and command |\n| File modification | Edit/write files | Yes                                                                                 | Until session end                             |\n\n## Manage permissions\n\nYou can view and manage Claude Code's tool permissions with `/permissions`. This UI lists all permission rules and the `settings.json` file each rule comes from.\n\n* **Allow** rules let Claude Code use the specified tool without manual approval.\n* **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool.\n* **Deny** rules prevent Claude Code from using the specified tool.\n\nRules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn't change the order.\n\nA broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can't carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call.\n\nDeny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude's context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them.\n\n<Note>\n  Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don't change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](/en/permission-modes), or a [PreToolUse hook](#extend-permissions-with-hooks).\n</Note>\n\n## Permission modes\n\nClaude Code supports several permission modes that control how it approves tool calls. See [Permission modes](/en/permission-modes) for when to use each one. Set the `defaultMode` in your [settings files](/en/settings#settings-files):\n\n| Mode                | Description                                                                                                                                                                                                                                                                  |\n| :------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `default`           | Standard behavior: prompts for permission on first use of each tool. {/* min-version: 2.1.200 */}Labeled Manual in the CLI and the VS Code and JetBrains extensions, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later |\n| `acceptEdits`       | Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories`                                                                                                       |\n| `plan`              | Claude reads files and runs read-only shell commands to explore but doesn't edit your source files. Labeled Plan in the CLI and the VS Code extension                                                                                                                        |\n| `auto`              | Auto-approves tool calls with background safety checks that verify actions align with your request                                                                                                                                                                           |\n| `dontAsk`           | Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules                                                                                                                                                                                        |\n| `bypassPermissions` | Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker                                                                                                            |\n\n<Warning>\n  `bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code can't cause damage.\n</Warning>\n\nTo prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `\"disable\"` in any [settings file](/en/settings#settings-files). These are most useful in [managed settings](#managed-settings) where they can't be overridden.\n\n## Permission rule syntax\n\nPermission rules follow the format `Tool` or `Tool(specifier)`.\n\n### Match all uses of a tool\n\nTo match all uses of a tool, use only the tool name without parentheses:\n\n| Rule       | Effect                         |\n| :--------- | :----------------------------- |\n| `Bash`     | Matches all Bash commands      |\n| `WebFetch` | Matches all web fetch requests |\n| `Read`     | Matches all file reads         |\n\n`Bash(*)` is equivalent to `Bash` and matches all Bash commands. As a deny rule, both forms remove the tool from Claude's context.\n\n### Use specifiers for fine-grained control\n\nAdd a specifier in parentheses to match specific tool uses:\n\n| Rule                           | Effect                                                   |\n| :----------------------------- | :------------------------------------------------------- |\n| `Bash(npm run build)`          | Matches the exact command `npm run build`                |\n| `Read(./.env)`                 | Matches reading the `.env` file in the current directory |\n| `WebFetch(domain:example.com)` | Matches fetch requests to example.com                    |\n\n### Match by input parameter\n\nDeny and ask rules can match a top-level input parameter on any tool with `Tool(param:value)`. The rule matches when Claude calls the tool with that parameter set to that exact value. An allow rule for one parameter value wouldn't establish that the call is safe overall, so allow rules continue to use each tool's own specifier syntax. This works for any scalar parameter the tool accepts:\n\n| Rule                           | Matches                                      |\n| :----------------------------- | :------------------------------------------- |\n| `Agent(model:opus)`            | Agent calls that request the Opus model tier |\n| `Agent(isolation:worktree)`    | Agent calls that request a git worktree      |\n| `Bash(run_in_background:true)` | Bash calls that run in the background        |\n\nParameter matching follows these rules:\n\n* The parameter name must be a direct field of the tool's input, such as `model` on the Agent tool. Fields nested inside an object or array are not matchable\n* Each rule names one parameter. To gate on both `model` and `isolation`, write two rules, `Agent(model:opus)` and `Agent(isolation:worktree)`, rather than combining them in one rule\n* The value supports `*` as a wildcard that matches any sequence of characters, so `Agent(isolation:*)` matches any explicit isolation value. Without `*` the match is exact\n* A parameter the model omits is never matched, so `Agent(model:*)` doesn't match a call that leaves `model` unset\n* The value is compared against the literal input Claude sends, before any normalization. `Agent(model:opus)` matches the alias `opus` but not a full model ID. Run with [`--verbose`](/en/cli-reference) to see the exact parameter names and values in each tool call\n* Whitespace around the colon is ignored\n\nFields that a tool already matches with its own canonicalizing rules are not matchable this way: `command` for Bash and PowerShell, `file_path` for Read, Edit, and Write, `path` for Grep and Glob, `notebook_path` for NotebookEdit, and `url` for WebFetch. A rule like `Bash(command:rm *)` would be bypassable by a compound command, so Claude Code ignores it and emits a startup warning. Use `Bash(rm *)`, `Read(./path)`, or `WebFetch(domain:host)` instead.\n\n### Wildcard patterns\n\nBash rules support glob patterns with `*`. Wildcards can appear at any position in the command. This configuration allows npm and git commit commands while blocking git push:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(npm run *)\",\n      \"Bash(git commit *)\",\n      \"Bash(git * main)\",\n      \"Bash(* --version)\",\n      \"Bash(* --help *)\"\n    ],\n    \"deny\": [\n      \"Bash(git push *)\"\n    ]\n  }\n}\n```\n\nThe space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`.\n\nThe permission dialog writes the space-separated form when you select \"Yes, don't ask again\" for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won't match git commands.\n\n### Tool name wildcards\n\nDeny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `\"*\"` matches every tool, and `\"mcp__*\"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude's context, the same as a bare tool name. This configuration denies every MCP tool:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\n      \"mcp__*\"\n    ]\n  }\n}\n```\n\nAllow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `\"*\"`, `\"B*\"`, or `\"mcp__*\"` is skipped with a warning and doesn't auto-approve anything.\n\nA deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check.\n\nThe label shown for a tool in the transcript and permission dialog can differ from its canonical name. For example, the tool labeled `Stop Task` in the transcript has the canonical name `TaskStop`. Permission rules and [hook matchers](/en/hooks) match the canonical name only, so a rule written as `Stop Task` doesn't match. For deny and ask rules, the startup warning above catches the mismatch. Use the canonical names listed in the [tools reference](/en/tools-reference).\n\n## Tool-specific permission rules\n\n### Bash\n\nBash permission rules support wildcard matching with `*`. Wildcards can appear at any position in the command, including at the beginning, middle, or end:\n\n* `Bash(npm run build)` matches the exact Bash command `npm run build`\n* `Bash(npm run test *)` matches Bash commands starting with `npm run test`\n* `Bash(npm *)` matches any command starting with `npm `\n* `Bash(* install)` matches any command ending with ` install`\n* `Bash(git * main)` matches commands like `git checkout main` and `git log --oneline main`\n\nA single `*` matches any sequence of characters including spaces, so one wildcard can span multiple arguments. `Bash(git *)` matches `git log --oneline --all`, and `Bash(git * main)` matches `git push origin main` as well as `git merge main`.\n\nWhen `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there's no word boundary constraint.\n\n#### Compound commands\n\n<Tip>\n  Claude Code is aware of shell operators, so a rule like `Bash(safe-cmd *)` won't give it permission to run the command `safe-cmd && other-cmd`. The recognized command separators are `&&`, `||`, `;`, `|`, `|&`, `&`, and newlines. A rule must match each subcommand independently.\n</Tip>\n\nWhen you approve a compound command with \"Yes, don't ask again\", Claude Code saves a separate rule for each subcommand that requires approval, rather than a single rule for the full compound string. For example, approving `git status && npm test` saves a rule for `npm test`, so future `npm test` invocations are recognized regardless of what precedes the `&&`. Subcommands like `cd` into a subdirectory generate their own Read rule for that path. Up to 5 rules may be saved for a single compound command.\n\n#### Process wrappers\n\nBefore matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`.\n\nBare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it.\n\nThis wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow.\n\nExec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can't be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn't cover these forms. To approve a specific invocation, write an exact-match rule for the full command string.\n\n#### Read-only commands\n\nClaude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it.\n\nUnquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`.\n\nA `cd` into a path inside your working directory or an [additional directory](#working-directories) is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory's hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn't trigger this prompt.\n\n<Warning>\n  Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won't match variations like:\n\n  * Options before URL: `curl -X GET http://github.com/...`\n  * Different protocol: `curl https://github.com/...`\n  * Redirects: `curl -L http://bit.ly/xyz`, which redirects to GitHub\n  * Variables: `URL=http://github.com && curl $URL`\n  * Extra spaces: `curl  http://github.com`\n\n  For more reliable URL filtering, consider:\n\n  * **Restrict Bash network tools**: use deny rules to block `curl`, `wget`, and similar commands, then use the WebFetch tool with `WebFetch(domain:github.com)` permission for allowed domains\n  * **Use PreToolUse hooks**: implement a hook that validates URLs in Bash commands and blocks disallowed domains\n  * **Add CLAUDE.md guidance**: describe your allowed curl patterns in `CLAUDE.md`. This shapes what Claude tries but doesn't enforce a boundary, so pair it with one of the options above\n\n  Note that using WebFetch alone doesn't prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL.\n</Warning>\n\n### PowerShell\n\nPowerShell permission rules use the same shape as Bash rules. Wildcards with `*` match at any position, the `:*` suffix is equivalent to a trailing ` *`, and a bare `PowerShell` or `PowerShell(*)` matches every command. This configuration allows `Get-ChildItem` and `git commit` commands while blocking `Remove-Item`:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"allow\": [\n      \"PowerShell(Get-ChildItem *)\",\n      \"PowerShell(git commit *)\"\n    ],\n    \"deny\": [\n      \"PowerShell(Remove-Item *)\"\n    ]\n  }\n}\n```\n\nCommon aliases are canonicalized before matching. A rule written for the cmdlet name also matches its aliases, so `PowerShell(Get-ChildItem *)` matches `gci`, `ls`, and `dir` as well. Matching is case-insensitive.\n\nClaude Code parses the PowerShell AST and checks each command in a compound command independently. Pipeline operators `|`, statement separators `;`, and on PowerShell 7+ the chain operators `&&` and `||` split a compound command into subcommands. A rule must match every subcommand for the compound command to be allowed.\n\n### Read and Edit\n\n`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](/en/vs-code#the-built-in-ide-mcp-server) shares with Claude.\n\n<Warning>\n  Read and Edit deny rules apply to Claude's built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don't apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](/en/sandboxing).\n</Warning>\n\nRead and Edit rules both follow the [gitignore](https://git-scm.com/docs/gitignore) specification with four distinct pattern types:\n\n| Pattern            | Meaning                              | Example                          | Matches                                          |\n| ------------------ | ------------------------------------ | -------------------------------- | ------------------------------------------------ |\n| `//path`           | Absolute path from filesystem root   | `Read(//Users/alice/secrets/**)` | `/Users/alice/secrets/**`                        |\n| `~/path`           | Path from home directory             | `Read(~/Documents/*.pdf)`        | `/Users/alice/Documents/*.pdf`                   |\n| `/path`            | Path relative to the settings source | `Edit(/src/**/*.ts)`             | `<project root>/src/**/*.ts` in project settings |\n| `path` or `./path` | Path relative to current directory   | `Read(*.env)`                    | `<cwd>/*.env`                                    |\n\n<Warning>\n  A pattern like `/Users/alice/file` isn't an absolute path. The single leading slash anchors at the settings source, not the filesystem root. Use `//Users/alice/file` for absolute paths.\n</Warning>\n\nA `/path` pattern anchors at the directory associated with the settings file that defines it, so the same rule matches different locations depending on where you put it:\n\n| Rule defined in                                            | `/path` resolves to        |\n| :--------------------------------------------------------- | :------------------------- |\n| Project or local settings, such as `.claude/settings.json` | `<project root>/path`      |\n| User settings at `~/.claude/settings.json`                 | `~/.claude/path`           |\n| A file passed with `--settings <file>`                     | `<directory of file>/path` |\n| CLI flags, `/permissions`, or session rules                | `<original cwd>/path`      |\n\nA deny rule such as `Read(/secrets/**)` in user settings blocks `~/.claude/secrets/**`, not a `secrets` directory in your project. To write a rule in user settings that applies inside every project, use a `//` absolute path or a `~/` home-relative path instead.\n\nOn Windows, paths are normalized to POSIX form before matching. `C:\\Users\\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`.\n\nExamples:\n\n* `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/`\n* `Read(~/.zshrc)`: reads your home directory's `.zshrc`\n* `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt`\n* `Read(src/**)`: reads from `<current-directory>/src/`\n\nA rule only matches files under its anchor, so the anchor determines how far a deny rule reaches. Bare filenames follow gitignore semantics and match at any depth, so `Read(.env)` and `Read(**/.env)` are equivalent:\n\n| Deny rule                       | Blocks                                       | Does not block                                       |\n| ------------------------------- | -------------------------------------------- | ---------------------------------------------------- |\n| `Read(.env)` or `Read(**/.env)` | any `.env` at or under the current directory | `.env` in a parent directory or another project      |\n| `Read(//**/.env)`               | any `.env` anywhere on the filesystem        | nothing; the rule is anchored at the filesystem root |\n\n<Note>\n  In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use only the tool name without parentheses: `Read`, `Edit`, or `Write`.\n</Note>\n\nWhen you approve a file path with \"Yes, don't ask again\", Claude Code escapes gitignore pattern characters in that path, such as `[`, `]`, and `*`, so the generated rule matches only the literal path you approved. Rules you write yourself aren't escaped. Before v2.1.202, Claude Code saved the path unescaped, so a generated rule for a directory named `[2024-06] Reports` could fail to match its own path or match unintended sibling directories.\n\nWhen Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright.\n\n* **Allow rules**: apply only when both the symlink path and its target match. A symlink inside an allowed directory that points outside it still prompts you.\n* **Deny rules**: apply when either the symlink path or its target matches. A symlink that points to a denied file is itself denied.\n\nFor example, with `Read(./project/**)` allowed and `Read(~/.ssh/**)` denied, a symlink at `./project/key` pointing to `~/.ssh/id_rsa` is blocked: the target fails the allow rule and matches the deny rule.\n\n### WebFetch\n\nWebFetch rules use a `domain:` prefix and match against the hostname of the requested URL. Matching is case-insensitive, supports `*` wildcards, and strips a trailing `.` from both the rule and the hostname so `example.com.` and `example.com` are treated the same.\n\n* `WebFetch(domain:example.com)` matches requests to `example.com`\n* `WebFetch(domain:*.example.com)` matches any subdomain at any depth, such as `api.example.com` or `a.b.example.com`, but not `example.com` itself\n* `WebFetch(domain:*)` matches every domain and is equivalent to a bare `WebFetch` rule\n\nIn any position other than a leading `*.` or a bare `*`, the wildcard matches only the text between two dots. `WebFetch(domain:example.*)` matches `example.org`, where `*` becomes `org`, but not `example.evil.com`, where `*` would have to become `evil.com` and cross a dot. This keeps a trailing wildcard from matching domains an attacker could register.\n\n### MCP\n\nMCP rules use the server name as configured in Claude Code, optionally followed by the name of a tool from that server.\n\n* `mcp__puppeteer` matches any tool provided by the `puppeteer` server\n* `mcp__puppeteer__*` uses wildcard syntax and also matches all tools from the `puppeteer` server\n* `mcp__puppeteer__puppeteer_navigate` matches the `puppeteer_navigate` tool provided by the `puppeteer` server\n\n### Agent (subagents)\n\nUse `Agent(AgentName)` rules to control which [subagents](/en/sub-agents) Claude can use:\n\n* `Agent(Explore)` matches the Explore subagent\n* `Agent(Plan)` matches the Plan subagent\n* `Agent(my-custom-agent)` matches a custom subagent named `my-custom-agent`\n\nAdd these rules to the `deny` array in your settings or use the `--disallowedTools` CLI flag to disable specific agents. To disable the Explore agent:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\"Agent(Explore)\"]\n  }\n}\n```\n\n### Cd\n\n`Cd` rules control which directories the [`/cd` command](/en/commands) can move the session to. `Cd` is not a model-invocable tool: Claude can't call it, and the rules apply only when you run `/cd` yourself.\n\nA bare `Cd` deny rule disables `/cd` entirely. A `Cd(<path-pattern>)` deny rule blocks matching targets. Deny rules check every spelling of the target, including each symlink hop it resolves through, so a rule written for one path also blocks targets that resolve to it.\n\nAdding any `Cd` allow rule switches `/cd` to allowlist mode: the resolved target directory must match one of your allow rules, or `/cd` refuses. With no `Cd` rules configured, `/cd` keeps its default behavior and prompts you to trust an unfamiliar directory.\n\nPath patterns share the `//`, `~/`, and `/` anchors from [Read and Edit rules](#read-and-edit), but matching is anchored to the whole directory path rather than gitignore-style. `*` matches exactly one path segment and `**` matches across segments. A trailing `/**` also matches its named root.\n\n| Rule                  | Matches                                   | Does not match               |\n| --------------------- | ----------------------------------------- | ---------------------------- |\n| `Cd(~/code/*)`        | `~/code/app`                              | `~/code/app/src`, `~/code`   |\n| `Cd(~/code/**)`       | `~/code` and any directory under it       | directories outside `~/code` |\n| `Cd(**/node_modules)` | any `node_modules` directory at any depth | `node_modules/pkg`           |\n\n## Extend permissions with hooks\n\n[Claude Code hooks](/en/hooks-guide) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed.\n\nHook decisions don't bypass permission rules. Deny and ask rules are evaluated regardless of what a PreToolUse hook returns, so a matching deny rule blocks the call and a matching ask rule still prompts even when the hook returned `\"allow\"` or `\"ask\"`. This preserves the deny-first precedence described in [Manage permissions](#manage-permissions), including deny rules set in managed settings.\n\nA blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `\"Bash\"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](/en/hooks-guide#block-edits-to-protected-files) for a hook script you can adapt.\n\n## Working directories\n\nBy default, Claude has access to files in the directory where you launched it. You can extend this access:\n\n* **During startup**: use `--add-dir <path>` CLI argument\n* **During session**: use `/add-dir` command\n* **Persistent configuration**: add to `additionalDirectories` in [settings files](/en/settings#settings-files)\n\nFiles in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode.\n\nTo change the session's primary working directory instead of adding another, use [`/cd`](/en/commands). The `/cd` command requires Claude Code v2.1.169 or later. Unlike `/add-dir`, it relocates the session: the new directory's `CLAUDE.md` is loaded and `--resume` finds the session from there.\n\n### Additional directories grant file access, not configuration\n\nAdding a directory extends where Claude can read and edit files. It doesn't make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions.\n\nThese exceptions apply only to directories added with the `--add-dir` flag or the `/add-dir` command. Directories listed in `permissions.additionalDirectories` in a settings file grant file access only and don't load any of the configuration below.\n\nThe following configuration types are loaded from `--add-dir` directories:\n\n| Configuration                                                                         | Loaded from `--add-dir`                                                                                                                                            |\n| :------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [Skills](/en/skills) in `.claude/skills/`                                             | Yes, with live reload                                                                                                                                              |\n| [Subagents](/en/sub-agents) in `.claude/agents/`                                      | Yes                                                                                                                                                                |\n| [Settings](/en/settings) in `.claude/settings.json` and `.claude/settings.local.json` | `enabledPlugins` and `extraKnownMarketplaces` keys only                                                                                                            |\n| [CLAUDE.md](/en/memory) files, `.claude/rules/`, and `CLAUDE.local.md`                | Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default |\n\nCommands and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory's `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches:\n\n* **User-level configuration**: place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project\n* **Plugins**: package and distribute configuration as a [plugin](/en/plugins) that teams can install\n* **Launch from the config directory**: run Claude Code from the directory containing the `.claude/` configuration you want\n\n## How permissions interact with sandboxing\n\nPermissions and [sandboxing](/en/sandboxing) are complementary security layers:\n\n* **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools, including Bash, Read, Edit, WebFetch, and MCP.\n* **Sandboxing** provides OS-level enforcement that restricts the Bash tool's filesystem and network access. It applies only to Bash commands and their child processes.\n\nUse both for defense-in-depth:\n\n* Permission deny rules block Claude from even attempting to access restricted resources\n* Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude's decision-making\n* Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](/en/sandboxing) settings with Read and Edit deny rules; both are merged into the final sandbox boundary\n* Network restrictions combine WebFetch permission rules with the sandbox's `allowedDomains` and `deniedDomains` lists\n\nWhen sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the [equivalent `Bash(*)` form](#match-all-uses-of-a-tool): the sandbox boundary substitutes for that whole-tool prompt. These checks still apply:\n\n* Content-scoped ask rules like `Bash(git push *)` still force a prompt\n* Explicit deny rules still apply\n* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt\n\nCommands that won't run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](/en/sandboxing#sandbox-modes) to change this behavior.\n\n## Managed settings\n\nFor organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can't be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, [server-managed settings](/en/server-managed-settings), or a self-hosted [Claude apps gateway](/en/claude-apps-gateway). See [settings files](/en/settings#settings-files) for delivery mechanisms and file locations.\n\n### Managed-only settings\n\nThe following settings are only read from managed settings. Placing them in user or project settings files has no effect.\n\n| Setting                                        | Description                                                                                                                                                                                                                                                                                                                         |\n| :--------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `allowAllClaudeAiMcps`                         | When `true`, claude.ai connectors load alongside a deployed `managed-mcp.json` instead of being suppressed by its exclusive control. See [Managed MCP configuration](/en/managed-mcp)                                                                                                                                               |\n| `allowedChannelPlugins`                        | Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](/en/channels#restrict-which-channel-plugins-can-run)                                                                                         |\n| `allowManagedHooksOnly`                        | When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked                                                                                                                                             |\n| `allowManagedMcpServersOnly`                   | When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](/en/managed-mcp)                                                                                                                                                       |\n| `allowManagedPermissionRulesOnly`              | When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Doesn't affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly`                                                                                                 |\n| `blockedMarketplaces`                          | Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](/en/plugin-marketplaces#managed-marketplace-restrictions)                                                                                                              |\n| `channelsEnabled`                              | Allow [channels](/en/channels) for the organization. See [enterprise controls](/en/channels#enterprise-controls) for the default on each plan                                                                                                                                                                                       |\n| `disableSideloadFlags`                         | {/* min-version: 2.1.193 */}Reject the `--plugin-dir`, `--plugin-url`, `--agents`, and `--mcp-config` CLI flags at startup. Without this, users can bypass `strictKnownMarketplaces` for a single run by passing these flags. See [`disableSideloadFlags`](/en/settings#available-settings). Requires Claude Code v2.1.193 or later |\n| `forceRemoteSettingsRefresh`                   | When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](/en/server-managed-settings#enforce-fail-closed-startup)                                                                                                                              |\n| `pluginTrustMessage`                           | Custom message appended to the plugin trust warning shown before installation                                                                                                                                                                                                                                                       |\n| `sandbox.filesystem.allowManagedReadPathsOnly` | When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources                                                                                                                                                                                                        |\n| `sandbox.network.allowManagedDomainsOnly`      | When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources                                                                                                |\n| `strictKnownMarketplaces`                      | Controls which plugin marketplace sources users can add and install plugins from. See [managed marketplace restrictions](/en/plugin-marketplaces#managed-marketplace-restrictions)                                                                                                                                                  |\n| `strictPluginOnlyCustomization`                | Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings. `true` locks all four surfaces; an array such as `[\"skills\", \"hooks\"]` locks only the named ones. See [`strictPluginOnlyCustomization`](/en/settings#strictpluginonlycustomization)             |\n| `wslInheritsWindowsSettings`                   | When `true` in the Windows HKLM registry key or `C:\\Program Files\\ClaudeCode\\managed-settings.json`, WSL reads managed settings from the Windows policy chain in addition to `/etc/claude-code`. See [Settings files](/en/settings#settings-files)                                                                                  |\n\n`disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode.\n\n<Note>\n  On Team and Enterprise plans, an Owner enables or disables [Remote Control](/en/remote-control) and [web sessions](/en/claude-code-on-the-web) organization-wide in [Claude Code admin settings](https://claude.ai/admin-settings/claude-code). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](/en/settings#available-settings) setting. Web sessions have no per-device managed settings key.\n</Note>\n\n## Settings precedence\n\nPermission rules follow the same [settings precedence](/en/settings#settings-precedence) as all other Claude Code settings:\n\n1. **Managed settings**: can't be overridden by any other level, including command line arguments\n2. **Command line arguments**: temporary session overrides\n3. **Local project settings** (`.claude/settings.local.json`)\n4. **Shared project settings** (`.claude/settings.json`)\n5. **User settings** (`~/.claude/settings.json`)\n\nIf a tool is denied at any level, no other level can allow it. For example, a managed settings deny can't be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define.\n\nThe same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules.\n\nEmbedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](/en/settings#settings-precedence) is set to `\"merge\"`; embedder values can tighten policy but not loosen it.\n\n## Project allow rules and workspace trust\n\n`permissions.allow` rules and `permissions.additionalDirectories` entries in a project's `.claude/settings.json` grant capability, so Claude Code applies them only after you accept the [workspace trust dialog](/en/security#additional-safeguards) for that workspace. Until then, Claude Code reads the rules but doesn't apply them. The trust dialog lists the allow rules and additional directories the folder would grant so you can review them before accepting. `deny` and `ask` rules aren't affected, since they only restrict.\n\nClaude Code saves trust per workspace, keyed on the git repository root or, outside a repository, the directory you started Claude Code from. When you start in your home directory, trust is held for the current session only and isn't written to disk; see the [additional safeguards](/en/security#additional-safeguards) note. Trusting a parent directory doesn't apply a nested project's allow rules.\n\n`.claude/settings.local.json` is your own file, so the workspace trust check usually doesn't apply to it. When a repository could have supplied the file, such as when it is committed to git or `.claude` is a symlink, its allow rules and additional directories go through the trust check like project settings.\n\nAllow rules and additional directories in `.claude/settings.local.json` also apply without workspace trust in two cases:\n\n* The directory you started Claude Code from isn't inside a git repository.\n* The session runs in your own configuration home: your home directory or any directory whose `.claude` subdirectory you've set as [`CLAUDE_CONFIG_DIR`](/en/env-vars).\n\nIn both cases the file is one you created rather than one a repository could have supplied, and a repository-committed `.claude/settings.local.json` still requires workspace trust. Versions 2.1.196 through 2.1.199 treated the file as repository-supplied in those workspaces, ignored its allow rules, and printed a [`this workspace has not been trusted`](/en/errors#workspace-has-not-been-trusted) warning to stderr. The two exceptions above match v2.1.195 and earlier and were restored in v2.1.200.\n\nAlso as of v2.1.200, a workspace whose allow rules or additional directories still aren't applied, but that never showed the trust dialog because a parent directory was already trusted, shows the dialog the next time you start Claude Code there interactively. The dialog offers two choices:\n\n* **Yes, I trust this folder**: saves trust for that workspace and applies the rules in the same session.\n* **No, continue without these permissions**: keeps working with those rules ignored. The dialog appears again in the next session.\n\nIn [non-interactive mode](/en/headless) with `-p`, no dialog appears and the rules stay ignored.\n\n## Example configurations\n\nThis [repository](https://github.com/anthropics/claude-code/tree/main/examples/settings) includes starter settings configurations for common deployment scenarios. Use these as starting points and adjust them to fit your needs.\n\n## See also\n\n* [Settings](/en/settings): complete configuration reference including the permission settings table\n* [Configure auto mode](/en/auto-mode-config): tell the auto mode classifier which infrastructure your organization trusts\n* [Sandboxing](/en/sandboxing): OS-level filesystem and network isolation for Bash commands\n* [Authentication](/en/authentication): set up user access to Claude Code\n* [Security](/en/security): security safeguards and best practices\n* [Hooks](/en/hooks-guide): automate workflows and extend permission evaluation\n"}]},"uuid":"2067d970-6eaa-45fe-9f30-80d5b00c2efc","timestamp":"2026-07-11T09:38:22.020Z","toolUseResult":{"bytes":48062,"code":200,"codeText":"OK","result":"> ## Documentation Index\n> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt\n> Use this file to discover all available pages before exploring further.\n\n# Configure permissions\n\n> Control what Claude Code can access and do with fine-grained permission rules, modes, and managed policies.\n\nClaude Code supports fine-grained permissions so that you can specify exactly what the agent is allowed to do and what it can't. Permission settings can be checked into version control and distributed to all developers in your organization, as well as customized by individual developers.\n\n## Permission system\n\nClaude Code uses a tiered permission system to balance power and safety:\n\n| Tool type         | Example          | Approval required                                                                   | \"Yes, don't ask again\" behavior               |\n| :---------------- | :--------------- | :---------------------------------------------------------------------------------- | :-------------------------------------------- |\n| Read-only         | File reads, Grep | No, within the [working directory and additional directories](#working-directories) | N/A                                           |\n| Bash commands     | Shell execution  | Yes, except a built-in set of [read-only commands](#read-only-commands)             | Permanently per project directory and command |\n| File modification | Edit/write files | Yes                                                                                 | Until session end                             |\n\n## Manage permissions\n\nYou can view and manage Claude Code's tool permissions with `/permissions`. This UI lists all permission rules and the `settings.json` file each rule comes from.\n\n* **Allow** rules let Claude Code use the specified tool without manual approval.\n* **Ask** rules prompt for confirmation whenever Claude Code tries to use the specified tool.\n* **Deny** rules prevent Claude Code from using the specified tool.\n\nRules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn't change the order.\n\nA broad deny rule like `Bash(aws *)` blocks every matching call, including calls that also match a narrower allow rule like `Bash(aws s3 ls)`, so a deny rule can't carry allowlist exceptions. The same precedence applies between ask and allow: a matching ask rule prompts even when a more specific allow rule also matches the same call.\n\nDeny rules behave differently depending on whether they name a tool or scope a pattern within one. A bare tool name like `Bash` removes the tool from Claude's context entirely, so Claude never sees it. A scoped rule like `Bash(rm *)` leaves the tool available and blocks matching calls when Claude attempts them.\n\n<Note>\n  Permission rules are enforced by Claude Code, not by the model. Instructions in your prompt or `CLAUDE.md` shape what Claude tries to do, but they don't change what Claude Code allows. To grant or revoke access, use `/permissions`, the rules described here, a [permission mode](/en/permission-modes), or a [PreToolUse hook](#extend-permissions-with-hooks).\n</Note>\n\n## Permission modes\n\nClaude Code supports several permission modes that control how it approves tool calls. See [Permission modes](/en/permission-modes) for when to use each one. Set the `defaultMode` in your [settings files](/en/settings#settings-files):\n\n| Mode                | Description                                                                                                                                                                                                                                                                  |\n| :------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `default`           | Standard behavior: prompts for permission on first use of each tool. {/* min-version: 2.1.200 */}Labeled Manual in the CLI and the VS Code and JetBrains extensions, and Claude Code accepts `manual` as an alias. The label and alias require Claude Code v2.1.200 or later |\n| `acceptEdits`       | Automatically accepts file edits and common filesystem commands such as `mkdir`, `touch`, `mv`, and `cp` for paths in the working directory or `additionalDirectories`                                                                                                       |\n| `plan`              | Claude reads files and runs read-only shell commands to explore but doesn't edit your source files. Labeled Plan in the CLI and the VS Code extension                                                                                                                        |\n| `auto`              | Auto-approves tool calls with background safety checks that verify actions align with your request                                                                                                                                                                           |\n| `dontAsk`           | Auto-denies tools unless pre-approved via `/permissions` or `permissions.allow` rules                                                                                                                                                                                        |\n| `bypassPermissions` | Skips permission prompts, except those forced by explicit `ask` rules. Root and home directory removals such as `rm -rf /` also still prompt as a circuit breaker                                                                                                            |\n\n<Warning>\n  `bypassPermissions` mode skips permission prompts, including for writes to `.git`, `.config/git`, `.claude`, `.vscode`, `.idea`, `.husky`, `.cargo`, `.devcontainer`, `.yarn`, and `.mvn`. Explicit `ask` rules still force a prompt, and removals targeting the filesystem root or home directory, such as `rm -rf /` and `rm -rf ~`, still prompt as a circuit breaker against model error. Only use this mode in isolated environments like containers or VMs where Claude Code can't cause damage.\n</Warning>\n\nTo prevent `bypassPermissions` or `auto` mode from being used, set `permissions.disableBypassPermissionsMode` or `permissions.disableAutoMode` to `\"disable\"` in any [settings file](/en/settings#settings-files). These are most useful in [managed settings](#managed-settings) where they can't be overridden.\n\n## Permission rule syntax\n\nPermission rules follow the format `Tool` or `Tool(specifier)`.\n\n### Match all uses of a tool\n\nTo match all uses of a tool, use only the tool name without parentheses:\n\n| Rule       | Effect                         |\n| :--------- | :----------------------------- |\n| `Bash`     | Matches all Bash commands      |\n| `WebFetch` | Matches all web fetch requests |\n| `Read`     | Matches all file reads         |\n\n`Bash(*)` is equivalent to `Bash` and matches all Bash commands. As a deny rule, both forms remove the tool from Claude's context.\n\n### Use specifiers for fine-grained control\n\nAdd a specifier in parentheses to match specific tool uses:\n\n| Rule                           | Effect                                                   |\n| :----------------------------- | :------------------------------------------------------- |\n| `Bash(npm run build)`          | Matches the exact command `npm run build`                |\n| `Read(./.env)`                 | Matches reading the `.env` file in the current directory |\n| `WebFetch(domain:example.com)` | Matches fetch requests to example.com                    |\n\n### Match by input parameter\n\nDeny and ask rules can match a top-level input parameter on any tool with `Tool(param:value)`. The rule matches when Claude calls the tool with that parameter set to that exact value. An allow rule for one parameter value wouldn't establish that the call is safe overall, so allow rules continue to use each tool's own specifier syntax. This works for any scalar parameter the tool accepts:\n\n| Rule                           | Matches                                      |\n| :----------------------------- | :------------------------------------------- |\n| `Agent(model:opus)`            | Agent calls that request the Opus model tier |\n| `Agent(isolation:worktree)`    | Agent calls that request a git worktree      |\n| `Bash(run_in_background:true)` | Bash calls that run in the background        |\n\nParameter matching follows these rules:\n\n* The parameter name must be a direct field of the tool's input, such as `model` on the Agent tool. Fields nested inside an object or array are not matchable\n* Each rule names one parameter. To gate on both `model` and `isolation`, write two rules, `Agent(model:opus)` and `Agent(isolation:worktree)`, rather than combining them in one rule\n* The value supports `*` as a wildcard that matches any sequence of characters, so `Agent(isolation:*)` matches any explicit isolation value. Without `*` the match is exact\n* A parameter the model omits is never matched, so `Agent(model:*)` doesn't match a call that leaves `model` unset\n* The value is compared against the literal input Claude sends, before any normalization. `Agent(model:opus)` matches the alias `opus` but not a full model ID. Run with [`--verbose`](/en/cli-reference) to see the exact parameter names and values in each tool call\n* Whitespace around the colon is ignored\n\nFields that a tool already matches with its own canonicalizing rules are not matchable this way: `command` for Bash and PowerShell, `file_path` for Read, Edit, and Write, `path` for Grep and Glob, `notebook_path` for NotebookEdit, and `url` for WebFetch. A rule like `Bash(command:rm *)` would be bypassable by a compound command, so Claude Code ignores it and emits a startup warning. Use `Bash(rm *)`, `Read(./path)`, or `WebFetch(domain:host)` instead.\n\n### Wildcard patterns\n\nBash rules support glob patterns with `*`. Wildcards can appear at any position in the command. This configuration allows npm and git commit commands while blocking git push:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"allow\": [\n      \"Bash(npm run *)\",\n      \"Bash(git commit *)\",\n      \"Bash(git * main)\",\n      \"Bash(* --version)\",\n      \"Bash(* --help *)\"\n    ],\n    \"deny\": [\n      \"Bash(git push *)\"\n    ]\n  }\n}\n```\n\nThe space before `*` matters: `Bash(ls *)` matches `ls -la` but not `lsof`, while `Bash(ls*)` matches both. The `:*` suffix is an equivalent way to write a trailing wildcard, so `Bash(ls:*)` matches the same commands as `Bash(ls *)`.\n\nThe permission dialog writes the space-separated form when you select \"Yes, don't ask again\" for a command prefix. The `:*` form is only recognized at the end of a pattern. In a pattern like `Bash(git:* push)`, the colon is treated as a literal character and won't match git commands.\n\n### Tool name wildcards\n\nDeny and ask rules also accept glob patterns in the tool-name position. The pattern must match the full tool name: `\"*\"` matches every tool, and `\"mcp__*\"` matches every MCP tool across all servers. A tool matched by a bare-name glob deny rule is removed from Claude's context, the same as a bare tool name. This configuration denies every MCP tool:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\n      \"mcp__*\"\n    ]\n  }\n}\n```\n\nAllow rules accept tool-name globs only after a literal `mcp__<server>__` prefix. The server segment must be glob-free so the rule names a specific server you configured. `mcp__puppeteer__*` matches every tool from the `puppeteer` server, and `mcp__github__get_*` matches its `get_` tools. An unanchored allow glob such as `\"*\"`, `\"B*\"`, or `\"mcp__*\"` is skipped with a warning and doesn't auto-approve anything.\n\nA deny or ask rule whose tool name matches no known tool produces a startup warning to catch typos. Tool names containing `_` or `*` are exempt from the check.\n\nThe label shown for a tool in the transcript and permission dialog can differ from its canonical name. For example, the tool labeled `Stop Task` in the transcript has the canonical name `TaskStop`. Permission rules and [hook matchers](/en/hooks) match the canonical name only, so a rule written as `Stop Task` doesn't match. For deny and ask rules, the startup warning above catches the mismatch. Use the canonical names listed in the [tools reference](/en/tools-reference).\n\n## Tool-specific permission rules\n\n### Bash\n\nBash permission rules support wildcard matching with `*`. Wildcards can appear at any position in the command, including at the beginning, middle, or end:\n\n* `Bash(npm run build)` matches the exact Bash command `npm run build`\n* `Bash(npm run test *)` matches Bash commands starting with `npm run test`\n* `Bash(npm *)` matches any command starting with `npm `\n* `Bash(* install)` matches any command ending with ` install`\n* `Bash(git * main)` matches commands like `git checkout main` and `git log --oneline main`\n\nA single `*` matches any sequence of characters including spaces, so one wildcard can span multiple arguments. `Bash(git *)` matches `git log --oneline --all`, and `Bash(git * main)` matches `git push origin main` as well as `git merge main`.\n\nWhen `*` appears at the end with a space before it (like `Bash(ls *)`), it enforces a word boundary, requiring the prefix to be followed by a space or end-of-string. For example, `Bash(ls *)` matches `ls -la` but not `lsof`. In contrast, `Bash(ls*)` without a space matches both `ls -la` and `lsof` because there's no word boundary constraint.\n\n#### Compound commands\n\n<Tip>\n  Claude Code is aware of shell operators, so a rule like `Bash(safe-cmd *)` won't give it permission to run the command `safe-cmd && other-cmd`. The recognized command separators are `&&`, `||`, `;`, `|`, `|&`, `&`, and newlines. A rule must match each subcommand independently.\n</Tip>\n\nWhen you approve a compound command with \"Yes, don't ask again\", Claude Code saves a separate rule for each subcommand that requires approval, rather than a single rule for the full compound string. For example, approving `git status && npm test` saves a rule for `npm test`, so future `npm test` invocations are recognized regardless of what precedes the `&&`. Subcommands like `cd` into a subdirectory generate their own Read rule for that path. Up to 5 rules may be saved for a single compound command.\n\n#### Process wrappers\n\nBefore matching Bash rules, Claude Code strips a fixed set of process wrappers so a rule like `Bash(npm test *)` also matches `timeout 30 npm test`. The recognized wrappers are `timeout`, `time`, `nice`, `nohup`, and `stdbuf`.\n\nBare `xargs` is also stripped, so `Bash(grep *)` matches `xargs grep pattern`. Stripping applies only when `xargs` has no flags: an invocation like `xargs -n1 grep pattern` is matched as an `xargs` command, so rules written for the inner command do not cover it.\n\nThis wrapper list is built in and is not configurable. Development environment runners such as `direnv exec`, `devbox run`, `mise exec`, `npx`, and `docker exec` are not in the list. Because these tools execute their arguments as a command, a rule like `Bash(devbox run *)` matches whatever comes after `run`, including `devbox run rm -rf .`. To approve work inside an environment runner, write a specific rule that includes both the runner and the inner command, such as `Bash(devbox run npm test)`. Add one rule per inner command you want to allow.\n\nExec wrappers such as `watch`, `setsid`, `ionice`, and `flock` always prompt and can't be auto-approved by a prefix rule like `Bash(watch *)`. The same applies to `find` with `-exec` or `-delete`: a `Bash(find *)` rule doesn't cover these forms. To approve a specific invocation, write an exact-match rule for the full command string.\n\n#### Read-only commands\n\nClaude Code recognizes a built-in set of Bash commands as read-only and runs them without a permission prompt in every mode. These include `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable; to require a prompt for one of these commands, add an `ask` or `deny` rule for it.\n\nUnquoted glob patterns are permitted for commands whose every flag is read-only, so `ls *.ts` and `wc -l src/*.py` run without a prompt. Commands with write-capable or exec-capable flags, such as `find`, `sort`, `sed`, and `git`, still prompt when an unquoted glob is present because the glob could expand to a flag like `-delete`.\n\nA `cd` into a path inside your working directory or an [additional directory](#working-directories) is also read-only. A compound command like `cd packages/api && ls` runs without a prompt when each part qualifies on its own. Combining `cd` with `git` in one compound command prompts when the `cd` changes into a different directory, since running `git` in a new directory can execute that directory's hooks. A `cd` whose target resolves to the current working directory is a no-op and doesn't trigger this prompt.\n\n<Warning>\n  Bash permission patterns that try to constrain command arguments are fragile. For example, `Bash(curl http://github.com/ *)` intends to restrict curl to GitHub URLs, but won't match variations like:\n\n  * Options before URL: `curl -X GET http://github.com/...`\n  * Different protocol: `curl https://github.com/...`\n  * Redirects: `curl -L http://bit.ly/xyz`, which redirects to GitHub\n  * Variables: `URL=http://github.com && curl $URL`\n  * Extra spaces: `curl  http://github.com`\n\n  For more reliable URL filtering, consider:\n\n  * **Restrict Bash network tools**: use deny rules to block `curl`, `wget`, and similar commands, then use the WebFetch tool with `WebFetch(domain:github.com)` permission for allowed domains\n  * **Use PreToolUse hooks**: implement a hook that validates URLs in Bash commands and blocks disallowed domains\n  * **Add CLAUDE.md guidance**: describe your allowed curl patterns in `CLAUDE.md`. This shapes what Claude tries but doesn't enforce a boundary, so pair it with one of the options above\n\n  Note that using WebFetch alone doesn't prevent network access. If Bash is allowed, Claude can still use `curl`, `wget`, or other tools to reach any URL.\n</Warning>\n\n### PowerShell\n\nPowerShell permission rules use the same shape as Bash rules. Wildcards with `*` match at any position, the `:*` suffix is equivalent to a trailing ` *`, and a bare `PowerShell` or `PowerShell(*)` matches every command. This configuration allows `Get-ChildItem` and `git commit` commands while blocking `Remove-Item`:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"allow\": [\n      \"PowerShell(Get-ChildItem *)\",\n      \"PowerShell(git commit *)\"\n    ],\n    \"deny\": [\n      \"PowerShell(Remove-Item *)\"\n    ]\n  }\n}\n```\n\nCommon aliases are canonicalized before matching. A rule written for the cmdlet name also matches its aliases, so `PowerShell(Get-ChildItem *)` matches `gci`, `ls`, and `dir` as well. Matching is case-insensitive.\n\nClaude Code parses the PowerShell AST and checks each command in a compound command independently. Pipeline operators `|`, statement separators `;`, and on PowerShell 7+ the chain operators `&&` and `||` split a compound command into subcommands. A rule must match every subcommand for the compound command to be allowed.\n\n### Read and Edit\n\n`Edit` rules apply to all built-in tools that edit files. Claude makes a best-effort attempt to apply `Read` rules to all built-in tools that read files like Grep and Glob, to `@file` mentions in your prompts, and to the selection and open-file context that a connected [IDE](/en/vs-code#the-built-in-ide-mcp-server) shares with Claude.\n\n<Warning>\n  Read and Edit deny rules apply to Claude's built-in file tools and to file commands Claude Code recognizes in Bash, such as `cat`, `head`, `tail`, and `sed`. They don't apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself. For OS-level enforcement that blocks all processes from accessing a path, [enable the sandbox](/en/sandboxing).\n</Warning>\n\nRead and Edit rules both follow the [gitignore](https://git-scm.com/docs/gitignore) specification with four distinct pattern types:\n\n| Pattern            | Meaning                              | Example                          | Matches                                          |\n| ------------------ | ------------------------------------ | -------------------------------- | ------------------------------------------------ |\n| `//path`           | Absolute path from filesystem root   | `Read(//Users/alice/secrets/**)` | `/Users/alice/secrets/**`                        |\n| `~/path`           | Path from home directory             | `Read(~/Documents/*.pdf)`        | `/Users/alice/Documents/*.pdf`                   |\n| `/path`            | Path relative to the settings source | `Edit(/src/**/*.ts)`             | `<project root>/src/**/*.ts` in project settings |\n| `path` or `./path` | Path relative to current directory   | `Read(*.env)`                    | `<cwd>/*.env`                                    |\n\n<Warning>\n  A pattern like `/Users/alice/file` isn't an absolute path. The single leading slash anchors at the settings source, not the filesystem root. Use `//Users/alice/file` for absolute paths.\n</Warning>\n\nA `/path` pattern anchors at the directory associated with the settings file that defines it, so the same rule matches different locations depending on where you put it:\n\n| Rule defined in                                            | `/path` resolves to        |\n| :--------------------------------------------------------- | :------------------------- |\n| Project or local settings, such as `.claude/settings.json` | `<project root>/path`      |\n| User settings at `~/.claude/settings.json`                 | `~/.claude/path`           |\n| A file passed with `--settings <file>`                     | `<directory of file>/path` |\n| CLI flags, `/permissions`, or session rules                | `<original cwd>/path`      |\n\nA deny rule such as `Read(/secrets/**)` in user settings blocks `~/.claude/secrets/**`, not a `secrets` directory in your project. To write a rule in user settings that applies inside every project, use a `//` absolute path or a `~/` home-relative path instead.\n\nOn Windows, paths are normalized to POSIX form before matching. `C:\\Users\\alice` becomes `/c/Users/alice`, so use `//c/**/.env` to match `.env` files anywhere on that drive. To match across all drives, use `//**/.env`.\n\nExamples:\n\n* `Edit(/docs/**)`: edits in `<project>/docs/`, not `/docs/` or `<project>/.claude/docs/`\n* `Read(~/.zshrc)`: reads your home directory's `.zshrc`\n* `Edit(//tmp/scratch.txt)`: edits the absolute path `/tmp/scratch.txt`\n* `Read(src/**)`: reads from `<current-directory>/src/`\n\nA rule only matches files under its anchor, so the anchor determines how far a deny rule reaches. Bare filenames follow gitignore semantics and match at any depth, so `Read(.env)` and `Read(**/.env)` are equivalent:\n\n| Deny rule                       | Blocks                                       | Does not block                                       |\n| ------------------------------- | -------------------------------------------- | ---------------------------------------------------- |\n| `Read(.env)` or `Read(**/.env)` | any `.env` at or under the current directory | `.env` in a parent directory or another project      |\n| `Read(//**/.env)`               | any `.env` anywhere on the filesystem        | nothing; the rule is anchored at the filesystem root |\n\n<Note>\n  In gitignore patterns, `*` matches within a single path segment and can appear at any position in the pattern, while `**` matches across directories. To allow all file access, use only the tool name without parentheses: `Read`, `Edit`, or `Write`.\n</Note>\n\nWhen you approve a file path with \"Yes, don't ask again\", Claude Code escapes gitignore pattern characters in that path, such as `[`, `]`, and `*`, so the generated rule matches only the literal path you approved. Rules you write yourself aren't escaped. Before v2.1.202, Claude Code saved the path unescaped, so a generated rule for a directory named `[2024-06] Reports` could fail to match its own path or match unintended sibling directories.\n\nWhen Claude accesses a symlink, permission rules check two paths: the symlink itself and the file it resolves to. Allow and deny rules treat that pair differently: allow rules fall back to prompting you, while deny rules block outright.\n\n* **Allow rules**: apply only when both the symlink path and its target match. A symlink inside an allowed directory that points outside it still prompts you.\n* **Deny rules**: apply when either the symlink path or its target matches. A symlink that points to a denied file is itself denied.\n\nFor example, with `Read(./project/**)` allowed and `Read(~/.ssh/**)` denied, a symlink at `./project/key` pointing to `~/.ssh/id_rsa` is blocked: the target fails the allow rule and matches the deny rule.\n\n### WebFetch\n\nWebFetch rules use a `domain:` prefix and match against the hostname of the requested URL. Matching is case-insensitive, supports `*` wildcards, and strips a trailing `.` from both the rule and the hostname so `example.com.` and `example.com` are treated the same.\n\n* `WebFetch(domain:example.com)` matches requests to `example.com`\n* `WebFetch(domain:*.example.com)` matches any subdomain at any depth, such as `api.example.com` or `a.b.example.com`, but not `example.com` itself\n* `WebFetch(domain:*)` matches every domain and is equivalent to a bare `WebFetch` rule\n\nIn any position other than a leading `*.` or a bare `*`, the wildcard matches only the text between two dots. `WebFetch(domain:example.*)` matches `example.org`, where `*` becomes `org`, but not `example.evil.com`, where `*` would have to become `evil.com` and cross a dot. This keeps a trailing wildcard from matching domains an attacker could register.\n\n### MCP\n\nMCP rules use the server name as configured in Claude Code, optionally followed by the name of a tool from that server.\n\n* `mcp__puppeteer` matches any tool provided by the `puppeteer` server\n* `mcp__puppeteer__*` uses wildcard syntax and also matches all tools from the `puppeteer` server\n* `mcp__puppeteer__puppeteer_navigate` matches the `puppeteer_navigate` tool provided by the `puppeteer` server\n\n### Agent (subagents)\n\nUse `Agent(AgentName)` rules to control which [subagents](/en/sub-agents) Claude can use:\n\n* `Agent(Explore)` matches the Explore subagent\n* `Agent(Plan)` matches the Plan subagent\n* `Agent(my-custom-agent)` matches a custom subagent named `my-custom-agent`\n\nAdd these rules to the `deny` array in your settings or use the `--disallowedTools` CLI flag to disable specific agents. To disable the Explore agent:\n\n```json theme={null}\n{\n  \"permissions\": {\n    \"deny\": [\"Agent(Explore)\"]\n  }\n}\n```\n\n### Cd\n\n`Cd` rules control which directories the [`/cd` command](/en/commands) can move the session to. `Cd` is not a model-invocable tool: Claude can't call it, and the rules apply only when you run `/cd` yourself.\n\nA bare `Cd` deny rule disables `/cd` entirely. A `Cd(<path-pattern>)` deny rule blocks matching targets. Deny rules check every spelling of the target, including each symlink hop it resolves through, so a rule written for one path also blocks targets that resolve to it.\n\nAdding any `Cd` allow rule switches `/cd` to allowlist mode: the resolved target directory must match one of your allow rules, or `/cd` refuses. With no `Cd` rules configured, `/cd` keeps its default behavior and prompts you to trust an unfamiliar directory.\n\nPath patterns share the `//`, `~/`, and `/` anchors from [Read and Edit rules](#read-and-edit), but matching is anchored to the whole directory path rather than gitignore-style. `*` matches exactly one path segment and `**` matches across segments. A trailing `/**` also matches its named root.\n\n| Rule                  | Matches                                   | Does not match               |\n| --------------------- | ----------------------------------------- | ---------------------------- |\n| `Cd(~/code/*)`        | `~/code/app`                              | `~/code/app/src`, `~/code`   |\n| `Cd(~/code/**)`       | `~/code` and any directory under it       | directories outside `~/code` |\n| `Cd(**/node_modules)` | any `node_modules` directory at any depth | `node_modules/pkg`           |\n\n## Extend permissions with hooks\n\n[Claude Code hooks](/en/hooks-guide) provide a way to register custom shell commands to perform permission evaluation at runtime. When Claude Code makes a tool call, PreToolUse hooks run before the permission prompt. The hook output can deny the tool call, force a prompt, or skip the prompt to let the call proceed.\n\nHook decisions don't bypass permission rules. Deny and ask rules are evaluated regardless of what a PreToolUse hook returns, so a matching deny rule blocks the call and a matching ask rule still prompts even when the hook returned `\"allow\"` or `\"ask\"`. This preserves the deny-first precedence described in [Manage permissions](#manage-permissions), including deny rules set in managed settings.\n\nA blocking hook also takes precedence over allow rules. A hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block applies even when an allow rule would otherwise let the call proceed. To run all Bash commands without prompts except for a few you want blocked, add `\"Bash\"` to your allow list and register a PreToolUse hook that rejects those specific commands. See [Block edits to protected files](/en/hooks-guide#block-edits-to-protected-files) for a hook script you can adapt.\n\n## Working directories\n\nBy default, Claude has access to files in the directory where you launched it. You can extend this access:\n\n* **During startup**: use `--add-dir <path>` CLI argument\n* **During session**: use `/add-dir` command\n* **Persistent configuration**: add to `additionalDirectories` in [settings files](/en/settings#settings-files)\n\nFiles in additional directories follow the same permission rules as the original working directory: they become readable without prompts, and file editing permissions follow the current permission mode.\n\nTo change the session's primary working directory instead of adding another, use [`/cd`](/en/commands). The `/cd` command requires Claude Code v2.1.169 or later. Unlike `/add-dir`, it relocates the session: the new directory's `CLAUDE.md` is loaded and `--resume` finds the session from there.\n\n### Additional directories grant file access, not configuration\n\nAdding a directory extends where Claude can read and edit files. It doesn't make that directory a full configuration root: most `.claude/` configuration is not discovered from additional directories, though a few types are loaded as exceptions.\n\nThese exceptions apply only to directories added with the `--add-dir` flag or the `/add-dir` command. Directories listed in `permissions.additionalDirectories` in a settings file grant file access only and don't load any of the configuration below.\n\nThe following configuration types are loaded from `--add-dir` directories:\n\n| Configuration                                                                         | Loaded from `--add-dir`                                                                                                                                            |\n| :------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [Skills](/en/skills) in `.claude/skills/`                                             | Yes, with live reload                                                                                                                                              |\n| [Subagents](/en/sub-agents) in `.claude/agents/`                                      | Yes                                                                                                                                                                |\n| [Settings](/en/settings) in `.claude/settings.json` and `.claude/settings.local.json` | `enabledPlugins` and `extraKnownMarketplaces` keys only                                                                                                            |\n| [CLAUDE.md](/en/memory) files, `.claude/rules/`, and `CLAUDE.local.md`                | Only when `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` is set. `CLAUDE.local.md` additionally requires the `local` setting source, which is enabled by default |\n\nCommands and output styles are discovered from the current working directory and its parents, your user directory at `~/.claude/`, and managed settings. Hooks and other `settings.json` keys load from the current working directory's `.claude/` folder with no parent-directory fallback, alongside your user `~/.claude/settings.json` and managed settings. To share that configuration across projects, use one of these approaches:\n\n* **User-level configuration**: place files in `~/.claude/agents/`, `~/.claude/output-styles/`, or `~/.claude/settings.json` to make them available in every project\n* **Plugins**: package and distribute configuration as a [plugin](/en/plugins) that teams can install\n* **Launch from the config directory**: run Claude Code from the directory containing the `.claude/` configuration you want\n\n## How permissions interact with sandboxing\n\nPermissions and [sandboxing](/en/sandboxing) are complementary security layers:\n\n* **Permissions** control which tools Claude Code can use and which files or domains it can access. They apply to all tools, including Bash, Read, Edit, WebFetch, and MCP.\n* **Sandboxing** provides OS-level enforcement that restricts the Bash tool's filesystem and network access. It applies only to Bash commands and their child processes.\n\nUse both for defense-in-depth:\n\n* Permission deny rules block Claude from even attempting to access restricted resources\n* Sandbox restrictions prevent Bash commands from reaching resources outside defined boundaries, even if a prompt injection bypasses Claude's decision-making\n* Filesystem restrictions in the sandbox combine the [`sandbox.filesystem`](/en/sandboxing) settings with Read and Edit deny rules; both are merged into the final sandbox boundary\n* Network restrictions combine WebFetch permission rules with the sandbox's `allowedDomains` and `deniedDomains` lists\n\nWhen sandboxing is enabled with `autoAllowBashIfSandboxed: true`, which is the default, sandboxed Bash commands run without prompting even if your permissions include a bare `Bash` ask rule, or the [equivalent `Bash(*)` form](#match-all-uses-of-a-tool): the sandbox boundary substitutes for that whole-tool prompt. These checks still apply:\n\n* Content-scoped ask rules like `Bash(git push *)` still force a prompt\n* Explicit deny rules still apply\n* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a prompt\n\nCommands that won't run sandboxed, such as excluded commands, respect the bare `Bash` ask rule as usual. See [sandbox modes](/en/sandboxing#sandbox-modes) to change this behavior.\n\n## Managed settings\n\nFor organizations that need centralized control over Claude Code configuration, administrators can deploy managed settings that can't be overridden by user or project settings. These policy settings follow the same format as regular settings files and can be delivered through MDM/OS-level policies, managed settings files, [server-managed settings](/en/server-managed-settings), or a self-hosted [Claude apps gateway](/en/claude-apps-gateway). See [settings files](/en/settings#settings-files) for delivery mechanisms and file locations.\n\n### Managed-only settings\n\nThe following settings are only read from managed settings. Placing them in user or project settings files has no effect.\n\n| Setting                                        | Description                                                                                                                                                                                                                                                                                                                         |\n| :--------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `allowAllClaudeAiMcps`                         | When `true`, claude.ai connectors load alongside a deployed `managed-mcp.json` instead of being suppressed by its exclusive control. See [Managed MCP configuration](/en/managed-mcp)                                                                                                                                               |\n| `allowedChannelPlugins`                        | Allowlist of channel plugins that may push messages. Replaces the default Anthropic allowlist when set. Requires `channelsEnabled: true`. See [Restrict which channel plugins can run](/en/channels#restrict-which-channel-plugins-can-run)                                                                                         |\n| `allowManagedHooksOnly`                        | When `true`, only managed hooks, SDK hooks, and hooks from plugins force-enabled in managed settings `enabledPlugins` are loaded. User, project, and all other plugin hooks are blocked                                                                                                                                             |\n| `allowManagedMcpServersOnly`                   | When `true`, only `allowedMcpServers` from managed settings are respected. `deniedMcpServers` still merges from all sources. See [Managed MCP configuration](/en/managed-mcp)                                                                                                                                                       |\n| `allowManagedPermissionRulesOnly`              | When `true`, prevents user and project settings from defining `allow`, `ask`, or `deny` permission rules. Only rules in managed settings apply. Doesn't affect the MCP server allowlist; for that, set `allowManagedMcpServersOnly`                                                                                                 |\n| `blockedMarketplaces`                          | Blocklist of marketplace sources. Blocked sources are checked before downloading, so they never touch the filesystem. See [managed marketplace restrictions](/en/plugin-marketplaces#managed-marketplace-restrictions)                                                                                                              |\n| `channelsEnabled`                              | Allow [channels](/en/channels) for the organization. See [enterprise controls](/en/channels#enterprise-controls) for the default on each plan                                                                                                                                                                                       |\n| `disableSideloadFlags`                         | {/* min-version: 2.1.193 */}Reject the `--plugin-dir`, `--plugin-url`, `--agents`, and `--mcp-config` CLI flags at startup. Without this, users can bypass `strictKnownMarketplaces` for a single run by passing these flags. See [`disableSideloadFlags`](/en/settings#available-settings). Requires Claude Code v2.1.193 or later |\n| `forceRemoteSettingsRefresh`                   | When `true`, blocks CLI startup until remote managed settings are freshly fetched and exits if the fetch fails. See [fail-closed enforcement](/en/server-managed-settings#enforce-fail-closed-startup)                                                                                                                              |\n| `pluginTrustMessage`                           | Custom message appended to the plugin trust warning shown before installation                                                                                                                                                                                                                                                       |\n| `sandbox.filesystem.allowManagedReadPathsOnly` | When `true`, only `filesystem.allowRead` paths from managed settings are respected. `denyRead` still merges from all sources                                                                                                                                                                                                        |\n| `sandbox.network.allowManagedDomainsOnly`      | When `true`, only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are respected. Non-allowed domains are blocked automatically without prompting the user. Denied domains still merge from all sources                                                                                                |\n| `strictKnownMarketplaces`                      | Controls which plugin marketplace sources users can add and install plugins from. See [managed marketplace restrictions](/en/plugin-marketplaces#managed-marketplace-restrictions)                                                                                                                                                  |\n| `strictPluginOnlyCustomization`                | Block skills, agents, hooks, and MCP servers from user and project sources, so they can only come from plugins or managed settings. `true` locks all four surfaces; an array such as `[\"skills\", \"hooks\"]` locks only the named ones. See [`strictPluginOnlyCustomization`](/en/settings#strictpluginonlycustomization)             |\n| `wslInheritsWindowsSettings`                   | When `true` in the Windows HKLM registry key or `C:\\Program Files\\ClaudeCode\\managed-settings.json`, WSL reads managed settings from the Windows policy chain in addition to `/etc/claude-code`. See [Settings files](/en/settings#settings-files)                                                                                  |\n\n`disableBypassPermissionsMode` is typically placed in managed settings to enforce organizational policy, but it works from any scope. A user can set it in their own settings to lock themselves out of bypass mode.\n\n<Note>\n  On Team and Enterprise plans, an Owner enables or disables [Remote Control](/en/remote-control) and [web sessions](/en/claude-code-on-the-web) organization-wide in [Claude Code admin settings](https://claude.ai/admin-settings/claude-code). Remote Control can additionally be disabled per device with the [`disableRemoteControl`](/en/settings#available-settings) setting. Web sessions have no per-device managed settings key.\n</Note>\n\n## Settings precedence\n\nPermission rules follow the same [settings precedence](/en/settings#settings-precedence) as all other Claude Code settings:\n\n1. **Managed settings**: can't be overridden by any other level, including command line arguments\n2. **Command line arguments**: temporary session overrides\n3. **Local project settings** (`.claude/settings.local.json`)\n4. **Shared project settings** (`.claude/settings.json`)\n5. **User settings** (`~/.claude/settings.json`)\n\nIf a tool is denied at any level, no other level can allow it. For example, a managed settings deny can't be overridden by `--allowedTools`, and `--disallowedTools` can add restrictions beyond what managed settings define.\n\nThe same holds across settings scopes: if user settings allow a permission and project settings deny it, the deny rule blocks it. The reverse is also true: a user-level deny blocks a project-level allow, because deny rules from any scope are evaluated before allow rules.\n\nEmbedding hosts can supply additional managed policy via the SDK `managedSettings` option when [`parentSettingsBehavior`](/en/settings#settings-precedence) is set to `\"merge\"`; embedder values can tighten policy but not loosen it.\n\n## Project allow rules and workspace trust\n\n`permissions.allow` rules and `permissions.additionalDirectories` entries in a project's `.claude/settings.json` grant capability, so Claude Code applies them only after you accept the [workspace trust dialog](/en/security#additional-safeguards) for that workspace. Until then, Claude Code reads the rules but doesn't apply them. The trust dialog lists the allow rules and additional directories the folder would grant so you can review them before accepting. `deny` and `ask` rules aren't affected, since they only restrict.\n\nClaude Code saves trust per workspace, keyed on the git repository root or, outside a repository, the directory you started Claude Code from. When you start in your home directory, trust is held for the current session only and isn't written to disk; see the [additional safeguards](/en/security#additional-safeguards) note. Trusting a parent directory doesn't apply a nested project's allow rules.\n\n`.claude/settings.local.json` is your own file, so the workspace trust check usually doesn't apply to it. When a repository could have supplied the file, such as when it is committed to git or `.claude` is a symlink, its allow rules and additional directories go through the trust check like project settings.\n\nAllow rules and additional directories in `.claude/settings.local.json` also apply without workspace trust in two cases:\n\n* The directory you started Claude Code from isn't inside a git repository.\n* The session runs in your own configuration home: your home directory or any directory whose `.claude` subdirectory you've set as [`CLAUDE_CONFIG_DIR`](/en/env-vars).\n\nIn both cases the file is one you created rather than one a repository could have supplied, and a repository-committed `.claude/settings.local.json` still requires workspace trust. Versions 2.1.196 through 2.1.199 treated the file as repository-supplied in those workspaces, ignored its allow rules, and printed a [`this workspace has not been trusted`](/en/errors#workspace-has-not-been-trusted) warning to stderr. The two exceptions above match v2.1.195 and earlier and were restored in v2.1.200.\n\nAlso as of v2.1.200, a workspace whose allow rules or additional directories still aren't applied, but that never showed the trust dialog because a parent directory was already trusted, shows the dialog the next time you start Claude Code there interactively. The dialog offers two choices:\n\n* **Yes, I trust this folder**: saves trust for that workspace and applies the rules in the same session.\n* **No, continue without these permissions**: keeps working with those rules ignored. The dialog appears again in the next session.\n\nIn [non-interactive mode](/en/headless) with `-p`, no dialog appears and the rules stay ignored.\n\n## Example configurations\n\nThis [repository](https://github.com/anthropics/claude-code/tree/main/examples/settings) includes starter settings configurations for common deployment scenarios. Use these as starting points and adjust them to fit your needs.\n\n## See also\n\n* [Settings](/en/settings): complete configuration reference including the permission settings table\n* [Configure auto mode](/en/auto-mode-config): tell the auto mode classifier which infrastructure your organization trusts\n* [Sandboxing](/en/sandboxing): OS-level filesystem and network isolation for Bash commands\n* [Authentication](/en/authentication): set up user access to Claude Code\n* [Security](/en/security): security safeguards and best practices\n* [Hooks](/en/hooks-guide): automate workflows and extend permission evaluation\n","durationMs":232,"url":"https://code.claude.com/docs/en/permissions.md"},"sourceToolAssistantUUID":"e2b5046a-dbed-4ebf-bad9-862bb22325bc","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"2067d970-6eaa-45fe-9f30-80d5b00c2efc","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3f78Yu43bL5NsTif2A","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"","signature":"EpIICpMBCA8YAipAxDO7CuGCW57gW6wt2hVs2oWl+NVAREy96LDzo6D9rgRhZ0J0PG/hruO0EQkM/U/DglRxXTQKc02m9k6rblgosTIZY2xhdWRlLWhhaWt1LTQtNS0yMDI1MTAwMTgAQgh0aGlua2luZ1okNGJkZDE1Y2MtNDcxZS00ZTU2LWJhMWEtM2QzZDViNGYwMTdjEgytlMpSfobKOC++09QaDGxmbhCIgxjuE2rA9iIw6jbEFm9hVzi6OHHN7ckdIJihLE34nmJvJVtnbp57STDyRCpBSrhcsbRnjUKZnsZUKqsGx7AfzuZhf1PNpBr9+7nacOEzy/pf3IQJh/aTx7/QiIzEEA90XHSBWtLn8Pl1OyVzKYWO2Fae+eEO28pPKfVg6okUpef7zurJ2lo03JPqOCmlD9DFYH9wGC+dK1PnSxzOj2Zp4ISLECdYpqvGkNSXY7wMnoYXRBKXozjKTlidih88EWpR0F6dFlLBZ0OeKvh1A55ngq9O8GxYFNsReodiBS/DOBNC30ibBUxd45y7Ud8qU2D1bQsliZ2Baq2EeVu/1aO4g9kmumhY3YNRZstgkmdxtQQmLToUDO0lknnLsgM7aI7g/xaEPKSuZxNr8KNQWCRP6bVgigwAYO0vEpaVdue2P8oldJ6VI8XcMO9Kry7ky+8OWuMujlDYzfVBl1n9GOE1iiYOCW/Y6AfLzQ7j9k8Rmmwa09Wa5WrD201Wq2HNZ/QHr6T+WfxsBUfkngaKN/RNoAO3aOMtQicmzeartAcHze0VghojpHy0RiH5uhVN6X2CSFr+bKIGKTSdxU6eXprUrtWlNajQluhrFD+mbl8W3Ioa4vThsWosCAr+4rVLOIk4CnonBDZEeF18qLmJ6vYiigl14gxAQAtYbKWfWimYFQtJpAEbiN3BYJwYA3sKRcHo50zvdJisEb2+uCcEUnKSmEMsoQQsJDElCycwXc9UMU+5KLx5F9n6mqvHp/EmRr92N95sfZp5m68C2+15D7eJCQK+ebGkRuhzNBlwlFufmdOUN8F/+CIp+MpwX2hXwjLm/AWH6eVnM9ipselVfhAogBsT9yBs3km6m61QrUr4X9JgT2xXKOyeyOwoH01r7e/z0L2KJUhHKgKWDFf/auDzF9IOrU2UYBTZAgfJBygs98PNsk9Uc15OxlXHFp3tjdwZ1OTcWSi8jsIs3cTA1OTtOl6D/sS51DkOKnQ9GylzScSNvMzTPN5Mll6h99OXRmEfpsbRZemI/QxV73L3eSrC55alTIG8Dr6HhV6s1uwj8jSp+lHpkUbxWBKL4ymi1/JGX/3usNORiWcyNVolRB7nwIh7iXpMVOt2sssWogi/FJ3DQiswAs6cpFFALqusdXRRw6A45ccJ2RgB"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":12194,"cache_read_input_tokens":42345,"cache_creation":{"ephemeral_5m_input_tokens":12194,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"diagnostics":null},"requestId":"req_011Ccv3f6CVaNQrYcsVsmtmq","attributionAgent":"claude-code-guide","type":"assistant","uuid":"475ad8c3-193f-4efc-a452-54d14c051ccf","timestamp":"2026-07-11T09:38:26.525Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
{"parentUuid":"475ad8c3-193f-4efc-a452-54d14c051ccf","isSidechain":true,"agentId":"aa6395b4c140e1c9d","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011Ccv3f78Yu43bL5NsTif2A","type":"message","role":"assistant","content":[{"type":"text","text":"Based on the official Claude Code documentation, here are precise answers:\n\n---\n\n## 1. User/Global scope registration file & JSON structure\n\n**File path:** `$CLAUDE_CONFIG_DIR/.claude.json` (or `~/.claude.json` if `CLAUDE_CONFIG_DIR` is unset)\n\n**JSON structure** for a stdio server at user scope:\n\n```json\n{\n  \"mcpServers\": {\n    \"aicontrol\": {\n      \"type\": \"stdio\",\n      \"command\": \"/abs/path/to/app\",\n      \"args\": [\"--mcp-panel\"]\n    }\n  }\n}\n```\n\nClaude Code reads MCP servers from this file. The `mcpServers` key at the top level applies to all projects (user scope). If you want it per-project only, use `.mcp.json` in the project root instead.\n\n**Environment variable:** If `CLAUDE_CONFIG_DIR` is set, Claude Code looks in `$CLAUDE_CONFIG_DIR/.claude.json`. Otherwise it defaults to `~/.claude.json`.\n\n---\n\n## 2. Trust/approval for project `.mcp.json`\n\nProject-scoped servers (from `.mcp.json`) require approval the first time Claude sees them. To auto-approve without the interactive \"trust this MCP server?\" prompt, add this to `.claude/settings.json` (project scope):\n\n```json\n{\n  \"enabledMcpjsonServers\": [\"aicontrol\"]\n}\n```\n\nOr to enable all project-scoped servers without prompt:\n\n```json\n{\n  \"enableAllProjectMcpServers\": true\n}\n```\n\n**Version note:** As of v2.1.196, workspace trust must be accepted first (the \"Do you trust this folder?\" dialog). Once workspace trust is set, the `enabledMcpjsonServers` or `enableAllProjectMcpServers` setting in `.claude/settings.json` skips the per-server approval prompt.\n\n---\n\n## 3. Exact permission string for pre-authorization\n\nThe MCP tool naming follows: `mcp__<servername>__<toolname>`\n\nFor your server `aicontrol` with tool `write_panel`:\n\n```json\n{\n  \"permissions\": {\n    \"allow\": [\n      \"mcp__aicontrol__write_panel\"\n    ]\n  }\n}\n```\n\n**Wildcard for all server tools:** Yes, both of these work:\n- `\"mcp__aicontrol\"` — matches all tools from the server\n- `\"mcp__aicontrol__*\"` — explicit wildcard, same effect\n\nPlace this rule in `$CLAUDE_CONFIG_DIR/settings.json` (user-scoped) or `.claude/settings.json` (project-scoped) depending on your needs.\n\n---\n\n## 4. Environment variable inheritance to stdio server subprocess\n\n**Yes, the child process inherits the parent's environment by default.**\n\nAdditionally, Claude Code **always sets `CLAUDE_PROJECT_DIR`** in the stdio server's environment to the project root, so your server can read it.\n\nTo pass or set additional env vars, add an `env` object to the server config in `.mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"aicontrol\": {\n      \"type\": \"stdio\",\n      \"command\": \"/abs/path/to/app\",\n      \"args\": [\"--mcp-panel\"],\n      \"env\": {\n        \"AI_CONTROL_PANEL\": \"/some/path\",\n        \"CUSTOM_VAR\": \"value\"\n      }\n    }\n  }\n}\n```\n\nThe `env` object is merged with the parent's environment; it doesn't replace it. Variable expansion is supported: `${EXISTING_VAR}` or `${EXISTING_VAR:-default}`.\n\n---\n\n## 5. Version-specific differences\n\nKey version notes for MCP server registration:\n\n- **v2.1.196+**: Project-scoped `.mcp.json` servers require workspace trust acceptance before `enabledMcpjsonServers` applies\n- **v2.1.195+**: Environment variable expansion in `.mcp.json` supports `${VAR}` and `${VAR:-default}` syntax\n- **v2.1.121+**: `alwaysLoad` field available to exempt a server from tool deferral\n- **v2.1.203+**: `CLAUDE_PROJECT_DIR` set in every stdio server's environment (before this, it wasn't)\n\nNo breaking schema changes in the stdio registration JSON between recent versions. The `type`, `command`, `args`, and `env` fields have remained stable.\n\n---\n\n**Summary for your Rust code:**\n\n- **User-scoped (all projects):** Write to `$CLAUDE_CONFIG_DIR/.claude.json` with key `mcpServers.aicontrol`\n- **Project-scoped (one project):** Write to `./.mcp.json` in project root with key `mcpServers.aicontrol`, then add `enabledMcpjsonServers: [\"aicontrol\"]` to `.claude/settings.json`\n- **Permission:** `\"mcp__aicontrol__write_panel\"` in `permissions.allow` array\n- **Env vars:** Set `env: { \"AI_CONTROL_PANEL\": \"...\" }` in the server config; inheritance is automatic"}],"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":12194,"cache_read_input_tokens":42345,"output_tokens":1498,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":12194},"inference_geo":"not_available","iterations":[{"input_tokens":8,"output_tokens":1498,"cache_read_input_tokens":42345,"cache_creation_input_tokens":12194,"cache_creation":{"ephemeral_5m_input_tokens":12194,"ephemeral_1h_input_tokens":0},"type":"message"}],"speed":"standard"},"diagnostics":null},"requestId":"req_011Ccv3f6CVaNQrYcsVsmtmq","attributionAgent":"claude-code-guide","type":"assistant","uuid":"76d16c0b-4523-4a90-a8ff-ec140605dc41","timestamp":"2026-07-11T09:38:40.141Z","userType":"external","entrypoint":"cli","cwd":"/Users/marcus.hinz/claude-projects/ai-control","sessionId":"f7704328-4eb4-4f0f-bf42-da68abab401d","version":"2.1.207","gitBranch":"main"}
