/ 目录 / 演练场 / Gemini CLI
● 官方 google-gemini 🔑 需要你的密钥

Gemini CLI

作者 google-gemini · google-gemini/gemini-cli

Gemini's official terminal agent — it does shell tasks autonomously and exposes that capability via MCP, so Claude can call Gemini for cross-model second opinions.

Gemini CLI is Google's terminal-native agent (Codex/Claude Code analog). Its MCP surface lets Claude delegate work to Gemini — useful for second opinions, large-context tasks, or model-comparison evaluations.

为什么要用

核心特性

实时演示

实际使用效果

就绪

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "gemini-cli-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@google/gemini-cli",
        "mcp"
      ]
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "gemini-cli-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@google/gemini-cli",
        "mcp"
      ]
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "gemini-cli-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@google/gemini-cli",
        "mcp"
      ]
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "gemini-cli-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@google/gemini-cli",
        "mcp"
      ]
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "gemini-cli-mcp",
      "command": "npx",
      "args": [
        "-y",
        "@google/gemini-cli",
        "mcp"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "gemini-cli-mcp": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@google/gemini-cli",
          "mcp"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add gemini-cli-mcp -- npx -y @google/gemini-cli mcp

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: Gemini CLI

Get a Gemini second opinion on Claude's plan

👤 Developers ⏱ ~15 min intermediate

何时使用: You're about to ship something risky; want a fresh take from a different model.

步骤
  1. Bridge
    Add Gemini CLI as an MCP server.✓ 已复制
    → Tool visible
  2. Ask
    Have Claude pass the plan to Gemini for critique.✓ 已复制
    → Critique returns
  3. Reconcile
    Claude updates the plan with Gemini's feedback.✓ 已复制
    → Better plan

结果: Two-model review without manual copy-paste.

组合

与其他 MCP 搭配,撬动十倍杠杆

gemini-cli-mcp + github

Have Gemini draft a refactor plan, then Claude opens the PR via GitHub MCP

Combine gemini-cli-mcp with github: Have Gemini draft a refactor plan, then Claude opens the PR via GitHub MCP✓ 已复制

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
gemini.ask (see docs) Send a prompt to Gemini, get a response 1 call
gemini.run_task (see docs) Run an autonomous shell task 1 call

成本与限制

运行它的成本

API 配额
Google AI free tier; paid for higher rate
每次调用 Token 数
Per Gemini pricing
费用
Free tier; paid plans
提示
Use Gemini for large-context summaries where its 2M-token window pays off

安全

权限、密钥、影响范围

最小权限: gemini:api
凭据存储: API key in env
数据出站: generativelanguage.googleapis.com
切勿授予: Pass real customer data without checking Gemini data terms

故障排查

常见错误与修复

429 quota exceeded

Wait or upgrade plan; check key has the right Vertex/AI Studio scope

替代方案

Gemini CLI 对比其他方案

替代方案何时用它替代权衡
claude-code (self)Single-model is fineNo second opinion

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills