[BUG] Cloud-hosted MCP tools (mcp__claude_ai_*) silently absent in pipe mode (-p) despite ENABLE_CLAUDEAI_MCP_SERVERS being enabled by default
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?
Cloud-hosted MCP tools (mcp__claude_ai_* — Slack, Notion, Vercel, Indeed, Gmail, Calendar, Snowflake, etc.) are completely absent from the system prompt when Claude Code runs in pipe mode (-p). These tools work perfectly in interactive CLI mode but are silently dropped in pipe/SDK mode.
The official docs state ENABLE_CLAUDEAI_MCP_SERVERS is "enabled by default for logged-in users" — but this default is not honored in pipe mode. Setting ENABLE_CLAUDEAI_MCP_SERVERS=true explicitly also has no effect.
Evidence from JSONL session files on the same machine, same user, same version (2.1.81), same model:
| | Interactive CLI | Pipe mode (-p) |
|---|---|---|
| entrypoint | "cli" | "sdk-cli" |
| system prompt tokens | ~128K | ~115K |
| cloud MCP tools | ✅ all present | ❌ none |
| local MCP tools | ✅ all present | ✅ all present |
The ~13K token difference corresponds exactly to the missing cloud MCP tool definitions.
What Should Happen?
Cloud-hosted MCP tools should be available in pipe mode for logged-in users, consistent with the documented behavior: "ENABLE_CLAUDEAI_MCP_SERVERS is enabled by default for logged-in users."
A flag like --enable-cloud-mcp or honoring ENABLE_CLAUDEAI_MCP_SERVERS=true in pipe mode would resolve this.
Error Messages/Logs
No error messages — the tools are silently absent with no warning.
Reproduction test:
$ claude -p "List tools starting with mcp__claude_ai_Slack. If none, say NONE FOUND."
→ NONE FOUND
$ ENABLE_CLAUDEAI_MCP_SERVERS=true claude -p "List tools starting with mcp__claude_ai_Slack. If none, say NONE FOUND."
→ NONE FOUND
Both return NONE FOUND despite being logged in and all cloud MCP tools working interactively.
Steps to Reproduce
- Log into Claude Code with a claude.ai account (Claude Pro)
- Verify cloud MCP tools work interactively:
$ claude
> List tools starting with "mcp__claude_ai_Slack"
→ Lists all Slack tools ✅
- Test pipe mode:
$ claude -p "List tools starting with mcp__claude_ai_Slack. If none, say NONE FOUND."
→ NONE FOUND ❌
- Test with explicit env var:
$ ENABLE_CLAUDEAI_MCP_SERVERS=true claude -p "List tools starting with mcp__claude_ai_Slack. If none, say NONE FOUND."
→ NONE FOUND ❌
- Test fake TTY:
$ script -q /dev/null claude -p "List tools starting with mcp__claude_ai_Slack. If none, say NONE FOUND."
→ NONE FOUND ❌
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.81
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
This blocks any application built on top of Claude Code using -p or the @anthropic-ai/claude-code SDK from accessing cloud-hosted MCP integrations that the user has connected through their claude.ai account.
Use case: Building a web UI (Claude Lens) that spawns sessions via -p --output-format stream-json --input-format stream-json. Users expect the same MCP tools available in the terminal to work in the web UI — same machine, same auth, same binary.
Workarounds tested (all failed):
ENABLE_CLAUDEAI_MCP_SERVERS=true— no effect- Fake TTY via
script -q /dev/null— no effect (not a TTY check) --input-format stream-jsonvs plain-p— no difference
Note: local MCP servers (mcp__github__, mcp__google-workspace__, mcp__notion-hq__) work correctly in pipe mode — only cloud-hosted mcp__claude_ai_ tools are affected.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