agy-orchestrator
Provides Git-based worker isolation and integration: creates per-worker worktrees and branches, computes diffs against a base commit including untracked files, predicts merge conflicts, refuses secret files, and safely merges worker branches without switching the user's branch.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agy-orchestrator spin up 3 workers to add tests, verify them, and merge results"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agy-orchestrator-mcp
Let Claude Code lead a team of Antigravity (agy) workers — with a fraction of the tokens.
agy-orchestrator is a zero-dependency MCP server that turns
Claude Code into a tech lead for headless
Antigravity CLI (agy) sub-agents. Claude plans and decides; the workers read and edit code; the server does the
babysitting — running your tests, sending failures back to the worker, detecting stalls and loops,
isolating parallel work in git worktrees, and merging the result safely. It optionally integrates with
Orca IDE (by Stably AI) so you can watch workers live and review their diffs.
🇻🇳 Tiếng Việt: README.vi.md
Contents
Related MCP server: agy-mcp
Why
Delegating to sub-agents only saves money if the orchestrator doesn't burn its own context watching them. A naive orchestrator reads every streamed event, every full response and every diff — and does every "run the tests, paste the failure back" loop itself.
This server moves that work out of Claude's context:
Without the server doing it | With agy-orchestrator v2 |
Claude polls status and reads raw event streams |
|
Claude reads the full response to learn what happened | Workers return a structured report ( |
Claude runs tests, reads failures, re-prompts |
|
Claude notices a stuck worker late (or never) | Stall / loop / permission-denied flags wake Claude early |
Parallel workers clobber each other | Each worker can get its own git worktree + branch |
Merging is manual and risky |
|
Measured on the same 3-worker scenario: agy_wait went from 7.3 KB to 0.4 KB (reports included), and
the tool schemas Claude loads shrank from ~6.3 KB to ~4.0 KB. See Token benchmarks.
Features
8 compact tools — spawn, wait, result, instruct, stop, list, merge, cleanup.
Fan-out in one call —
tasks: [...]with shared defaults.Role presets —
coder,tester,reviewer,researcher.Structured worker reports — summary, files changed, commands run, tests, open questions, confidence.
Server-side verify loop — run your test/lint/build command after each turn, auto-send failures back for up to N fix rounds.
Attention detection —
stalled,looping,deniedflags;agy_waitreturns early on them.Concurrency limit with queueing — default 4 running workers.
Git worktree isolation — per-worker branch
agy/<id>, diff vs base including untracked files.Safe merge —
git merge-treeconflict prediction, secret-file refusal, never switches branches.Survives MCP restarts — workers run detached and log to disk; the server re-attaches on start.
Orca IDE integration (optional) — show worktrees in the sidebar, live log terminal, open diffs for review.
Zero dependencies — plain Node.js ≥ 20, nothing to
npm install.
How it works
flowchart LR
C[Claude Code<br/>tech lead] -- agy_spawn --> S[agy-orchestrator<br/>MCP server]
S -- "spawn detached<br/>agy -p --output-format stream-json" --> W1[agy worker 1<br/>worktree agy/…]
S --> W2[agy worker 2]
W1 -- NDJSON --> L[(logs/<id>.ndjson)]
W2 -- NDJSON --> L
L -- tail + filter --> S
S -- "verify_cmd fails →<br/>fix prompt (same conversation)" --> W1
S -- "agy_wait: digest + report (once)" --> C
S -. optional .-> O[Orca IDE<br/>live log · diffs]agy_spawnstarts each worker as a detachedagy -p --output-format stream-jsonprocess whose stdout goes straight tologs/<id>.ndjson.The server tails that file, keeps only milestones (tool calls, errors, results), coalesces repeats (
read_file ×7) and drops text deltas.When a turn ends, the server computes a change summary against the worker's base commit and, if
verify_cmdis set, runs it. Failures are sent back to the worker in the sameagyconversation.agy_waitwakes Claude only when a worker is done or needs attention, and hands over each report exactly once.
Requirements
Requirement | Notes |
Node.js ≥ 20 | No npm packages needed. |
Antigravity CLI ( | Logged in; |
git ≥ 2.38 | Only for worktrees and |
Claude Code | Or any MCP client that supports stdio servers. |
Orca IDE (optional) | Desktop app running; CLI at |
Installation
git clone https://github.com/dattnguyen16/agy-orchestrator-mcp.git ~/.claude/mcp-servers/agy-orchestrator
cd ~/.claude/mcp-servers/agy-orchestrator
npm test # optional: runs the test suite against mock agy/orca binariesRegister the server with Claude Code (user scope, available in every project):
claude mcp add --scope user agy-orchestrator -- node ~/.claude/mcp-servers/agy-orchestrator/server.mjsOr add it to ~/.claude.json / a project .mcp.json by hand:
{
"mcpServers": {
"agy-orchestrator": {
"type": "stdio",
"command": "node",
"args": ["/Users/you/.claude/mcp-servers/agy-orchestrator/server.mjs"],
"env": { "AGY_MAX_CONCURRENT": "4" }
}
}
}Install the companion skill — a short playbook that teaches Claude the token-lean workflow:
mkdir -p ~/.claude/skills
ln -s ~/.claude/mcp-servers/agy-orchestrator/skills/agy-monitor ~/.claude/skills/agy-monitorRestart Claude Code (or run /mcp and reconnect) and check that agy-orchestrator shows 8 tools.
Quick start
Ask Claude something like:
Use agy workers to fix the failing tests in
src/parser/and add a test for empty input. Run them in parallel worktrees and verify withnpm test.
A typical session from Claude's side:
// 1. fan out
agy_spawn {
"cwd": "/path/to/repo", "use_worktree": true, "verify_cmd": "npm test",
"tasks": [
{ "name": "parser-fix", "role": "coder", "prompt": "Fix the failing tests in src/parser/. Only touch src/parser/." },
{ "name": "empty-input", "role": "tester", "prompt": "Add a test for empty input to tests/parser.test.ts." }
]
}
// → {"spawned":[{"id":"agy-parser-fix-3fa1c2","status":"running","branch":"agy/agy-parser-fix-3fa1c2"}, …]}
// 2. wait (blocks server-side, returns early on attention)
agy_wait { "wait_for": "all" }
// → {"agents":[{"id":"agy-parser-fix-3fa1c2","status":"completed","turn":2,"secs":41,"fix":"1/2",
// "report":{"summary":"Fixed off-by-one in tokenize()…","files_changed":["src/parser/tokenize.ts"],
// "tests":"npm test passes","confidence":"high"},
// "changes":"1 files +3-2: src/parser/tokenize.ts +3-2","verify":"pass"}, …]}
// 3. integrate
agy_merge { "agent_id": "agy-parser-fix-3fa1c2" }
agy_cleanup { "agent_id": "agy-parser-fix-3fa1c2", "delete_branch": true }Real run (actual agy, gemini-3.8-flash-low, a repo with two planted bugs): the worker fixed add(),
the server's verify_cmd caught the second bug in mul(), sent it back, the worker fixed it, verify passed,
and the squash-merge landed — Claude read ~1.5 KB in total.
Tools reference
All tools return compact JSON (null/empty/false fields omitted) or plain text.
agy_spawn
Start one worker (prompt) or several (tasks[]). Top-level fields are defaults for every task.
Param | Type | Default | Description |
| string | — | Task brief (single worker). |
|
| — | Fan-out. Each item inherits the top-level fields. |
| string | role or | Label, used in ids, branch names and commit messages. |
|
| — | Preset, see below. |
| string | server cwd | Absolute working directory. |
| bool | false | Create |
| string |
| Base commit for the worktree. |
| string | — | Shell command run in the worker dir after each turn. |
| number | 2 | Auto-fix rounds on verify failure. |
| string | agy default | e.g. |
|
|
| agy execution mode. |
|
| agy default | Reasoning effort. |
| bool | false |
|
| bool | false |
|
| number | 0 (none) | Per-turn limit. |
| bool | false | Open a live log terminal in Orca. |
| string | built-in report | Custom result schema (JSON string or file path). |
Advanced (accepted, not advertised in the schema to save tokens): add_dirs (string[]), report (false disables
the built-in report schema), stall_seconds (default 180), verify_timeout_seconds (default 600),
dangerously_skip_permissions (alias of skip_permissions).
Role presets
Role | Mode | Extra | Preamble gist |
| accept-edits | — | Minimal changes, follow local style, don't commit. |
| accept-edits |
| Write/update tests, run them, report exact commands and results. |
| plan | — | Read-only; report defects with file:line, severity, fix. |
| plan | — | Read-only; answer with evidence. |
Every prompt also gets: "You run unattended… If blocked, stop and list the blockers in open_questions."
Built-in report schema (enforced by agy --json-schema):
{
"summary": "≤ 5 short lines: what was done and the outcome",
"files_changed": ["relative/paths"],
"commands_run": ["…"],
"tests": "what was run and the result, or 'not run'",
"open_questions": ["blockers or decisions the worker couldn't make"],
"confidence": "high | medium | low"
}agy_wait
Block until workers finish or need attention.
Param | Default | Description |
| all active + unreported | Workers to watch. |
|
|
|
| 120 | 0–300. |
Returns {timed_out?, agents: [digest]}. A digest is {id, status, turn, secs, fix, last, flags, error}; for a
finished worker the first digest after it finishes also carries report, changes, verify (and stderr on
failure). Later digests omit them — use agy_result if you need them again.
agy_result
Param | Default | Description |
| — | Required. |
|
|
|
| — | Limit |
| 8000 | Budget for |
| — |
|
agy_instruct
Continue the same agy conversation (--conversation <id>).
Param | Description |
| Required. |
| Stop a running/verifying turn first. Without it, instructing a busy worker is an error. |
| Per-turn overrides. |
Resets the fix-round counter, so verify_cmd applies again.
agy_stop
Kills the worker's whole process group (SIGTERM, then SIGKILL after 3 s), stops a running verify, or removes a queued worker from the queue.
agy_list
One line per worker: id status tN secs branch [flags] — last event or change summary.
status: all (default) · active · done.
agy_merge
Commit the worker's uncommitted changes in its worktree and merge branch agy/<id> into the branch currently
checked out at the repo root. See Safe merging.
Param | Default | Description |
| — | Required; worker must have |
|
|
|
|
| Commit message. |
| checked-out branch | Must equal the checked-out branch; otherwise refused. |
agy_cleanup
Remove the worktree (default), optionally delete agy/<id> (delete_branch: true — allowed after a squash
merge), force for dirty worktrees/unmerged branches, and forget the worker. Logs are kept.
Worker lifecycle
stateDiagram-v2
[*] --> queued: no free slot
[*] --> running
queued --> running: slot frees
running --> verifying: turn ok + verify_cmd
running --> completed: turn ok
running --> failed: error / timeout
running --> stopped: agy_stop
running --> interrupted: died while server was down
verifying --> completed: verify passes
verifying --> running: verify fails, fix round left
verifying --> needs_attention: out of fix rounds
completed --> running: agy_instruct
needs_attention --> running: agy_instruct
failed --> running: agy_instruct
interrupted --> running: agy_instructqueued, running and verifying count as active; the others are terminal. A worker holds its concurrency
slot through running → verifying → running (fix).
Verify & auto-fix
With verify_cmd, after every successful turn the server runs /bin/sh -c "<verify_cmd>" in the worker's
directory (own process group, verify_timeout_seconds limit, full output in logs/<id>.verify.log).
Pass →
completed,verify: "pass".Fail and rounds left → the worker gets, in the same conversation: "The verification command
<cmd>failed (exit N). Fix the root cause with minimal changes; do not weaken or skip the checks. Last output: …" (last 80 lines).Fail and no rounds left →
needs_attentionwith the last 30 lines in the digest.
Good verify_cmds are fast and scoped: npm test -- src/parser, pytest tests/test_parser.py -q,
tsc --noEmit, cargo check. They run with your permissions, not sandboxed.
Attention flags
Flag | Trigger | Suggested reaction |
| No new event for |
|
| Same tool with identical arguments ≥ 5 times in a row. | Redirect with a more specific instruction. |
| agy auto-denied a shell command in headless mode (only flagged when there's no | Add |
A worker that finished with denied and no verify_cmd ends in needs_attention, because agy still reports
SUCCESS even though it could not run what it wanted to.
Safe merging
agy_merge is designed to never leave your repo in a broken state:
Never switches branches. Target = whatever is checked out at the repo root. A different
target_branchis refused.Refuses a dirty target (tracked changes at the repo root).
Refuses likely secrets in the worktree:
.env*,*.pem,*.key,id_*,*.p12,credentials.json— remove or gitignore them first. Otherwise commits withgit add -A(respects.gitignore).Predicts conflicts with
git merge-tree --write-tree(touches no working tree). On conflicts it returns the file list and changes nothing.Merges with
--squash+ commit (default) or--no-ff; rolls back on failure.
If the repo has no git identity configured, commits fall back to agy-orchestrator <agy-orchestrator@localhost>.
Persistence across restarts
Workers are spawned detached with stdout/stderr redirected to files, so they keep running if Claude Code restarts the MCP server (
/mcpreconnect, new session).The registry is saved (debounced) to
state/agents.json.On start the server restores it:
worker still alive → keep tailing its log;
worker exited with a result → finished (if it had
verify_cmd, it becomesneeds_attention: verify is never re-run silently);worker gone without a result →
interrupted(resume withagy_instruct);a verify that was running →
needs_attention.
Finished workers older than
AGY_RETENTION_DAYS(and their logs) are pruned, unless they still own a worktree.By default workers are not killed when the server exits. Set
AGY_KILL_ON_EXIT=1to kill them.
Orca IDE integration
All Orca calls are best-effort: failures become warnings, never errors. The server never runs orca open
and never passes --focus (it won't steal your window).
Feature | How |
Worktrees in the sidebar | On worktree creation: |
Live view |
|
Review handoff |
|
You can also run the live viewer anywhere: node bin/agy-tail.mjs logs/<id>.ndjson.
Set AGY_ORCA=0 to disable Orca entirely.
Configuration
Variable | Default | Description |
|
| agy executable. |
|
| Per-worker |
|
|
|
|
| Running + verifying workers; the rest are |
|
| Prune finished workers and logs after this. |
| unset |
|
| Orca.app bundled CLI, else | Orca CLI. |
| unset |
|
Notes on headless agy
Observed with the agy CLI as of November 2026 (fixtures in test/fixtures/):
Shell commands are auto-denied in
-pmode unless--dangerously-skip-permissionsis passed (or an allow-rule exists in agy'ssettings.json). The turn still ends withstatus: SUCCESS; the denial only shows up inresult.denied_actions. The server surfaces it as thedeniedflag.A denied command aborts the turn. agy stops right there ("no output produced") and never runs the
--json-schemastep, so the report is lost. The server therefore tells workers withoutskip_permissionsnot to run shell commands (and that it will runverify_cmditself). If a report is still missing, the digest says so inreport.missinginstead of returning nothing.--json-schemaputs the parsed object inresult.structured_outputand costs the worker one extra short step. Disable withreport: false.--disable-slash-commandsturns--mode planinto a no-op (agy prints a warning). The server passes it only outside plan mode.Stream format:
{"event":"init"},{"event":"step_update","step_update":{step_type, state, tool_name, tool_info, text_delta, usage}},{"event":"result","result":{status, response, structured_output, usage, denied_actions}}.
Token benchmarks
Same scenario on v1 (the original single-file server) and v2: 3 workers, each reading 4 files and returning a result.
Payload Claude reads | v1 | v2 |
| ~6,340 B | ~3,990 B |
| 7,306 B | 435 B (reports included) |
| 1,164 B | 274 B (usually unnecessary) |
Reproduce with the size assertions in test-mcp.mjs.
Testing
npm test21 end-to-end tests drive the real server over stdio with mock agy and orca executables:
report parsing, event filtering, role flags, worktree diff with untracked files, merge refusal / conflict
prediction / squash merge, verify fail→fix→pass, verify exhaustion, verify timeout, denied/loop/stall flags,
concurrency queue, process-group kill (including grandchildren), interrupt + resume, restart with a live
worker and with a dead one, Orca calls and Orca failure fallback, and payload size budgets.
Troubleshooting
Symptom | Cause / fix |
Worker | Look for the |
| Run your check yourself or |
Orca warning | Add the repo in Orca ( |
| Check out the target branch yourself; the tool never switches branches. |
| Delete or gitignore the listed files in the worktree, then retry. |
| It isn't merged; pass |
| The worker is still working; check |
Tools missing in Claude Code |
|
Raw logs: logs/<id>.ndjson (agy stream + server markers), logs/<id>.stderr, logs/<id>.verify.log.
Limitations
The stream-json schema is not formally documented by agy; the parser is built from observed output and keeps a generic fallback. A future agy release may need parser updates.
Orca integration is verified against Orca 1.4.272 (worktree visibility, live terminal, open-changed) and depends on your repo being added to Orca.
verify_cmdruns unsandboxed with your user's permissions.Process liveness after a restart is checked by PID, so PID reuse is theoretically possible on a long-idle machine.
Tested on macOS. Linux should work; Windows is untested (process groups,
/bin/sh).
Security
verify_cmdandskip_permissionsexecute arbitrary commands. Only use them in repos you trust, ideally in worktrees and withsandbox.Logs may contain code, prompts and command output from your projects.
logs/andstate/are gitignored; don't publish them.agy_mergerefuses common secret files, but that is a safety net, not a guarantee. Review what you merge.
Project layout
server.mjs JSON-RPC 2.0 stdio transport
lib/engine.mjs detached processes, log tailing, queue, verify/auto-fix, restore
lib/events.mjs stream-json parser (schema: test/fixtures/*.ndjson)
lib/git.mjs worktrees, change summary, budgeted diff, safe merge
lib/orca.mjs Orca IDE integration (best-effort)
lib/state.mjs persistence
lib/tools.mjs tool schemas + handlers, role presets
lib/util.mjs helpers
bin/agy-tail.mjs live log viewer (used by Orca watch terminals)
skills/agy-monitor/ Claude Code skill: the orchestration playbook
test-mcp.mjs end-to-end tests with mock agy/orca
test/fixtures/ real agy stream-json capturesContributing
Issues and PRs welcome. Please:
keep the server dependency-free;
keep tool descriptions short — every byte is loaded into the orchestrator's context;
add or update a test in
test-mcp.mjsand runnpm test;if agy's stream format changes, add a new fixture in
test/fixtures/captured withagy -p "<task>" --output-format stream-json > test/fixtures/<name>.ndjson(scrub local paths).
License
Available Tools
8 toolsagy_cleanupC
Forget a finished worker and remove its worktree.
Inputs: agent_id (required), force, delete_branch, remove_worktree.
agy_instructC
Follow-up in the same conversation.
Inputs: prompt (required), agent_id (required), mode, model, +3 more.
agy_listD
One line per worker.
Inputs: status.
agy_mergeA
Commit a worktree worker's changes and merge into the checked-out branch. Refuses on dirty target, secrets or conflicts.
Inputs: agent_id (required), message, strategy, target_branch.
agy_resultD
Worker output. orca_open shows changes to the user in Orca.
Inputs: agent_id (required), view, paths, max_chars, +1 more.
agy_spawnC
Start Antigravity worker(s) async. Top-level fields are defaults for each tasks item.
Inputs: cwd, mode, name, role, +13 more.
agy_stopC
Stop or dequeue a worker.
Inputs: agent_id (required).
agy_waitB
Block until workers finish or need attention; returns each report once. timeout_seconds=0 = snapshot.
Inputs: wait_for, agent_ids, timeout_seconds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool maps to a distinct phase of the worker lifecycle: spawn, result, instruct, stop, list, merge, cleanup, wait. There is minor overlap between agy_result and agy_wait since both surface worker output, but the blocking/snapshot semantics of wait keep them separable.
All tools use the same agy_ snake_case prefix and mostly verb-based names. agy_result is noun-like rather than a verb, but the overall pattern remains predictable.
Eight tools is well-scoped for an orchestration server, covering creation, monitoring, interaction, termination, merge, and cleanup without obvious redundancy.
The surface covers the full worker lifecycle from spawn through cleanup, including follow-up instructions and worktree merging. Minor gaps exist around detailed status or conflict inspection, but core workflows have no dead ends.
Maintenance
Related MCP Connectors
Multiplayer for the coding agents your team already uses: shared tasks, decisions, skills and tools.
Multiplayer workspace where your team's AI coding agents share threads and split up work.
1Command center for developers coordinating AI coding agents across projects.
Your AI dev team: agents that build, test, review and ship, each on its own cloud machine.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code to delegate implementation tasks to Antigravity CLI and OpenCode, run them fully autonomously, and then review and gate the results.1MIT
- AlicenseAqualityBmaintenanceEnables Claude Code and Claude Desktop to delegate token-heavy tasks to Antigravity headless subagents, offloading file edits, test runs, and exploration while preserving Claude's context window.121MIT
- AlicenseNot gradedqualityCmaintenanceEnables multiple AI coding CLIs (Claude Code, Gemini/Antigravity, Codex, and OpenCode) to collaborate as a coordinated team by routing cross-agent prompts, sharing messages and review tickets, tracking tasks on a shared store, and isolating each agent in its own Git worktree with turn-budget safeguards—all inspectable and steerable from a local web dashboard.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Codex or Claude Code to orchestrate persistent Antigravity CLI workers as independent implementers and testers within restricted workspace roots. It supports asynchronous task dispatch, progress polling, result inspection, follow-up messages, and cancellation with bounded, audited local event logging.5MIT