gemini-cli-mcp
gemini-cli-mcp is an MCP server that lets MCP clients like Claude Code interact with Google Gemini AI models through a locally authenticated Gemini CLI, without needing an API key.
gemini_query — Send prompts to Gemini models:
Choose from multiple models (
gemini-2.5-pro,gemini-2.5-flash,gemini-2.5-flash-lite, preview models, or aliases likeauto,pro,flash)Reference local files in prompts using
@file.tssyntaxEnable sandbox mode for safe code execution
Set approval modes:
default,auto_edit,yolo(auto-approve all actions), orplan(read-only)Specify a working directory and additional workspace directories for file context
Include token usage statistics in responses
gemini_info — Diagnostics and metadata with minimal/zero API calls:
ping: Test CLI connectivityversion: Get the installed Gemini CLI versionlist_models: View available models and aliaseslist_sessions: Browse past conversation sessionslist_extensions: View installed extensions
Defaults for model, timeouts, binary path, and system prompts can be configured via environment variables. Works cross-platform on macOS, Linux, and Windows with security measures to prevent command injection.
Wraps the Google Gemini CLI to provide tools for querying Gemini models (such as Gemini 2.5 and 3), listing available models and aliases, and managing past sessions using local OAuth authentication.
Click on "Install 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-mcpask gemini-2.5-pro to explain the logic in @index.ts"
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
A secure MCP server that wraps Google's Gemini CLI. It lets Claude Code (or any MCP client) call Gemini models using your local OAuth session — no API key required.
Highlights
Secure —
spawn(shell:false)on Unix; controlledshell:true+ arg escaping on Windows. No command injection.Cross-platform — macOS, Linux, Windows. Auto-resolves
.cmdwrappers and forces UTF-8.Activity-based timeout — idle timer resets on each output chunk. Long thinking won't be killed; stuck 429 retries will.
Low token overhead — replaces Gemini's ~8 800-token default system prompt with a minimal one (~50 tokens).
Clean output — internally uses
stream-jsonand parses structured responses. No stdout noise pollution.2 tools only —
gemini_query+gemini_info. Minimal context-window footprint for the host AI.
Prerequisites
Node.js >= 18 — Download
Google Gemini CLI — installed globally and logged in:
npm install -g @google/gemini-cli
gemini # run once — complete the Google OAuth login in your browserVerify it works before using this MCP server:
gemini -p "say hello" -o text
# Should print a response. If you see auth errors, re-run `gemini` to log in.Install
NPM (recommended)
npm install -g @xjoker/gemini-cli-mcp
# Register with Claude Code
claude mcp add gemini-cli -s user -- gemini-cli-mcpFrom source
git clone https://github.com/xjoker/gemini-cli-mcp.git
cd gemini-cli-mcp
npm install && npm run build
claude mcp add gemini-cli -s user -- node $(pwd)/dist/index.jsClaude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"gemini-cli": {
"command": "gemini-cli-mcp"
}
}
}Upgrade
npm update -g @xjoker/gemini-cli-mcpTools
gemini_query
Send a prompt to Gemini.
Parameter | Type | Required | Description |
| string | Yes | Prompt text. Use |
| string | No | Model name or alias (default: |
| boolean | No | Run in sandboxed environment |
| boolean | No | Auto-approve all tool actions |
| enum | No |
|
| boolean | No | Append token usage stats |
| string[] | No | Extra workspace directories |
| string | No | Working directory for |
gemini_info
Diagnostics and metadata — most actions cost zero API calls.
Action | Description | API call? |
| Test CLI connectivity | No |
| Get CLI version | No |
| Show available models and aliases | No |
| List past Gemini sessions | No |
| List installed Gemini extensions | No |
Models
Model | Tier | Description |
| stable | High reasoning & creativity |
| stable | Fast, balanced (default) |
| stable | Fastest, lightest |
| preview | Gemini 3 Pro |
| preview | Gemini 3 Flash |
| preview | Gemini 3.1 Pro (rolling out) |
| preview | Gemini 3.1 Flash Lite |
Aliases: auto, pro, flash, flash-lite
Free tier quota: 60 RPM / 1 000 requests per day.
Environment Variables
Variable | Default | Description |
|
| Default model |
|
| Phase 1 idle timeout (ms) — CLI startup and initial response |
|
| Phase 2 idle timeout (ms) — thinking, resets on each output chunk |
|
| Max response chars before truncation |
|
| Path to Gemini CLI binary |
| (bundled minimal) | Path to custom system prompt, or |
Security
Platform | Strategy |
Unix |
|
Windows |
|
Zero usage of
exec()/execSync()/ template-string commands.Verify:
grep -rn "exec(" src/returns nothing.
License
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/xjoker/gemini-cli-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server