这是一个借助 Google 的 Gemini 2 API 来提供图像生成能力的模型上下文协议(MCP)服务器。它能让你更便捷地使用 Gemini 2 的图像生成功能。
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"gemini-imagen": {
"command": "npx",
"args": ["-y", "github:sanxfxteam/gemini-mcp-server"],
"env": {
"GEMINI_API_KEY": "your_api_key_here"
}
}
}
}
npm install
创建根目录下的 .env 文件并添加你的 Google API 密钥:
GEMINI_API_KEY=your_api_key_here
npm start
npx @modelcontextprotocol/inspector npm run start
使用 Gemini 2 的实验性图像生成 API 生成图像。
prompt (string, 必填):你想要生成的图像描述。numSamples (number, 可选, 默认: 4):要生成的图像数量。aspectRatio (string, 可选, 默认: '1:1'):生成图像的宽高比。personGeneration (string, 可选, 默认: 'ALLOW_ADULT'):人物生成设置。{
"tool": "generateImage",
"params": {
"prompt": "一个宁静的日落 mountain 风光",
"numSamples": 2,
"aspectRatio": "16:9"
}
}