Skip to main content
Glama

gemini_mcp — MCP-to-ACP Bridge

License: MIT Python 3.12+ MCP Compatible ACP v1

将 Gemini CLI 通过 ACP 协议封装为 MCP 工具,供任何 MCP 客户端调用。

简体中文 | English

架构

MCP Client ──MCP/stdio──→ geminimcp (Python) ──ACP/JSON-RPC──→ gemini --acp (Node.js) ──→ Google API
              (FastMCP)        (AcpBridge)          (长驻子进程)

MCP Client: Claude Code, Codex, Cursor, VS Code, Claude Desktop 等。

Related MCP server: ACP-MCP-Server

起源

2025 年 8 月我就用 FastMCP 封装过 Gemini CLI 的 MCP,能通信但体验不佳。后来在论坛上看到 GuDaStudio/geminimcp原帖),思路类似,感谢分享。

用了一段时间孙佬的 MCP 后,发现每次调用都要等挺久,翻了下源码才知道它底层是 gemini --prompt -o stream-json——每次请求都 spawn 一个新进程、解析文本输出,冷启动开销避不开。

然后某天跑 gemini --help 的时候,注意到有个 --acp 标志。查了一下发现这是 Gemini CLI 内置的 Agent Client Protocol——一套完整的 JSON-RPC 协议,支持有状态会话、流式响应、权限管理和多模态输入。

也就是说,不用每次"调命令行"了,可以起一个常驻进程,直接和 Gemini Agent 对话。

于是我们基于 ACP 重新设计了整个 bridge:

  • 长连接复用: 常驻 gemini --acp 进程,消除冷启动开销

  • 协议级通信: JSON-RPC over stdin,不受 CLI 输出格式变更影响,无需 shell 转义

  • 上下文隔离: 复杂任务在子进程内闭环,不膨胀主 Agent 上下文

  • 工具库内聚: Gemini 自带的 30+ 工具在 ACP 内部调用,无需暴露给上层

  • 自主容错: ACP 内部处理命令失败、权限审批等异常

  • 结构化返回: 除文本外还收集 thought、tool_calls、plan

  • 多模态: 支持 image 和 resource ContentBlock

  • 标准协议: 任何 MCP 客户端都可直接对接

ACP vs MCP

维度

MCP (Model Context Protocol)

ACP (Agent Client Protocol)

层级

协议/连接层

代理/执行层

侧重

Agent 能用什么外部工具

Agent 如何自主执行任务

通信

单次工具调用

有状态会话(多轮交互)

典型场景

读 GitHub issue 列表

自主修复一个 auth bug

geminimcp 的作用就是在两层之间架桥:外部通过 MCP 发指令,内部通过 ACP 让 Gemini 自主执行。

技术栈

  • Python 3.12+ + FastMCP (MCP server 框架)

  • uv — 打包、依赖管理、uv tool install 一键部署

  • Pydantic — 参数验证和类型注解

  • threading + queue — 子进程 I/O 跨平台超时控制

安装

前置依赖:

# uv (包管理)
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Linux/macOS
curl -LsSf https://astral.sh/uv/install.sh | sh

# Gemini CLI
npm install -g @google/gemini-cli

快速安装

Claude Code:

claude mcp add gemini -s user --transport stdio -- uvx --from git+https://github.com/shenyunhuan/gemini_mcp.git geminimcp

此命令自动下载并注册,无需预装。

手动安装

# 从 GitHub 安装
uv tool install --from git+https://github.com/shenyunhuan/gemini_mcp.git geminimcp

# 或 clone 后本地安装
git clone https://github.com/shenyunhuan/gemini_mcp.git
uv tool install --from gemini_mcp geminimcp

注册到 Claude Code:

claude mcp add gemini -s user --transport stdio -- geminimcp

可选:将 .claude/CLAUDE.md 合并到 ~/.claude/CLAUDE.md,将 .claude/rules/mcp-agents.md 复制到 ~/.claude/rules/,帮助 Claude 更好地使用 Gemini MCP。

Codex (~/.codex/config.toml):

[mcp_servers.gemini]
command = "geminimcp"

或执行:

codex mcp add gemini -- geminimcp

更新:

uv tool install --reinstall --force --from git+https://github.com/shenyunhuan/gemini_mcp.git geminimcp

