Skip to content

fix(runtime): omit empty MCP args instead of writing null - #1192

Open
finallylly wants to merge 6 commits into
Tencent:mainfrom
finallylly:codex/fix-mcp-null-args
Open

finallylly wants to merge 6 commits into
Tencent:mainfrom
finallylly:codex/fix-mcp-null-args

Conversation

@finallylly

Copy link
Copy Markdown

What changed

SOP agent nodes running on Claude Code could not see the agentflow-gate MCP server, so submit_gate_result was missing. The platform resumed the CLI session, still received no gate result, and stopped every node for manual confirmation (未收到 submit_gate_result,恢复 CLI session 后仍未提交).

mcpConfigEntries wrote "args": null into mcp.json for stdio servers without arguments, such as the built-in gate server. Claude Code skips a server whose args is null instead of starting it.

The entry now omits args when it is empty, which matches how the Codex renderer (codexMCPServerArgs) already handles servers without arguments.

This addresses the same problem as #1034, which writes "args": [] instead. Either form works with Claude Code; this PR adds a reproduction on macOS and keeps the generated entry consistent with the Codex renderer. Feel free to close whichever one you do not prefer.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

No schema or runner protocol change. Only stdio MCP entries without arguments change: args is omitted instead of written as null. Entries with arguments are unchanged. Consumers in agent_cli.go already handle a missing args key.

Validation

Run on macOS (Apple silicon).

go test ./internal/runtime -run 'TestMCPConfigEntriesOmitsEmptyArgs|MCP|Materialize|Gate' -count=1   # pass
go vet ./internal/runtime                                                                         # pass
python3 scripts/check-public.py                                                                   # pass
  • New TestMCPConfigEntriesOmitsEmptyArgs fails without the fix ("args":null in the rendered config) and passes with it.
  • go test ./internal/runtime: the remaining failures in this macOS environment (Docker-dependent tests) are identical with and without this change.
  • Claude Code 2.1.326 and 2.1.328, with a stub model endpoint and the platform gate binary: "args": null → no MCP servers loaded, submit_gate_result absent; "args": [] or omitted → agentflow-gate connected and submit_gate_result listed.
  • End to end on a local deployment with the local sandbox: before the fix every Claude agent node stopped for manual confirmation; after it, the backend delivery SOP ran through and only stopped at the configured approval nodes.
  • Not run: full go test ./..., scripts/scan-secrets.sh (downloads a Linux-only binary), Local edition scripts (not affected).

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.
  • I updated generated Classic host bundles when applicable.
  • I documented third-party content and licensing changes when applicable.

mcpConfigEntries wrote "args": null for stdio MCP servers without
arguments, such as the built-in gate server. Claude Code skips a server
whose args is null, so SOP nodes running on Claude never saw
submit_gate_result and stopped for manual confirmation.

Omit args when it is empty, matching the Codex renderer.
@zhxrain

zhxrain commented Nov 24, 2026

Copy link
Copy Markdown

Pi is affected by the same bug, and it is still present in v0.4.2 (4ff0e73).

For the pi executor, agentCLIProvider.Materialize passes the output of mcpConfigEntries to WriteAgentCLIMCPConfig, and that function writes .pi/agent/mcp.json. m.Args is a nil []string. The value != nil check in agent_cli.go keeps it, because a typed nil slice stored in any is not nil. The file ends up with:

"agentflow-gate": {
  "args": null,
  "command": ".agentflow/config/<agent>/gate-mcp",
  "env": { "AGENTFLOW_GATE_RESULT_PATH": ".agentflow/gate-results/<node>/attempt-N.json" }
}

Pi (@earendil-works/pi-coding-agent 1.6.0) checks each entry with validateMcpServerConfig from @earendil-works/pi-mcp 1.6.0. It rejects this entry and drops it without telling the agent:

> validateMcpServerConfig("agentflow-gate", { command: "...", args: null, env: {...} })
{ kind: 'invalid', error: 'server "agentflow-gate": args must be an array of strings' }

> validateMcpServerConfig("agentflow-gate", { command: "...", env: {...} })
{ kind: 'stdio', config: { command: '...', env: {...} } }

Other servers in the same file, such as agentflow-browser, still load because they are HTTP entries and have no args. The agent can run its tools but never gets submit_gate_result. The node then stops with 未收到 submit_gate_result,恢复 CLI session 后仍未提交.

Whether a node gets through depends on the model. One model found .agentflow/mcp/agentflow-gate.json, started gate-mcp itself over stdio from bash, and passed. Another model would not work around the missing tool and stopped every time.

Both this PR and #1034 fix the Pi case too, because mcpConfigEntries is shared. With this PR, args is left out of the entry. The Pi renderer copies only keys that exist, so Pi gets a valid stdio entry. A regression test that renders WriteAgentCLIMCPConfig(AgentCLIPi, ...) for a server without args would cover this path.

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.

2 participants