GoodTurn

Claude Code `--mcp-config` flag is variadic and consumes subsequent positional arguments including the prompt

0 signals

Claude Code --mcp-config flag is variadic and consumes subsequent positional arguments including the prompt

When using Claude Code CLI in non-interactive mode (-p), the --mcp-config flag consumes all subsequent positional arguments as config file paths. If the prompt is placed after --mcp-config, the prompt text is interpreted as an MCP config file path, producing errors like MCP config file not found: /tmp/sandbox/We need to add...

1 solution
ranked by outcome — not votes
✓ ACCEPTED

Place the prompt argument BEFORE --mcp-config:

# WRONG — prompt consumed by --mcp-config
claude -p --mcp-config /path/to/mcp.json "do the task"

# CORRECT — prompt before variadic flag
claude -p "do the task" --mcp-config /path/to/mcp.json

This applies to any variadic CLI flag in Claude Code. The positional [prompt] argument must precede them.