Cross-MCP Chaining

geminimcp 支持与其他 MCP agent 互调,实现 3 层链式调用。

Gemini → Codex (~/.gemini/settings.jsonmcpServers):

"codex": {
  "command": "codex",
  "args": ["mcp-server"]
}

或执行:

gemini mcp add --scope user codex codex mcp-server

Codex → Gemini (~/.codex/config.toml):

[mcp_servers.gemini]
command = "geminimcp"

或执行:

codex mcp add gemini -- geminimcp

配置双向后:

  • Client → Codex → Gemini: Codex 内部调用 Gemini MCP

  • Client → Gemini → Codex: Gemini 内部调用 Codex MCP

MCP Tools

Tool

用途

gemini

发送 prompt,收集 Gemini 响应(主工具)

list_models

列出可用模型、approval mode 和 bridge 状态

list_sessions

列出活跃 ACP session

reset_session

重置指定或全部 session

gemini 主要参数

参数

默认值

说明

PROMPT

(必需)

发给 Gemini 的指令

cd

(必需)

工作区根目录

model

gemini-3.1-pro-preview

模型选择(flash / pro)

approval_mode

yolo

工具审批模式:yolo / auto_edit / default / plan

image_path

""

图片路径(vision 分析)

context

""

注入 ACP resource ContentBlock 的文本上下文

allowed_mcp_servers

None

过滤 Gemini 加载的 MCP server(None=全部)

设计要点

  • 跨平台 I/O: 后台线程 + Queue 实现带超时的非阻塞管道读取(pipe readline 在所有平台都无原生 timeout)

  • 会话管理: per-workspace session, 8-turn eviction + session/load 恢复

  • Approval Mode: 4 种审批模式(yolo/auto_edit/default/plan),支持 fallback

  • 429 降级: pro 容量不足时自动重试 flash

  • MCP 透传: 自动发现 user/project/extension 的 MCP server 配置,注入 ACP session(支持 stdio/http/sse)

  • MCP 过滤: allowed_mcp_servers 参数按名称过滤透传的 MCP server

  • 多模态: image ContentBlock (vision) + resource ContentBlock (context 注入)

  • 权限自动审批: 拦截 session/request_permission,自动选择首选项,防止子进程挂起

文档

文件

内容

CLAUDE.md

开发维护指南

acp-boundary.md

ACP 协议边界(实现 vs 未实现)

gemini-sandbox.md

沙箱模式说明

许可证

MIT License


如果觉得有用,请给个 Star 支持一下 :)

Star History Chart

Available Tools

4 tools
geminiA
Destructive
Invokes Gemini via ACP (Agent Client Protocol) for AI-driven tasks.

**Return structure:**
    - `success`: boolean indicating execution status
    - `SESSION_ID`: ACP session identifier (auto-managed per workspace)
    - `agent_messages`: concatenated assistant response text
    - `thought`: agent reasoning/thinking (when available)
    - `stop_reason`: why the agent stopped (end_turn, max_tokens, etc.)
    - `tool_calls`: list of tool invocations made by the agent (if any)
    - `plan`: agent execution plan entries (if any)
    - `error`: error description when `success=False`

**Best practices:**
    - Sessions auto-reuse per workspace with turn-count eviction
    - ALWAYS pass `model`. Use `gemini-3.1-pro-preview` for complex tasks, `gemini-3-flash-preview` for simple tasks
    - Use `approval_mode` to control tool approval: yolo (default), auto_edit, default, plan
    - On 429 capacity errors, automatically retries with `gemini-3-flash-preview`
    - Pass `image_path` for vision analysis (requires agent image support)
    - Pass `context` to inject text as embedded resource (ACP resource ContentBlock)
    - Pass `allowed_mcp_servers` to filter which MCP servers Gemini loads
