NanoBanana MCP
Integrates Google's Gemini models to provide image generation and editing tools, allowing for 2K image creation from text prompts, natural language image manipulation, and session-based character or style consistency.
Click on "Deploy 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 create a 16:9 image of a cozy cabin in a snowy forest"
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.
NanoBanana MCP
MCP server that brings Gemini's image generation and editing capabilities to Claude Desktop, Claude Code, and Cursor. Supports Nano Banana 2 (Flash) and Nano Banana Pro models.
Features
Image Generation - Create 2K images from text prompts
Image Editing - Transform images with natural language instructions
Session Consistency - Maintain style/character across generations
Runtime Model Switching - Switch between Flash and Pro models without restart
Multi-turn Chat - Conversational context with image support
Related MCP server: NanoBanana MCP
Quick Start
Prerequisites
Node.js 18+
Google AI API Key (Get one here)
Add to Claude Code
claude mcp add nanobanana-mcp -- npx -y @ycse/nanobanana-mcp \
-e "GOOGLE_AI_API_KEY=your_api_key"Add to Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"nanobanana-mcp": {
"command": "npx",
"args": ["-y", "@ycse/nanobanana-mcp"],
"env": {
"GOOGLE_AI_API_KEY": "your_api_key"
}
}
}
}Add to Cursor
Create or edit .cursor/mcp.json (project-level) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"nanobanana-mcp": {
"command": "npx",
"args": ["-y", "@ycse/nanobanana-mcp"],
"env": {
"GOOGLE_AI_API_KEY": "your_api_key"
}
}
}
}See Cursor MCP Documentation for more details.
Tools
Tool | Purpose |
| Required. Set aspect ratio before image generation |
| Switch between flash/pro models at runtime |
| Generate images from text prompts |
| Edit images with natural language |
| Multi-turn conversation with images |
| View session image history |
| Reset session context |
set_aspect_ratio (Required)
Must be called before generating or editing images.
Valid ratios: 1:1, 9:16, 16:9, 3:4, 4:3, 3:2, 2:3, 5:4, 4:5, 21:9set_model
Switch models per-session without restarting:
Value | Model | Description |
| gemini-3.1-flash-image-preview | Nano Banana 2 - Faster (default) |
| gemini-3-pro-image-preview | Nano Banana Pro - Higher quality |
gemini_generate_image
{
prompt: string; // Image description
aspect_ratio?: string; // Override session ratio
output_path?: string; // Save path (default: ~/Documents/nanobanana_generated/)
conversation_id?: string; // Session ID
use_image_history?: boolean; // Use previous images for consistency
reference_images?: string[]; // Reference images for style
}gemini_edit_image
{
image_path: string; // File path, "last", or "history:N"
edit_prompt: string; // Edit instructions
aspect_ratio?: string; // Override session ratio
output_path?: string; // Save path
conversation_id?: string; // Session ID
reference_images?: string[]; // Style references
}Slash Commands
Claude Code
npx @ycse/nanobanana-mcp --install-commands claude-code
# Or manually:
# mkdir -p ~/.claude/commands
# cp commands/claude-code/*.md ~/.claude/commands/Cursor
npx @ycse/nanobanana-mcp --install-commands cursor
# Or manually:
# mkdir -p .cursor/commands
# cp commands/cursor/*.md .cursor/commands/See Cursor Slash Commands for more details.
Available Commands
/nb-flash - Switch to Flash model (faster)
/nb-pro - Switch to Pro model (higher quality)Usage Examples
Basic Generation
1. Set aspect ratio: set_aspect_ratio("16:9")
2. Generate: "A cyberpunk cityscape at sunset"Character Consistency
// First image
{ prompt: "A red-hat cat", conversation_id: "cat" }
// Second image - same character
{ prompt: "The cat taking a nap", conversation_id: "cat", use_image_history: true }Edit with History Reference
// Edit the last generated image
{ image_path: "last", edit_prompt: "Change hat to blue" }
// Edit specific image from history
{ image_path: "history:0", edit_prompt: "Add sunglasses" }Switch Models Mid-Session
// Start with Flash for quick iterations
set_model({ model: "flash" })
{ prompt: "Draft concept art" }
// Switch to Pro for final render
set_model({ model: "pro" })
{ prompt: "Final polished version", use_image_history: true }Configuration
Environment Variables
Variable | Required | Description |
| Yes | Google AI API key |
| No | Default model ( |
Output Location
Generated images save to ~/Documents/nanobanana_generated/:
Generated:
generated_[timestamp].pngEdited:
[original]_edited_[timestamp].png
Development
git clone https://github.com/YCSE/nanobanana-mcp.git
cd nanobanana-mcp
npm install
npm run dev # Development mode with hot reload
npm run build # Production build
npm run start # Run compiled serverTroubleshooting
Image generation fails:
Verify API key is valid
Check quota at Google AI Studio
Ensure
set_aspect_ratiowas called first
Tools not showing:
Restart Claude Desktop/Code
Check config file syntax
Verify
npx -y @ycse/nanobanana-mcpruns without errors
License
MIT
Links
Available Tools
7 toolsclear_conversationB
Clear conversation history for a specific conversation ID
Inputs: conversation_id (required).
gemini_chatA
Chat with Gemini 3.1 Flash model. Supports multi-turn conversations with up to 10 reference images.
Inputs: message (required), images, conversation_id, system_prompt.
gemini_edit_imageB
Edit or modify existing images based on prompts. Supports session history references ('last' or 'history:N') and image consistency features.
Inputs: image_path (required), edit_prompt (required), aspect_ratio, output_path, +3 more.
gemini_generate_imageB
Generate images using Gemini's image generation capabilities. Supports session-based image consistency for maintaining style/character across multiple generations.
Inputs: prompt (required), aspect_ratio, output_path, conversation_id, +3 more.
get_image_historyA
Get the list of generated/edited images in a session for reference
Inputs: conversation_id (required).
set_aspect_ratioA
Set the aspect ratio for subsequent image generation and editing in this session. Must be called before generating/editing images if a specific ratio is desired.
Inputs: aspect_ratio (required), conversation_id.
set_modelA
Set the Gemini model for this session. 'flash' for faster generation (default), 'pro' for higher quality.
Inputs: model (required), conversation_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose with no overlap: conversation management (clear_conversation), chat (gemini_chat), image generation (gemini_generate_image), image editing (gemini_edit_image), history retrieval (get_image_history), aspect ratio configuration (set_aspect_ratio), and model selection (set_model). The boundaries between tools are well-defined and unambiguous.
The naming follows a mostly consistent pattern with six tools using snake_case and clear action-object naming (clear_conversation, get_image_history, set_aspect_ratio, set_model). The three gemini_* tools deviate slightly by prefixing with 'gemini_' but maintain internal consistency. The main inconsistency is that gemini_chat doesn't follow the verb_noun pattern as strictly as others.
Seven tools is an ideal number for this Gemini interaction server, covering core functionality without bloat. Each tool serves a distinct purpose in the workflow: conversation management, chat interaction, image generation/editing, history access, and session configuration. No tool feels redundant or unnecessary for the server's scope.
The tool surface provides excellent coverage for Gemini-based chat and image workflows, including conversation management, multi-modal chat, image generation/editing, and session configuration. The only minor gap is the lack of a tool to manage multiple conversations or sessions beyond the current one, but agents can work effectively with the provided tools for most use cases.
Maintenance
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
Hosted MCP server for AI photo editing: nothing to install, no desktop photo editor needed.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
MCP server for Google Veo AI video generation
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides AI image generation and editing capabilities using Google's Gemini 2.5 Flash Image API. It allows users to create new images from text, modify existing files, and perform iterative edits through natural language prompts.61,740 npmMIT
- AlicenseAqualityDmaintenanceMCP server that brings Gemini's image generation and editing capabilities to Claude Desktop, Claude Code, and Cursor. Supports Nano Banana 2 (Flash) and Nano Banana Pro models.7704 npm32MIT
- AlicenseAqualityCmaintenanceMCP server for Google Gemini image generation with configurable model support, enabling text-to-image generation, image editing, and iterative refinement.640MIT
- AlicenseAqualityDmaintenanceMCP server for generating and editing images using Google Gemini API, with support for multi-turn iterative refinement.3135 npmMIT