This server provides AI-powered image generation and editing using Google's Gemini models with intelligent model selection between Gemini 2.5 Flash (fast, up to 1024px) and Gemini 3 Pro (high-quality, up to 4K).
Core Capabilities:
Generate new images from text prompts with automatic or manual model selection
Edit existing images using natural language instructions via file paths or Files API IDs
Multi-image conditioning - provide up to 3 input images to guide generation
Batch generation - create multiple images at once (up to 4 per request)
Aspect ratio control - specify output dimensions (1:1, 16:9, 9:16, 21:9, and more)
Negative prompts and custom system instructions for precise control
Advanced Pro Features (Gemini 3 Pro):
4K resolution output for professional-grade images
Google Search grounding for factually accurate images
Configurable thinking levels (LOW/HIGH) for complex compositions
Superior text rendering and media resolution control
File Management:
Upload files to Gemini Files API for large images (>20MB) or reusable assets
Track file metadata including URIs, expiration times, and display names
View output statistics and directory information
Maintenance & Cleanup:
Remove expired Files API entries and clean old local files
Check storage quota against the ~20GB Files API budget
Database hygiene and full cleanup operations with dry-run support
Output: Returns MCP image content blocks for direct client display with structured JSON metadata, local file storage, and smart templates for photography, design, and editing workflows.
Provides AI-powered image generation capabilities through Google's Gemini 2.5 Flash Image model, including file management via the Gemini Files API and smart prompt templates for photography, design, and editing
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nanobanana-mcp-servergenerate a futuristic cityscape at sunset with flying cars"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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: Nano Banana 2 — Gemini 3.1 Flash Image! 🍌🚀
Nano Banana 2 (gemini-3.1-flash-image-preview) is now the default model — delivering Pro-level quality at Flash speed:
🍌 Flash Speed + 4K Quality: Up to 3840px at Gemini 2.5 Flash latency
🌐 Google Search Grounding: Real-world knowledge for factually accurate images
🎯 Subject Consistency: Up to 5 characters and 14 objects per scene
✍️ Precision Text Rendering: Crystal-clear text placement in images
🏆 Gemini 3 Pro Image still available for maximum reasoning depth
Related MCP server: Gemini MCP Server for Claude Desktop
✨ Features
🎨 Multi-Model AI Image Generation: Three Gemini models with intelligent automatic selection
🍌 Gemini 3.1 Flash Image (NB2): Default model — 4K resolution at Flash speed with grounding
🏆 Gemini 3 Pro Image: Maximum reasoning depth for the most complex compositions
⚡ Gemini 2.5 Flash Image: Legacy Flash model for high-volume rapid prototyping
🤖 Smart Model Selection: Automatically routes to NB2 or Pro 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
Option 3: Using pip
🔧 Configuration
Authentication Methods
Nano Banana supports two authentication methods via NANOBANANA_AUTH_METHOD:
API Key (
api_key): UsesGEMINI_API_KEY. Best for local development and simple deployments.Vertex AI ADC (
vertex_ai): Uses Google Cloud Application Default Credentials. Best for production on Google Cloud (Cloud Run, GKE, GCE).Automatic (
auto): Defaults to API Key if present, otherwise tries Vertex AI.
1. API Key Authentication (Default)
Set GEMINI_API_KEY environment variable.
2. Vertex AI Authentication (Google Cloud)
Required environment variables:
NANOBANANA_AUTH_METHOD=vertex_ai(orauto)GCP_PROJECT_ID=your-project-idGCP_REGION=us-central1(default)
Prerequisites:
Enable Vertex AI API:
gcloud services enable aiplatform.googleapis.comGrant IAM Role:
roles/aiplatform.userto the service account.
Claude Desktop
Option 1: Using Published Server (Recommended)
Add to your claude_desktop_config.json:
Option 2: Using Local Source (Development)
If you are running from source code, point to your local installation:
Option 3: Using Vertex AI (ADC)
To authenticate with Google Cloud Application Default Credentials (instead of an API Key):
Configuration file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%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:
Continue.dev (VS Code/JetBrains)
Add to your config.json:
Open WebUI
Configure in Open WebUI settings:
Gemini CLI / Generic MCP Client
🤖 Model Selection
Nano Banana supports three Gemini models with intelligent automatic selection:
🍌 NB2 — Nano Banana 2 (Gemini 3.1 Flash Image) ⭐ DEFAULT
Flash speed with Pro-level quality — the best of both worlds
Quality: Production-ready 4K output
Resolution: Up to 4K (3840px)
Speed: ~2-4 seconds per image (Flash-class latency)
Special Features:
🌐 Google Search Grounding: Real-world knowledge for factually accurate images
🎯 Subject Consistency: Up to 5 characters and 14 objects per scene
✍️ Precision Text Rendering: Clear, well-placed text in images
Best for: Almost everything — production assets, marketing, photography, text overlays
model_tier:
"nb2"(or"auto"— NB2 is the auto default)
🏆 Pro Model — Nano Banana Pro (Gemini 3 Pro Image)
Maximum reasoning depth for the most demanding compositions
Quality: Highest available
Resolution: Up to 4K (3840px)
Speed: ~5-8 seconds per image
Special Features:
🧠 Advanced Reasoning: Configurable thinking levels (LOW/HIGH)
🌐 Google Search Grounding: Real-world knowledge integration
📐 Media Resolution Control: Fine-tune vision processing detail
Best for: Complex narrative scenes, intricate compositions, maximum reasoning required
model_tier:
"pro"
⚡ Flash Model (Gemini 2.5 Flash Image)
Legacy model for high-volume rapid iteration
Speed: Very fast (2-3 seconds)
Resolution: Up to 1024px
Best for: High-volume generation, quick drafts where 4K is not needed
model_tier:
"flash"
🤖 Automatic Selection (Recommended)
By default, the server uses AUTO mode which routes to NB2 unless Pro's deeper reasoning is clearly needed:
Pro Model Selected When:
Strong quality keywords: "4K", "professional", "production", "high-res", "HD"
High thinking level requested:
thinking_level="HIGH"Multi-image conditioning with multiple input images
NB2 Model Selected When (default):
Standard requests, everyday image generation
Speed keywords: "quick", "draft", "sketch", "rapid"
High-volume batch generation (
n > 2)
Usage Examples
📐 Aspect Ratio Control
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
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".
📁 Output Path Control ⭐ NEW!
Control where generated images are saved with the output_path parameter:
Three modes of operation:
Specific file path - Save to an exact file location:
Directory path - Use auto-generated filename in a specific directory:
Default location - Uses IMAGE_OUTPUT_DIR or ~/nanobanana-images:
Multiple images (n > 1): When generating multiple images with a file path, images are automatically numbered:
First image:
/path/to/image.pngSecond image:
/path/to/image_2.pngThird image:
/path/to/image_3.png
Precedence Rules:
output_pathparameter (if provided) - highest priorityIMAGE_OUTPUT_DIRenvironment variable~/nanobanana-images(default fallback)
⚙️ Environment Variables
Configuration options:
🐛 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@latestCheck that your client supports MCP (Claude Desktop 0.10.0+)
"Permission denied" errors
The server creates images in
~/nanobanana-imagesby defaultEnsure write permissions to your home directory
Development Setup
For local development:
📄 License
MIT License - see LICENSE for details.
🆘 Support
Issues: GitHub Issues
Discussions: GitHub Discussions