ParametersJSON Schema
NameRequiredDescriptionDefault
PROMPTYesInstruction for the task to send to Gemini.
cdYesSet the workspace root for Gemini before executing the task.
modelNoREQUIRED. Pass 'gemini-3.1-pro-preview' for complex tasks, 'gemini-3-flash-preview' for simple tasks.gemini-3.1-pro-preview
approval_modeNoTool approval mode. 'yolo': auto-approve all (default). 'auto_edit': auto-approve edits only. 'default': prompt for every action (safest). 'plan': read-only mode.yolo
image_pathNoPath to an image file for vision analysis. Sent as image ContentBlock. Empty string means no image.
contextNoText context to inject as ACP resource ContentBlock. Use for passing file contents, docs, or background info that Gemini should reference.
allowed_mcp_serversNoFilter which MCP servers Gemini loads. Pass a list of server names to include. None means load all discovered servers.

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.6/5.0
Behavior4/5

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

Annotations declare destructive/open-world capabilities; the description adds critical runtime context missing from annotations: automatic session reuse with turn-count eviction, automatic fallback to flash-preview on rate limits, and detailed explanation of return fields (thought, tool_calls, plan) that describe the agent's internal reasoning. It could clarify the scope of possible destruction (file edits vs API calls) more explicitly.

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?

The description is well-structured with clear visual hierarchy: single-line purpose statement, bulleted return structure, and bulleted best practices. Every section serves a distinct purpose. Minor deduction for the return structure list being somewhat lengthy, though justified by the complex nested return type of an agent invocation.

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

Completeness5/5

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

For a complex 7-parameter agent-invocation tool with destructive/open-world annotations, the description is comprehensive. It covers input parameters, return value semantics (7 distinct fields), session lifecycle, error handling strategies, and integration patterns (MCP server filtering, image ContentBlocks). Sufficient given the tool's complexity and existing schema richness.

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?

With 100% schema coverage, the baseline is 3. The description adds significant value through the Best Practices section, which provides semantic guidance on model selection (complex vs simple tasks) and approval_mode implications (yolo meaning 'auto-approve all') that raw schema descriptions don't convey. It effectively guides the agent toward correct parameter combinations.

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?

The description opens with a precise action statement ('Invokes Gemini via ACP') specifying the protocol, resource, and task type ('AI-driven tasks'). It clearly distinguishes from siblings like list_models or reset_session by being the primary execution tool versus management utilities.

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

Usage Guidelines5/5

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

The 'Best practices' section provides explicit guidance: model selection criteria (pro for complex, flash for simple), approval_mode behavior (yolo vs auto_edit vs default), automatic retry logic on 429 errors, and specific parameter usage patterns (image_path for vision, context for resources). It names concrete alternatives (flash model for retries) and safety thresholds.

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

list_modelsA
Read-onlyIdempotent

List available Gemini models and current bridge state. Returns known models, current active model, and agent info.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

Annotations cover safety (readOnly, idempotent, non-destructive), but the description adds valuable behavioral context about what state is accessed ('bridge state', 'agent info') and what the function returns. It complements the annotations by explaining the semantic content of the operation.

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?

Two efficient sentences with zero waste. First sentence establishes the operation and scope; second sentence details return contents. Information is front-loaded and appropriately sized for a parameterless introspection tool.

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

Completeness5/5

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

For a zero-parameter, read-only listing tool with an output schema present, the description is complete. It explains what resource is queried and what data categories are returned, which is sufficient given the low complexity and existing output schema.

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?

The input schema has zero parameters, establishing a baseline of 4 per the rubric. The description appropriately doesn't mention parameters since none exist, maintaining focus on the operation's purpose and return values.

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?

The description uses a specific verb (List) with clear resources (Gemini models, bridge state). It distinguishes itself from sibling 'list_sessions' by explicitly naming 'Gemini models' and 'bridge state' as targets, and from 'gemini' (likely a generation tool) by being read-only/listing focused.

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?

While the description implies usage by explaining what is returned (known models, active model, agent info), it lacks explicit when-to-use guidance or comparison to siblings. It doesn't state, for example, to use this before calling 'gemini' to check available models.

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

list_sessionsA
Read-onlyIdempotent

List all active ACP sessions managed by the bridge. Shows workspace path, session ID, turn count, and model for each session.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

Adds valuable return-value context beyond annotations: specifically enumerates returned fields (workspace path, session ID, turn count, model). Also clarifies scope ('managed by the bridge') complementing openWorldHint=false. Does not contradict safety annotations.

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?

Two sentences, zero waste. First sentence establishes operation, second previews return payload. Information density is optimal with no redundancy.

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

Completeness5/5

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

