Skip to main content
Glama

gemini-cli-mcp

npm version npm downloads license node GitHub stars

中文文档

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

  • Securespawn(shell:false) on Unix; controlled shell:true + arg escaping on Windows. No command injection.

  • Cross-platform — macOS, Linux, Windows. Auto-resolves .cmd wrappers 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-json and parses structured responses. No stdout noise pollution.

  • 2 tools onlygemini_query + gemini_info. Minimal context-window footprint for the host AI.

Related MCP server: Gemini CLI MCP/OpenAI Bridge

Prerequisites

  1. Node.js >= 18Download

  2. Google Gemini CLI — installed globally and logged in:

npm install -g @google/gemini-cli
gemini   # run once — complete the Google OAuth login in your browser
  1. Verify 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 install -g @xjoker/gemini-cli-mcp

# Register with Claude Code
claude mcp add gemini-cli -s user -- gemini-cli-mcp

From 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.js

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "gemini-cli": {
      "command": "gemini-cli-mcp"
    }
  }
}

Upgrade

npm update -g @xjoker/gemini-cli-mcp

Tools

gemini_query

Send a prompt to Gemini.

Parameter

Type

Required

Description

prompt

string

Yes

Prompt text. Use @file.ts to include local files.

model

string

No

Model name or alias (default: gemini-2.5-flash)

sandbox

boolean

No

Run in sandboxed environment

yolo

boolean

No

Auto-approve all tool actions

approval_mode

enum

No

default / auto_edit / yolo / plan

include_stats

boolean

No

Append token usage stats

include_directories

string[]

No

Extra workspace directories

cwd

string

No

Working directory for @file references

gemini_info

Diagnostics and metadata — most actions cost zero API calls.

Action

Description

API call?

ping

Test CLI connectivity

No

version

Get CLI version

No

list_models

Show available models and aliases

No

list_sessions

List past Gemini sessions

No

list_extensions

List installed Gemini extensions

No

Models

Model

Tier

Description

gemini-2.5-pro

stable

High reasoning & creativity

gemini-2.5-flash

stable

Fast, balanced (default)

gemini-2.5-flash-lite

stable

Fastest, lightest

gemini-3-pro-preview

preview

Gemini 3 Pro

gemini-3-flash-preview

preview

Gemini 3 Flash

gemini-3.1-pro-preview

preview

Gemini 3.1 Pro (rolling out)

gemini-3.1-flash-lite-preview

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

GEMINI_MODEL

gemini-2.5-flash

Default model

GEMINI_STARTUP_TIMEOUT

15000

Phase 1 idle timeout (ms) — CLI startup and initial response

GEMINI_TIMEOUT

120000

Phase 2 idle timeout (ms) — thinking, resets on each output chunk

GEMINI_MAX_RESPONSE

100000

Max response chars before truncation

GEMINI_BIN

gemini

Path to Gemini CLI binary

GEMINI_SYSTEM_MD

(bundled minimal)

Path to custom system prompt, or "default" for Gemini built-in

Security

Platform

Strategy

Unix

child_process.spawn() with shell: false — user input never reaches a shell

Windows

shell: true (required for .cmd) with % -> %% and ! -> ^^! escaping

  • Zero usage of exec() / execSync() / template-string commands.

  • Verify: grep -rn "exec(" src/ returns nothing.

License

MIT

Available Tools

2 tools
gemini_infoB

Gemini CLI diagnostics: check connectivity, get version, list sessions or extensions.

ParametersJSON Schema
NameRequiredDescriptionDefault
actionYesping: test CLI works, version: CLI version, list_models: available models and aliases, list_sessions: past sessions, list_extensions: available extensions.

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It implies read-only behavior through terms like 'diagnostics' and 'list', but fails to disclose output formats, error conditions, or whether these operations are cached/live. It meets minimum expectations for a metadata tool but lacks rich behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the category ('Gemini CLI diagnostics') and follows with a colon-delimited list of specific capabilities. No words are wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple single-parameter tool with complete schema coverage, the description is adequate. It covers the primary use cases (though misses list_models in prose). No output schema exists, but the description sufficiently indicates the return type nature (diagnostic info).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, the baseline is 3. The description maps most enum values to user-friendly intents (ping→connectivity, etc.) but omits 'list_models' entirely. It adds minimal semantic value beyond what the schema's detailed descriptions already provide.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly identifies the tool's purpose using specific verbs (check, get, list) and identifies the resource (Gemini CLI diagnostics). It implicitly distinguishes from sibling 'gemini_query' by focusing on introspection/metadata rather than active querying, though explicit differentiation would strengthen this further.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description lists capabilities but provides no explicit guidance on when to use this tool versus 'gemini_query'. It lacks prerequisites (e.g., 'use ping to verify connectivity before querying') or exclusion criteria that would help an agent select the correct tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gemini_queryA

