这是一个使用 Google 的 Gemini 2 API 提供图像生成能力的 Model Context Protocol (MCP) 服务器。
<a href="https://glama.ai/mcp/servers/@sanxfxteam/gemini-mcp-server"> <img width="380" height="200" src="https://gips3.baidu.com/it/u=225996366,2227056164&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Gemini 图像生成服务器 MCP 服务器" /> </a>获取 Gemini API 密钥
配置 Claude Desktop
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"
}
}
}
}
重启 Claude Desktop
npm install
.env 文件,并添加你的 Google API 密钥:GEMINI_API_KEY=your_api_key_here
运行服务器:
npm start
测试:
npx @modelcontextprotocol/inspector npm run start
使用 Gemini 2 的实验性图像生成 API 生成图像。
参数:
prompt (字符串,必需):你想要生成的图像描述numSamples (数字,可选,默认值:4):要生成的图像数量aspectRatio (字符串,可选,默认值:'1:1'):生成图像的宽高比personGeneration (字符串,可选,默认值:'ALLOW_ADULT'):人物生成设置示例 MCP 请求:
{
"tool": "generateImage",
"params": {
"prompt": "日落时宁静的山景",
"numSamples": 2,
"aspectRatio": "16:9"
}
}