mcp-nano-banana
MCP server for AI-powered image generation using Google Gemini Nano Banana models. Enables text-to-image generation, image editing, multi-image combination, and favicon generation directly from your AI coding assistant.
README
mcp-nano-banana
MCP server for AI-powered image generation using Google Gemini Nano Banana models. Generate, edit, and combine images from text prompts — directly from your AI coding assistant.
Features
- Text-to-image generation — Create images from natural language descriptions
- Image editing — Upload images and modify them with text instructions
- Multi-image combination — Mix up to 14 reference images into one composite
- Resolution control — Generate at 512px, 1K, 2K, or 4K resolution
- 13+ aspect ratios — From square (1:1) to ultra-wide (21:9) and tall (1:8)
- Auto-fallback — Pro model falls back to Flash on rate limits (429/403/402)
- File output — Save to specific paths or return inline base64
- Favicon generation — Generate complete favicon packages with one command
- Multi-format output — PNG, JPEG, and WebP support
Quick Start
Prerequisites
- Get a Gemini API key from Google AI Studio
- Enable billing on your Google Cloud project — image generation requires a paid tier (~$0.04-0.05/image for NB2 at standard resolution)
Installation
npm install -g mcp-nano-banana
Set your API key:
export GEMINI_API_KEY=your-api-key
For MCP Registry publication metadata, the registry name is io.github.codeFi/mcp-nano-banana.
MCP Configuration
Codex
codex mcp add nano-banana --env GEMINI_API_KEY=your-api-key -- npx -y mcp-nano-banana@latest
Or add manually to ~/.codex/config.toml:
[mcp_servers.nano-banana]
command = "npx"
args = ["-y", "mcp-nano-banana@latest"]
[mcp_servers.nano-banana.env]
GEMINI_API_KEY = "your-api-key"
Qwen Code
Add to ~/.qwen/settings.json:
{
"mcpServers": {
"nano-banana": {
"command": "npx",
"args": ["-y", "mcp-nano-banana@latest"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Claude Code
claude mcp add nano-banana -e GEMINI_API_KEY=your-api-key -- npx -y mcp-nano-banana@latest
Or add manually to ~/.claude/claude_desktop_config.json:
{
"mcpServers": {
"nano-banana": {
"command": "npx",
"args": ["-y", "mcp-nano-banana@latest"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Other MCP Clients
For CLIs and desktop clients that use the standard mcpServers JSON format, register:
{
"mcpServers": {
"nano-banana": {
"command": "npx",
"args": ["-y", "mcp-nano-banana@latest"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Local / Development Build
git clone https://github.com/codeFi/mcp-nano-banana.git
cd mcp-nano-banana
npm install
npm run build
Then register with your MCP client:
{
"mcpServers": {
"nano-banana": {
"command": "node",
"args": ["/path/to/mcp-nano-banana/dist/index.js"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Models
| Model | MCP Name | Description | Max Ref Images |
|---|---|---|---|
gemini-3-pro-image-preview |
Nano Banana Pro | High quality, thinking mode, professional assets | 6 object + 5 character |
gemini-3.1-flash-image-preview |
Nano Banana 2 | Fast, high-efficiency, 1:4/4:1/1:8/8:1 ratios | 10 object + 4 character |
gemini-2.5-flash-image |
Nano Banana | Fastest, optimized for high-volume tasks | - |
The server defaults to Nano Banana Pro for best quality and automatically falls back to Flash on rate limits.
Available Parameters
Resolution
| Value | Approx. Pixels | Supported Models |
|---|---|---|
"512" |
~512px | Nano Banana 2 only |
"1K" |
~1024px | All models |
"2K" |
~2048px | All models |
"4K" |
~4096px | All models |
Default: "1K"
Aspect Ratio
| Value | Dimensions at 1K | Common Use Case |
|---|---|---|
1:1 |
1024×1024 | Social posts, icons |
16:9 |
1344×768 | Headers, presentations |
9:16 |
768×1344 | Stories, mobile |
4:3 |
1152×896 | Desktop, photos |
3:4 |
896×1152 | Portraits |
2:3 |
~896×1344 | Print, magazines |
3:2 |
~1344×896 | Photos |
4:5 |
~896×1120 | Instagram posts |
5:4 |
~1120×896 | Instagram landscape |
21:9 |
~2048×878 | Ultra-wide banners |
1:4 |
~512×2048 | Nano Banana 2 only — tall strips |
4:1 |
~2048×512 | Nano Banana 2 only — wide strips |
1:8 |
~512×4096 | Nano Banana 2 only — extra tall |
8:1 |
~4096×512 | Nano Banana 2 only — extra wide |
Tools
generate_image
Generate or edit images from text prompts.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | ✅ Yes | — | Text description or editing instructions |
imagePaths |
string[] | No | — | Reference image paths on disk (up to 14) |
model |
string | No | gemini-3-pro-image-preview |
Model to use |
aspectRatio |
string | No | 1:1 |
See table above for all options |
resolution |
string | No | 1K |
512, 1K, 2K, or 4K |
outputFormat |
string | No | png |
png, jpeg, webp |
outputPath |
string | No | — | Save image to this file path |
Examples
Generate from text:
{
"prompt": "A sunset over mountains with dramatic lighting",
"aspectRatio": "16:9",
"resolution": "2K",
"outputPath": "/Users/currentUser/Desktop/sunset.png"
}
Edit an existing image:
{
"prompt": "Change the background to a coffee shop interior",
"imagePaths": ["/Users/currentUser/photo.jpg"],
"outputPath": "/Users/currentUser/edited.png"
}
Combine multiple images:
{
"prompt": "Put these glasses on this person's face",
"imagePaths": ["/path/to/face.jpg", "/path/to/glasses.jpg"],
"outputPath": "/path/to/result.png"
}
High-res wallpaper:
{
"prompt": "A futuristic cityscape at night with neon lights and rain",
"aspectRatio": "16:9",
"resolution": "4K",
"outputPath": "/path/to/wallpaper.png"
}
generate_favicons
Generate a complete favicon package from a prompt or existing image.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | No* | — | Icon description (required if imagePath not set) |
imagePath |
string | No* | — | Path to existing master icon image |
model |
string | No | gemini-3-pro-image-preview |
Model for prompt generation |
outputDir |
string | No | — | Directory for individual favicon files |
outputPath |
string | No | — | Save ZIP package to this path |
returnZipBase64 |
boolean | No | false |
Return ZIP as base64 text |
appName |
string | No | My App |
Manifest name |
shortName |
string | No | App |
Manifest short_name |
themeColor |
string | No | #ffffff |
Manifest theme color |
backgroundColor |
string | No | #ffffff |
Manifest background color |
includeReadme |
boolean | No | true |
Include README.md in package |
Example
{
"prompt": "A minimalist banana icon with a soft gradient",
"outputDir": "/path/to/favicon",
"outputPath": "/path/to/favicon.zip",
"appName": "MyBrand",
"shortName": "Brand",
"themeColor": "#1a1a2e",
"backgroundColor": "#ffffff"
}
Generated files:
favicon.ico— Multi-size icon (16/32/48px)favicon-16x16.png— Browser tabsfavicon-32x32.png— Higher-res tabsapple-touch-icon.png— iOS home screenandroid-chrome-192x192.png— Androidandroid-chrome-512x512.png— Android HDsite.webmanifest— PWA manifest
HTML snippet (included in response):
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
Pricing
Image generation requires a paid Google AI Studio account. Approximate costs:
| Model | 1K | 2K | 4K |
|---|---|---|---|
| Nano Banana 2 | ~$0.04 | ~$0.08 | ~$0.15 |
| Nano Banana Pro | ~$0.06 | ~$0.13 | ~$0.24 |
You only pay for what you generate — no monthly minimum.
Supported Image Formats
Input (reference images): png, jpg, jpeg, webp, gif
Output: png, jpeg, webp
Development
# Build TypeScript
npm run build
# Watch mode
npm run dev
# Run tests
npm test
# Run the server directly
node dist/index.js
Troubleshooting
| Issue | Solution |
|---|---|
GEMINI_API_KEY is not set |
Export the env var or add it to your MCP config |
429 Too Many Requests |
Server auto-falls back to Flash model. Add billing to your account. |
403/402 Quota exceeded |
Enable billing at Google Cloud Console |
503 Unavailable |
High demand — retry in a moment. Common with 4K requests. |
| Image not updating after edit | Make sure you rebuilt the TypeScript (npm run build) |
imagePaths not found |
Use absolute paths. Relative paths may not resolve correctly. |
Architecture
AI Assistant (MCP Client)
│ (MCP Protocol over stdio)
▼
mcp-nano-banana Server
│ (HTTPS POST)
▼
Google Gemini API
│
▼
Generated Image → saved to outputPath (or returned inline base64)
License
Author
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。