agy-bridge
The agy-bridge server is an MCP bridge that lets Claude Code delegate heavy, context-intensive tasks to the Antigravity CLI (agy), routing them to powerful models (Gemini, Claude Opus, GPT) so large files, deep searches, and web lookups never consume Claude's context window.
Core capabilities:
analyze_files: Delegate analysis of large files (>200 lines) or multiple files (>3 at once) — logs, database dumps, generated code, cross-file comparisons — without loading them into Claude's context.deep_search: Perform codebase archaeology (git log/diff/blame, repo-wide greps, historical change investigations) without running many commands yourself.web_lookup: Fetch library docs, API references, error messages, current package versions, or any external/up-to-date knowledge via web access.adversarial_review: Get a critical second opinion from a different model family on plans, designs, diffs, or code — hunting for flaws, edge cases, security issues, and unstated assumptions.follow_up: Continue a previousagysession bysession_idwithout resending prior context, enabling multi-turn conversations with full session continuity.delegate: Raw delegation of any heavy or miscellaneous task toagy, which has full tool access (shell, file reads, web) within the specified working directory.
Additional features:
Automatic model routing with availability detection and fallback chains.
Quota-aware failover: Detects
429 RESOURCE_EXHAUSTEDerrors, kills hung processes, and retries on the next available model.Configurable timeouts per tool, with environment variable overrides.
Output truncation (configurable via
AGY_MAX_OUTPUT_CHARS, default 50,000 chars) to protect Claude's context.Strict failure mode (
AGY_ON_FAILURE=strict) to prevent Claude from silently absorbing failed delegations.
agy-bridge
An MCP bridge that lets Claude Code delegate heavy tasks to the Antigravity CLI (agy) — saving Claude's context window and tokens for what matters.
Claude sends a task → the bridge routes it to the best available model via agy → only the answer comes back. Large files, deep git searches, and web lookups never touch Claude's context.
Listed on
User → Claude Code → agy-bridge (MCP) → agy CLI → Gemini / Claude / GPT-OSS
← ← ←Why this over claude-to-agy?
claude-to-agy | agy-bridge | |
Tool surface | 1 generic | 6 purpose-built tools — Claude self-routes reliably |
Model selection | none (agy default only) | per-tool routing across all |
Multi-turn | stateless | session continuity — |
Output safety | unbounded | configurable truncation cap protects Claude's context |
Sandbox | no | optional |
Install | uvx (Python) | npx (Node) — zero install |
Related MCP server: claude-to-agy
Requirements
Node.js 18+
Antigravity CLI (
agy) installed and authenticated
Install
# 1. Register the MCP server (user scope = all projects).
# add-json bakes in a generous client-side timeout so long analyze_files /
# delegate calls don't trip Claude Code's tool-call deadline (see Timeouts).
claude mcp add-json -s user agy-bridge \
'{"command":"npx","args":["-y","agy-bridge"],"timeout":600000}'
# 2. Add delegation rules to your project (or ~/.claude/CLAUDE.md for global)
curl -o CLAUDE.md https://raw.githubusercontent.com/sshahzaiib/agy-bridge/main/CLAUDE.mdThe
"timeout": 600000(10 min, milliseconds) is the client-side tool-call deadline — without it, a cold-startanalyze_files(~40–50s) or a longdelegatecan hit Claude Code's default and returntimed out waiting for responsewhile the agy run is still going. If your client doesn't honor a per-servertimeout, set the global env varMCP_TOOL_TIMEOUT=600000instead. Details and the agy-side budgets are in Timeouts and cancellation.
Tools
Tool | Use for | Model routing (first available) |
| Files >200 lines, >3 files at once, logs, dumps, generated code | Gemini 3.5 Flash (High) → Gemini 3.1 Pro (Low) |
| git log/diff/blame archaeology, repo-wide greps | Gemini 3.5 Flash (Medium) → (High) |
| Docs, API references, external/current knowledge | Gemini 3.5 Flash (Medium) → (High) |
| Plan critiques, design and code reviews | Gemini 3.1 Pro (High) → Claude Opus 4.6 (Thinking) → Flash (High) |
| Continue a prior session by | inherits the session |
| Anything else heavy | Gemini 3.5 Flash (High) |
All tools accept optional cwd (project root) and model (exact name from agy models; validated, with available models listed on mismatch).
Every response ends with a footer:
---
[agy-bridge] model: Gemini 3.5 Flash (High) | session: 1f0c…-d4 (use follow_up to continue)Model routing
On first use the bridge runs agy models (cached for the process lifetime) and picks the first available model in the tool's preference chain. If none is available it falls back to AGY_DEFAULT_MODEL, and finally to agy's own default. agy silently ignores unknown --model values, so the bridge validates names up front instead of letting requests land on the wrong model.
Quota-aware failover
agy never surfaces quota exhaustion in print mode — it silently retries the 429 until its print-timeout, then exits 0 with empty output, which used to look like an indefinite hang. The bridge now watches each run's log file (via --log-file) and on RESOURCE_EXHAUSTED (code 429):
kills the agy process group immediately (no waiting out the timeout),
parses the reset time ("Resets in 4h24m") into an in-process cooldown registry,
retries the same prompt on the next model in the tool's chain,
skips cooled-down models on all subsequent calls until their quota resets.
Failovers are annotated in the response footer (failover: <model>: quota exhausted (resets in 4h24m)). Only when every candidate is exhausted does the call fail — in seconds, with reset times listed — instead of hanging.
Timeouts and cancellation
Each tool has its own default timeout sized to its job: web_lookup 120s, deep_search 180s, analyze_files / adversarial_review / follow_up 300s, delegate 600s. Setting AGY_TIMEOUT explicitly overrides all of them at once. To change a single tool, set AGY_TIMEOUT_<TOOL_NAME> instead (e.g. AGY_TIMEOUT_DEEP_SEARCH=300); a per-tool override takes precedence over the global AGY_TIMEOUT and the tool's default. The full set of per-tool variables is AGY_TIMEOUT_ANALYZE_FILES, AGY_TIMEOUT_DEEP_SEARCH, AGY_TIMEOUT_WEB_LOOKUP, AGY_TIMEOUT_ADVERSARIAL_REVIEW, AGY_TIMEOUT_FOLLOW_UP, and AGY_TIMEOUT_DELEGATE. The kill path escalates SIGTERM → SIGKILL across the whole process group, and the deadline fires even if agy's helper processes hold the output pipes open. Cancelling the tool call from the MCP client (e.g. pressing Esc in Claude Code) also kills the agy run instead of orphaning it.
Two timeout layers — align them. The timeouts above are the agy-side budget. Your MCP client (Claude Code) has its own, separate tool-call timeout, and if it is shorter than the agy budget the client gives up first — you'll see Error: timed out waiting for response (note: agy-bridge's own timeout reads agy timed out after Ns instead). The work is not lost: the agy session persists, so follow_up with the returned session_id retrieves the result. But the real fix is to make the client wait at least as long as agy: the Install command already sets a per-server timeout of 600000ms (scoped to the agy-bridge entry only). If you registered the server without it, re-run the add-json command from Install, or set the global env var MCP_TOOL_TIMEOUT=600000. Rule of thumb: client timeout ≥ agy budget.
Expected latency. Most of the perceived "slowness" is cold start: the first call in a session spawns the agy CLI and warms the model. A simple analyze_files over 3 files measures around 40–50s cold (≈46s observed), dropping on subsequent same-session calls. A first call that also hits a quota 429 takes longer while the bridge fails over. So a client timeout below ~60s will intermittently trip on cold starts even for "simple" questions — size it generously.
Configuration
All optional, via environment variables:
Variable | Default | Description |
|
| Path to the agy binary |
| per-tool | Seconds; overrides all per-tool timeouts at once (see above), passed as |
| per-tool | Seconds; overrides the timeout for a single tool only, e.g. |
|
| Truncation cap for tool output |
| unset | Fallback model when no chain entry is available |
|
| Pass |
|
| Run agy with |
|
|
|
Failure behavior
The bridge always fails loudly: agy errors surface as MCP tool errors with agy's actual stderr, and degraded model routing is annotated in the response footer. By default the calling agent (Claude) will typically do the work itself after a failure — visible in the transcript, but easy to stop noticing in a long session. Set AGY_ON_FAILURE=strict to append an explicit "do NOT perform this work yourself — report the failure to the user" instruction to every delegation error, so you keep control over when token savings are silently lost.
Development
npm install
npm test # vitest unit tests (exec mocked — no agy needed)
npm run typecheck
npm run build # tsup → dist/index.jsContributors
Contributions are welcome — open an issue or PR.
Star History
License
MIT
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sshahzaiib/agy-bridge'
If you have feedback or need assistance with the MCP directory API, please join our Discord server