Send a prompt to Google Gemini via locally authenticated CLI. Supports all Gemini models. Use @path to reference local files. Options: sandbox mode, yolo (auto-approve), approval modes, extra directories.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesPrompt for Gemini. Use @file.ts to include file context.
modelNoModel name (e.g. gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite). Default: gemini-2.5-flash
sandboxNoRun in sandbox mode for safe code execution.
yoloNoAuto-approve all tool actions (no confirmation prompts).
approval_modeNoApproval mode: default (prompt), auto_edit (auto-approve edits), yolo (auto-approve all), plan (read-only).
include_statsNoInclude token usage stats in the response.
include_directoriesNoAdditional directories to include in Gemini's workspace.
cwdNoWorking directory for file references (@ syntax).

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, description carries full burden. It discloses authentication method (locally authenticated CLI), safety controls (sandbox, yolo, approval modes), and file referencing (@path). However, misses return format, error behavior, and side effects of auto-approve modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with core purpose, followed by model support, file syntax, and options list. Efficiently packs 8 parameters worth of context into four brief statements. Minor deduction for the slightly telegraphic 'Options:' list which could flow better.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers key capabilities well for a complex 8-parameter tool: authentication, model flexibility, file inclusion, workspace directories, and safety modes. Absence of output schema is mitigated by clear description of what the tool does, though mention of return format would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Adds conceptual value beyond 100% schema coverage by explaining @path syntax for file references and grouping related boolean flags (sandbox, yolo) under 'Options'. Schema handles individual parameter docs; description provides usage context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific action (Send), resource (prompt to Google Gemini), and mechanism (locally authenticated CLI). Clearly distinguishes from sibling 'gemini_info' by focusing on active querying vs. information retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies usage through 'Send a prompt' and lists capabilities, but lacks explicit guidance on when to use gemini_info instead, or when-not-to-use scenarios (e.g., when file contexts are inappropriate).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv1.0.1
    • First observedgemini_info
    • First observedgemini_query

TDQS

A3.6/5.0
Disambiguation5/5

The two tools have completely distinct purposes: gemini_info handles diagnostics and system information, while gemini_query handles querying the Gemini model. There is no overlap in functionality that could cause confusion.

Naming Consistency5/5

Both tools follow a consistent gemini_ prefix pattern with clear descriptive suffixes (info and query). The naming is uniform and predictable across the toolset.

Tool Count2/5

With only two tools, the server feels under-scoped for a CLI interface to Gemini. A typical CLI would include more operations like session management, configuration handling, or batch processing, making this set feel incomplete for the domain.

Completeness2/5

The toolset is severely incomplete for a Gemini CLI interface. It lacks essential operations such as managing sessions, configuring settings, handling file uploads beyond references, or listing available models. The two tools cover only basic diagnostics and querying, leaving significant gaps in typical CLI workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that wraps the Gemini CLI to provide tools for executing prompts, managing chat sessions, and accessing CLI extensions. It supports both local stdio and remote SSE transports for flexible integration with MCP clients.
    1
    -
  • A
    license
    Not graded
    quality
    F
    maintenance
    Exposes Gemini CLI's built-in tools and external MCP proxies through a unified MCP endpoint while providing an OpenAI-compatible API for Gemini models. It features configurable security modes to safely manage file system operations, web searches, and shell command execution.
    22
    138
    Apache 2.0
  • A
    license
    A
    quality
    B
    maintenance
    A stateless MCP server that wraps the headless Gemini CLI, providing tools to send prompts to Google's Gemini models and receive text responses. It supports both simple prompts and prompts with contextual information.
    2
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Wraps the Gemini CLI as an MCP server, enabling AI tools to perform Gemini queries, interactive sessions, and extension management via a unified tool.
    1
    1
    -

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