[BUG] ENABLE_EXPERIMENTAL_MCP_CLI is ignored when a prompt is passed as a command line argument
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Problem
The ENABLE_EXPERIMENTAL_MCP_CLI environment variable is being ignored when a prompt is passed to claude on the command line.
What Should Happen?
ENABLE_EXPERIMENTAL_MCP_CLI should be respected when a prompt is passed to claude on the command line.
Steps to Reproduce
In this example, we call claude without a command line prompt. You can see the subsequent /context shows no MCP context is loaded (as expected with the mcp-cli feature).
andrewhannigan:repro_mcp_cli_bug/ $ ENABLE_EXPERIMENTAL_MCP_CLI=true claude [23:45:01]
╭─── Claude Code v2.1.1 ─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back Andrew! │ Run /init to create a CLAUDE.md file with instructions for Claude │
│ │ ───────────────────────────────────────────────────────────────── │
│ ▐▛███▜▌ │ Recent activity │
│ ▝▜█████▛▘ │ No recent activity │
│ ▘▘ ▝▝ │ │
│ │ │
│ Sonnet 4.5 (1M context) · API Usage Billing · TRM │ │
│ Labs │ │
│ ~/src/repro_mcp_cli_bug │ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
❯ /context
⎿ Context Usage
⛀ ⛁ ⛁ ⛁ ⛀ ⛀ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-sonnet-4-5-20250929[1m] · 18k/1000k tokens (2%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 2.8k tokens (0.3%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 15.0k tokens (1.5%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 322 tokens (0.0%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Skills: 11 tokens (0.0%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 8 tokens (0.0%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 937k (93.7%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ Autocompact buffer: 45.0k tokens (4.5%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝
Memory files · /memory
└ ~/.claude/CLAUDE.md: 322 tokens
Skills and slash commands · /skills
User
└ psql: 11 tokens
In this example, we pass a prompt via the command line ("test" in this case). When we run /context we see that the MCP tools have been loaded into the context and are taking up significant tokens, which should not happen when using the mcp-cli.
andrewhannigan:repro_mcp_cli_bug/ $ ENABLE_EXPERIMENTAL_MCP_CLI=true claude "test" [23:45:22]
╭─── Claude Code v2.1.1 ─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back Andrew! │ Run /init to create a CLAUDE.md file with instructions for Claude │
│ │ ───────────────────────────────────────────────────────────────── │
│ ▐▛███▜▌ │ Recent activity │
│ ▝▜█████▛▘ │ No recent activity │
│ ▘▘ ▝▝ │ │
│ │ │
│ Sonnet 4.5 (1M context) · API Usage Billing · TRM │ │
│ Labs │ │
│ ~/src/repro_mcp_cli_bug │ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
❯ test
⏺ Hello! I'm Claude Code, ready to help you with your software engineering tasks.
I can assist you with: - Writing and debugging code
- Exploring and understanding codebases
- Running commands and tests
- Working with git and GitHub
- Querying databases (including Citus/Postgres via psql)
- And much more!
What would you like to work on today?
(And remember to take breaks and get outside when you need to! 🌳)
❯ /context
⎿ Context Usage
⛀ ⛁ ⛁ ⛁ ⛁ ⛀ ⛀ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ claude-sonnet-4-5-20250929[1m] · 24k/1000k tokens (2%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 2.8k tokens (0.3%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 15.3k tokens (1.5%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: 5.5k tokens (0.6%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 322 tokens (0.0%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Skills: 11 tokens (0.0%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 114 tokens (0.0%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 931k (93.1%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ Autocompact buffer: 45.0k tokens (4.5%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝
MCP tools · /mcp
└ mcp__groundcover__get_workloads: 329 tokens
└ mcp__groundcover__logsql_query_logs: 256 tokens
└ mcp__groundcover__query_traces: 984 tokens
└ mcp__groundcover__get_k8s_infrastructure_list: 176 tokens
└ mcp__groundcover__query_monitors_issues: 537 tokens
└ mcp__groundcover__query_logs: 721 tokens
└ mcp__groundcover__query_monitors: 415 tokens
└ mcp__groundcover__get_k8s_object_yaml: 133 tokens
└ mcp__groundcover__logsql_query_traces: 257 tokens
└ mcp__groundcover__query_metrics: 800 tokens
└ mcp__groundcover__query_events: 670 tokens
└ mcp__groundcover__logsql_query_events: 259 tokens
Memory files · /memory
└ ~/.claude/CLAUDE.md: 322 tokens
Skills and slash commands · /skills
User
└ psql: 11 tokens
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[Sonnet 4.5 (1M context)] 25k/1000k (2%) Update available! Run: brew upgrade claude-code
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.2 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
Using Ghostty with zsh
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