gemini-mcp-tool

v2.4.0
@joeytheman/gemini-mcp-tool Checked 4 hours ago Published 19 days ago

MCP server for asking Gemini through Antigravity CLI (agy)

This is a simple Model Context Protocol (MCP) server that lets AI assistants ask Gemini through Google's Antigravity CLI (agy). The primary use case is giving Codex, Claude Code, and other MCP clients a second opinion from Gemini on plans, implementations, code reviews, architecture tradeoffs, and large files using the @ syntax. Version 2.0 moves the Gemini backend from the retired Gemini CLI/API path to Google's Antigravity CLI (agy) and brings the MCP-facing ask-gemini workflow along with several capabilities: Before using this tool, ensure you have:

Summary extracted from the README.

Gemini MCP Tool

GitHub Release npm version npm downloads License: MIT Non-Commercial Open Source

πŸ“š View Full Documentation - Search me!, Examples, FAQ, Troubleshooting, Best Practices

Fork Notice: This project is a fork of jamubc/gemini-mcp-tool, originally created by jamubc. We are grateful to the original author for their foundational work.

This is a simple Model Context Protocol (MCP) server that lets AI assistants ask Gemini through Google's Antigravity CLI (agy). The primary use case is giving Codex, Claude Code, and other MCP clients a second opinion from Gemini on plans, implementations, code reviews, architecture tradeoffs, and large files using the @ syntax.

  • Ask gemini natural questions, through claude or Brainstorm new ideas in a party of 3!

TLDR: Claude + Google Gemini + Antigravity (agy)

Goal: Use Gemini's analysis capabilities directly from Codex or Claude Code for reviews, critiques, and large-file questions.

What's New in 2.4

  • Gemini 4 Carbon support β€” ask-gemini and brainstorm now default to Gemini 4 Carbon (High). Carbon Low and Medium, and every Gemini 4 Argon tier, remain available as explicit overrides when listed by agy models. live-pass and screen-review continue to default to Gemini 3.8 Flash (Medium).

What's New in 2.2

  • Gemini 4 Argon support β€” ask-gemini and brainstorm now default to Gemini 4 Argon (High). Argon Low and Medium are available as explicit overrides when listed by agy models. live-pass and screen-review continue to default to Gemini 3.8 Flash (Medium).

What's New in 2.1

  • live-pass β€” hand a live UI verification to Gemini. It drives its own Playwright (web) or Maestro (iOS simulator) MCP server, captures each requested screen/state/viewport into an artifact directory inside the worktree under test, opens every PNG itself, and returns a PASS/FAIL/BLOCKED verdict with a sentence per frame. The caller never opens an image. The verdict is derived in code from the requested targets, so a frame Gemini forgot, a stale PNG, or an uncovered target fails the pass even when Gemini says PASS.
  • screen-review β€” a second pair of eyes on frames someone else captured (mode: "review"), or an action inventory of a route file before anything is built (mode: "plan"). Also text only.
  • JSON envelopes for ask-gemini β€” outputFormat: "json" returns agy's envelope: the conversation ID line, the response (or structured_output when you pass a jsonSchema), and a token-usage line. conversationId resumes an exact conversation and errors if agy silently started a different one.

What's New in 2.0.2

  • Gemini 3.8 Flash support β€” the default model is now Gemini 3.8 Flash (High) for strong coding and complex-analysis performance. Pass model: "Gemini 3.8 Flash (Low)" or model: "Gemini 3.8 Flash (Medium)" when latency matters more than the High reasoning budget. Gemini 3.1 Pro (Low/High) remains available as an explicit alternative when exposed by agy models.

What's New in 2.0

