Claude-Code-Antigravity-CLI-MCP-Server
SinanTufekci/Claude-Code-Antigravity-CLI-MCP-Server
MCP bridge that exposes Google's Antigravity CLI (agy) to Claude Code as a sub-agent. Works around the headless agy -p stdout bug by reading the response from agy's own transcript files.
Instalação
npx convez-ai SinanTufekci/Claude-Code-Antigravity-CLI-MCP-Server1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
README
A tradução para o português deste README ainda está na fila.
Claude Code × Antigravity CLI — MCP Bridge
Use Google's Antigravity (Gemini 3.5 Flash) as a sub-agent inside Claude Code — for text answers and image generation, on the AI Pro quota you already pay for.
agy, Google's Antigravity CLI, ships a headless print mode (agy -p) that's broken: it
authenticates, talks to the model, gets the answer back… and then never prints it. This bridge
runs agy -p anyway, reads the answer straight out of agy's own transcript files, and hands it
to Claude Code as clean MCP tools. Delegate cheap tool-calling work to Gemini without leaving
your terminal.
[!WARNING] This runs unsandboxed code with your privileges.
agy -pauto-executes its tools (read/write files, run shell commands, reach the network) with no usable approval gate.--sandbox(fixed for-pin agy 1.0.6+) blocks only shell commands — file writes and network egress stay wide open — so it's no real boundary. Theworkspaceargument is a starting context, not a security boundary. Only use it with trusted prompts on trusted content; for real isolation, run the bridge inside a container or VM. Full details →
Why you'd want this
| 🧠 Second opinion | Ask a different model family mid-task without switching tools. |
| 🎨 Image generation | Have Gemini draw an image and get the saved file back — no extra API key or image tool. |
| 💸 Cheap delegation | Burn Antigravity AI Pro quota on grunt work instead of Claude tokens. |
| 📁 Cross-repo reads | Point it at another project directory and let Gemini read/answer there. |
| 🔌 Zero new auth | Piggybacks the login you already did in the Antigravity IDE — no keys to manage. |
How it works
flowchart LR
A([Claude Code]) -- "MCP tool call" --> B["agy bridge<br/>(server.py)"]
B -- "agy -p prompt" --> C[Antigravity CLI]
C -- "Gemini 3.5 Flash (High)" --> M((model))
M -- "answer" --> C
C -. "writes (but never prints)" .-> T[("transcript.jsonl")]
B -- "reads final PLANNER_RESPONSE" --> T
B -- "plain text" --> A
agy -p persists its real answer — the one it forgets to print — to:
~/.gemini/antigravity-cli/brain/<conv-id>/.system_generated/logs/transcript.jsonl
The bridge runs agy, locates the conversation via cache/last_conversations.json (falling back to
the newest brain/ directory touched since launch), streams the transcript, and returns the final
source=MODEL, status=DONE, type=PLANNER_RESPONSE entry — the answer, minus the intermediate
tool-calling steps. agy_continue pins the workspace's exact conversation id via
--conversation, so it never resumes the wrong thread.
Set up in 60 seconds
git clone https://github.com/SinanTufekci/Claude-Code-Antigravity-CLI-MCP-Server.git
cd Claude-Code-Antigravity-CLI-MCP-Server
pip install fastmcp
python test_smoke.py # 3 real round-trips (ask, continue, image) — should print three PASS lines
[!NOTE] The smoke test costs a tiny bit of AI Pro quota and takes ~30–60 s. You must have logged into Antigravity once (via the IDE or
agy -i) so agy has a credential to reuse.
Then register the server with Claude Code — add this under mcpServers in ~/.claude.json,
using the absolute path to server.py:
"agy": {
"command": "python",
"args": ["C:\\path\\to\\server.py"]
}
"agy": {
"command": "python3",
"args": ["/path/to/server.py"]
}
Restart Claude Code. Four tools appear: mcp__agy__agy_ask, mcp__agy__agy_continue, mcp__agy__agy_status, and mcp__agy__agy_image.
"Use agy_ask to summarize the README of this repo in three bullets." → Claude routes the prompt through the bridge, agy reads the file under the workspace root, and the answer comes back as a plain string.
Tools
| Tool | Purpose |
|---|---|
agy_ask(prompt, workspace?, timeout_s?=180) | Start a new Antigravity conversation. |
agy_continue(prompt, workspace?, timeout_s?=180) | Continue the conversation rooted at workspace (pinned by id). |
agy_status() | Offline setup diagnostics (agy version/compat, state dirs, newest transcript readable). Spends no quota. |
agy_image(prompt, output_path?, workspace?, timeout_s?=240) | Generate an image with Antigravity; saves the file (extension corrected to the real bytes) and returns its path + format/size. |
workspace defaults to the MCP server's current working directory. Point it at a real project dir
for context-aware answers — agy gives the model access to files under that root.
agy_image forces agy to save to an explicit absolute path — without one, agy
falls back to its own scratch dir (~/.gemini/antigravity-cli/scratch/). It then
corrects the file extension to match the real bytes: agy's image model picks the
format itself (JPEG for photo-like images, PNG for flat graphics), so a requested
out.png may come back as out.jpg. The returned path always reflects the true
format.
Model & auth
- Model: effectively Gemini 3.5 Flash (High) — whatever the
"model"field in agy'ssettings.jsonis set to. agy 1.0.5 added a--modelflag (and amodelssubcommand) that is wired into print mode, but switching to a different model in-phangs the call (verified on 1.0.5: passing the already-active label returns in seconds, any other label hangs >60 s). So the bridge stays single-model; change it via agy'ssettings.jsonif you need a different one. Flash High is speed-optimized for tool-calling, so this fits best as a fast sub-agent for cheap work, not a heavy reasoning partner. - Auth: piggybacks whatever credential store
agyuses on your OS (Windows Credential Manager, macOS Keychain, libsecret on Linux — the bridge never touches it directly). Log in once; every call after that silent-auths on the same AI Pro quota you already pay for.
⚠️ Security
agy -p runs the model as an autonomous agent that auto-executes its own tools — reading and
writing files, running shell commands, and reaching the network — with no approval gate and no
opt-out. This isn't a choice the bridge makes; it's how agy's print mode works. Re-verified
empirically on agy 1.0.7 / Windows:
- Print mode runs out-of-workspace file writes and live network fetches even without
--dangerously-skip-permissions— that flag is a no-op for-p. There is no agy flag that disables tool execution in print mode. - agy 1.0.5 integrated a permission system (its logs show
toolPermission=request-review), but it still does not gate print-mode execution — a fresh-prun created a file outside the workspace with no prompt. --sandboxis not a usable boundary. agy 1.0.6 fixed its propagation into-p(the 1.0.6/1.0.7 changelog calls this "sandbox isolation correctly enforced") and it now does block terminal/ shell command execution — but verified here that it leaves thewrite_to_filetool and network wide open: under--sandboxthe model still wrote a file outside its workspace, and its own permission dump showedcommand(*)/execute_url(*)/read_url(*)allallowed. On top of that, a--sandboxrun whose blocked terminal command halts it writes no JSONL transcript, so the bridge couldn't read a response — so the bridge deliberately never passes--sandbox.
What that means for you:
- The
workspaceargument is only a starting context, not a security boundary — the agent can and does act outside it. - Every call effectively runs arbitrary code with your user privileges.
- Only invoke this with trusted prompts on trusted content. Untrusted input here is the classic prompt-injection lethal trifecta: private-data access + code execution + network egress.
- For real isolation, run the whole bridge inside a container or VM.
The bridge itself does only cross-platform filesystem reads under ~/.gemini/antigravity-cli/ — no
private APIs, no token theft. The risk above is entirely in what the agy sub-agent is allowed to do.
FAQ
It runs the official agy CLI under your own AI Pro session — no private APIs, no token theft,
no quota abuse. It just bridges what the CLI already does. That said, your AI Pro / Antigravity ToS
apply, and you're responsible for staying within them.
Possibly — it reads agy's internal, undocumented state files, so a release can change paths or
schemas and break it silently. Re-verified working on 1.0.7 (transcript schema and -p JSONL
output unchanged; live smoke test passes). The known future risk is agy's SQLite (.db)
conversation format (added in 1.0.4, slated to become the default): agy 1.0.7 already
dual-writes every conversation to ~/.gemini/antigravity-cli/conversations/<id>.db alongside
the JSONL transcript, so once it stops writing JSONL the reader needs a SQLite path. Pin a
known-good agy version if you depend on this.
agy 1.0.5 added a --model flag, but switching to a different model in -p hangs (print mode
waits on a step it never gets headless), so in practice you get whatever model agy's settings.json
selects — Gemini 3.5 Flash (High) by default. The bridge doesn't expose a model knob because it
would hang on any real switch.
Yes — that's the agy_image tool. agy's print mode generates real images on
your AI Pro quota; agy_image drives it, saves the file to a path you choose (or
a timestamped default in your workspace), fixes the extension to match the real
bytes (agy picks JPEG or PNG itself), and returns the path. Verified on agy 1.0.7 / Windows.
It's request/response only and runs a normal, unsandboxed agy session (see
Security).
No. It uses the same AI Pro quota you already pay for. The smoke test spends a negligible amount.
No. agy -p is request/response only, so the bridge is too. Each call typically takes 10–30 s.
They're serialized inside the server. agy rewrites last_conversations.json on every call, so
concurrent runs would race and could return the wrong conversation. A threading.Lock makes extra
requests queue rather than race — plan latency accordingly under load.
Status & caveats
- ✅ Verified on agy 1.0.7 — base dir,
last_conversations.json, thebrain/.../transcript.jsonlpath, the transcript schema, and the-p/-c/--print-timeoutflags are all unchanged; a live smoke test passes all three round-trips (text ask/continue plus image generation). The 1.0.5-pmetadata fix also means agy no longer litters the workspace dir. - ⏳ SQLite migration is the real risk — agy 1.0.7 already dual-writes a
.dbper conversation; see the FAQ._read_responseraises a clear, SQLite-aware error if the JSONL transcript ever disappears. - 🐛 Stdout bug —
-pstill doesn't print the answer on 1.0.7. If a future release fixes stdout, this workaround becomes redundant but harmless. - 🔒 No real sandbox — agy 1.0.7's
--sandboxnow blocks shell commands in-pbut still leaves file writes and network egress open (and breaks transcript reading), so it's no boundary; see Security.
Requirements
- Python 3.10+
agy1.0.0 or newer onPATH(state-file layout re-verified on 1.0.7)- An active Antigravity / AI Pro session
The bridge uses only cross-platform Python (Path.home(), subprocess) and reads paths under
~/.gemini/antigravity-cli/, which agy writes the same way on every OS. Developed and verified
on Windows; macOS and Linux should work unmodified provided agy -i runs there. If you test it on
those platforms, please open an issue / PR to confirm.
Development
pip install -e ".[dev]" # fastmcp + pytest + ruff
pytest test_server.py # offline unit tests — no agy, no quota
ruff check . && ruff format --check .
test_server.py covers the pure parsing/version logic with temp fixtures (no agy needed);
test_smoke.py is the live end-to-end check that spends a little quota. Set AGY_BRIDGE_DEBUG=1
to log per-call diagnostics (resolved conversation id, agy exit code, elapsed) to stderr — and on
startup the server warns if your installed agy is newer than the version it was verified against.
Contributing
Personal project, best-effort maintenance — issues and PRs welcome, but no uptime/compat
promises. If agy -p ever starts printing to stdout correctly, this whole repo becomes a fun
historical artefact.
License
MIT. Do whatever you want with it.