Skip to content

feat(claude-cli): env-var passthrough for extra Claude CLI args (e.g. --strict-mcp-config) #1743

Description

@verothous

Problem

The claude-cli backend builds its command as a fixed list in _call_claude_cli (graphify/llm.py, ~line 1177; a second builder around line 2064):

claude -p --output-format json --no-session-persistence [--model $GRAPHIFY_CLAUDE_CLI_MODEL]

There is no way to pass additional CLI flags. The case that motivated this: a project whose .mcp.json defines stdio MCP servers pointing at local dev backends (Expo dev server, self-hosted Firecrawl). Every claude -p graphify spawns inherits the project cwd, loads .mcp.json, and pays the MCP spawn-and-connect cost on every chunk of an extraction/labeling run. I measured roughly 0-6s of extra wall time per headless call from MCP startup alone (Windows 11, npx-launched servers), and it can be much worse when an npx-launched server stalls on a dead backend. Over a 31-chunk sequential extraction that is pure overhead - graphify never uses those tools.

Claude Code already has the right lever:

claude -p --strict-mcp-config --mcp-config '{"mcpServers":{}}'

which skips project MCP config entirely. graphify just has no way to say it.

Proposal

Honour an env var, consistent with the existing GRAPHIFY_* knob style:

GRAPHIFY_CLAUDE_CLI_ARGS=--strict-mcp-config --mcp-config {"mcpServers":{}}

split with shlex.split() and appended to cli_args in both command builders. Users who need other flags (--settings, --add-dir, future CLI options) get them for free, and default behaviour is unchanged when the var is unset.

Happy to open a PR if you want it - and to test on Windows 11 with the Pro-subscription auth path.

Workaround for anyone landing here

Wrap the dev-dependent MCP servers in .mcp.json with a launcher that TCP-probes the backend port and exits non-zero when it is down. Claude Code then treats the server as unavailable instead of spawning npx trees, which removes most of the per-chunk cost without touching graphify.

Environment

  • graphifyy 0.9.10 (pip, Python 3.12, Windows 11); confirmed still applies to main at v0.9.11 (2026-07-09)
  • backend: claude-cli (Claude Code native install, subscription auth)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions