Skip to main content
Glama

agy-bridge

CI npm version npm downloads node license

Glama score

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

Glama MCP Market PulseMCP mcp.so MCP Servers

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 delegate_to_agy

6 purpose-built tools — Claude self-routes reliably

Model selection

none (agy default only)

per-tool routing across all agy models, with availability detection and fallback

Multi-turn

stateless

session continuity — follow_up resumes agy conversations without resending context

Output safety

unbounded

configurable truncation cap protects Claude's context

Sandbox

no

optional --sandbox mode

Install

uvx (Python)

npx (Node) — zero install

Related MCP server: codex-agy-bridge

Requirements

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.md

The "timeout": 600000 (10 min, milliseconds) is the client-side tool-call deadline — without it, a cold-start analyze_files (~40–50s) or a long delegate can hit Claude Code's default and return timed out waiting for response while the agy run is still going. If your client doesn't honor a per-server timeout, set the global env var MCP_TOOL_TIMEOUT=600000 instead. Details and the agy-side budgets are in Timeouts and cancellation.

Tools

Tool

Use for

Model routing (first available)

analyze_files

Files >200 lines, >3 files at once, logs, dumps, generated code

Gemini 3.5 Flash (High) → Gemini 3.1 Pro (Low)

deep_search

git log/diff/blame archaeology, repo-wide greps

Gemini 3.5 Flash (Medium) → (High)

web_lookup

Docs, API references, external/current knowledge

Gemini 3.5 Flash (Medium) → (High)

adversarial_review

Plan critiques, design and code reviews

Gemini 3.1 Pro (High) → Claude Opus 4.6 (Thinking) → Flash (High)

follow_up

Continue a prior session by session_id — no context resend

inherits the session

delegate

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):

  1. kills the agy process group immediately (no waiting out the timeout),

  2. parses the reset time ("Resets in 4h24m") into an in-process cooldown registry,

  3. retries the same prompt on the next model in the tool's chain,

  4. 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

AGY_PATH

agy

Path to the agy binary

AGY_TIMEOUT

per-tool

Seconds; overrides all per-tool timeouts at once (see above), passed as --print-timeout, enforced with a 15s kill grace

AGY_TIMEOUT_<TOOL>

per-tool

Seconds; overrides the timeout for a single tool only, e.g. AGY_TIMEOUT_DEEP_SEARCH=300. Wins over AGY_TIMEOUT

AGY_MAX_OUTPUT_CHARS

50000

Truncation cap for tool output

AGY_DEFAULT_MODEL

unset

Fallback model when no chain entry is available

AGY_SKIP_PERMISSIONS

true

Pass --dangerously-skip-permissions to agy

AGY_SANDBOX

false

Run agy with --sandbox

AGY_ON_FAILURE

fallback

strict appends an instruction to failed-tool errors telling the calling agent not to absorb the work itself

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.js

Contributors

Contributions are welcome — open an issue or PR.

Star History

Star History Chart

License

MIT

Available Tools

6 tools
adversarial_reviewA

Get an adversarial second opinion from a different model family (Gemini Pro). ALWAYS use this for plan critiques, design reviews, and pre-merge code review: it hunts for flaws, edge cases, security issues, and unstated assumptions you may have missed.

ParametersJSON Schema
NameRequiredDescriptionDefault
contentNoInline content to review (plan, diff, code snippet).
filesNoFile paths to review instead of inline content.
focusNoOptional focus area, e.g. 'security', 'concurrency'.
cwdNoAbsolute path to the working directory / project root. Defaults to the server's cwd.
modelNoOverride the model (exact name from `agy models`, e.g. "Gemini 3.1 Pro (High)"). Normally omit — the tool routes automatically.

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral burden. It reveals the tool uses a different model family, hunts for flaws, edge cases, security issues, and unstated assumptions, which gives a clear sense of its adversarial nature. It doesn't detail side effects or performance, but the core behavior is well disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no fluff. The first sentence defines the tool; the second gives explicit usage directives. Every word earns its place, and the key information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (5 optional params, no output schema), the description provides sufficient context for selection and invocation. It covers what the tool does, when to use it, and the schema handles parameters. It doesn't explain return format, but that's not critical for this review-style tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with descriptive parameter docs. The tool description itself does not add parameter-level semantics, so the baseline of 3 applies. The schema already explains each parameter adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool provides an adversarial second opinion from a different model family (Gemini Pro), and explicitly lists concrete use cases (plan critiques, design reviews, pre-merge code review). This distinguishes it from sibling tools like analyze_files or deep_search, which serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'ALWAYS use this for' the listed review scenarios, giving clear when-to-use guidance. It does not explicitly mention when not to use it or name alternatives, but the strong directive and adversarial framing effectively guide selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

analyze_filesA

Delegate file analysis to the Antigravity CLI (Gemini) instead of reading files yourself. USE THIS whenever a file is large (>200 lines) or the task spans more than 3 files: logs, database dumps, generated code, cross-file reviews, comparisons. The files never enter your context — only the answer does.

ParametersJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths to analyze (relative to cwd or absolute).
questionYesWhat you want to know about these files.
cwdNoAbsolute path to the working directory / project root. Defaults to the server's cwd.
modelNoOverride the model (exact name from `agy models`, e.g. "Gemini 3.1 Pro (High)"). Normally omit — the tool routes automatically.

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses the key behavioral trait that files never enter the agent's context and only the answer is returned, plus the delegation mechanism (Antigravity CLI/Gemini). It doesn't mention latency, cost, or failure modes, but it does reveal the most important side effect.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded: it states the core action first, then gives crisp usage thresholds and a final context-preservation note. Every sentence earns its place, with no redundant wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema or annotations, the description covers the essential context: what the tool does, when to use it, and a crucial behavioral trait. It doesn't detail the answer format, but the phrase 'only the answer does' implies a returned answer, which is sufficient for most decisions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers all parameters at 100%, so the baseline is 3. The description adds some color to the 'files' parameter by listing example file types (logs, database dumps) and to the overall use case, but it doesn't add detailed semantics for 'cwd' or 'model' beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool as delegating file analysis to the Antigravity CLI (Gemini) instead of reading files directly, and even lists concrete scenarios (logs, database dumps, generated code, cross-file reviews, comparisons). It does not explicitly name sibling tools, but the purpose is unambiguous and distinct from generic file reading.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit, actionable guidance: 'USE THIS whenever a file is large (>200 lines) or the task spans more than 3 files' and enumerates specific use cases. This leaves no doubt about when to choose this tool, and implicitly indicates when not to (small/simple cases).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

delegateA

