Remote MCP servers not visible in -p (headless) mode — deferred tools frozen before connections establish
Summary
Remote MCP servers configured via claude.ai integrations connect successfully in claude -p (headless/print) mode, but the deferred tools list is frozen before they finish connecting. The model never sees them — only locally-configured servers (e.g., github with a static Bearer token) are available.
This is a regression introduced around version 2.1.81. The same setup worked correctly in versions prior to 2.1.81 (confirmed working through March 28, 2026).
Environment
- Claude Code version: 2.1.81
- Platform: macOS (darwin arm64)
- Auth: claude.ai (Team subscription)
- Remote MCP servers: 23 configured via claude.ai account (Slack, Google Calendar, Granola, Asana, Databricks, etc.)
Steps to Reproduce
- Have remote MCP servers configured via claude.ai (Settings > Integrations)
- Confirm they work in interactive mode:
claude mcp listshows them as "✓ Connected" - Run a headless prompt:
``bash``
claude -p --no-session-persistence "List all MCP tools you have access to"
- Only locally-configured servers (e.g.,
github) appear. Allclaude.ai *remote servers are missing.
Debug Evidence
Running with --debug-file reveals the race condition:
T+0.000s [STARTUP] Session begins
T+0.014s [STARTUP] MCP configs resolved in 9ms (awaited at +14ms)
T+0.020s MCP server "google-workspace": Starting connection
T+0.028s MCP server "github": Starting connection
T+0.200s [claudeai-mcp] Fetching from https://api.anthropic.com/v1/mcp_servers?limit=1000
T+0.466s [claudeai-mcp] Fetched 23 servers
T+0.666s MCP server "github": Connection established ← local server, fast
T+1.350s MCP server "claude.ai Fi AWS": Starting connection ← remote servers start late
T+1.352s MCP server "claude.ai Google Calendar": Starting connection
T+1.367s MCP server "claude.ai Slack": Starting connection
T+1.369s MCP server "claude.ai Granola": Starting connection
...
T+2.316s MCP server "claude.ai Google Calendar": Connection established
T+2.719s MCP server "claude.ai Slack": Connection established
T+2.963s MCP server "claude.ai Granola": Connection established
T+4.159s MCP server "claude.ai Fi Babel": Connection established ← last server
16 of 23 remote servers connect within 3 seconds, but the deferred tools system-reminder is generated before they finish. The model processes the prompt with only locally-connected servers visible.
Workarounds Attempted (None Successful)
sleep Nin prompt — Deferred tools list already frozen; sleeping doesn't help- ToolSearch after sleep — Returns stale snapshot, not live connections
- Two-phase with
--resume— New process = new MCP connections = same race stream-jsondelayed input — Didn't produce output- Retry after 20-30s — Each invocation has the same race condition
Expected Behavior
In versions prior to 2.1.81, claude -p waited for remote MCP servers to connect before processing the prompt, or updated the tool list dynamically. Remote MCP tools were available in headless mode.
Impact
This blocks all headless automation that depends on remote MCP integrations:
- Scheduled jobs via launchd (morning briefings, meeting prep automation)
- CI/CD pipelines using MCP tools
- Any
claude -pworkflow relying on claude.ai remote integrations
Suggested Fix
Either:
- Wait for MCP connections before generating the deferred tools list / processing the prompt in
-pmode (with a configurable timeout) - Add a
--wait-for-mcpflag to explicitly request waiting for all servers - Dynamically update the deferred tools list as servers connect during the session
🤖 Generated with Claude Code
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