gemini-mcp-bridge
Allows interaction with Google's Gemini AI via the Gemini CLI, providing tools for agentic prompting with file context, web search, structured JSON output (with JSON Schema validation), and more.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gemini-mcp-bridge explain the authentication flow in this project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gemini-mcp-bridge
Deprecated and unmaintained
Google is retiring Gemini CLI on June 18, 2026 in favor of Antigravity CLI. After that date, Gemini CLI stops serving requests for Google AI Pro, Ultra, and free tier accounts (Gemini Code Assist for individuals). Enterprise customers on paid Gemini Code Assist Standard/Enterprise licenses retain access.
Because this bridge wraps Gemini CLI as a subprocess, it stops working for individual users on the same date. This repository is archived and the npm package is deprecated. No further releases are planned.
Migration options:
Antigravity CLI is Google's successor, written in Go, with Agent Skills, Hooks, Subagents, and plugins. Note: it is not open source.
For other terminal agents, see the sibling bridges: claude-mcp-bridge, codex-mcp-bridge.
Existing installs continue to function until June 18, 2026. The historical README follows.
MCP server that wraps Gemini CLI as a subprocess, exposing its capabilities as Model Context Protocol tools.
Works with any MCP client: Claude Code, Codex CLI, Cursor, Windsurf, VS Code, or any tool that speaks MCP.
Related MCP server: Vertex AI MCP Server
Do you need this?
If you're in a terminal agent (Claude Code, Codex CLI) with shell access, call Gemini CLI directly:
# File context query
gemini -p "Explain how this auth flow works" -- @src/auth.ts @src/session.ts
# Quick question
gemini -p "Is this approach sound for handling retries?"
# Web search
gemini -p --yolo "What's the latest stable Node.js LTS?"Tips: --yolo is needed for agentic file access in headless mode (without it, tool calls block). Use -m gemini-2.5-pro to skip the CLI's internal model routing (~1-2s). Cold start is ~16s per invocation. For code review, see Code review with this CLI below.
Use this MCP bridge instead when:
Your client has no shell access (Cursor, Windsurf, Claude Desktop, VS Code)
You need structured output with JSON Schema validation (Gemini CLI has no custom schema support)
You need concurrency management (max 3 parallel spawns, FIFO queue, optional pacing/jitter between CLI starts)
You need partial response capture on timeout (NDJSON streaming) and automatic model fallback on quota errors
You need response length controls (
maxResponseLengthparameter)You need oversized query/search responses paginated safely instead of getting truncated by MCP client limits (
structuredis intentionally not chunked, preserves machine-consumable JSON)You want subprocess isolation: env allowlist, path sandboxing, no shell escape
Quick Start
npx gemini-mcp-bridgePrerequisites
Gemini CLI installed (
npm i -g @google/gemini-cli)Authenticated (
gemini auth login)
Claude Code
claude mcp add gemini -s user -- npx -y gemini-mcp-bridgeCodex CLI
Add to ~/.codex/config.json:
{
"mcpServers": {
"gemini": {
"command": "npx",
"args": ["-y", "gemini-mcp-bridge"]
}
}
}Cursor / Windsurf / VS Code
Add to your MCP settings:
{
"gemini": {
"command": "npx",
"args": ["-y", "gemini-mcp-bridge"]
}
}Tools
Tool | Description |
query | Agentic prompt with optional file context. Gemini runs inside your repo with read/grep/glob tools. Supports text and images. |
search | Google Search grounded query. Gemini searches the web and synthesizes an answer with source URLs. |
structured | JSON Schema validated output via Ajv. Data extraction, classification, or any task needing machine-parseable output. |
ping | Health check. Verifies CLI is installed and authenticated, reports versions and capabilities. |
fetch-chunk | Retrieve later segments from a chunked |
query
Send a prompt with optional file paths as hints. Gemini reads the files itself and can explore surrounding code for context. Text queries run under --approval-mode plan (read-only agentic). Image queries use --yolo for native pixel access.
Key parameters: prompt (required), files (text or images), model, workingDirectory, timeout (default 120s, max 1800s), changeMode (see below).
Change mode: set changeMode: true to ask Gemini to emit structured **FILE: <path>:<start>-<end>** / ===OLD=== / ===NEW=== edit blocks instead of prose. The raw response stays in response (chunked normally); parsed edits are returned on _meta.edits as a machine-applicable array and are never chunked. A pre/post-spawn git snapshot detects any file writes Gemini might attempt, if writes are found, _meta.appliedWrites is set to true and edits is omitted so callers can't re-apply half-applied state. Text-only for v1; requires a git workingDirectory. Plan mode refuses to emit edit blocks (verified on CLI 0.38.0), so change mode runs in default agentic mode with the snapshot guardrail as the safety net.
search
Google Search grounded query. Spawns Gemini CLI in agentic mode with google_web_search, then synthesizes an answer with source URLs.
Key parameters: query (required), model, workingDirectory, timeout.
Large query and search responses are automatically chunked when they exceed the bridge threshold. The first chunk includes a cacheKey and chunk count in _meta and the response footer. Use fetch-chunk with that cacheKey and a 1-based chunkIndex to retrieve later segments within the 10-minute in-memory cache window. structured responses are intentionally not chunked (preserves machine-consumable JSON output).
structured
Generate JSON conforming to a provided schema. Schema is embedded in the prompt, response validated with Ajv. Returns isError: true with validation details on failure.
Key parameters: prompt (required), schema (required, JSON string), files, model, workingDirectory, timeout.
ping
No parameters. Returns CLI version, auth status, and server info.
All tools attach execution metadata (_meta) with durationMs, model, and partial (timeout indicator). See DESIGN.md for details.
Code review with this CLI
The review and assess tools were removed in v0.7.0 (see ADR-001). The gemini ecosystem already ships several review surfaces, listed here in priority order:
Official
gemini-cli-extensions/code-reviewextension (repo). Adds/code-reviewand/pr-code-reviewslash commands to the CLI.Skills (
/skills,.gemini/skills/code-reviewer/SKILL.md). Project- or user-scoped review prompts, invokable as slash commands.Subagents (
.gemini/agents/,~/.gemini/agents/). Specialized reviewer personas the CLI can delegate to.Gemini Code Assist GitHub app. Inline review on pull requests.
Direct
gemini -pwith hardened isolation flags. Pipe the diff via stdin (using$(git diff ...)as positional args expands the diff into shell tokens):git diff origin/main...HEAD | gemini --approval-mode plan \ -e "" \ --allowed-mcp-server-names "" \ -p "Review the diff on stdin for bugs, missing tests, and unhandled errors"--approval-mode planis read-only agentic.-e ""disables loaded extensions for this run.--allowed-mcp-server-names ""blocks bundled MCP servers. Default text output is preferred over--output-format jsonfor human-readable review notes.Third-party MCP servers if you specifically need an MCP-shaped review tool (e.g.
nicobailon/gemini-code-review-mcp).
Configuration
Variable | Default | Description |
| (CLI default) | Default model for all tools |
|
| Fallback on quota/rate-limit errors ( |
|
| Path to CLI binary |
|
| Max concurrent subprocess spawns |
|
| Minimum gap between Gemini CLI start times |
|
| Random extra delay before spawn to avoid deterministic timing |
Prompt templates for the search, structured, and query change-mode tools live in prompts/. Editable when running from a local clone; bundled when running via npx.
Choosing a Gemini MCP server
You need... | Consider |
Schema-validated structured output, concurrency management, response chunking | This bridge |
Shell command generation, Google Workspace integration | |
Lightweight large-context codebase analysis | |
No CLI dependency (API-only, broadest feature set) | |
Simple API wrapper with broad client support |
Performance
Each invocation spawns a fresh CLI process with ~15-20s cold start (large dependency tree, sync auth checks). No daemon mode yet (tracking; PR in progress).
Scenario | Typical time |
Minimal query | 17-25s |
File-context query (small repo) | 30-60s |
Web search + synthesis | 35-60s |
Structured output (small schema) | 25-45s |
Setting GEMINI_DEFAULT_MODEL avoids the CLI's internal model routing step (~1-2s savings per call).
Bridge family
Three MCP servers, same architecture, different underlying CLIs. Each wraps a terminal agent as a subprocess and exposes it as MCP tools. Pick the one that matches your model provider, or run multiple for cross-model workflows.
CLI | Gemini CLI | Claude Code | Codex CLI |
Provider | Anthropic | OpenAI | |
Tools | query, structured, search, fetch-chunk, ping | query, structured, search, ping, listSessions | codex, query, structured, search, ping, listSessions |
Code review | Use the gemini ecosystem: code-review extension, skills, subagents, Code Assist, or | Use Claude Code built-ins ( | Use |
Structured output | Ajv validation | Native | Ajv validation |
Session resume | Not supported | Native | Session IDs with multi-turn |
Budget caps | Not supported | Native | Not supported |
Effort control | Not supported |
|
|
Cold start | ~16s | ~1-2s | <100ms (inference dominates) |
Auth |
|
|
|
Cost | Free tier available | Subscription (included) or API credits | Pay-per-token |
Concurrency | 3 (configurable) | 3 (configurable) | 3 (configurable) |
Model fallback | Auto-retry with fallback model | Auto-retry with fallback model | Auto-retry with fallback model |
All three share: subprocess env isolation, path sandboxing, FIFO concurrency queue, MCP tool annotations, _meta response metadata, progress heartbeats. The codex and claude bridges also perform output redaction (secret stripping).
Development
npm install
npm run build # Compile TypeScript
npm run dev # Watch mode
npm test # Run tests
npm run lint # ESLint
npm run typecheck # tsc --noEmitFurther reading
DESIGN.md - Architecture, output streaming, concurrency, response metadata, prompt templates
SECURITY.md - Environment isolation, path sandboxing, agentic mode caveats, resource limits
CHANGELOG.md - Release history
License
MIT
Available Tools
5 toolsfetch-chunkARead-onlyIdempotent
Retrieve a cached chunk from a previously chunked response. Large query and search responses may return only the first chunk plus a cacheKey. Use this tool with that cacheKey and a 1-based chunkIndex to fetch the remaining segments before the 10-minute in-memory cache expires.
Inputs: cacheKey (required), chunkIndex (required), workingDirectory.
pingARead-onlyIdempotent
Health check. Verifies gemini CLI is installed and authenticated, reports CLI version, auth status, configured models, and server version. Fast (~1s, no model call).
Inputs: no named parameters.
queryA
Agentic query: Gemini runs inside your workingDirectory with read_file, grep, list_directory, and glob tools. Pass file paths as hints (not content) — Gemini reads them itself and can explore surrounding code for context.
Capabilities:
Code analysis with full repo exploration (Gemini follows imports, reads tests, checks related files)
Image understanding: screenshots, diagrams, architecture charts (png/jpg/gif/webp/bmp)
General knowledge questions and technical research
Text transformation, summarization, and generation
Change mode: structured edit blocks parsed into a machine-applicable
editsarray (see 'changeMode' below)
File handling: Pass file paths in the 'files' array as hints. Text files are referenced via @{path} — Gemini reads them with its own tools. Image files use --yolo mode for native pixel access. Gemini may also read files beyond the ones you hint at.
Note: Gitignored files cannot be read in text-query mode (plan mode restriction). Image queries (--yolo) can read gitignored files.
Change mode: set 'changeMode: true' to ask Gemini to emit structured **FILE: <path>:<start>-<end>** / ===OLD=== / ===NEW=== blocks instead of prose. The response text stays in response; parsed edits are returned on _meta.edits and never chunked. The tool runs in default agentic mode (NOT plan mode, which refuses to emit edit blocks) with a pre/post-spawn git snapshot that detects any file writes Gemini might attempt. If writes are detected the tool returns _meta.appliedWrites: true and omits edits for safety. Text-only (image files rejected). Requires a git working directory.
Model tips: Use gemini-2.5-flash for speed, gemini-2.5-pro for depth and complex reasoning. If omitted, the CLI auto-selects via its routing model.
Each invocation spawns a fresh CLI process (~15-20s startup overhead). Plan timeouts accordingly.
Inputs: prompt (required), files, model, timeout, +3 more.
searchARead-onlyIdempotent
Google Search grounded research. Gemini searches the web using google_web_search and synthesizes a comprehensive answer with source URLs and citations.
Use for: current events, documentation lookups, API references, comparing technologies, verifying facts, finding recent releases or changelogs.
The query can be a natural language question or a search-style keyword string. Gemini may issue multiple searches to build a complete answer. Results include source URLs for verification.
Output is a synthesized summary (500-1500 words by default), not raw search results. Use maxResponseLength to adjust.
Inputs: query (required), model, timeout, workingDirectory, +1 more.
structuredARead-only
Agentic structured output: generate a JSON response conforming to a provided JSON Schema. Gemini runs inside workingDirectory with read_file and grep tools, so it can read files for context. Use for data extraction, classification, or any task needing machine-parseable output. The response is validated against the schema; isError is true if validation fails.
Inputs: prompt (required), schema (required), files, model, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: ping for health, query for agentic code/Q&A, search for web-grounded answers, structured for schema-validated JSON, and fetch-chunk for retrieving large responses. Even query and structured, which both use file access, are differentiated by output format and validation.
Names are all lowercase and concise, but they mix verbs (ping, search, fetch-chunk), a noun (query), and an adjective (structured). There is no consistent verb_noun pattern, though the simple style remains readable and not chaotic.
Five tools is well-scoped for a Gemini bridge, covering health checking, general and code-aware querying, web search, structured output, and chunk retrieval. Each tool has a clear role and none feels redundant.
The tool set covers core Gemini workflows: health verification, agentic analysis, web research, structured extraction, and large-response handling. Minor gaps exist, such as explicit model management or conversation history, but they are not essential for the server's stated purpose.
Maintenance
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseAqualityDmaintenanceModel Context Protocol (MCP) server implementation that enables Claude Desktop to interact with Google's Gemini AI models.675 npm260MIT
- AlicenseAqualityDmaintenanceImplementation of Model Context Protocol (MCP) server that provides tools for accessing Google Cloud's Vertex AI Gemini models, supporting features like web search grounding and direct knowledge answering for coding assistance and general queries.20235 npm88MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that wraps the Gemini CLI to provide tools for executing prompts, managing chat sessions, and accessing CLI extensions. It supports both local stdio and remote SSE transports for flexible integration with MCP clients.1-
- AlicenseAqualityDmaintenanceWraps the Gemini CLI as an MCP server, enabling AI tools to perform Gemini queries, interactive sessions, and extension management via a unified tool.411MIT