Raw delegation to the Antigravity CLI for heavy tasks that don't fit the other tools. agy has full tool access (shell, file reads, web) in the given cwd.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesThe complete task prompt for agy.
cwdNoAbsolute path to the working directory / project root. Defaults to the server's cwd.
modelNoOverride the model (exact name from `agy models`, e.g. "Gemini 3.1 Pro (High)"). Normally omit — the tool routes automatically.

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of disclosing behavior. It reveals that this is 'raw' delegation with full tool access (shell, file reads, web) in a given cwd, which is crucial for understanding the tool's power and potential side effects. However, it doesn't mention output behavior or run duration, so not a perfect score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at two sentences. It front-loads the core purpose and immediately provides key differentiators and capabilities with zero wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a raw delegation tool with no output schema, the description gives enough context: it explains the tool's scope (heavy tasks), capabilities (full tool access), and working directory (cwd). It could mention that prompts should be detailed or that execution may be long, but the essentials are covered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters. The description adds context about the 'given cwd' but does not add new semantic details beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: raw delegation to the Antigravity CLI for heavy tasks. It uses a specific verb ('delegation') and resource ('Antigravity CLI'), and distinguishes itself from siblings by explicitly targeting tasks that 'don't fit the other tools'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides clear context for when to use the tool ('heavy tasks that don't fit the other tools'), but does not explicitly name alternative tools for lighter tasks. The description also highlights agy's full tool access, which hints at appropriate use cases, but could be more explicit about exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

follow_upA

Continue a previous Antigravity session by session_id (returned by every other tool). USE THIS for follow-up questions about a prior delegation — the full prior context is already on agy's side, so you don't resend anything.

ParametersJSON Schema
NameRequiredDescriptionDefault
session_idYesThe session id returned by a previous agy-bridge call.
questionYesThe follow-up question.
cwdNoAbsolute path to the working directory / project root. Defaults to the server's cwd.
modelNoOverride the model (exact name from `agy models`, e.g. "Gemini 3.1 Pro (High)"). Normally omit — the tool routes automatically.

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description bears full burden. It discloses that the prior context is already on the server side, reducing data transfer, but does not mention potential behaviors like session expiration, idempotency, or error conditions. This is adequate but lacks depth.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is exceptionally concise: two sentences delivering purpose, usage direction, and behavioral hint with zero wasted words. Information is front-loaded and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 params, no output schema, no annotations), the description covers what the tool does, when to use it, and a key behavioral trait (no resending). It does not explain return format or error scenarios, but for a follow-up tool this is mostly sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already describes all four parameters. The description adds no new semantic information beyond what the schema's descriptions provide (e.g., session_id's origin, question's purpose). Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool's purpose: continuing a previous Antigravity session via session_id for follow-up questions. It specifies the resource (session) and action (continue), and the note about not resending context differentiates it from starting new delegations, though explicit sibling differentiation is minimal.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly directs use for follow-up questions after a prior delegation, and explains the benefit (no resending context). However, it does not explicitly state when to use alternatives like 'delegate' for new tasks, leaving some inference required.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

web_lookupA

Delegate a web/documentation lookup to the Antigravity CLI (Gemini with web access): library docs, API references, error messages, current versions, external knowledge. USE THIS when you need information you don't have or that may be newer than your training data.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesWhat to look up on the web.
cwdNoAbsolute path to the working directory / project root. Defaults to the server's cwd.
modelNoOverride the model (exact name from `agy models`, e.g. "Gemini 3.1 Pro (High)"). Normally omit — the tool routes automatically.

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden of explaining behavior. It reveals that the lookup is delegated to an external CLI with Gemini web access, implying web freshness. However, it does not disclose potential latency, failure modes, or output format, which would be useful for a tool that depends on an external service.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core action and examples, followed by a clear usage trigger. Every sentence serves a purpose with no filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a relatively simple lookup tool with full schema coverage and no output schema, the description covers what, when, and the underlying mechanism (external CLI with web access). It is slightly incomplete in not hinting at what the response looks like, but this is not critical for a lookup tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description does not add parameter-specific meaning beyond the schema; it only lists example query topics. The schema already documents query, cwd, and model, so the description adds marginal value for parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool's function: 'Delegate a web/documentation lookup to the Antigravity CLI (Gemini with web access).' It lists specific use cases (library docs, API references, error messages, current versions) and distinguishes it from local-analysis siblings like analyze_files and deep_search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use the tool: 'USE THIS when you need information you don't have or that may be newer than your training data.' This is clear guidance, though it does not mention exclusions or directly compare to sibling tools like deep_search.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updatesv0.1.0
    • First observedadversarial_review
    • First observedanalyze_files
    • First observeddeep_search
    • First observeddelegate
    • First observedfollow_up
    • First observedweb_lookup

TDQS

A4.2/5.0

Scored across 6 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: adversarial review, file analysis, codebase search, generic delegation, session follow-up, and web lookup. No overlap or ambiguity.

Naming Consistency5/5

All tool names follow a consistent snake_case pattern with descriptive verbs and nouns (e.g., adversarial_review, analyze_files). No mix of styles.

Tool Count5/5

With 6 tools, the server is well-scoped for its role as a bridge to a CLI, covering common delegation needs without excess or deficiency.

Completeness5/5

The tool set provides complete coverage for the intended purpose: specialized delegation for review, file analysis, search, and web lookup, plus a generic delegate and follow-up for continuity.

Maintenance

ActivityStale
ResponsivenessResponsive

Related MCP Connectors

Related MCP Servers