nano-banana-claude
An MCP server that provides image generation using Google's Nano Banana Gemini models, with additional tools for background removal, upscaling, and format conversion via deterministic post-processing.
README
nano-banana-claude
Generated by generate_image (Nano Banana flash, 16:9).
A small MCP server that gives Claude Code (or any MCP client) image generation via Google's Nano Banana Gemini image models — plus the deterministic post-processing the model can't do reliably on its own: true alpha transparency, AI upscaling, resizing, and format conversion.
The idea: keep generation in the model, but put the things that need real code (a genuine alpha channel, exact dimensions, super-resolution) behind tools so they're reliable instead of prompt-and-hope.
Tools
| Tool | What it does |
|---|---|
generate_image |
Text → image. model (flash/pro), aspect_ratio, format, output_path. |
generate_transparent_image |
Generate, then remove the background with rembg (U2-Net) → a real RGBA PNG. Nano Banana can't produce reliable alpha on its own. |
edit_image |
One or more input images + a prompt → edited / composited result. |
process_image |
Local Pillow ops, no API call: resize/fit/crop, convert (png/webp/jpeg + quality), optional background removal. |
upscale_image |
AI super-resolution with Real-ESRGAN (realesr-general-x4v3). Tiled for large images, alpha-preserving. |
Models: flash → gemini-2.5-flash-image (Nano Banana, default, fast/cheap),
pro → gemini-3-pro-image-preview (Nano Banana Pro, higher quality).
Requirements
- Python 3.10+
- A Gemini API key (free tier available) from https://aistudio.google.com/apikey
- ~500 MB disk for dependencies; CPU is fine (no GPU required)
Install
git clone https://github.com/tougenrip/nano-banana-claude.git
cd nano-banana-claude
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
Two ML models download automatically on first use (not committed):
- rembg U2-Net (~176 MB) →
~/.u2net/— first transparent-image call - Real-ESRGAN x4 (~4.6 MB) →
~/.cache/nano-banana/— first upscale call
Register with Claude Code
From inside the cloned directory:
claude mcp add nano-banana --scope user \
--env GEMINI_API_KEY=your-key-here \
-- "$(pwd)/.venv/bin/python" "$(pwd)/server.py"
--scope user makes it available in every project; drop it to scope to the current project.
Reconnect and the five nano-banana tools appear. The API key is read from the environment
at runtime and is never written into the code.
Usage
Once registered, just ask in natural language — Claude picks the tool:
- "Generate a 16:9 image of a neon city at night." →
generate_image - "Make a transparent PNG of a red sneaker." →
generate_transparent_image - "Put the logo in photo.png onto the mug in mug.jpg." →
edit_image - "Resize hero.png to 1200px wide as webp." →
process_image - "Upscale icon.png 4×." →
upscale_image
Tools can chain: generate a transparent cutout, then upscale it — the alpha survives.
Outputs are written next to the working directory (or to output_path) and the absolute
path is returned. Set NANO_BANANA_OUTPUT_DIR to change the default location.
How transparency works
Image models paint pixels; asking for a "transparent background" usually yields a flat color
or a drawn-in checkerboard, not a real alpha channel. So generate_transparent_image
generates the subject on a plain background, then runs rembg (U2-Net) to compute an actual
alpha matte, producing a true RGBA PNG. process_image(remove_background=true) does the same
on any existing image.
<img src="examples/transparent-banana.png" alt="Transparent cutout example" width="320">
Output of generate_transparent_image — a real RGBA PNG (~90% of pixels fully
transparent), not a painted-on checkerboard.
Layout
server.py FastMCP server + tool definitions; Gemini REST via stdlib urllib
upscale.py Real-ESRGAN inference (onnxruntime), lazily loaded, with tiling
requirements.txt mcp, Pillow, rembg, onnxruntime
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。