Version 2.0 moves the Gemini backend from the retired Gemini CLI/API path to Google's Antigravity CLI (agy) and brings the MCP-facing ask-gemini workflow along with several capabilities:

  • Antigravity backend β€” Gemini is reached through agy --print.
  • Opt-in response caching β€” LRU cache (30-minute TTL, 10 MB max) for repeated queries, enabled with AGY_CACHE_ENABLED=true.
  • Conversation resume β€” continue the latest agy conversation or resume a specific one via the resume option (--continue / --conversation <id>).
  • Extra workspace directories β€” add directories to the Antigravity workspace with includeDirectories (maps to repeated --add-dir).
  • Configurable print timeout β€” bound long-running calls with printTimeout (for example 5m or 90s; maps to --print-timeout).
  • Working directory control β€” run agy from a chosen directory (or a drive root on Windows) via workingDirectory, supported by both ask-gemini and brainstorm.
  • Structured change mode β€” OLD/NEW edit suggestions Claude can apply directly, with automatic chunking and a fetch-chunk tool for large edit sets.

Removed: there is no longer a Pro→Flash quota fallback, and legacy Gemini CLI flags (outputFormat, extensions, debug, promptInteractive, and approvalMode other than yolo) now return explicit unsupported-option errors.

Prerequisites

Before using this tool, ensure you have:

  1. Node.js (v20.12.0 or higher)
  2. Antigravity CLI (agy) installed and configured

Verify agy before adding the MCP server:

agy --version
agy install
agy models

The ask-gemini and brainstorm default requires Gemini 4 Carbon (High) to appear in agy models (verified with agy 1.5.5). Google currently lists Carbon access in Antigravity for Google AI Ultra and Enterprise accounts (Argon is also on Google AI Pro); see model availability. If Carbon is missing, update Antigravity CLI and check your account's access. You can explicitly select another available model, such as model: "Gemini 4 Argon (High)" or model: "Gemini 3.8 Flash (High)". The MCP server does not automatically fall back. live-pass and screen-review continue to require Gemini 3.8 Flash (Medium) for their default requests.

One-Line Setup

claude mcp add gemini-feedback -- npx -y @joeytheman/gemini-mcp-tool

Verify Installation

Type /mcp inside Claude Code to verify the gemini-feedback MCP is active.


Alternative: Import from Claude Desktop

If you already have it configured in Claude Desktop:

  1. Add to your Claude Desktop config:
"gemini-feedback": {
  "command": "npx",
  "args": ["-y", "@joeytheman/gemini-mcp-tool"]
}
  1. Import to Claude Code:
claude mcp add-from-claude-desktop

Configuration

Register the MCP server with your MCP client:

Add this configuration to your Claude Desktop config file:

{
  "mcpServers": {
    "gemini-feedback": {
      "command": "npx",
      "args": ["-y", "@joeytheman/gemini-mcp-tool"]
    }
  }
}

For Global Installation

If you installed globally, use this configuration instead:

{
  "mcpServers": {
    "gemini-feedback": {
      "command": "gemini-mcp"
    }
  }
}

Optional: Enable Response Caching

To enable the LRU response cache for near-instant repeated queries, add the AGY_CACHE_ENABLED environment variable:

{
  "mcpServers": {
    "gemini-feedback": {
      "command": "npx",
      "args": ["-y", "@joeytheman/gemini-mcp-tool"],
      "env": {
        "AGY_CACHE_ENABLED": "true"
      }
    }
  }
}

Caching is disabled by default. When enabled, responses are cached with a 30-minute TTL and 10MB max size.

Configuration File Locations:

  • Claude Desktop:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/claude/claude_desktop_config.json

After updating the configuration, restart your terminal session.

Live UI passes (setup)

live-pass needs Gemini to have its own MCP servers registered with Antigravity CLI. Register them once:

agy mcp add playwright -- npx -y @playwright/mcp@latest --browser chromium --headless --isolated \
  --codegen none --allow-unrestricted-file-access   # artifact dirs live inside each worktree, so no fixed --output-dir
agy mcp add maestro /path/to/maestro mcp
agy mcp list                         # playwright + maestro

--allow-unrestricted-file-access is what lets browser_run_code_unsafe read each target's capture file and browser_evaluate write its layout file in a worktree-local artifact directory; the capture file's page.screenshot writes the PNG itself. --codegen none keeps @playwright/mcp from echoing each capture file's code back into Gemini's history under "Ran Playwright code", which would add about 5.5k characters per frame. A web pass needs a @playwright/mcp with browser_run_code_unsafe (0.0.84 has it). The tool compensates: artifactDir must be inside workingDirectory, every frame is checked on disk (matching PNG or JPEG filename and file signature, fresh, non-empty, inside the artifact dir), and the working tree is diffed before and after the run.

