A production-ready MCP server for AI-powered image generation using Gemini 3 Pro Image (Nano Banana Pro) and Gemini 2.5 Flash Image with intelligent model selection
Project description
Nano Banana MCP Server 🍌
A production-ready Model Context Protocol (MCP) server that provides AI-powered image generation capabilities through Google's Gemini models with intelligent model selection.
⭐ NEW: Gemini 3 Pro Image Support! 🚀
Now featuring Nano Banana Pro - Google's latest and most powerful image generation model:
- 🏆 Professional 4K Quality: Generate stunning images up to 3840px resolution
- 🌐 Google Search Grounding: Access real-world knowledge for factually accurate images
- 🧠 Advanced Reasoning: Configurable thinking levels for complex compositions
- 🎯 Superior Text Rendering: Crystal-clear text in images at high resolution
- 🎨 Enhanced Understanding: Better context comprehension for complex prompts
✨ Features
- 🎨 Multi-Model AI Image Generation: Intelligent selection between Flash (speed) and Pro (quality) models
- ⚡ Gemini 2.5 Flash Image: Fast generation (1024px) for rapid prototyping
- 🏆 Gemini 3 Pro Image: High-quality up to 4K with Google Search grounding
- 🤖 Smart Model Selection: Automatically chooses optimal model based on your prompt
- 📐 Aspect Ratio Control ⭐ NEW: Specify output dimensions (1:1, 16:9, 9:16, 21:9, and more)
- 📋 Smart Templates: Pre-built prompt templates for photography, design, and editing
- 📁 File Management: Upload and manage files via Gemini Files API
- 🔍 Resource Discovery: Browse templates and file metadata through MCP resources
- 🛡️ Production Ready: Comprehensive error handling, logging, and validation
- ⚡ High Performance: Optimized architecture with intelligent caching
🚀 Quick Start
Prerequisites
- Google Gemini API Key - Get one free here
- Python 3.11+ (for development only)
Installation
Option 1: From MCP Registry (Recommended) This server is available in the Model Context Protocol Registry. Search for "nanobanana" or use the MCP name below with your MCP client.
mcp-name: io.github.zhongweili/nanobanana-mcp-server
Option 2: Using uvx
uvx nanobanana-mcp-server@latest
Option 3: Using pip
pip install nanobanana-mcp-server
🔧 Configuration
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"nanobanana": {
"command": "uvx",
"args": ["nanobanana-mcp-server@latest"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
}
}
Configuration file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Claude Code (VS Code Extension)
Install and configure in VS Code:
- Install the Claude Code extension
- Open Command Palette (
Cmd/Ctrl + Shift + P) - Run "Claude Code: Add MCP Server"
- Configure:
{ "name": "nanobanana", "command": "uvx", "args": ["nanobanana-mcp-server@latest"], "env": { "GEMINI_API_KEY": "your-gemini-api-key-here" } }
Cursor
Add to Cursor's MCP configuration:
{
"mcpServers": {
"nanobanana": {
"command": "uvx",
"args": ["nanobanana-mcp-server@latest"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
}
}
Continue.dev (VS Code/JetBrains)
Add to your config.json:
{
"mcpServers": [
{
"name": "nanobanana",
"command": "uvx",
"args": ["nanobanana-mcp-server@latest"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
]
}
Open WebUI
Configure in Open WebUI settings:
{
"mcp_servers": {
"nanobanana": {
"command": ["uvx", "nanobanana-mcp-server@latest"],
"env": {
"GEMINI_API_KEY": "your-gemini-api-key-here"
}
}
}
}
Gemini CLI / Generic MCP Client
# Set environment variable
export GEMINI_API_KEY="your-gemini-api-key-here"
# Run server in stdio mode
uvx nanobanana-mcp-server@latest
# Or with pip installation
python -m nanobanana_mcp_server.server
🤖 Model Selection
Nano Banana supports two Gemini models with intelligent automatic selection:
🏆 Pro Model - Nano Banana Pro (Gemini 3 Pro Image) ⭐ NEW!
Google's latest and most advanced image generation model
- Quality: Professional-grade, production-ready
- Resolution: Up to 4K (3840px) - highest available
- Speed: ~5-8 seconds per image
- Special Features:
- 🌐 Google Search Grounding: Leverages real-world knowledge for accurate, contextual images
- 🧠 Advanced Reasoning: Configurable thinking levels (LOW/HIGH) for complex compositions
- 📐 Media Resolution Control: Fine-tune vision processing detail (LOW/MEDIUM/HIGH/AUTO)
- 📝 Superior Text Rendering: Exceptional clarity for text-in-image generation
- 🎨 Enhanced Context Understanding: Better interpretation of complex, narrative prompts
- Best for: Production assets, marketing materials, professional photography, high-fidelity outputs, images requiring text, factual accuracy
- Cost: Higher per image (premium quality)
⚡ Flash Model (Gemini 2.5 Flash Image)
Fast, reliable model for rapid iteration
- Speed: Very fast (2-3 seconds)
- Resolution: Up to 1024px
- Quality: High quality for everyday use
- Best for: Rapid prototyping, iterations, high-volume generation, drafts, sketches
- Cost: Lower per image
🤖 Automatic Selection (Recommended)
By default, the server uses AUTO mode which intelligently analyzes your prompt and requirements:
Pro Model Selected When:
- Quality keywords detected: "4K", "professional", "production", "high-res", "HD"
- High resolution requested:
resolution="4k"orresolution="high" - Google Search grounding enabled:
enable_grounding=True - High thinking level requested:
thinking_level="HIGH" - Multi-image conditioning with multiple input images
Flash Model Selected When:
- Speed keywords detected: "quick", "draft", "sketch", "rapid"
- High-volume batch generation:
n > 2 - Standard or lower resolution requested
- No special Pro features required
Usage Examples
# Automatic selection (recommended)
"Generate a professional 4K product photo" # → Pro model (quality keywords + 4K)
"Quick sketch of a cat" # → Flash model (speed keyword)
"Create a diagram with clear text labels" # → Pro model (text rendering)
"Draft mockup for website hero section" # → Flash model (draft keyword)
# Explicit model selection
generate_image(
prompt="A scenic landscape",
model_tier="flash" # Force Flash model for speed
)
# Leverage Nano Banana Pro features
generate_image(
prompt="Professional product photo of vintage camera on wooden desk",
model_tier="pro", # Use Pro model
resolution="4k", # 4K resolution (Pro-only)
thinking_level="HIGH", # Enhanced reasoning
enable_grounding=True, # Use Google Search for accuracy
media_resolution="HIGH" # High-detail vision processing
)
# Pro model for high-quality text rendering
generate_image(
prompt="Infographic showing 2024 market statistics with clear labels",
model_tier="pro", # Pro excels at text rendering
resolution="4k" # Maximum clarity for text
)
# Control aspect ratio for different formats ⭐ NEW!
generate_image(
prompt="Cinematic landscape at sunset",
aspect_ratio="21:9" # Ultra-wide cinematic format
)
generate_image(
prompt="Instagram post about coffee",
aspect_ratio="1:1" # Square format for social media
)
generate_image(
prompt="YouTube thumbnail design",
aspect_ratio="16:9" # Standard video format
)
generate_image(
prompt="Mobile wallpaper of mountain vista",
aspect_ratio="9:16" # Portrait format for phones
)
📐 Aspect Ratio Control ⭐ NEW!
Control the output image dimensions with the aspect_ratio parameter:
Supported Aspect Ratios:
1:1- Square (Instagram, profile pictures)4:3- Classic photo format3:4- Portrait orientation16:9- Widescreen (YouTube thumbnails, presentations)9:16- Mobile portrait (phone wallpapers, stories)21:9- Ultra-wide cinematic2:3,3:2,4:5,5:4- Various photo formats
# Examples for different use cases
generate_image(
prompt="Product showcase for e-commerce",
aspect_ratio="3:4", # Portrait format, good for product pages
model_tier="pro"
)
generate_image(
prompt="Social media banner for Facebook",
aspect_ratio="16:9" # Landscape banner format
)
Note: Aspect ratio works with both Flash and Pro models. For best results with specific aspect ratios at high resolution, use the Pro model with resolution="4k".
⚙️ Environment Variables
Configuration options:
# Required
GEMINI_API_KEY=your-gemini-api-key-here
# Model Selection (optional)
NANOBANANA_MODEL=auto # Options: flash, pro, auto (default: auto)
# Optional
IMAGE_OUTPUT_DIR=/path/to/image/directory # Default: ~/nanobanana-images
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
LOG_FORMAT=standard # standard, json, detailed
🐛 Troubleshooting
Common Issues
"GEMINI_API_KEY not set"
- Add your API key to the MCP server configuration in your client
- Get a free API key at Google AI Studio
"Server failed to start"
- Ensure you're using the latest version:
uvx nanobanana-mcp-server@latest - Check that your client supports MCP (Claude Desktop 0.10.0+)
"Permission denied" errors
- The server creates images in
~/nanobanana-imagesby default - Ensure write permissions to your home directory
Development Setup
For local development:
# Clone repository
git clone https://github.com/zhongweili/nanobanana-mcp-server.git
cd nanobanana-mcp-server
# Install with uv
uv sync
# Set environment
export GEMINI_API_KEY=your-api-key-here
# Run locally
uv run python -m nanobanana_mcp_server.server
📄 License
MIT License - see LICENSE for details.
🆘 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanobanana_mcp_server-0.2.0.tar.gz.
File metadata
- Download URL: nanobanana_mcp_server-0.2.0.tar.gz
- Upload date:
- Size: 196.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deba0fdce796ec715285c7d295ce5c33cb6b5551da8945767b035ddff1c95376
|
|
| MD5 |
ba878d879dcb9f08d9c4e8d1aa5d0c9e
|
|
| BLAKE2b-256 |
8f0a49826aab324e391bfb1baf8aecf0b2b0eae7a2e5d619db49881bc2e5e8f6
|
File details
Details for the file nanobanana_mcp_server-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nanobanana_mcp_server-0.2.0-py3-none-any.whl
- Upload date:
- Size: 79.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e667ea1f5d8d11f95766b6af9e8e006d863ab165a704b27a06a2b9211883265d
|
|
| MD5 |
65fcf3af5da7a00d5ac153c88315924d
|
|
| BLAKE2b-256 |
6017b82145cffa34114bc219df19ac1d0cbe73108505e1c9a97519d0041a023a
|