Gemini CLI

v1.0.0Developer Toolsstable

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

aiai-agentscligeminigemini-api
Share:
104,466
Stars
0
Downloads
0
Weekly
0/5

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

Google Gemini model access
Secure API wrapping
Local OAuth sessions
xjoker

Maintainer

LicenseMIT License
Languagetypescript
Versionv1.0.0
UpdatedMay 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y gemini-cli

Manual Installation

npx -y gemini-cli

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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 text
2

Install 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-mcp
3

Register 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-mcp
4

Add 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"
    }
  }
}
5

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.

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.

Quick Config Preview

{ "mcpServers": { "gemini-cli": { "command": "npx", "args": ["-y", "gemini-cli"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides