gemini-cli-mcp

gemini-cli-mcp

Enables AI assistants to delegate complex tasks to the local Gemini CLI, returning structured results with execution metadata.

Category
访问服务器

README

<div align="center"> <img src="./assets/banner.svg" alt="Gemini CLI MCP Banner" width="100%" />

🤖 Gemini CLI MCP Server

Seamless AI-to-AI Delegation via Local Gemini CLI

npm version License: MIT Node.js Version

English · 繁體中文

</div>


🌟 Why Gemini CLI MCP?

gemini-cli-mcp is an advanced Model Context Protocol (MCP) server that empowers your AI assistants by delegating complex tasks to your locally installed Gemini CLI.

Rather than collapsing failures into generic errors, this server returns structured results along with execution metadata, making it an essential tool for robust AI-to-AI handoffs and deep debugging.

✨ Key Features

  • 🚀 Zero-Friction Auth: Transparently utilizes your existing local Gemini CLI setup and credentials.
  • 🔌 Standard MCP Ready: Runs headless over stdio, effortlessly integrating with standard MCP client setups.
  • 🛠️ Task-Oriented & Flexible: Choose executeTask for direct answers, or drop down to executePrompt for precise control.
  • 🎨 Native Image Generation: Harnesses your local nanobanana extension to generate and retrieve images seamlessly.
  • 🔍 Environment Inspection: Instantly discover available commands, extensions, skills, and MCP servers on the local machine.

📦 Installation

For normal usage, install the published package globally or run it through your package manager. Ensure you have Node.js 18.18+ installed along with a configured local Gemini CLI.

# npm
npm install -g @cainmaila/gemini-cli-mcp

# pnpm
pnpm add -g @cainmaila/gemini-cli-mcp

# one-off execution without a global install
npx -y @cainmaila/gemini-cli-mcp

The published package name is @cainmaila/gemini-cli-mcp, but the installed executable name is gemini-cli-mcp.

If you use pnpm add -g, make sure your MCP client can see your PNPM_HOME/global bin directory. Some desktop MCP clients do not inherit the same PATH as your interactive shell, which can make gemini-cli-mcp look missing even though the package is installed.

If you want to work on this repository itself instead of using the published package, use the local development flow in DEVELOPMENT.md.


🚀 Quick Start & Usage

Running the Server

Since this is an MCP server, it is designed to communicate over stdio and should be launched by your MCP client.

gemini-cli-mcp

Client Configuration Example

Add the following to your AI assistant's MCP configuration:

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

If your MCP client cannot resolve global binaries reliably, use one of these alternatives instead:

{
  "mcpServers": {
    "gemini-cli": {
      "command": "npx",
      "args": ["-y", "@cainmaila/gemini-cli-mcp"]
    }
  }
}
{
  "mcpServers": {
    "gemini-cli": {
      "command": "node",
      "args": ["/absolute/path/to/installed/package/build/index.js"]
    }
  }
}

Running gemini-cli-mcp directly in a terminal is only useful as a smoke test. It will wait for MCP traffic over stdio, so it may look idle until a client connects.


🛠️ Available Tools

<details> <summary><b><code>executeTask</code> (Recommended)</b></summary>

Best for upstream AI systems. Hands off a task to the Gemini CLI and returns a ready-to-use answer. Auto-applies edit approvals when necessary!

Input Example:

{
  "task": "Query today's weather in Taipei and provide a short summary.",
  "expectedOutput": "Direct answer, no intro.",
  "timeoutMs": 180000
}

Output Example:

{
  "answer": "...",
  "ok": true,
  "stdout": "...",
  "stderr": "...",
  "exitCode": 0,
  "elapsedMs": 23053
}

</details>

<details> <summary><b><code>executePrompt</code></b></summary>

A lower-level interface designed for callers who demand exact prompt control.

Input Example:

{
  "prompt": "Summarize the current repository",
  "model": "gemini-2.5-pro",
  "timeoutMs": 60000
}

Output Example:

{
  "ok": true,
  "finalText": "...",
  "stdout": "...",
  "stderr": "",
  "exitCode": 0,
  "elapsedMs": 1532
}

</details>

<details> <summary><b><code>executeImageTask</code></b></summary>

Flawless image-generation backed by the local nanobanana extension. Bypasses interactive prompts automatically!

Input Example:

{
  "prompt": "a cute orange cat portrait, clean light background",
  "count": 1,
  "timeoutMs": 180000
}

Output Example:

{
  "ok": true,
  "responseText": "/path/to/project/nanobanana-output/cat.png",
  "imagePaths": ["/path/to/project/nanobanana-output/cat.png"],
  "primaryImagePath": "/path/to/project/nanobanana-output/cat.png",
  "exitCode": 0,
  "elapsedMs": 12000
}

</details>

<details> <summary><b><code>inspectGeminiCli</code></b></summary>

Discover your AI environment's capabilities on the fly. Returns top-level commands, installed extensions, available skills, and configured MCP servers.

Input Example:

{
  "includeModelReportedTools": true,
  "timeoutMs": 60000
}

</details>


⚙️ Environment Overrides

Tailor the server to your specific environment simply by setting these variables:

Variable Description Default
GEMINI_CLI_PATH Path to the Gemini executable gemini
GEMINI_PROMPT_FLAG The flag used for passing prompts -p
GEMINI_MODEL_FLAG The flag used to specify the model --model

📚 Notes & Contributing

  • Authentication: This server relies on your existing local Gemini CLI authentication.
  • Resilience: If the local CLI is missing or broken, you will receive structured failure details—never a silent crash.
  • Want to build with us? Check out our developer guide in DEVELOPMENT.md.

<br/> <div align="center"> <i>Built for the next generation of AI collaboration.</i> </div>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选