Gemini CLI
A secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
What is Gemini CLI?
Gemini CLI is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to secure mcp server that wraps the google gemini cli, allowing clients to query gemini models using local oauth sessions without requiring an api key. it provides tools for model interaction and diagnos...
A secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- A secure MCP server that wraps the Google Gemini CLI, allowi
Use Cases
Maintainer
Works with
Installation
NPM
npx -y gemini-cliManual Installation
npx -y gemini-cliConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Gemini CLI
The gemini-cli-mcp server is a secure MCP wrapper around Google's Gemini CLI that lets Claude (or any MCP client) query Gemini models using your existing local Google OAuth session — no API key required. It exposes exactly two tools: gemini_query for sending prompts to Gemini models and gemini_info for diagnostics. The server is built with security-first process spawning (no shell injection), an activity-based timeout that handles long thinking responses, and a minimal system prompt that cuts Gemini's default 8,800-token prompt down to ~50 tokens, saving significant context on every call.
Prerequisites
- Node.js 18 or higher
- Google Gemini CLI installed globally: npm install -g @google/gemini-cli
- Gemini CLI authenticated: run 'gemini' once to complete Google OAuth login
- An MCP-compatible client such as Claude Desktop or Claude Code CLI
Install and authenticate the Gemini CLI
Install the official Google Gemini CLI globally and complete the OAuth login flow. The gemini-cli-mcp server delegates all authentication to this pre-authenticated session.
npm install -g @google/gemini-cli
gemini
# Complete OAuth login in browser, then verify:
gemini -p "say hello" -o textInstall the gemini-cli-mcp package
Install the MCP wrapper globally from npm under the package name @xjoker/gemini-cli-mcp, which publishes the gemini-cli-mcp binary.
npm install -g @xjoker/gemini-cli-mcpRegister with Claude Code CLI (optional)
If you use Claude Code CLI, register the server at user scope so it is available across all projects.
claude mcp add gemini-cli -s user -- gemini-cli-mcpAdd to Claude Desktop configuration
Edit your Claude Desktop config to register the server. No environment variables are required for basic use; the OAuth session from the Gemini CLI login is reused automatically.
{
"mcpServers": {
"gemini-cli": {
"command": "gemini-cli-mcp"
}
}
}Verify the connection
Ask your MCP client to ping the Gemini server or query a model. The gemini_info tool with action 'ping' costs zero API calls and confirms the CLI is reachable.
Gemini CLI Examples
Client configuration
Full Claude Desktop config for gemini-cli-mcp with optional model and timeout overrides.
{
"mcpServers": {
"gemini-cli": {
"command": "gemini-cli-mcp",
"env": {
"GEMINI_MODEL": "gemini-2.5-flash",
"GEMINI_TIMEOUT": "120000",
"GEMINI_MAX_RESPONSE": "100000"
}
}
}
}Prompts to try
Example prompts that use the gemini_query and gemini_info tools exposed by the server.
- "Ask Gemini 2.5 Pro to review this code and suggest optimizations"
- "Use gemini_info to list the available Gemini models"
- "Query Gemini with the prompt: 'Explain quantum entanglement in plain English' using the flash model"
- "Ask Gemini to analyze the file @src/main.py and identify potential bugs"
- "Get the current Gemini CLI version and check connectivity"Troubleshooting Gemini CLI
gemini_query returns auth errors or 'not logged in'
Re-run the 'gemini' command in your terminal to complete the OAuth flow again. Sessions can expire. After re-authenticating, verify with 'gemini -p "hello" -o text' before restarting your MCP client.
Server exits immediately or cannot find the gemini binary
The GEMINI_BIN environment variable defaults to 'gemini'. If your Gemini CLI is installed to a non-standard path, set GEMINI_BIN to the absolute path of the binary. Confirm the CLI is on your PATH by running 'which gemini'.
Long prompts time out before Gemini responds
Increase GEMINI_TIMEOUT (default 120000ms = 2 minutes) and GEMINI_STARTUP_TIMEOUT (default 15000ms) in your env config. The timeout is activity-based and resets on each output chunk, so very long thinking sessions may still hit the idle limit.
Frequently Asked Questions about Gemini CLI
What is Gemini CLI?
Gemini CLI is a Model Context Protocol (MCP) server that secure mcp server that wraps the google gemini cli, allowing clients to query gemini models using local oauth sessions without requiring an api key. it provides tools for model interaction and diagnostics with built-in protection against command in It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Gemini CLI?
Install via npm with the command: npx -y gemini-cli. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with Gemini CLI?
Gemini CLI works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Gemini CLI free to use?
Yes, Gemini CLI is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
Gemini CLI Alternatives — Similar Developer Tools Servers
Looking for alternatives to Gemini CLI? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Awesome Claude Skills
★ 61.1kA curated list of awesome Claude Skills, resources, and tools for customizing Claude AI workflows
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Gemini CLI in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Gemini CLI?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.