agent-mcp¶
agent-mcp is a local MCP server. It lets Claude Code, Codex and agy start each other as subagents. This page describes how this repository sets it up (Issue #3316).
Hosts¶
p620 and razer get it, because both import Users/olafkfreund/profile.nix. p510 does not. p510 still gets the
handoff and second-opinion skill text, which has fallback commands for a host without agent-mcp.
With the flag on, Home Manager installs:
- the
agent-mcppackage (flake inputagent-mcp, exposed aspkgs.agent-mcp); ~/.config/agent-mcp/config.json;- the registrations in the three clients;
- the package's
agent-mcp-delegateandagent-mcp-reviewskills.
The version is pinned by flake.lock. Bump it with nix flake update agent-mcp.
Options¶
| Option | Values | Default | Set here | Effect |
|---|---|---|---|---|
features.development.agentMcp |
true, false |
false |
true |
package, config, registrations, skills |
features.development.agentMcpClaudeWorker |
acceptEdits, bypassPermissions |
acceptEdits |
bypassPermissions |
roles.worker.claude.permission_mode |
features.development.agentMcpCodexWorker |
workspace-write, danger-full-access |
workspace-write |
danger-full-access |
roles.worker.codex.sandbox |
agyTarget |
true, false |
false |
false |
backends.agy.enabled and the routing text |
- The three
features.developmentoptions are declared inUsers/common/features.nix. "Set here" is the value inUsers/olafkfreund/profile.nix. They take effect only withfeatures.development.enable. - The unrestricted worker values are an owner decision (Issue #2812). Reviews and asks stay read-only whatever they say.
agyTargetis a plain attribute inmodules/programs/agent-team.nix, not a module option. It also picks the routing text in/etc/claude-code/CLAUDE.mdand in the Codex and agyAGENTS.md. The skill texts do not change with it.- Turning
agyTargeton does not make agy implementation work yet: agent-mcp does not passAGY_WORKTREE.
The generated config¶
home/development/agent-mcp.nix generates config.json. The build runs agent-mcp runs list against the file, so
a config that agent-mcp rejects fails the build.
| Key | Value | Source or reason |
|---|---|---|
roles.<role>.claude, .codex |
model, effort |
roles in agent-team.nix |
roles.<role>.agy |
model, as <model>-<effort> |
same; agy model names carry the effort |
roles.worker.claude, .codex |
permission mode, sandbox | the two worker options |
backends.<each>.allow_unverified |
true |
lets review and ask run on an untested version |
backends.agy.enabled |
the value of agyTarget |
agent-team.nix |
policy.protected_paths |
~/.config/nixos |
no run may use the shared checkout |
policy.required_guards |
the coder guard of each backend | table below |
policy.guard_probe.codex |
a shell check | /etc/codex/requirements.toml registers the guard as PreToolUse |
policy.coder_markers |
CODEX_CODER=1, AGY_CODER=1 |
set on implement children so the guard hooks know them |
herdr.enabled |
false |
runs never go through herdr; herdr-team is separate |
modules/programs/claude-code-managed.nix installs the guards:
| Backend | Guard (an executable) |
|---|---|
| claude | /etc/claude-code/hooks/coder-guard |
| codex | /etc/codex/hooks/coder-guard |
| agy | /etc/antigravity/hooks/coder-guard |
Everything else keeps agent-mcp's defaults. For every key, see agent-mcp's configuration reference.
Client registrations¶
All three start agent-mcp serve from the Home Manager profile path. That path survives rebuilds, and ~/.claude
and ~/.gemini sync between hosts.
| Client | Declared in | Written to | On each switch |
|---|---|---|---|
| Claude Code | home/development/claude-code-mcp.nix |
~/.claude.json, user scope |
the entry is replaced |
| Codex | home/development/codex-agent-mcp.sh |
~/.codex/config.toml |
appends or migrates the exact managed table |
| agy | home/development/antigravity-config.nix |
~/.gemini/config/mcp_config.json |
an existing entry wins |
The Codex table is [mcp_servers.agent_mcp], with tool_timeout_sec = 60. It passes
AGENT_MCP_DEPTH and the Herdr environment, session, socket and pane identifiers.
For Codex, the server matches the calling thread in MCP request metadata to
the live pane session. A shared daemon with absent or stale pane context
produces a host-level entry.
The agy entry sets timeoutSeconds = 300 and marks six tools as eager. codex-cli.nix runs the Codex script,
which upgrades the original depth-only managed stanza and preserves custom entries.
Turning the flag off does not remove every registration:
- Claude Code: add
agent-mcptoretiredMcpServersinclaude-code-mcp.nix, or runclaude mcp remove agent-mcp. - Codex: delete the
[mcp_servers.agent_mcp]table. - agy: delete the
agent-mcpentry.
Changing a setting¶
- On a task branch, edit the option in the file named under Options.
- Check it:
just validate, thenjust test-host p620andjust test-host razer. - Merge and deploy, following the rules in
AGENTS.md. - Restart the client session. The server reads the config when it starts.
A changed registration also needs the old Codex table or agy entry deleted first, because neither is overwritten.
First run after a switch¶
On each host:
doctor prints one line per check. --probe also runs the Codex guard probe and, on a CLI version agent-mcp has
not tested, spends one model turn. Run it again after a CLI update.
The first Claude worker run needs bypassPermissions accepted once. If a run reports owner_action, start your own
Claude Code session with claude --permission-mode bypassPermissions, accept the prompt, and retry.
Why agy is off¶
Google's Antigravity terms say using third-party tools to access the service is a breach that can lead to account suspension. See agent-mcp's vendor terms. agy can still be the caller: an agy session can use agent-mcp to reach Claude Code and Codex.
Troubleshooting¶
| Reason or symptom | Meaning | What to do |
|---|---|---|
backend_unverified |
the CLI version is untested and not probed | agent-mcp doctor --probe --backend <x>, retry |
guard_unprobed |
no passed guard probe for this CLI version | the same |
guard_missing |
a guard file is absent or not executable | check the guard path; the system config installs it |
protected_path |
the run's directory is under ~/.config/nixos |
use a task worktree elsewhere |
protected_path_unresolved |
~/.config/nixos does not exist |
every run is blocked until it exists |
WARNING: codex agent-mcp: … left unchanged |
the script will not edit your Codex config | see below |
The Codex script warns and leaves the file alone in three cases:
- The table exists with another command, or without
tool_timeout_sec. Delete the table and switch again. agent_mcpis defined in another form, such as a quoted or inline table. Remove it and switch again.codex mcp listfails, usually because the file does not parse. Fix it first.
agent-mcp runs list shows recent runs. Their logs are under ~/.local/state/agent-mcp/runs/.
Observe managed runs¶
Run agent-mcp runs observe on the workspace host to list metadata for
existing runs. Use agent-mcp runs observe <id> --after-event 0 for a run's
timestamp/type timeline. Pass the returned after_event on the next call to
continue. Each page contains up to 100 complete events. An empty store
returns []. These commands only read the store.
In Herdr, prefix+alt+r or the herdr-runs shell command opens the same
history. Verify a run by matching its ID and state with the CLI, then press
Enter to inspect events. After its parent exits, refreshing groups the run
under the host. Herdr run view