gemini-cli-mcp
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
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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