Remote MCP servers not visible in -p (headless) mode — deferred tools frozen before connections establish

Resolved 💬 1 comment Opened Apr 3, 2026 by bmiller6 Closed Apr 3, 2026

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

  1. Have remote MCP servers configured via claude.ai (Settings > Integrations)
  2. Confirm they work in interactive mode: claude mcp list shows them as "✓ Connected"
  3. Run a headless prompt:

``bash
claude -p --no-session-persistence "List all MCP tools you have access to"
``

  1. Only locally-configured servers (e.g., github) appear. All claude.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)

  1. sleep N in prompt — Deferred tools list already frozen; sleeping doesn't help
  2. ToolSearch after sleep — Returns stale snapshot, not live connections
  3. Two-phase with --resume — New process = new MCP connections = same race
  4. stream-json delayed input — Didn't produce output
  5. 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 -p workflow relying on claude.ai remote integrations

Suggested Fix

Either:

  1. Wait for MCP connections before generating the deferred tools list / processing the prompt in -p mode (with a configurable timeout)
  2. Add a --wait-for-mcp flag to explicitly request waiting for all servers
  3. Dynamically update the deferred tools list as servers connect during the session

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