@dondonudonjp/nanobanana-mcp-server
v0.4.0
Published
MCP server for Google Gemini NanoBanana (2.5 Flash Image, 3 Pro Image & 3.1 Flash Image) AI image generation and editing
Maintainers
Readme
NanoBanana MCP Server
Model Context Protocol server for Google Gemini NanoBanana (2.5 Flash Image & 3 Pro Image) AI generation and editing.
🚀 Installation
Global Installation (Recommended)
Install globally via npm:
npm install -g nanobanana-mcp-serverAfter installation, the server will be available as nanobanana-mcp command.
Local Development Installation
git clone <repository-url>
cd Gemini2.5FlashImageMCPServer
npm install
npm run build⚙️ Configuration
Environment Variables
Create a .env file or set environment variables:
GEMINI_API_KEY=your_gemini_api_key_here
NANOBANANA_OUTPUT_DIR=~/Downloads/nanobanana-images
DEBUG=false
MCP_SERVER_NAME=nanobanana-mcp-serverClaude Desktop Integration
Global Installation Setup
Add to your Claude Desktop configuration (%APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"nanobanana": {
"command": "nanobanana-mcp",
"env": {
"GEMINI_API_KEY": "your_gemini_api_key_here",
"NANOBANANA_OUTPUT_DIR": "C:\\Users\\YourUsername\\Downloads\\nanobanana-images",
"DEBUG": "false"
}
}
}
}Local Installation Setup
{
"mcpServers": {
"nanobanana": {
"command": "node",
"args": ["path/to/dist/index.js"],
"env": {
"GEMINI_API_KEY": "your_gemini_api_key_here",
"NANOBANANA_OUTPUT_DIR": "path/to/output/directory",
"DEBUG": "false"
}
}
}
}🎨 Available Tools
generate_image
Generate images from text prompts with optional style, aspect ratio, and reference images for style/content guidance.
Parameters:
prompt(required): Text description of the imagestyle(optional): Style specification (e.g., "photorealistic", "artistic", "cartoon")aspectRatio(optional): Aspect ratio (e.g., "16:9", "4:3", "1:1", "9:16")referenceImagePaths(optional): Array of reference image paths for style/content guidance- Flash model: max 3 images
- Pro model: max 14 images
model(optional):gemini-2.5-flash-imageorgemini-3-pro-image-previewresolution(optional):1K,2K, or4K(Pro model only)output_path(optional): Custom output path
Example (text only):
{
"prompt": "A serene mountain lake at sunset with reflections",
"aspectRatio": "16:9",
"style": "photorealistic"
}Example (with reference images):
{
"prompt": "Generate a new scene with this character looking at snowy night sky",
"referenceImagePaths": ["./character_sheet.png"],
"aspectRatio": "3:4",
"model": "gemini-3-pro-image-preview",
"resolution": "1K"
}edit_image
Edit existing images using natural language instructions.
Parameters:
imagePath(required): Path to input imageinstruction(required): Editing instructionoutputPath(optional): Custom output path
multi_image_fusion
Blend multiple images into a single image.
Parameters:
imagePaths(required): Array of image paths- Flash model: max 3 images
- Pro model: max 14 images
instruction(required): Fusion instructionsmodel(optional):gemini-2.5-flash-imageorgemini-3-pro-image-previewresolution(optional):1K,2K, or4K(Pro model only)output_path(optional): Custom output path
character_consistency
Create new images with consistent character from reference.
Parameters:
characterImagePath(required): Reference character imagescenePrompt(required): New scene descriptionoutputPath(optional): Custom output path
list_generated_images
List all generated images with metadata.
Parameters:
limit(optional): Maximum number of images (default: 50)
📏 Supported Aspect Ratios
| Ratio | Description | Resolution |
|-------|-------------|------------|
| 16:9 | Widescreen | 1920×1080 |
| 9:16 | Portrait (mobile) | 1080×1920 |
| 4:3 | Standard | 1600×1200 |
| 3:4 | Portrait | 1200×1600 |
| 1:1 | Square | 1024×1024 |
| 3:2 | Photo standard | 1536×1024 |
| 2:3 | Portrait photo | 1024×1536 |
| 21:9 | Ultrawide | 2560×1097 |
🔧 Usage
MCP Server (for Claude Desktop)
# Start the MCP server
nanobanana-mcp
# Or with environment variables
GEMINI_API_KEY=your_key nanobanana-mcpBatch CLI (for command line)
# Basic batch processing
nanobanana-batch batch.json
# Specify output directory
nanobanana-batch batch.json --output-dir ./my-images
# JSON output for scripting
nanobanana-batch batch.json --format json > result.json
# Custom timeout (20 minutes)
nanobanana-batch batch.json --timeout 1200000
# Show help
nanobanana-batch --helpProgrammatic Usage
# Local development (MCP server)
npm run dev
# Local development (Batch CLI)
npm run dev:batch batch.json
# Production
npm start # MCP server
npm run batch # Batch CLI📦 Batch Processing
The nanobanana-batch command processes multiple image jobs from a JSON configuration file.
Batch Config Format
{
"jobs": [
{
"type": "generate",
"prompt": "A beautiful sunset over mountains",
"output_filename": "sunset.png",
"aspectRatio": "16:9",
"style": "photorealistic"
},
{
"type": "generate",
"prompt": "This character gazing at snowy night sky",
"referenceImagePaths": ["./character_sheet.png"],
"output_filename": "character_snow.png",
"aspectRatio": "3:4",
"model": "gemini-3-pro-image-preview",
"resolution": "1K"
},
{
"type": "edit",
"imagePath": "./input.png",
"instruction": "Make it more vibrant",
"output_filename": "edited.png"
},
{
"type": "fusion",
"imagePaths": ["./a.png", "./b.png"],
"instruction": "Blend the styles together"
},
{
"type": "character",
"characterImagePath": "./character.png",
"scenePrompt": "In a magical forest"
}
],
"output_dir": "./output",
"max_concurrent": 2,
"timeout": 600000
}Supported Job Types
| Type | Required Fields | Optional Fields | Description |
|------|-----------------|-----------------|-------------|
| generate | prompt | referenceImagePaths[], style | Text-to-image generation with optional reference images |
| edit | imagePath, instruction | | Edit existing image |
| fusion | imagePaths[], instruction | | Blend multiple images |
| character | characterImagePath, scenePrompt | | Character consistency |
Common Job Options
All job types support these optional fields:
output_filename: Custom output filenamemodel:gemini-2.5-flash-imageorgemini-3-pro-image-previewresolution:1K,2K, or4K(Pro model only)aspectRatio:1:1,16:9,9:16, etc.
Batch CLI Options
| Option | Description |
|--------|-------------|
| --output-dir <path> | Output directory (overrides config and env) |
| --format <text\|json> | Output format (default: text) |
| --timeout <ms> | Timeout in milliseconds (default: 600000) |
| --help, -h | Show help |
| --version, -v | Show version |
🛠 Development
Build
npm run buildClean
npm run clean📋 Requirements
- Node.js 18+
- Google Gemini API key
- Claude Desktop (for MCP integration)
🤖 Model Comparison
| Feature | gemini-2.5-flash-image | gemini-3-pro-image-preview | |---------|------------------------|----------------------------| | Speed | Fast (~5-10s) | Slower (~20-30s) | | Resolution | 1K (fixed) | 1K / 2K / 4K (selectable) | | Max Reference Images | 3 | 14 | | Aspect Ratio | Via prompt | Via API parameter | | Pricing | Free tier available | Paid preview | | Best For | Quick iterations | High quality output |
💰 Pricing
- Gemini 2.5 Flash Image: Free tier available (60 requests/min via AI Studio)
- Gemini 3 Pro Image: Paid preview, requires billing enabled
📄 License
MIT License
