claude -p: MCP tools unavailable when prompt mixes file operations with MCP calls
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?
When using claude -p (pipe mode), MCP tools become unavailable to the model if the prompt also includes file operations (Write, Edit, Bash). MCP tools work perfectly when called in isolation. File operations work perfectly in isolation. But combining both in a single prompt causes the model to conclude MCP tools are "not available" without attempting to call them.
Steps to Reproduce
This works (MCP call alone):
echo 'Call mcp__collab-governance__get_governance_status.' | \
claude -p --model sonnet --dangerously-skip-permissions --output-format text
Result: Returns real governance status data.
This also works (file operation alone):
echo 'Write "hello" to test.txt' | \
claude -p --model sonnet --dangerously-skip-permissions --output-format text
Result: File created successfully.
This fails (mixed prompt):
echo 'Do these 2 things:
1. Write "hello" to test.txt
2. Call mcp__collab-governance__get_governance_status' | \
claude -p --model sonnet --dangerously-skip-permissions --output-format text
Result: File is written, but model says MCP tools are "not available" or "not in my tool list" without trying.
Even putting MCP calls first doesn't help:
echo 'Do these 2 things:
1. Call mcp__collab-governance__get_governance_status
2. Write "hello" to test.txt' | \
claude -p --model sonnet --dangerously-skip-permissions --output-format text
Result: Same failure. Model skips MCP calls, only does the file write.
Expected Behavior
MCP tools should be callable regardless of what other tools are in the same prompt. The model should attempt the MCP call rather than deciding upfront that it won't work.
Actual Behavior
The model evaluates the full prompt upfront and concludes MCP tools are not accessible when file operations are present. Common model responses include:
- "MCP tools are not directly callable via bash commands or available in my tool list"
- "no MCP socket available"
- "This is expected behavior for subprocess or isolated test environments"
The model appears to be making an incorrect planning decision rather than encountering an actual tool limitation.
Additional Observations
- Haiku cannot call MCP tools at all in
-pmode. It reads MCP tool names from CLAUDE.md but doesn't see them as callable tools. Only Sonnet and above can invoke MCP tools in pipe mode.
- This does NOT affect interactive sessions, Task tool subagents, or Agent Teams teammates. We verified via automated testing that Task subagents have full MCP access (file ops + MCP calls work together). The issue is specific to
claude -ppipe mode.
- Workaround: Split multi-step prompts into focused single-purpose
claude -pcalls (one for file ops, one per MCP server). This produces correct results.
Environment
- Claude Code version: Latest (February 2026)
- OS: macOS Darwin 25.2.0
- MCP servers: User-scope (
~/.claude/mcp.json), stdio transport - Models tested: Haiku (fails entirely), Sonnet (fails with mixed prompts only)
Impact
This primarily affects automated testing and scripted workflows that use claude -p to exercise both file operations and MCP tools. It does not affect interactive development or agent-based workflows.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