Skip to content

python: flow agent on claude --mcp, stdio MCP servers behind the proxy through claude mcp - #45

Merged
pwngh merged 1 commit into
mainfrom
agent-mcp
Dec 2, 2026
Merged

pwngh merged 1 commit into
mainfrom
agent-mcp

Conversation

@pwngh

@pwngh pwngh commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

flow agent on claude routes Claude Code's model calls through the gateway, but its MCP servers still ran directly, so the proxy's record of what each server was asked and answered stayed empty. The plan's --mcp option puts them behind the proxy.

flow agent on claude --mcp reads the MCP servers Claude Code uses from this folder: user and local scope in ~/.claude.json, project scope in .mcp.json. For each name it takes the entry Claude Code actually uses here (local, then project, then user). A stdio entry keeps its keys; command becomes Flow's Python and args becomes -m flowd.proxy.stdio --server <name> -- <command> <args>.... Every write goes through claude mcp remove and claude mcp add-json --scope.

A project server gets a local entry of the same name, so the committed .mcp.json is never written. That happens only for servers Claude Code has approved, and the approve-all setting is taken from the highest-priority settings file that sets it. HTTP and SSE servers are left alone and listed. Servers from managed settings, plugins and claude.ai connectors aren't in these files, and the output says they are not changed.

flow agent off claude restores the MCP entries first. If any entry is no longer what Flow wrote, it shows the difference and changes nothing, settings included. A failed write during on is undone. The code is in flowd/agents/claude_mcp.py, beside flowd/agents/claude.py, which is unchanged.

Proof: tests/agents/test_claude_mcp.py (10 tests, new) runs in a temporary HOME with a fake claude command that edits ~/.claude.json the way Claude Code does. It covers test_mcp_json_never_written, test_off_restores_entries and test_off_stops_on_edited_entry, plus the entry used here, approval, rollback, FLOW_HOME reaching the proxy, and off restoring MCP before settings. Claude Code's real files and command were never touched. Python suite 410 passed. The real Claude Code run is the owner's.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved

Sol's fixes: only the entry Claude Code uses here changes, unapproved project servers are left alone, no state is saved when nothing changed, the retry message is clearer, and off never reads .mcp.json. Declined: naming managed, plugin and connector servers (the only way is claude mcp list, which starts every server), and tracking a half-finished restore.

@pwngh
pwngh force-pushed the agent-mcp branch 5 times, most recently from f6010ea to 5a0556d Compare December 2, 2026 08:42
@pwngh
pwngh merged commit 797f385 into main Dec 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant