clagy

clagy

MCP server that bridges Claude Code to Google Antigravity's CLI, enabling Claude to orchestrate Gemini workers in parallel for reading, writing, verifying, and autonomous tasks. It provides tools for single dispatch, parallel fan-out, background jobs, and handles permission, cwd, and shell pitfalls.

Category
访问服务器

README

clagy — a Claude Code → Antigravity (agy) bridge

An MCP server that exposes Google Antigravity's CLI as sub-agents you can invoke from Claude Code. Claude orchestrates; Gemini workers execute in parallel.

Claude Code
  └─ agy_fanout({tasks:[…]})
       ├─ agy.exe -p --output-format json  → worker 1  ┐
       ├─ agy.exe -p --output-format json  → worker 2  ├─ in parallel
       └─ agy.exe -p --output-format json  → worker 3  ┘

When it's worth using

The benefit here is not speed — a worker takes 20–130 s to return something Claude would write in half the time. The benefit is context that never enters Claude's window, which means a longer session. Hence the only rule that matters:

Delegate when the ratio between what the worker consumes and what it hands back is high.

case consumes : returns
Research fan-out across a repo ~300 : 1 ★★★
Adversarial tests against existing code ~100 : 1 ★★★
Cross-file static audit ~60 : 1 ★★★
Mechanical edit across ≥4 files 1 : N ★★
Spec → code for a new file ~1 : 1 neutral
One-line fix · debug loop · anything that depends on the conversation negative ✗

The measured numbers, the reasoning behind each row, and the second axis of benefit — that workers fail differently than Claude, so they cover blind spots — are in docs/when-to-delegate.md.

Documentation

docs/when-to-delegate.md which cases show a net benefit, with measured ratios
docs/async-and-autonomous.md background jobs + hook, and the permissionless mode
docs/other-repos.md how to use this workflow in any other repository
prompts/ 7 general prompt templates + schemas, so you don't write them from scratch
skills/agy-orchestration/ the playbook Claude loads on its own; copy to ~/.claude/skills/

Requirements

  • Node 18+
  • Claude Code
  • Google Antigravity's CLI (agy) installed and already authenticated. The bridge reuses the OAuth credentials in ~/.gemini/; it does not need GEMINI_API_KEY. If agy is not in %LOCALAPPDATA%\agy\bin\, set AGY_BIN to the executable's path.

Installation

In the examples below, C:\path\to\clagy is wherever you cloned this repo — substitute your own.

1. The bridge.

git clone https://github.com/mateo-cuello/orchestrator-claude--agy.git C:\path\to\clagy
cd C:\path\to\clagy
npm install
node mcp/agy-bridge.mjs --selftest    # must report 11/11 before you continue
claude mcp add --scope user agy -- node C:\path\to\clagy\mcp\agy-bridge.mjs

Scope user = available from every project, with nothing to install per repo.

2. The Stop hook, so async jobs report back on their own. In ~/.claude/settings.json:

"hooks": {
  "Stop": [
    { "hooks": [
      { "type": "command", "command": "node C:\\path\\to\\clagy\\hooks\\agy-stop-hook.mjs" }
    ] }
  ]
}

3. The skill, so Claude loads the orchestration playbook by itself: copy skills/agy-orchestration/ into ~/.claude/skills/ and replace the C:\path\to\clagy placeholders inside with your real path.

MCP servers and hooks are loaded at session startup: restart Claude Code after registering them. To use this from other repositories, see docs/other-repos.md.

Verification

node mcp/agy-bridge.mjs --selftest

Runs 11 checks: round trip, structured output, silent-failure detection, tool-contract effectiveness, the cwd regression (that writes land in your project and not in agy's scratch), the autonomous-mode guard, the full lifecycle of an async job, that the hook delivers a result and does not repeat it, that 21 consecutive registry writes lose none and leave no .tmp behind (this was a real bug: see async-and-autonomous.md), and that a hung job gets detected. It must report 11/11 checks OK.

Tools

agy_dispatch — a single task

field default notes
prompt — required
model gemini-3.6-flash-high gemini-3.1-pro-high for depth
mode read read / write / verify
cwd the bridge's cwd working root; added to the workspace automatically. Scope it anyway
schema — JSON Schema; arrives parsed in structured
timeout 10m
resumeFrom — a previous conversationId, to continue the thread

agy_fanout — N in parallel

tasks[] + maxConcurrency (default 4). Returns {summary, results[]}.

agy_start / agy_result / agy_jobs — in the background

agy_start takes the same fields as agy_dispatch (plus label) but does not wait: it returns a jobId immediately while the worker keeps running. When it finishes, the Stop hook injects the result at the end of the next turn — no polling required. agy_result fetches it manually; agy_jobs lists everything.

Use it when you have something else to do meanwhile — the notification lands on a turn boundary, so launching one and immediately going idle buys you nothing. If your next step depends on the result, a blocking agy_dispatch is simpler. Details in docs/async-and-autonomous.md.

Modes

  • read — read-only. This is the default and needs no extra permissions.
  • write — also edits files. write_file(*) is already permitted in headless mode.
  • verify — also runs allowlisted commands (npm test, pytest, ruff check, npx tsc --noEmit, make, git status|diff|log, …).
  • autonomous — ⚠️ no permission system (--dangerously-skip-permissions): arbitrary commands, iterating on its own until tests pass. It exists so the write→test→fix cycle doesn't run through the orchestrator's context window. It requires an explicit cwd, rejects dangerous directories, and the contract forces the worker to paste raw test output. Run the tests yourself once anyway. Read docs/async-and-autonomous.md before using it.

The five agy traps this bridge solves

  1. Silent failure on permissions. If a tool needs a permission it doesn't have, agy exits with code 0 and status:"SUCCESS" but an empty response, sending the notice to stderr. A naive orchestrator counts that as success. The bridge turns it into ok:false with denials[]. That's check #3 in the selftest.
  2. Silent failure on quota, which looks just like it. agy never reports a 429 in print mode: it silently retries until --print-timeout runs out and exits equally empty. The bridge passes --log-file, looks for RESOURCE_EXHAUSTED and returns quotaExhausted: true with a different message — otherwise the diagnosis sends you off to fix permissions that were fine.
  3. agy ignores the process cwd. Its default workspace is ~/.gemini/antigravity-cli/scratch, so a write_to_file with a relative path lands there instead of in your project — with no error at all. Measured across 4 variants: cwd alone fails; --add-dir <cwd> works; an absolute path in the prompt works. The bridge does both: it puts cwd in the workspace and forbids relative paths in the contract. That's check #5.
  4. Unpredictable tool selection. The model may wander into run_command and die auto-denied. Every prompt is prefixed with a contract pinning the mode's toolset.
  5. Shell escaping. An inline --json-schema breaks in PowerShell (the quotes get eaten). The bridge uses spawn with an argv array and passes the schema via file.

Also: -p does not accept stdin, so prompts longer than 8000 chars are written to a temporary BRIEF.md for the worker to read. And --agent is never used: a nonexistent name raises no error, it silently falls back to the default agent.

agy's permission model in headless mode

Category Default Effect
read_file(*) allowed reads with no configuration
write_file(*) allowed can edit code
command(*) ask → auto-denied only what's in permissions.allow

Config lives in ~/.gemini/antigravity-cli/settings.json (permissions.allow, which supports alternation: command(npm run (build|lint|test))) and ~/.gemini/config/config.json (userSettings.globalPermissionGrants, where the UI accumulates every "Always allow").

Sensitive paths (.env*, .git, .npmrc, .netrc, .git-credentials) are already in ask/denied by default — except in mode:"autonomous", which turns all of that off.

Review permissions.allow every so often: it grows on its own. agy's UI accumulates there every "Always allow" you accepted in an interactive session, and those grants also apply in headless mode. Which means mode:"verify" can run considerably more than the contract enumerates. command(git checkout), command(git add) and command(git commit) were removed from that list once — they let a non-autonomous worker discard uncommitted changes. Only read-only git remains.

Cost

A floor of ~18–26k input tokens per call (agy's system prompt), even for a "hello". A real research task measured 328k input + 1.4M cache-read + 10.5k output in 75s. Aggressive fan-out burns quota fast: use flash-high for broad sweeps and reserve gemini-3.1-pro-high for depth.

Quality

gemini-3.6-flash-low gave an incorrect answer on a trivial file-reading task during testing. Rule of thumb: schemas should always ask for files_read[] and confidence, and no claim about the code is accepted without opening the file it cites.

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选