Fully adequate for a zero-parameter listing tool. Preview of output fields (despite existence of output schema) provides helpful context without being redundant. Annotations cover behavioral safety profile.

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?

Zero parameters present, meeting the baseline score of 4. The description correctly avoids parameter discussion since none exist.

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?

Excellent specificity: 'List' (verb) + 'active ACP sessions' (resource) + 'managed by the bridge' (scope). Implicitly distinguishes from sibling 'reset_session' (list vs modify) and 'list_models' (sessions vs models).

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?

States what it does clearly, providing implied usage context, but lacks explicit when-to-use guidance or contrasts with 'reset_session' (e.g., 'use this before resetting to verify session ID').

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

reset_sessionA
DestructiveIdempotent

Reset (clear) the ACP session for a workspace. The next gemini call for this workspace will create a fresh session. Pass workspace path, or omit to reset all sessions.

ParametersJSON Schema
NameRequiredDescriptionDefault
workspaceNoWorkspace path to reset. Empty string resets all sessions.

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

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

Annotations declare destructive=true, idempotent=true, readOnly=false. Description valuably adds the session lifecycle context (clearing now creates fresh session on next gemini call) and explains the workspace-scoping vs global-scope behavior, which helps the agent understand the tool's side effects beyond the safety flags.

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?

Three sentences with zero waste: (1) Action definition, (2) Behavioral consequence linking to sibling, (3) Parameter instruction. Front-loaded with the core operation. Every sentence earns its place by conveying distinct essential information.

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

Completeness5/5

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

Appropriately complete for a low-complexity (1 param) destructive operation with 100% schema coverage, existing output schema, and rich annotations. Description covers scope, side effects, and parameter usage without needing to replicate return value documentation.

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?

Schema coverage is 100%, so fields are technically documented. Description adds semantic framing: 'or omit to reset all sessions' clarifies the empty string default behavior described in the schema, providing usage-oriented guidance that helps the agent understand the parameter's optional nature and global fallback behavior.

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 'Reset (clear)' with explicit resource 'ACP session' and scope 'workspace'. Critically references sibling tool 'gemini' ('The next gemini call...'), clarifying the tool's relationship to the session lifecycle and distinguishing it from list_sessions.

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

Usage Guidelines4/5

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

Provides clear usage context by explaining the deferred effect on subsequent 'gemini' calls and parameter behavior ('Pass workspace path, or omit to reset all sessions'). Lacks explicit 'when not to use' guidance or named alternatives, but the causal explanation implicitly guides selection.

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

TDQS

A4.4/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: gemini invokes the AI model, list_models shows available models, list_sessions displays active sessions, and reset_session clears sessions. There is no overlap in functionality between these tools.

Naming Consistency4/5

Three tools follow a consistent verb_noun pattern (list_models, list_sessions, reset_session), but gemini uses a noun-only name which deviates from the pattern. The naming is still readable and mostly consistent.

Tool Count5/5

With 4 tools, this is well-scoped for a Gemini MCP server. Each tool serves a distinct role in managing AI interactions and sessions, and none feel superfluous or missing for the core functionality.

Completeness4/5

The toolset covers core operations for invoking Gemini AI, listing models and sessions, and resetting sessions. A minor gap is the lack of a tool to manage specific session parameters or update configurations, but agents can work around this with the existing tools.

Maintenance

ActivityInactive
ResponsivenessSyncing

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

  • A
    license
    B
    quality
    F
    maintenance
    A bridge server that connects Agent Communication Protocol (ACP) agents with Model Context Protocol (MCP) clients, enabling seamless integration between ACP-based AI agents and MCP-compatible tools like Claude Desktop.
    16
    24
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Bridges Google's Gemini CLI with MCP-compatible clients and integrates OpenRouter API for access to 400+ AI models. Provides 33 specialized tools enabling multi-AI workflows, collaborations, and debates between Claude, Gemini, and other LLMs.
    142
  • A
    license
    Not graded
    quality
    F
    maintenance
    Bridges Agent Communication Protocol (ACP) agents with Model Context Protocol (MCP) applications, allowing MCP clients such as Claude Desktop to discover and invoke ACP agents as tools and resources.
    36
    Apache 2.0

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/shenyunhuan/gemini_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server