Gemini Image MCP
An MCP server for generating and editing images with Google's Gemini image models, exposing a single tool that AI assistants can call to create or edit images using your own API key.
README
Gemini Image MCP

An MCP server for generating and editing
images with Google's Gemini image models (Nano Banana, Nano Banana 2, Nano
Banana Pro). It exposes one tool, generate_image, which AI tools like Claude,
Codex, and Cline can call using your own API key.
What it does
generate_imagehandles text-to-image, plus editing and composition when you pass it reference images (local file paths or base64).- Every generation knob is exposed per call:
temperature(1),topP(0.95),topK,maxOutputTokens(65536 for flash/lite, 32768 for pro),seed,stopSequences,presencePenalty,frequencyPenalty,systemInstruction,thinkingLevel(minimal/high),thinkingBudget,enableGoogleSearch(default true),imageSize(512/1K/2K/4K),aspectRatio("auto" default + standard ratios),personGeneration. - Ships an
instructionsblock and per-parameter descriptions, so MCP clients figure out how to use the tool without extra prompting. - Saves images to disk and returns file paths. No base64 in the response, so a 4K image won't eat the client's context window.
- Errors come back with hints (bad key, rate limit, safety block, unknown model) instead of a raw API dump.
- stdio transport, the usual setup for local MCP servers.
Requirements
- Bun 1.0+
- A Gemini API key from https://aistudio.google.com/apikey
Install
bun install
Configuration
Three environment variables, normally set in the MCP client's config:
| Variable | Required | Default | What it does |
|---|---|---|---|
GEMINI_API_KEY |
Yes (or GOOGLE_API_KEY) |
Your Gemini API key. If both are set, GEMINI_API_KEY wins. |
|
GEMINI_IMAGE_MODEL |
No | gemini-3.1-flash-image |
Model used when a call doesn't specify one. |
GEMINI_IMAGE_OUTPUT_DIR |
No | <cwd>/generated-images |
Where images go. Created if it doesn't exist. |
Models you can pick:
| Model | Max Output Tokens | Thinking Level | Google Search | Max Size | Notes |
|---|---|---|---|---|---|
gemini-3.1-flash-image |
65536 | minimal / high | Supported | 2K | Nano Banana 2. Fast, cheap, general purpose. The default. |
gemini-3.1-flash-lite-image |
65536 | minimal / high | Supported | 2K | Lightweight, high-throughput model. |
gemini-3-pro-image |
32768 | (none) | Supported | 4K | Nano Banana Pro. Best quality and in-image text, and the only one that does 4K. |
Models can also be specified with the models/ prefix (e.g.
models/gemini-3.1-flash-image).
Client setup
Claude Desktop
Add this to ~/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" }
From npm (bunx/npx)
Once the package is published, point your client at bunx instead:
{
"mcpServers": {
"gemini-image": {
"command": "bunx",
"args": ["gemini-image-mcp"],
"env": { "GEMINI_API_KEY": "YOUR_KEY_HERE" }
}
}
}
generate_image parameters
Only prompt is required. Everything else defaults to something sensible for
image generation.
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
string | — (required) | Narrative description of the image, or of the edit when referenceImages are provided. |
model |
string | env / gemini-3.1-flash-image |
Gemini image model (see table above). Accepts models/ prefix. |
referenceImages |
array (≤14) | — | Source images for editing/composition: { path } or { base64, mimeType }. |
imageSize |
"512" | "1K" | "2K" | "4K" |
"1K" |
Output resolution: 512 (fastest, lightweight), 1K (default), 2K, 4K (requires gemini-3-pro-image). |
aspectRatio |
enum | "auto" |
"auto" (default, infers from prompt or matches reference images) or explicit: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1. |
personGeneration |
enum | allow_all |
allow_all / allow_adult / allow_none. |
thinkingLevel |
enum | "minimal" (on flash models) |
"minimal" / "high". Supported on gemini-3.1-flash-image and gemini-3.1-flash-lite-image. Not supported on Pro. |
enableGoogleSearch |
boolean | true |
Enables Google Search grounding tool for real-time web knowledge and accuracy across all models. |
thinkingBudget |
int | — | Explicit thinking budget (0 = off, -1 = auto). |
temperature |
number 0–2 | 1 |
Sampling randomness. |
topP |
number 0–1 | 0.95 |
Nucleus sampling. |
topK |
int | — | Top-k sampling. |
maxOutputTokens |
int 1–65536 | 65536 (flash) / 32768 (pro) | Output token cap. |
seed |
int | — | Best-effort reproducibility. |
stopSequences |
string[] (≤5) | — | Stop sequences for the text portion. |
presencePenalty / frequencyPenalty |
number -2..2 | — | Token penalties. |
systemInstruction |
string | — | Style/behavior steering, e.g. "flat vector style". |
outputDir |
string | env / <cwd>/generated-images |
Where to save. |
fileName |
string | gemini-image-<timestamp> |
Base file name (extension auto from MIME type). |
The tool returns a text summary with the saved file path(s), the model, the effective config, and token usage. It never returns image data inline; open the file to see the result.
Things you can ask your AI
- "Generate a 16:9 hero image of a rainy Tokyo street at night, cinematic neon lighting."
- "Edit
/tmp/product.png: put it on a marble table with soft morning light" (this usesreferenceImages). - "Generate a 4K poster with the exact headline 'LAUNCH DAY' using gemini-3-pro-image."
Development
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
Troubleshooting
- "Missing Gemini API key": put
GEMINI_API_KEYin theenvblock of the client's MCP config. Setting it in your shell isn't enough for GUI apps like Claude Desktop, since they don't read your shell environment. - Safety blocks: rephrase the prompt. If people are involved, check
personGeneration. - 429 / quota exceeded: wait and retry, or stick to
gemini-3.1-flash-image, which has the higher quota. - Logs: the server writes logs to stderr only. stdout carries the MCP
protocol, so don't add
console.loganywhere.
Author
Thomi Jasir dev@venobi.com
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。