gemini-cli-bridge
Integrates with Google's Gemini AI model and Google Search, allowing AI agents to send prompts, perform web fetches, and execute Google searches through the Gemini CLI, with structured JSON responses.
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-cli-bridge prompt: write a short story about a robot"
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 CLI MCP Bridge
[English] | 简体中文
A tiny bridge that exposes your local Gemini CLI as an MCP (Model Context Protocol) stdio server. It wraps common Gemini CLI flows and adds handy file/network utilities for tools-capable clients like Codex CLI and Claude Code.
Note: In client UIs and configs, the server is displayed as "Gemini" while the command remains gemini-cli-bridge (or uvx --from . gemini-cli-bridge).
Features
Standard MCP (stdio) server
Thin wrappers for common Gemini CLI flows: version, prompt, WebFetch/Search, MCP management
Utilities: read/write files, list folders, simple web fetch, text search, optional Shell (disabled by default)
Runs with uv/uvx without manually installing dependencies
Related MCP server: Gemini CLI MCP/OpenAI Bridge
Prerequisites
Python 3.10+ (3.11+ recommended)
Gemini CLI installed and authenticated (used to call the actual model)
On macOS, ensure Homebrew bin is in PATH:
/opt/homebrew/bin
Quick checks:
python3 --version
which gemini && gemini --versionInstall & Run
Quick install (PyPI)
pip
pip install gemini-cli-bridgeStart:
gemini-cli-bridge(Ctrl+C to exit)
pipx (isolated)
pipx install gemini-cli-bridgegemini-cli-bridge
Clone first:
git clone https://github.com/chaodongzhang/gemini_cli_bridge.git
cd gemini_cli_bridgeClone repository (for dev workflows):
git clone https://github.com/chaodongzhang/gemini_cli_bridge.git
cd gemini_cli_bridgeFrom source (dev), install as a global tool via uv:
uv tool install --from . gemini-cli-bridge
# Verify (should work from any directory)
gemini-cli-bridgeAdd uv tools dir to PATH if needed.
macOS (zsh):
# Typically: $HOME/Library/Application Support/uv/tools/bin echo 'export PATH="$HOME/Library/Application Support/uv/tools/bin:$PATH"' >> ~/.zshrc && source ~/.zshrcLinux: usually
~/.local/bin.
One-off try (uvx, no install):
uvx --from . gemini-cli-bridgeDirect run (repo checkout):
python3 ./gemini_cli_bridge.pyRelease downloads
Prebuilt wheels and source tarballs are available on GitHub Releases: https://github.com/chaodongzhang/gemini_cli_bridge/releases
Notes
Runs in foreground; press Ctrl+C to stop.
On macOS ensure
/opt/homebrew/binis on PATH.uv tools bin (if needed):
$HOME/Library/Application Support/uv/tools/bin.
Use with common clients (stdio)
Examples below use stdio; adjust command/paths for your system.
1) Codex CLI (global TOML)
~/.codex/config.toml:
[mcp_servers.Gemini]
command = "gemini-cli-bridge"
args = []
[mcp_servers.Gemini.env]
NO_COLOR = "1"Notes:
As of 2025-09-10, Codex only supports a global
~/.codex/config.toml.Restart Codex after changes. Use
gemini_versionas a quick health check.
2) Claude Code (VS Code extension)
User Settings (JSON):
{
"claude.mcpServers": {
"Gemini": {
"command": "gemini-cli-bridge",
"args": [],
"env": { "NO_COLOR": "1" }
}
}
}3) Generic MCP CLI (for local testing)
npm i -g @modelcontextprotocol/cli
mcp-cli --server gemini-cli-bridge4) Claude Desktop (optional)
{
"mcpServers": {
"Gemini": {
"command": "gemini-cli-bridge",
"args": [],
"env": { "NO_COLOR": "1" }
}
}
}Typical usage (from clients)
Version:
gemini_versionNon-interactive prompt:
gemini_prompt(prompt=..., model="gemini-2.5-pro")Advanced prompt with attachments/approval:
gemini_prompt_plus(...)Web fetch:
gemini_web_fetch(prompt, urls=[...])Manage Gemini CLI MCP:
gemini_mcp_list / gemini_mcp_add / gemini_mcp_removeGoogle search:
GoogleSearch(query="...", limit=5)(defaults to CLI built-in)Alias to avoid tool name conflicts:
GeminiGoogleSearch(...)(same args asGoogleSearch)
Return shape note (wrappers):
Gemini CLI wrappers now return structured JSON:
{ "ok", "exit_code", "stdout", "stderr" }. Tools affected:gemini_version,gemini_prompt,gemini_prompt_plus,gemini_prompt_with_memory,gemini_search,gemini_web_fetch,gemini_extensions_list,gemini_mcp_list/add/remove.
Notes about GoogleSearch:
By default it uses Gemini CLI’s built-in GoogleSearch (no Google API keys needed, assuming you’re logged in to the CLI).
If both
GOOGLE_CSE_IDandGOOGLE_API_KEYare set (env or args), it switches to Google Programmable Search (CSE).You can force the mode via
mode:"gemini_cli" | "gcs" | "auto"(default auto).
MCP tool call examples
gemini_prompt_plus payload example:
{
"name": "gemini_prompt_plus",
"arguments": {
"prompt": "hello",
"extra_args": ["--debug", "--proxy=http://127.0.0.1:7890"]
}
}Minimal GoogleSearch payload (defaults to CLI built-in):
{
"name": "GoogleSearch",
"arguments": {
"query": "Acme Corp",
"limit": 5
}
}Use the alias to avoid naming conflicts in some IDEs:
{
"name": "GeminiGoogleSearch",
"arguments": {
"query": "today ai industry news",
"limit": 5
}
}Force built-in mode (no keys):
{
"name": "GoogleSearch",
"arguments": {
"query": "today ai industry news",
"limit": 5,
"mode": "gemini_cli"
}
}Troubleshooting startup/handshake timeouts
Prefer installed command over
uvx --from .to avoid cold-start dependency resolution.Increase client startup/handshake timeouts if supported.
PATH issues on macOS: ensure
/opt/homebrew/binor set PATH in client env.
Make sure it uses CLI built-in search (avoid unintended CSE mode)
Possible causes:
Another tool named
GoogleSearchfrom a different server/extension.Your environment sets both
GOOGLE_API_KEYandGOOGLE_CSE_ID, which switches this bridge into CSE mode.
What to do:
Explicitly clear two vars in your MCP config
Codex (~/.codex/config.toml):
[mcp_servers.Gemini]
command = "gemini-cli-bridge"
args = []
[mcp_servers.Gemini.env]
PATH = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
GOOGLE_API_KEY = ""
GOOGLE_CSE_ID = ""Claude Code (VS Code settings JSON):
{
"claude.mcpServers": {
"Gemini": {
"command": "gemini-cli-bridge",
"args": [],
"env": { "GOOGLE_API_KEY": "", "GOOGLE_CSE_ID": "" }
}
}
}Disambiguate in prompts
Ask explicitly: “Use GoogleSearch from MCP server ‘Gemini’ …”.
Verify the path taken
Call
gemini_version(should returngemini --version).Call
GoogleSearch(query="test", limit=3); the JSON should include"mode":"gemini_cli"if it used CLI built-in.
Avoid tool name conflicts (optional)
If another GoogleSearch exists in your IDE, consider renaming this tool to GeminiGoogleSearch in code to remove ambiguity.
Developer Notes
Standardized gemini wrapper output
Use the helper
_run_gemini_and_format_output(cmd, timeout_s)for allgemini_*tools to return a consistent JSON shape:{ ok, exit_code, stdout, stderr }.When adding new Gemini CLI wrappers, focus on building the
cmdlist and delegate execution/formatting to the helper.
WebFetch behavior
Uses
requestsand respectsGEMINI_BRIDGE_MAX_OUTfor truncation viaget_max_out().Blocks private/loopback/link-local targets using
_is_private_url.Returns
{ ok, status, content?, error? }.
Running tests
pytest -qafter installing dev deps, or run without installing by settingPYTHONPATH:PYTHONPATH=.::tests pytest -q
A lightweight
tests/fastmcp.pyshim is included so tests run without installing external packages.
Publishing
GitHub Release: push a tag like
v0.1.xto trigger artifact build and release.PyPI: supports Trusted Publisher (OIDC). Push a tag
v*to publish viapypa/gh-action-pypi-publish(no API token needed once Trusted Publisher is configured on PyPI).See
CHANGELOG.mdfor version history.
Configuration (env)
GEMINI_BRIDGE_MAX_OUT(int > 0): unified output truncation length. Default 200000.GEMINI_BRIDGE_DEFAULT_TIMEOUT_S(int > 0): default timeout when a tool argtimeout_sis not provided.GEMINI_BRIDGE_EXTRA_PATHS: colon-separated directories to append to PATH.GEMINI_BRIDGE_ALLOWED_PATH_PREFIXES: colon-separated safe prefixes that extra paths must reside under. Defaults include/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/sbin.
Notes
PATH cannot be overridden directly by tools; only appended via the whitelist above.
Shell tool remains disabled unless
MCP_BASH_ALLOW=1.
License
MIT
Available Tools
22 toolsEditEditC
String replace; count=0 means replace all. Return JSON {"replaced": n}.
Inputs: find (required), path (required), replace (required), count. Returns: result
FindFilesFindfilesC
Find files; return JSON array of paths. Supports recursion.
Inputs: base, pattern, recursive. Returns: result
gemini_extensions_listGemini Extensions ListB
List available Gemini CLI extensions (gemini --list-extensions).
Inputs: timeout_s. Returns: result
GeminiGoogleSearchGeminigooglesearchC
Alias to GoogleSearch to avoid tool name collisions in some IDEs.
Inputs: query (required), mode, limit, model, +3 more. Returns: result
gemini_mcp_addGemini Mcp AddB
Add an MCP server via gemini CLI (gemini mcp add ...). transport: stdio|http|sse; for stdio pass executable, for http/sse pass URL. headers are only valid for http/sse. Returns CLI stdout.
Inputs: name (required), command_or_url (required), args, scope, +9 more. Returns: result
gemini_mcp_listGemini Mcp ListB
List MCP servers configured in gemini CLI (gemini mcp list). Scope: user|project.
Inputs: scope, timeout_s. Returns: result
gemini_mcp_removeGemini Mcp RemoveB
Remove an MCP server from gemini CLI (gemini mcp remove ).
Inputs: name (required), scope, timeout_s. Returns: result
gemini_promptGemini PromptC
Run local gemini CLI non-interactively; return structured JSON.
Inputs: prompt (required), model, timeout_s, extra_args, +1 more. Returns: result
gemini_prompt_plusGemini Prompt PlusC
Advanced non-interactive run with attachments/approval/checkpoint/dirs/flags.
attachments: file/dir paths appended as @path at the end of prompt.
approval_mode: default|auto_edit|yolo; if unset and yolo=True, add --yolo.
Inputs: prompt (required), yolo, model, timeout_s, +5 more. Returns: result
gemini_prompt_with_memoryGemini Prompt With MemoryC
Inject memory_paths as high-priority context, then run non-interactively.
memory_paths: authoritative project/system memory (e.g., GEMINI.md, conventions).
attachments: additional files/dirs injected as @path.
Inputs: prompt (required), yolo, model, timeout_s, +6 more. Returns: result
gemini_searchGemini SearchC
Lightweight search: guide the model to use built-in GoogleSearch and cite sources. Note: tool invocation is model-driven; default yolo=True to avoid interactive prompts.
Inputs: query (required), yolo, model, timeout_s, +4 more. Returns: result
gemini_versionGemini VersionB
Return installed gemini CLI version (gemini --version) as JSON.
Inputs: timeout_s. Returns: result
gemini_web_fetchGemini Web FetchC
Convenience wrapper: inject URLs into prompt to trigger CLI WebFetch. Note: WebFetch is a CLI built-in; the model decides whether to call it.
Inputs: urls (required), prompt (required), yolo, model, +5 more. Returns: result
GoogleSearchGooglesearchA
Search tool (defaults to Gemini CLI built-in GoogleSearch).
Modes:
mode="gemini_cli": force CLI built-in (no keys; requires signed-in gemini CLI)
mode="gcs": force Google Programmable Search (requires GOOGLE_CSE_ID + GOOGLE_API_KEY)
mode=None/"auto": auto-select (use gcs if both keys present, else gemini_cli)
Returns JSON:
gemini_cli: { ok: true, mode: "gemini_cli", answer: string }
gcs: { ok: true, mode: "gcs", results: [{title, link, snippet}] } on error: { ok: false, error, results? }
Inputs: query (required), mode, limit, model, +3 more. Returns: result
ReadFileReadfileB
Read a text file (utf-8, ignore errors). Raises if missing.
Inputs: path (required). Returns: result
ReadFolderReadfolderC
Read a directory; return JSON array of entries (optionally recursive).
Inputs: path, recursive, max_entries. Returns: result
ReadManyFilesReadmanyfilesC
Read multiple files; return JSON object {path: content}.
Inputs: paths (required), ignore_missing. Returns: result
SaveMemorySavememoryC
Save content to path; mode=append|overwrite; return JSON {ok, bytes}.
Inputs: path (required), content (required), mode. Returns: result
SearchTextSearchtextC
Search text within a file; return JSON array [{line, text}].
Inputs: path (required), pattern (required), case_insensitive. Returns: result
ShellShellB
Execute a shell command; return JSON {code, stdout, stderr}. Disabled by default; set MCP_BASH_ALLOW=1 to enable.
Inputs: cmd (required), cwd, timeout_s. Returns: result
WebFetchWebfetchB
Minimal web fetch using the requests library; return JSON {ok,status,content?,error?}.
Inputs: url (required), timeout_s. Returns: result
WriteFileWritefileB
Write a UTF-8 text file, creating parents as needed. Return "ok".
Inputs: path (required), content (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 22 tools
Several tool families overlap: gemini_prompt/plus/with_memory, gemini_search/GoogleSearch/GeminiGoogleSearch, and WebFetch/gemini_web_fetch. Descriptions distinguish intended use cases, but an agent still faces non-trivial selection among prompt and search variants.
Names split into a snake_case gemini_* family for CLI operations and a PascalCase family for local file/search/shell tools. This is readable but not a single predictable convention.
22 tools is on the heavy side for a CLI bridge, spanning CLI invocation, MCP management, search, file I/O, memory, and shell. The surface is broad but many tools earn their place.
Core bridge operations are covered: prompt execution, MCP add/list/remove, version/extensions, search/fetch, file read/write/search/find, memory, and shell. Minor gaps like file deletion/move or MCP update are workaroundable via shell or overwrite.
Maintenance
Related MCP Connectors
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- 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-
- AlicenseNot gradedqualityFmaintenanceExposes Gemini CLI's built-in tools and external MCP proxies through a unified MCP endpoint while providing an OpenAI-compatible API for Gemini models. It features configurable security modes to safely manage file system operations, web searches, and shell command execution.24 npm138Apache 2.0
- 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
- AlicenseNot gradedqualityDmaintenanceThin MCP server wrapping the Gemini CLI for AI assistants, supporting workspace-aware multi-repository analysis and forward-compatible flags.81 PyPIMIT