/ 目錄 / 演練場 / 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