Bug: disabledMcpServers setting not enforced at session startup
Bug: disabledMcpServers setting not enforced at session startup
Environment
- Claude Code version: 2.0.61
- OS: Fedora 43 (Linux 6.17.9)
- Shell: bash
Description
MCP servers listed in disabledMcpServers are not actually disabled when starting a new Claude Code session. The setting is persisted correctly in ~/.claude.json and the /mcp command shows them as disabled, but Claude can still connect to and use all the servers.
Steps to Reproduce
- Configure MCP servers globally in
~/.claude.json:
{
"mcpServers": {
"pixellab": { ... },
"leonardo-ai": { ... },
"gemini-cli": { ... },
"chrome-devtools": { ... },
"codex-cli": { ... }
}
}
- Add all servers to
disabledMcpServersfor a project (either via/mcptoggle or programmatically):
{
"projects": {
"/home/rob/Projects/ziggurat": {
"disabledMcpServers": [
"leonardo-ai",
"pixellab",
"gemini-cli",
"chrome-devtools",
"codex-cli"
]
}
}
}
-
Start a new Claude Code session in that project directory
-
Run
/mcp- shows all servers as disabled (correct) -
Ask Claude to check MCP server status with
claude mcp list
Expected Behavior
- Disabled MCP servers should not be connected
- Claude should not have access to tools from disabled servers
-
claude mcp listshould show disabled servers as disconnected or not listed
Actual Behavior
- All 5 servers show as "✓ Connected" when running
claude mcp list - Claude can see and invoke tools from all MCP servers
- The
disabledMcpServerssetting is completely ignored at runtime
Evidence
Config in ~/.claude.json:
{
"projects": {
"/home/rob/Projects/ziggurat": {
"disabledMcpServers": [
"leonardo-ai",
"pixellab",
"gemini-cli",
"chrome-devtools",
"codex-cli"
]
}
}
}
Output of claude mcp list:
Checking MCP server health...
pixellab: https://api.pixellab.ai/mcp (HTTP) - ✓ Connected
leonardo-ai: https://mcp.leonardo.ai/v1/mcp (HTTP) - ✓ Connected
gemini-cli: npx -y gemini-mcp-tool - ✓ Connected
codex-cli: npx -y codex-mcp-server - ✓ Connected
chrome-devtools: npx chrome-devtools-mcp@latest - ✓ Connected
Related Issues
- #12025 - Feature request to disable MCP servers globally and enable per-project
- #4879 - Feature request for MCP Server Enable/Disable Toggle
- #7068 - Feature request for enable/disable in
/mcpcommand
Impact
Users cannot disable MCP servers per-project. This affects:
- Projects that don't need certain MCP tools (unnecessary tool clutter)
- Security/privacy (servers connect even when not wanted)
- Token usage (disabled tools may still be included in context)
Found 1 possible duplicate issue:
- https://github.com/anthropics/claude-code/issues/9996
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Additional Testing Results (2025-12-08)
Finding 1: UI toggle doesn't persist either
Initially suspected only programmatic edits were ignored. Further testing confirms:
- Used
/mcpUI to toggle all 5 servers OFF - Verified
disabledMcpServersarray was updated in~/.claude.json - Started fresh Claude Code session
-
Result: All 5 servers still show "✓ Connected" in
claude mcp list
The /mcp UI toggle is also not respected - the bug affects both programmatic and UI-based disabling.
Finding 2: No config inheritance issue
Checked for parent path overrides:
- Project path has all 5 servers in
disabledMcpServers✓ - No parent directory entry overriding the setting ✓
- No
disabledMcpServersin~/.claude/settings.json✓
The config is correct - it's simply not being read/enforced at startup.
Finding 3: Token cost impact
"Connected" servers likely still:
- Spawn the MCP server process (npx runs on startup)
- Fetch tool schemas from each server
- Inject tool definitions into the system prompt
This means disabled servers are costing tokens on every request - tool definitions consume input tokens even when you never intend to use them. The bug isn't just about unwanted tool availability; it's actively wasting context window and increasing costs.
Re: Duplicate Detection
This is not a duplicate of #9996 - that issue is about plugin marketplace UI, not MCP server disabledMcpServers setting.