Back to MCP directory
publicPublicdnsLocal runtime

gemini-mcp-server

基于Gemini 2 API的图像生成MCP服务

article

README

🚀 网星双子座图像生成 MCP 服务器

这是一个借助 Google 的 Gemini 2 API 来提供图像生成能力的模型上下文协议(MCP)服务器。它能让你更便捷地使用 Gemini 2 的图像生成功能。

🚀 快速开始

获取 Gemini API 密钥

配置 Claude 桌面

  • 找到你的配置文件:
    Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
    Windows: %APPDATA%\Claude\claude_desktop_config.json
    Linux: ~/.config/Claude/claude_desktop_config.json
    
  • 添加 Gemini 配置:
    {
      "mcpServers": {
        "gemini-imagen": {
          "command": "npx",
          "args": ["-y", "github:sanxfxteam/gemini-mcp-server"],
          "env": {
            "GEMINI_API_KEY": "your_api_key_here"
          }
        }
      }
    }
    
  • 重启 Claude 桌面。

📦 安装指南

安装依赖项

npm install

配置环境变量

创建根目录下的 .env 文件并添加你的 Google API 密钥:

GEMINI_API_KEY=your_api_key_here

💻 使用示例

运行服务器

npm start

测试时运行

npx @modelcontextprotocol/inspector npm run start

可用工具 - generateImage

使用 Gemini 2 的实验性图像生成 API 生成图像。

参数说明

  • prompt (string, 必填):你想要生成的图像描述。
  • numSamples (number, 可选, 默认: 4):要生成的图像数量。
  • aspectRatio (string, 可选, 默认: '1:1'):生成图像的宽高比。
  • personGeneration (string, 可选, 默认: 'ALLOW_ADULT'):人物生成设置。

示例 MCP 请求

{
  "tool": "generateImage",
  "params": {
    "prompt": "一个宁静的日落 mountain 风光",
    "numSamples": 2,
    "aspectRatio": "16:9"
  }
}

⚠️ 重要提示

  • 此服务器使用 Gemini 2 的实验性图像生成功能。
  • 确保你拥有适当的访问权限和 Google API 密钥。
  • 该服务器通过标准输入输出使用模型上下文协议进行通信。
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client