Gemini Image MCP
Gemini 图像 MCP

一个 MCP 服务器,用于使用 Google 的 Gemini 图像模型(Nano Banana、Nano Banana 2、Nano Banana Pro)生成和编辑图像。它公开了一个工具 generate_image,像 Claude、Codex 和 Cline 这样的 AI 工具可以使用您自己的 API 密钥调用它。
它能做什么
generate_image处理文本到图像,以及当您传递参考图像(本地文件路径或 base64)时的编辑和合成。每次调用都会公开每个生成参数:
temperature(1)、topP(0.95)、topK、maxOutputTokens(flash/lite 为 65536,pro 为 32768)、seed、stopSequences、presencePenalty、frequencyPenalty、systemInstruction、thinkingLevel(minimal/high)、thinkingBudget、enableGoogleSearch(默认为 true)、imageSize(512/1K/2K/4K)、aspectRatio(默认 "auto" + 标准比例)、personGeneration。附带一个
instructions块和每个参数的描述,因此 MCP 客户端无需额外提示即可知道如何使用该工具。将图像保存到磁盘并返回文件路径。响应中没有 base64,因此 4K 图像不会占用客户端的上下文窗口。
错误会附带提示信息(错误的密钥、速率限制、安全阻止、未知模型)返回,而不是原始的 API 转储。
使用 stdio 传输,这是本地 MCP 服务器的常规设置。
要求
Bun 1.0+
来自 https://aistudio.google.com/apikey 的 Gemini API 密钥
安装
bun install配置
三个环境变量,通常在 MCP 客户端的配置中设置:
变量 | 必需 | 默认值 | 作用 |
| 是(或 | 您的 Gemini API 密钥。如果两者都设置了, | |
| 否 |
| 当调用未指定模型时使用的模型。 |
| 否 |
| 图像保存的位置。如果目录不存在则会创建。 |
您可以选择的模型:
模型 | 最大输出令牌 | 思维级别 | Google 搜索 | 最大尺寸 | 说明 |
| 65536 | minimal / high | 支持 | 2K | Nano Banana 2。快速、便宜、通用。默认选项。 |
| 65536 | minimal / high | 支持 | 2K | 轻量级、高吞吐量模型。 |
| 32768 | (无) | 支持 | 4K | Nano Banana Pro。最佳质量和图像内文本,也是唯一支持 4K 的模型。 |
模型也可以使用 models/ 前缀指定(例如 models/gemini-3.1-flash-image)。
客户端设置
Claude Desktop
将其添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"gemini-image": {
"command": "bun",
"args": ["run", "/absolute/path/to/gemini-image-mcp/index.ts"],
"env": {
"GEMINI_API_KEY": "YOUR_KEY_HERE"
}
}
}
}Cline (VS Code)
cline_mcp_settings.json:
{
"mcpServers": {
"gemini-image": {
"command": "bun",
"args": ["run", "/absolute/path/to/gemini-image-mcp/index.ts"],
"env": {
"GEMINI_API_KEY": "YOUR_KEY_HERE"
}
}
}
}Codex
~/.codex/config.toml:
[mcp_servers.gemini-image]
command = "bun"
args = ["run", "/absolute/path/to/gemini-image-mcp/index.ts"]
env = { GEMINI_API_KEY = "YOUR_KEY_HERE" }从 npm (bunx/npx)
一旦包发布,将您的客户端指向 bunx 而不是:
{
"mcpServers": {
"gemini-image": {
"command": "bunx",
"args": ["gemini-image-mcp"],
"env": { "GEMINI_API_KEY": "YOUR_KEY_HERE" }
}
}
}generate_image 参数
只有 prompt 是必需的。其他所有参数都有适用于图像生成的合理默认值。
参数 | 类型 | 默认值 | 描述 |
| string | — (必需) | 图像的叙述性描述,或者当提供 |
| string | 环境变量 / | Gemini 图像模型(见上表)。接受 |
| array (≤14) | — | 用于编辑/合成的源图像: |
|
|
| 输出分辨率:512(最快,轻量级)、1K(默认)、2K、4K(需要 |
| enum |
|
|
| enum |
|
|
| enum |
|
|
| boolean |
| 启用 Google 搜索基础工具,用于在所有模型上获取实时网络知识和准确性。 |
| int | — | 显式思考预算(0 = 关闭,-1 = 自动)。 |
| number 0–2 |
| 采样随机性。 |
| number 0–1 |
| 核采样。 |
| int | — | Top-k 采样。 |
| int 1–65536 | 65536 (flash) / 32768 (pro) | 输出令牌上限。 |
| int | — | 尽力而为的可复现性。 |
| string[] (≤5) | — | 文本部分的停止序列。 |
| number -2..2 | — | 令牌惩罚。 |
| string | — | 风格/行为引导,例如 "flat vector style"。 |
| string | 环境变量 / | 保存位置。 |
| string |
| 基础文件名(扩展名根据 MIME 类型自动添加)。 |
该工具返回一个文本摘要,其中包含保存的文件路径、模型、有效配置和令牌使用情况。它永远不会内联返回图像数据;打开文件查看结果。
您可以向 AI 询问的事情
"生成一张 16:9 的雨夜东京街道英雄图,电影级霓虹灯光。"
"编辑
/tmp/product.png:将其放在大理石桌上,带有柔和的晨光"(这使用了referenceImages)。"使用 gemini-3-pro-image 生成一张带有确切标题 'LAUNCH DAY' 的 4K 海报。"
开发
bun test # unit tests (config, schema, request/response parsing)
bun run typecheck # tsc --noEmit
bun run inspector # interactive MCP inspector (needs GEMINI_API_KEY)
bun run start # run the server on stdio故障排除
"缺少 Gemini API 密钥":将
GEMINI_API_KEY放入客户端 MCP 配置的env块中。在 shell 中设置它对于 Claude Desktop 等 GUI 应用是不够的,因为它们不读取您的 shell 环境。安全阻止:重新表述提示。如果涉及人物,请检查
personGeneration。429 / 超出配额:等待并重试,或者坚持使用
gemini-3.1-flash-image,它的配额更高。日志:服务器仅将日志写入 stderr。stdout 承载 MCP 协议,因此不要在任何地方添加
console.log。
作者
Thomi Jasir dev@venobi.com
许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for NanoBanana AI image generation and editing
MCP server for Google Veo AI video generation
MCP server for Flux AI image generation
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/thomijasir/gemini-image-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server