MCP servers not loaded in --print mode (stdio servers)

Resolved 💬 2 comments Opened Mar 25, 2026 by ramesh-st Closed Mar 26, 2026

Description

MCP servers configured via --mcp-config are not loaded when using --print (non-interactive) mode. This affects both stdio-based and HTTP-based servers.

Reproduction

# Create MCP config with a stdio-based Playwright server
echo '{"mcpServers":{"playwright":{"command":"npx","args":["@playwright/mcp@0.0.28","--headless","--browser","chromium"]}}}' > /tmp/mcp-config.json

# Run Claude with --print and --mcp-config
echo "Navigate to https://example.com using Playwright browser" | claude --print --mcp-config /tmp/mcp-config.json --dangerously-skip-permissions --output-format json

Result: Claude runs but Playwright MCP tools are not available. Claude falls back to WebFetch. The result field is empty.

Expected: Playwright MCP server should start and its tools (browser_navigate, browser_click, browser_snapshot, etc.) should be available to Claude.

Context

  • This also affects the Claude Agent SDK (@anthropic-ai/claude-agent-sdk) which uses the same underlying mechanism
  • When using the Agent SDK, system/init shows the server as "status": "connected" but with zero tools registered
  • In interactive mode (claude without --print), MCP servers load correctly and tools are available
  • The same .mcp.json config works perfectly in interactive mode

Environment

  • Claude Code version: 2.1.77
  • OS: tested on both macOS (local) and Ubuntu 24.04 (GitHub Actions runner)
  • MCP server: @playwright/mcp@0.0.28 (stdio-based)

Impact

This blocks using MCP-dependent tools (like Playwright browser automation) in any CI/CD or automation context that requires --print mode. Specifically blocks AI-driven exploratory browser testing in GitHub Actions.

Related

  • #34131 (HTTP MCP servers in -p mode)
  • #26364
  • #32191

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