Add .live-pass/ to the repository's .gitignore so frames never land in a commit; deleting the worktree then removes them. Add .playwright-mcp/ too β€” the Playwright MCP server creates that directory in whatever it runs from, which the working-tree guard will otherwise report as a WARNING on every pass.

A full pass can run for many minutes inside one MCP call. The server sends keepalive progress notifications every 25 seconds when the client passes a progressToken; raise your client's MCP_TIMEOUT if a pass outlives it, and consider calling live-pass from a small relay sub-agent so the orchestrating session stays free.

Example Workflow

  • Natural language: "use gemini to explain index.html", "understand the massive project using gemini", "ask gemini to search for latest news"
  • Claude Code: Use /ask-gemini directly, or ask naturally for Gemini feedback.

Usage Examples

With File References (using @ syntax)

  • ask gemini to analyze @src/main.js and explain what it does
  • use gemini to summarize @. the current directory
  • analyze @package.json and tell me about dependencies

General Questions (without files)

  • ask gemini to search for the latest tech news
  • use gemini to explain div centering
  • ask gemini about best practices for React development related to @file_im_confused_about

Using Antigravity Sandbox Mode

The sandbox mode maps to agy --sandbox, which runs with terminal restrictions enabled.

  • use gemini sandbox to create and run a Python script that processes data
  • ask gemini to safely test @script.py and explain what it does
  • use gemini sandbox to install numpy and create a data visualization
  • test this code safely: Create a script that makes HTTP requests to an API

Tools (for the AI)

