Skip to main content
Glama

gemini-mcp

npm MCP Registry Node.js License: MIT

轻量级 MCP 服务器,将 Google Gemini 作为工具暴露给 Claude Code(或任何 MCP 客户端)。

使用 Gemini 获取第二意见、大上下文分析、代码审查,或任何需要不同模型视角的帮助。

工具

工具

描述

gemini_ask

向 Gemini 提问或分配任务

gemini_analyze

发送代码/文本并附带特定指令进行分析

gemini_chat

带完整历史的多轮对话

gemini_models

列出可用的 Gemini 模型

Related MCP server: Gemini Bridge

快速开始

1. 获取 API 密钥

前往 Google AI Studio 创建免费 API 密钥。

2. 安装

选项 A — 克隆(推荐用于 Claude Code)

git clone https://github.com/PavelGuzenfeld/gemini-mcp.git ~/.claude/mcp-servers/gemini
cd ~/.claude/mcp-servers/gemini
npm install

选项 B — npx(无需安装)

npx claude-gemini-mcp

3. 在 Claude Code 中注册

添加到 ~/.claude/settings.json

{
  "mcpServers": {
    "gemini": {
      "command": "node",
      "args": ["/home/you/.claude/mcp-servers/gemini/index.js"],
      "env": {
        "GEMINI_API_KEY": "your-key-here"
      }
    }
  }
}

或使用 npx:

{
  "mcpServers": {
    "gemini": {
      "command": "npx",
      "args": ["-y", "claude-gemini-mcp"],
      "env": {
        "GEMINI_API_KEY": "your-key-here"
      }
    }
  }
}

使用示例

提问

> Use gemini_ask to explain the difference between std::expected and std::optional

Gemini says: std::optional<T> represents a value that may or may not be present...
std::expected<T, E> additionally carries an error value when the expected value is absent...

分析代码

> Use gemini_analyze to review this function for performance issues:
  instruction: "Find performance bottlenecks"
  content: <your code here>

Gemini says: Line 12 allocates inside the loop — move the vector outside...

多轮对话

> Use gemini_chat with messages:
  [{"role": "user", "content": "Design a REST API for a task manager"},
   {"role": "model", "content": "Here's a RESTful design..."},
   {"role": "user", "content": "Now add authentication"}]

Gemini says: Building on the previous design, add JWT-based auth...

每次调用覆盖模型

> Use gemini_ask with model: "gemini-2.5-flash" to quickly summarize this error log

环境变量

变量

默认值

描述

GEMINI_API_KEY

(必填)

Google AI Studio API 密钥

GEMINI_MODEL

gemini-2.5-pro

所有工具的默认模型

模型

模型

最适合

gemini-2.5-pro

最佳质量,大上下文(100 万 tokens)

gemini-2.5-flash

快速,适合大多数任务

gemini-2.0-flash

最快,简单任务

每个工具都接受可选的 model 参数,用于覆盖每次调用的默认模型。

特性

  • 在速率限制(429)和服务器错误(5xx)时使用指数退避重试

  • 优雅地将错误报告返回给 MCP 客户端(不会崩溃)

  • 每次调用可覆盖模型

  • 除 API 密钥外零配置

故障排除

问题

解决方案

GEMINI_API_KEY is not set

将密钥添加到 settings.json 中的 env

429 Too Many Requests

内置重试会处理此问题 — 等待几秒

Model not found

运行 gemini_models 列出有效的模型名称

工具未出现在 Claude Code 中

检查 ~/.claude/settings.json 语法,重启 Claude Code

ECONNREFUSED

检查网络/防火墙 — 服务器调用 generativelanguage.googleapis.com

开发

git clone https://github.com/PavelGuzenfeld/gemini-mcp.git
cd gemini-mcp
npm install
npm test          # Run smoke tests
node index.js     # Start the MCP server locally

许可证

MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Augments MCP Server - A comprehensive framework documentation provider for Claude Code

  • Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer

  • MCP server for AI dialogue using various LLM models via AceDataCloud

View all MCP Connectors

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/PavelGuzenfeld/gemini-mcp'

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