nano-banana-mcp
A Cloudflare Worker exposing Google's Gemini 2.5 Flash Image model as an MCP tool for Claude.ai, enabling image generation and editing via natural language.
README
nano-banana-mcp
A Cloudflare Worker exposing Google's Gemini 2.5 Flash Image model ("nano banana") as an MCP tool, for use as a custom connector in Claude.ai.
Exposes two tools: generate_image(prompt, aspect_ratio?, count?, seed?, temperature?) and edit_image(image, instruction, aspect_ratio?, seed?, temperature?).
Connector URL format (once deployed):
https://nano-banana-mcp.<subdomain>.workers.dev/<MCP_AUTH_TOKEN>/mcp
See DEPLOY.md for first-time setup.
Parameters
generate_image
| Param | Type | Required | Default | Notes |
|---|---|---|---|---|
prompt |
string | yes | — | Description of the image. Style direction belongs here. |
aspect_ratio |
enum | no | 1:1 |
One of 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. |
count |
integer | no | 1 |
1–4. Each variation is a separate billed generation with its own URL. |
seed |
integer | no | random, always reported | int32. Same prompt + ratio + temperature + seed reproduces the same image. With count > 1 the seed is incremented per variation (seed, seed+1, …). |
temperature |
number | no | model default | 0–2. Lower is more literal, higher more inventive. |
num_images is still accepted as a deprecated alias for count, so clients holding a cached copy of the old tool definition keep working.
edit_image
| Param | Type | Required | Default | Notes |
|---|---|---|---|---|
image |
string | yes | — | Public HTTPS URL, or the 8-character id from a previous result. |
instruction |
string | yes | — | The edit to perform, e.g. "make it dusk". |
aspect_ratio |
enum | no | source framing | Same values as above. Omit to leave the framing alone. |
seed |
integer | no | random, always reported | int32, as above. |
temperature |
number | no | model default | 0–2, as above. |
An invalid enum value or an out-of-range number comes back as an isError result naming the valid values, without spending a Gemini call.
How the parameters reach Gemini
All of them go into generationConfig on the generateContent body — the aspect ratio specifically into generationConfig.imageConfig.aspectRatio:
{
"contents": [...],
"generationConfig": {
"temperature": 0.9,
"seed": 4821,
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": { "aspectRatio": "16:9" }
}
}
temperature is omitted from the body entirely when not supplied, so the model's own default applies. seed never is — see below. Earlier versions of this server instead appended (aspect ratio 16:9) to the prompt text, which left the ratio a suggestion the model was free to ignore — that is why 16:9 requests kept coming back square. count is handled as sequential generateContent calls rather than one call asking for N images, which the model answers inconsistently.
Settings echo
Every image comes back as its own text content block: the URL on the first line, then the settings it was actually produced under, so the chat side can report them and reuse them in a follow-up request.
https://nano-banana-mcp.<subdomain>.workers.dev/<token>/img/8be62d09
variant 2/3 · 1376×768 (16:9) · seed 101 · temp 0.9
The seed is always present. A caller who omits seed gets one generated by the Worker, which is sent to Gemini and reported back. Letting the model pick its own unreported seed would make the image impossible to reproduce, so refinement — "same image but at dusk" — would be impossible too. temperature reads temp default when it wasn't supplied, since there is no single number to name.
1376×768 (16:9) · seed 868960483 · temp default
The resolution is read from the returned image's own header rather than assumed from the requested ratio, so if the model ignores the aspect ratio the line says so:
1024×1024 (16:9) ⚠ model returned a different aspect ratio than the requested 16:9
When no aspect_ratio was requested — the usual case for edit_image — the ratio in the line is inferred from the returned pixels instead, and never carries the mismatch warning.
If a variation fails partway through a count > 1 batch, the images already generated are still returned, with a trailing note naming the variation that failed and why.
Image URLs
Since Claude.ai doesn't render raw base64 image blocks from custom MCP connectors, generate_image also stores each generated image in a Workers KV namespace (IMAGES) and returns a public URL alongside the base64 content:
https://nano-banana-mcp.<subdomain>.workers.dev/<MCP_AUTH_TOKEN>/img/<id>
- Each image is available at its URL for 24 hours, after which it expires from KV and the route returns a 404.
- The URL is auth-gated the same way as
/mcp: the token must matchMCP_AUTH_TOKEN.
Rendering
Tool results are plain MCP content blocks — one text block per image (URL + settings) followed by the raw image blocks — and the chat side decides how to display them. The server declares no resources capability and no MCP Apps extension, so no host-rendered widget is involved.
Editing
edit_image edits an existing image with a natural-language instruction, using the same Gemini 2.5 Flash Image model. The source image argument accepts either:
- a public HTTPS URL to an image, or
- the 8-character id from a previous
generate_image/edit_imageresult (the trailing segment of its returned/img/<id>URL).
If aspect_ratio is omitted, no imageConfig is sent at all and the source image's framing is preserved. Source images are capped at ~6 MB. Like generate_image, results are stored in KV and returned as URL(s) + raw image content, so edited images can themselves be passed back into edit_image by id for further edits.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。