claude -p --mcp-config does not connect MCP servers
Summary
claude -p --mcp-config <file> accepts the config file but does not actually connect to the specified MCP server. The spawned session sees the config but reports "MCP tools not loaded in session." This blocks any use of claude -p as an autonomous agent with MCP tool access.
Reproduction
# 1. Create a valid MCP config
cat > mcp-config.json << 'CONF'
{
"mcpServers": {
"openquant": {
"command": "python",
"args": ["-m", "openquant_mcp"],
"cwd": "/path/to/openquant",
"env": { "JESSE_PORT": "9000" }
}
}
}
CONF
# 2. Verify the MCP server starts correctly
cd /path/to/openquant && python -m openquant_mcp # runs on stdio, ctrl-c to stop
# 3. Try using it via claude -p
claude -p "Call the list_strategies tool" --output-format json --mcp-config mcp-config.json
Expected: Claude connects to the MCP server, discovers tools (list_strategies, backtest, etc.), and calls them.
Actual: Claude sees the config file but reports:
"The OpenQuant MCP server is configured in mcp-config.json, but it's not currently connected to this session — no mcp__openquant__* tools are available."
What was tried
| Approach | Result |
|----------|--------|
| claude -p --mcp-config mcp-config.json (file path) | Config seen, server not connected |
| claude -p --mcp-config /absolute/path/mcp-config.json | Same |
| claude -p --mcp-config '{"mcpServers":...}' (inline JSON string) | Same |
| claude -p --mcp-config ... --strict-mcp-config | Same |
| claude --bare -p --mcp-config ... | Auth fails ("Not logged in") — --bare skips OAuth/keychain |
| .mcp.json in project root + enableAllProjectMcpServers: true in settings | Config discovered but still not connected in -p mode |
Context
We're building TradingAgentHarness — a pipeline that wraps claude -p to autonomously develop and evaluate trading strategies. The harness spawns claude -p as a subprocess with an MCP server that wraps a trading engine (jesse/openquant). Without MCP tool access, claude -p can reason about strategies but cannot execute any of them.
The architecture:
Harness → [claude -p + MCP config] → Claude writes strategy code → calls MCP backtest tool → harness reads results from disk → runs statistical eval
This is completely blocked because claude -p never connects to the MCP server.
Environment
- Claude Code version: 2.1.91
- Platform: macOS Darwin 25.3.0
- Auth: OAuth (Claude Pro/Max subscription)
- MCP server: Python stdio-based, using
mcppackage withFastMCP
Impact
This blocks the primary use case of claude -p as an autonomous agent with tool access. The --mcp-config flag exists and is documented in --help, but it doesn't appear to function in practice.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