These tools are designed to be used by the AI assistant.

  • ask-gemini: Ask Gemini through Antigravity CLI (agy) for plan review, implementation critique, code review, architecture feedback, debugging, and tradeoff analysis.

    • prompt (required): The analysis request. Use the @ syntax to include file or directory references (e.g., @src/main.js review this implementation) or ask general questions.
    • model (optional): The Antigravity model to use. Defaults to Gemini 4 Carbon (High). Other verified options include Gemini 4 Carbon (Low), Gemini 4 Carbon (Medium), Gemini 4 Argon (Low/Medium/High), and Gemini 3.8 Flash (Low/Medium/High) (use the exact tier name, such as Gemini 3.8 Flash (High)). Availability depends on your CLI version and account; check agy models. Some accounts also expose Gemini 3.1 Pro (Low) and Gemini 3.1 Pro (High).
    • sandbox (optional): Set to true to pass --sandbox.
    • changeMode (optional): Enable structured change mode for edit suggestions that Claude can apply directly.
    • yolo (optional): Pass --dangerously-skip-permissions. Use with caution.
    • includeDirectories (optional): Additional directories to include in the Antigravity workspace; maps to repeated --add-dir.
    • printTimeout (optional): Pass --print-timeout: a duration such as 90s, 15m, 2h30m or 2.5h, or 0 for no limit; other values are rejected. The server stops agy 2 minutes after this limit, or after 2 hours when no limit is given.
    • resume (optional): true, latest, or continue maps to --continue; any other string maps to --conversation <id>.
    • conversationId (optional): Resume this exact conversation (--conversation <id>); wins over resume. The call fails with CONVERSATION_NOT_RESUMED when agy silently starts a different conversation β€” a stale ID only warns on stderr and would otherwise return an unrelated answer. IDs come from the [GEMINI_CONVERSATION_ID=...] line of a previous json call; a text call reports its ID only when it fails with an empty answer.
    • outputFormat (optional): "text" (default) or "json". "json" returns agy's envelope rendered as the conversation line, the answer, and a usage line. "stream-json" is unsupported.
    • jsonSchema (optional): Inline JSON Schema passed to --json-schema, constraining the answer to structured_output. Requires outputFormat: "json".
    • effort (optional): low, medium, or high, passed to --effort. Tiered Gemini names already encode effort in the name, and agy rejects --effort for them β€” the rejection is surfaced verbatim.
    • workingDirectory (optional): Working directory to run agy from. Use drive root (e.g., 'C:/' or 'D:/') on Windows to access files across drives.
    • Unsupported legacy options: extensions, debug, promptInteractive, outputFormat: "stream-json", and approvalMode except approvalMode: "yolo".
  • live-pass: Delegate a live UI verification to Gemini. It drives its own Playwright or Maestro MCP server, captures the requested frames, looks at them, and returns text.

    • targets (required): One {screen, state, viewport, expected} per frame the pass must produce; for playwright, viewport must be WxH, such as 390x844. expected is what that state must show β€” for an intentional error/empty/offline state, name the reason text and the recovery affordance. The effective verdict is derived from this list: any target that produced no frame fails the pass, whether Gemini skipped it with a reason or never reported it at all. A skip explains missing evidence; it does not excuse it. Each target's screenshot filename is derived in code from its screen/state/viewport, so two targets can never be answered by one image β€” a reused file is reported as DUPLICATE and fails the pass.
    • brief (required): Every fact Gemini needs, because the pass forbids it to read product code, tests, docs, tool schemas or the database, or to run git: the app's start URL or app id, any link a user arrives by (an invite, email or share link) with where it comes from, the served-branch marker, and per target the user path, the labels or testIDs on it, the seed account and ids, and how long toasts and pending states stay on screen. App specifics belong here, not in the tool. The pass opens the app once, at its start URL (or by launching it on a device). A target may begin at a link of its own only when the brief says the user arrives by that link and names where it comes from; that frame quotes the source in link_source, and the report prints it. Every other target is reached by taps from the previous screen (sign-in form, navigation taps, form submits; no scripted shortcuts), and any other URL in the brief is context, never a navigation target. A reload opens the current URL, and only where the brief makes it part of the path. A target whose path breaks is skipped with the step where it broke, and one whose fact is missing is skipped with brief missing: <fact>; either fails the pass. The branch and HEAD of workingDirectory are read in code and printed in the prompt as context: the pass is BLOCKED only when the app's served-branch marker contradicts them (a detached HEAD never contradicts a branch name).
    • workingDirectory (required): Absolute path to the worktree under test. Used as agy's cwd and workspace root.
    • driver (required): playwright or maestro.
    • artifactDir (optional): Absolute path, strictly inside workingDirectory. Defaults to <workingDirectory>/.live-pass/<timestamp>, so deleting the worktree cleans up the frames. Add .live-pass/ to the repo's .gitignore.
    • publishCommand (optional): Shell command run in code after validation, with {files} replaced by the shell-quoted paths of the frames that validated OK; its stdout is returned as PR markdown. Never run on a BLOCKED pass.
    • conversationId (optional): Resume the previous pass so Gemini reports deltas (resolved, regressions, changes) instead of a bare snapshot. The browser or simulator still starts fresh β€” resume only changes what Gemini remembers. Start fresh when the brief changed materially, after a BLOCKED pass, or after about three rounds (each resumed round roughly doubles input tokens).
    • yolo (optional, default true): Without --dangerously-skip-permissions, headless agy denies the MCP tool calls and the pass is BLOCKED. The tool snapshots the working tree before and after β€” status lines and content hashes of every dirty file, since a file Gemini rewrites in a PR worktree was already modified before the run β€” and reports any change as a WARNING, including when the agy call itself fails.
    • model (optional, default Gemini 3.8 Flash (Medium)), printTimeout (optional, default 15m).
    • Capture files and layout checks (playwright only): before agy starts, the tool writes one capture file per target next to its frame, <frame>.capture.js, and Gemini runs it with browser_run_code_unsafe {filename} once the state has settled. In one call it sets the target's viewport, measures how far the page or its largest shown scroller overflows (only scrollers inside an open aria-modal sheet count while one shows, and textareas never do), grows the viewport by that much and measures again, a few times at most, while the overflow keeps shrinking and up to 4000 px tall (a screen that still scrolls after that is shot as it stands), saves the PNG, runs a fixed layout snippet in the page at the shot's size, and restores the viewport. A failed restore is noted in the call's answer and never hides the capture's own result or error. Gemini then saves that snippet's result next to the frame as <frame>.layout.json with a one-line browser_evaluate. Neither snippet is in Gemini's prompt. A failed screenshot fails the capture, so Gemini skips the target; a failed layout step still keeps the frame and leaves the layout file "not run". The layout check lists horizontal page scroll, text spilling its box, clipped text, controls covered by something else (hit-testing only the part of a control its scroll containers show, and skipping controls under an open aria-modal sheet, and a control in a horizontal scroller only when what covers it belongs to that scroller's row: a sibling, or the row's edge control within the row's height), and controls cut off at the screen edge, each as {kind, text, testID, rect} (at most 50). A framework dev overlay (Expo's #error-overlay / #error-toast) is kept out of every check and reported once as dev-overlay when its host or anything inside it shows, including inside the host's shadow root as Expo draws it, with the largest shown box and its text, marking the frame as polluted. Text capped with -webkit-line-clamp or text-overflow: ellipsis (React Native Web's numberOfLines) is listed separately as "capped (line clamp / ellipsis)". The report's "Layout checks (measured in the page)" section shows each frame's entries, or "not run" when the file is missing, stale, outside artifactDir, malformed, or measured at another width than the frame. The snippet's readable source is src/layout-check.snippet.js; npm run snippet:build regenerates the minified constant, and npm test and the CI Chromium step fail when the two drift. The caller judges the entries; they never change the verdict.
    • The usage line is followed by Gemini's model steps, read from agy's conversation store (~/.gemini/antigravity-cli/conversations/<id>.db), and per frame for a live pass. It prints ? when the store can't be read.
  • screen-review: Have Gemini judge captured screens, or inventory a route before it is built.

    • mode (required): review judges PNGs after a live pass; plan inventories a route file and returns no verdict.
    • instructions (required): The caller's reviewer prompt, passed through verbatim so rule citations stay exact.
    • workingDirectory (required): The checkout the instructions cite; used as agy's cwd so repository-relative rule paths resolve.
    • images (review mode, required): Absolute PNG/JPEG paths that must exist. routeFile (plan mode, required): absolute path inside workingDirectory. Neither may contain whitespace β€” agy resolves an @reference up to the first space, so a spaced path would hang until printTimeout; the tool rejects it up front instead.
    • context (optional): Composition contract, issue text, anything else the reviewer prompt cites.
    • changedRoutes (optional, review mode): Repo-relative files the diff touched (from git diff --name-only). Gemini maps each image to the route file it shows, and a changed screen (under an app/ directory) that no image shows makes the review REQUEST_CHANGES β€” partial screenshot coverage is as unreviewed as none. A changed file under components/ only warns. The report prints a route β†’ image coverage table.
    • baseRef (optional, review mode): The git ref the diff is based on, such as origin/main. The tool resolves its merge base with HEAD in code and fails before calling Gemini when it does not resolve. Gemini may then run read-only git diff <merge-base>...HEAD (optionally --name-only, -- <paths>) and git show <merge-base>:<path>, so severity follows the branch's own diff (set yolo: true, since headless agy denies the shell otherwise); without it Gemini runs no git. Both modes bound Gemini's reads to the route file each image shows (or the plan's route file) and the components and primitives it renders, the changed files, the producer lines a capability check needs, and the cited rule files, READMEs and boards, and forbid running tests or npm and reading node_modules or release notes.
    • conversationId (optional): Round 2 keeps round 1's visual analysis.
    • model (optional, default Gemini 3.8 Flash (Medium)), printTimeout (optional, default 10m).
    • yolo (optional, default false): a review only reads. Set it to true when the instructions ask Gemini to read repository files that are not among the images β€” it reaches for a shell to do that, headless agy denies the shell, and the call fails naming the denied action.
  • brainstorm: Generate creative ideas with structured methodologies and domain context.

    • prompt (required): Brainstorming challenge or question to explore.
    • model (optional): The Antigravity model to use. Defaults to Gemini 4 Carbon (High). Pass an exact model listed by agy models to override it.
    • methodology (optional): Framework to use: divergent, convergent, scamper, design-thinking, lateral, or auto (default).
    • domain (optional): Domain context (e.g., 'software', 'business', 'creative', 'research').
    • constraints (optional): Known limitations or requirements.
    • existingContext (optional): Background information, previous attempts, or current state to build upon.
    • ideaCount (optional): Number of ideas to generate (default: 12).
    • includeAnalysis (optional): Include feasibility and impact analysis (default: true).
    • workingDirectory (optional): Working directory to run agy from.
  • fetch-chunk: Retrieve cached chunks from large changeMode responses.

    • cacheKey (required): Cache key from initial changeMode response.
    • chunkIndex (required): Chunk number to retrieve (1-based index).
  • ping: Echo test message to verify server connection.

    • prompt (optional): Message to echo back.
  • Help: Display Antigravity CLI (agy) help information.

Slash Commands (for the User)

You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested).

  • /ask-gemini: Ask Gemini through Antigravity CLI with caching and change mode.

    • Example: /ask-gemini prompt:@src/ summarize this directory
    • With sandbox: /ask-gemini prompt:@script.py test this safely sandbox:true
    • With change mode: /ask-gemini prompt:Refactor this code changeMode:true
    • Supported backend flags: model, sandbox, yolo, includeDirectories, printTimeout, resume, workingDirectory.
  • /brainstorm: Generate structured ideas with creative methodologies.

    • Example: /brainstorm prompt:How can we improve user onboarding? methodology:design-thinking domain:software
    • Quick use: /brainstorm prompt:Ideas for a mobile app feature
    • Supported flags: model, methodology, domain, constraints, existingContext, ideaCount, includeAnalysis, workingDirectory.
  • /live-pass: Walk a running app with Gemini and get a text verdict with per-frame observations.

    • Example: /live-pass driver:playwright workingDirectory:/path/to/worktree brief:"Base URL http://localhost:8081; marker: footer BRANCH: my-branch" targets:[{"screen":"home","state":"default","viewport":"390x844","expected":"order list with one seeded order"}]
    • Supported flags: targets, brief, workingDirectory, driver, artifactDir, model, printTimeout, yolo, publishCommand, conversationId.
  • /screen-review: Judge captured frames, or inventory a route file before building it.

    • Example: /screen-review mode:review workingDirectory:/path/to/worktree images:["/path/to/.live-pass/run/home-default-390x844.png"] instructions:"<reviewer prompt>"
    • Plan mode: /screen-review mode:plan workingDirectory:/path/to/worktree routeFile:/path/to/app/orders.tsx instructions:"<action inventory rules>"
  • /fetch-chunk: Retrieve next chunk of a large changeMode response.

    • Example: /fetch-chunk cacheKey:abc123 chunkIndex:2
  • /Help: Display Antigravity CLI help information.

    • Example: /Help
  • /ping: Test the MCP server connection.

    • Example: /ping prompt:Hello server!

Performance Features

This MCP server includes several performance optimizations:

  • LRU Response Cache (opt-in): Near-instant responses for repeated queries with 30-minute TTL and 10MB max size. Enable via AGY_CACHE_ENABLED=true env var.
  • Efficient Command Execution: O(n) array buffer performance for large outputs
  • Smart Chunking: Large changeMode responses are automatically chunked for better handling
  • Progress Notifications: Real-time progress updates during long-running operations

Contributing

Contributions are welcome! Please see our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.

Acknowledgments

This project was originally created by jamubc and is maintained as a fork by joeytheman. The original repository can be found at jamubc/gemini-mcp-tool.

License

This project is licensed under the MIT License (Non-Commercial). Commercial use is prohibited without prior written permission from the original copyright holder. See the LICENSE file for full details.

Disclaimer: This is an unofficial, third-party tool and is not affiliated with, endorsed, or sponsored by Google.