Gemini CLI MCP Server
A lightweight FastMCP server that wraps Google's Gemini CLI as MCP tools. Works with any MCP client — Hermes Agent, Claude Code, Claude Desktop, Cursor, etc.
Prerequisites
- Node.js — for the Gemini CLI
- Python 3.11+ — for the MCP server
- Gemini CLI — installed and authenticated
npm install -g @google/gemini-cli
gemini --version # Verify install
gemini # Run once to complete OAuth login
Installation
Option 1: pip install
pip install gemini-cli-fastmcp
gemini-mcp # starts the MCP server
Option 2: From source
# Clone the repo
git clone https://github.com/jxsprt/gemini-mcp-server.git
cd gemini-mcp-server
# Create venv and install deps
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
Configuration
Add to your MCP client's config:
Hermes Agent (~/.hermes/config.yaml)
mcp_servers:
gemini-cli:
command: "/path/to/gemini-mcp-server/.venv/bin/python3"
args: ["/path/to/gemini-mcp-server/server.py"]
timeout: 240
Restart your Hermes gateway. Tools will be available as mcp_gemini_cli_*.
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"gemini-cli": {
"command": "/path/to/gemini-mcp-server/.venv/bin/python3",
"args": ["/path/to/gemini-mcp-server/server.py"]
}
}
}
Claude Code
fastmcp install claude-code /path/to/gemini-mcp-server/server.py
Cursor
fastmcp install cursor /path/to/gemini-mcp-server/server.py -e .
Tools
gemini_prompt
Send any prompt to Gemini CLI non-interactively. Supports model selection and JSON output.
Safe by default — uses --approval-mode auto-edit (auto-approves file edits, prompts for shell). Pass dangerous=true for full yolo mode.
gemini_prompt(prompt="Explain TCP handshake", model="gemini-2.5-flash")
gemini_prompt(prompt="Refactor this module", dangerous=True) # full auto-approval
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | ✅ | — | Prompt text (max ~100K chars) |
model |
string | ❌ | CLI default | Model name (e.g., gemini-3-flash-preview) |
output_format |
string | ❌ | text |
text, json, or stream-json |
dangerous |
bool | ❌ | false |
Use --approval-mode yolo (auto-approves shell) |
gemini_plan
Read-only audit and review mode. Uses --approval-mode plan — guarantees no file mutations or shell execution. Safe for whole-repo analysis and code reviews.
gemini_plan(prompt="Review this auth module for security issues")
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | ✅ | — | Analysis question or review request |
model |
string | ❌ | CLI default | Gemini model |
include_directories |
string | ❌ | — | Comma-separated additional dirs |
gemini_version
Returns the installed Gemini CLI version.
gemini_version() # → "0.41.2"
Verification
cd /path/to/gemini-mcp-server
.venv/bin/python -c "
import server
print('Version:', server.gemini_version())
print('Prompt:', server.gemini_prompt('Say hello in one word'))
print('Plan:', server.gemini_plan('What tools does this server have?'))
"
How It Works
The server shells out to gemini -p "prompt" --approval-mode yolo for each tool call. It does NOT use the Google Gen AI Python SDK — it goes through the Gemini CLI binary (OAuth-authenticated).
Key design decisions:
- Stdio transport — runs as a subprocess of your MCP client
- No hardcoded paths — discovers
geminion PATH - No API keys in config — uses the CLI's existing OAuth session
- Retry-friendly — generous timeouts (120s default, 240s for plan mode) to handle Gemini's capacity retries
Notes
- Capacity errors: Gemini's reasoning models can hit rate limits. The CLI retries up to 7 times with backoff. If it fails, try again later or use a different model.
- Plan mode is safe:
--approval-mode planexplicitly prevents the agent from writing files or executing shell commands. Read-only, guaranteed. - 1M token context: Gemini CLI supports the full 1M token context window of Gemini models.
License
MIT
Metadata
Release files for gemini-cli-mcp-fast 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gemini_cli_mcp_fast-1.0.1.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gemini_cli_mcp_fast-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / gemini_cli_mcp_fast-1.0.1.tar.gz
| Download URL | gemini_cli_mcp_fast-1.0.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3252981027f5c9fcf65eb934eea56d14a4b9263c29d3d819bdda1f0e07dae75d
|
|
BLAKE2b-256 checksum How to use checksums |
1bd2c6a2c4d01d3544cd4f2675025371944db85983b72d8328bf9972479ed70b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / gemini_cli_mcp_fast-1.0.1-py3-none-any.whl
| Download URL | gemini_cli_mcp_fast-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e08b50c8069e2d929942c9dffdf846de6076fc9936b82d746007b1c63034fd92
|
|
BLAKE2b-256 checksum How to use checksums |
09f186449af215faa45542bf4fa5783209fa144dfae59b51cf865d3fa97e2486
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|