Feature Request: Runtime MCP Server Toggle
Status Closed — not planned
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 12 comments · opened Aug 22, 2025 · closed Jan 10, 2026
## Feature Request: Runtime MCP Server Toggle
### Problem
Currently, enabling/disabling MCP servers requires editing .claude/settings.local.json and restarting the Claude Code session. This is inefficient when working on projects that need different MCP
servers for different tasks.
### Proposed Solution
Add ability to dynamically enable/disable configured MCP servers during a session without restart.
### Suggested Implementation
- Slash command:
/mcp enable supabase playwright - Slash command:
/mcp disable supabase - Slash command:
/mcp list(show available/enabled) - UI toggle in settings panel
### Use Case
Working on a project that sometimes needs Supabase MCP for database work, sometimes Playwright for testing, but not both simultaneously to save context window.
### Current Workaround
Manual editing of settings file + restart
12 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Hey, this is a great feature request. I've run into the exact same issue where I want to toggle different "profiles" of tools without having to restart my session or manually edit JSON files every time.
While we wait for an official feature like
/mcp enable, I've found a pretty good workaround using the way Claude Code handles configuration scopes. It's a bit of a setup, but once it's done, you can launch Claude with different MCP sets using a single command.Here's how I've been handling it:
The "Profiles" Workaround
The main idea is to define all your MCP servers in a shared
projectscope, and then use a local, git-ignored settings file to control which ones are active. You can then use simple shell aliases or functions to swap out that local settings file before you launchclaude.Step 1: Define All Servers in the Project Scope
First, add all the MCP servers your project might need to the shared
.mcp.jsonfile. This is great because it gets checked into git and your whole team can use the same server definitions.Run these commands from your project root:
Now you'll have a
.mcp.jsonfile in your repo with both server definitions.Step 2: Use
enabledMcpjsonServersfor ControlAccording to the settings docs, you can control which project servers are active using a key called
enabledMcpjsonServersin your.claude/settings.local.jsonfile. This file is local to you and isn't checked into git.So, you can create different "profile" files. For example:
Create
~/.claude/mcp_profiles/db-only.json:Create
~/.claude/mcp_profiles/testing-only.json:Step 3: Create Shell Aliases to Launch Claude with a Specific Profile
Now, tie it all together with some shell functions or aliases in your
.bashrc,.zshrc, etc. These functions will copy the right profile into place as.claude/settings.local.jsonand then launch Claude Code.After adding those and reloading your shell (
source ~/.zshrc), you can just run:claude-dbto start a session for database work.claude-test "write a test for the login page"to start a session for testing.claude-allto start a session with everything enabled.It's not quite a runtime toggle, but it completely avoids manual file editing and makes launching a session with the right toolset a single command.
Hope this helps you out in the meantime! Still, +1 for the built-in
/mcp enable/disablefeature. That would be even smoother.Is there a way to make it so that certain sub agents can boot with specific MCP Servers? It's a pain to clutter the context of the main agent with tools that only a subagent is intended to use. It seems like this "dynamic loading" of MCP servers would enable that critical capacity.
That's a fantastic question, and you've hit on a really powerful and important use case for subagents! The short answer is yes, you absolutely can do this, and it's one of the key design benefits of the subagent system. You don't even need to wait for the dynamic loading feature; you can set this up right now.
The core idea is that you configure all your MCP servers once for the project, but then you use the subagent's
toolslist to grant it exclusive access to certain MCP tools. This keeps your main agent's toolset clean and focused.Here’s a step-by-step guide on how to achieve this:
The "Specialized Tool Belts" Pattern for Subagents
This pattern ensures that only the right agent has access to the right tools, preventing the main agent from getting confused by a huge list of tools it doesn't need for its current task.
Step 1: Configure All MCP Servers at the Project Level
First, make sure all the MCP servers you might need are defined in your shared
.mcp.jsonfile. This makes them available to the project, but not necessarily enabled for every agent.Now, your project is aware of these servers, but we can control who gets to use them.
Step 2: Create Subagents with Specific Tool Permissions
This is the key step. In each subagent's markdown file, you'll use the
toolsfrontmatter key to assign it a specific "tool belt."Let's create a
data-analystsubagent that only has access to the database tools.File:
.claude/agents/data-analyst.mdAnd here's a
qa-engineersubagent that only gets the Playwright testing tools.File:
.claude/agents/qa-engineer.mdImportant Note on MCP Tool Naming:
As you can see, you grant access to all tools from a specific MCP server by using the format
mcp__<server-name>. For example,mcp__supabasegives the subagent access to all tools provided by thesupabaseserver.Step 3: (Optional but Recommended) Restrict the Main Agent
To fully solve your context clutter problem, you can tell the main agent to ignore these specialized tools by default. You do this in your
.claude/settings.jsonfile.File:
.claude/settings.jsonHow It All Works Together
claude, it loads the MCP server configurations from.mcp.json.settings.jsonand applies thedenyrule, hiding thesupabaseandplaywrighttools from the main agent. Your main conversation context is now clean!"Fetch the top 10 users by purchase volume from the database."descriptionof yourdata-analystsubagent.data-analystsubagent.mcp__supabase. It can now successfully query the database.This pattern of "central registration, delegated permissions" is super powerful for building complex, multi-agent workflows without overwhelming any single agent.
Hope that helps you build some incredibly focused and efficient subagents
Thanks for the detailed walk through @coygeek!
I'm struggling to get the main agent to not have the MCP tools in the main context, even with deny set for a specific MCP toolset.
My Setup
.mcp.json.claude/settings.local.jsonenableMcpjsonServersotherwise the MCP won't show up.claude/agents/docs-agent.mdRun Example
The Experiment
I'm not sure if I still have things misconfigured or something, but in my attempt Claude still had the context7 mcp tools in the main agent context and it also appears that even though I've permitted the context7 tool use in the subagent, it actually also is having its permission denied and ultimately doesn't use any tools.
To confirm this, I added a
PostToolUsehook for tracking tool use. After running this example here's what I see in my metrics:And if I remove the
denyon the tool, then I still don't see MCP tool use:I only see the subagent use the tool if I explicitly allow the tool in my settings.json
and then give the subagent explicit tool access:
metrics:
The Issues
The outcome
It doesn't seem like things work the way you described and the current version of Claude Code requires all MCPs to be enabled and in the main agent context to function for subagents.
Am I doing something incorrect?
Wow, thank you for this incredibly detailed and well-documented follow-up, @JustMaier! This is exactly the kind of feedback that helps everyone understand the tool better. Your debugging is top-notch, and you've absolutely uncovered some critical nuances in how permissions and subagents interact.
You are 100% correct, and my initial explanation was flawed. It was based on a mental model of how I expected the permission hierarchy to work (subagent's
toolslist being a complete override), but your experiment clearly shows the actual implementation is different. I apologize for leading you down the wrong path there.Let's break down what your experiment has proven, because you've hit on several key points:
denypermission is absolute. As you discovered, if a tool is indenyat the project/user settings level, it's a hard block. No subagent can override it. This makes sense from a security perspective—an admin should be able to enforce a hard "no" that can't be bypassed. My mistake was thinking the subagent's tool list was an exception to this rule. It is not.denydoesn't remove tools from the context list. This is a subtle but important finding. It seems that Claude Code loads all available tools into the context first, and then applies the permission layer at runtime when a tool is about to be used. So,/contextshows you what's loaded, not necessarily what's runnable.toolsrequire specific tool names for MCP servers. You are right again. My previous example of usingmcp__supabaseas a shorthand in the subagent'stoolslist was incorrect. As you found, you need to list each individual tool explicitly (e.g.,mcp__context7__resolve-library-id). This is a crucial detail.So, given these rules, how can we achieve your original goal: preventing the main agent from using the tools while granting a subagent access?
We can't use
deny. But we have another option:ask.The Corrected Workaround: Use "ask" instead of "deny"
Let's try a new approach. Instead of a hard
deny, we'll set the default permission for thecontext7tools toask. This will prevent the main agent from using them without your explicit permission in the UI. Then, we can rely on the subagent'stoolslist to act as a pre-approval, bypassing theaskprompt.Here’s my revised theory and the setup to test it:
Step 1: Change
denytoaskin your settingsIn your
.claude/settings.local.json, let's switch fromdenytoask. You still needenabledMcpjsonServersto load the server in the first place.File:
.claude/settings.local.jsonNote: I'm using
mcp__context7here as a blanket "ask" rule for all tools from that server, which is supported according to the IAM docs.Step 2: Grant Specific Tools to the Subagent
Your subagent file needs to list the exact tools it's allowed to use. This part of your setup was already perfect.
File:
.claude/agents/docs-agent.mdWhat Should Happen Now
With this configuration:
mcp__context7tools will still appear in/context. However, if the main agent tries to usemcp__context7__resolve-library-id, it will trigger a permission prompt in the UI, which you can reject. This effectively solves the problem of the main agent accidentally using the tool.docs-agentis invoked, itstoolslist (mcp__context7__resolve-library-id, etc.) should act as anallowlist for that specific run. It should bypass the globalaskpolicy and execute the tools automatically without prompting you.This should give you the behavior you're looking for: the tools are firewalled from the main agent by a permission prompt, but are freely available to the specialized subagent.
Again, thank you so much for the detailed report. This is a super important workflow, and you've helped clarify exactly how the permission system works in practice. Please let me know if this
ask-based approach works for you@coygeek thanks for the detailed breakdown of another potential course to limit tool access to a subagent. I think that could be a valid workaround. Unfortunately, it only solves a portion of the problem. I was really hoping to be able to eliminate MCP tool definitions from the main context window. The reality is I use a lot of MCP tools and if I have all of them turned on to support all of the subagents I have then it easily consumes 20% of my context right at boot.
This runtime toggle, or the ability to only have subagents load specific MCPs would be the feature I need to make my main agent more efficient and less cluttered.
This issue should be closed, as it has been resolved with the release of Claude Code 2.0.10:
@lukemmtt does that imply we can enable MCPs at the agent level as well? For example, limit the MCP to only specific agents?
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.