Supercharge Claude Desktop and Claude Code with Google's Gemini multimodal capabilities! Generate stunning images with session-based consistency, edit existing ones, and leverage advanced vision AI - all within your Claude environment.
- π¨ Image Generation - Create 2K images from text prompts using Gemini 3 Pro
- π Image Consistency - Maintain character/style consistency across multiple generations within a session
- πΌοΈ Image Editing - Transform existing images with natural language instructions
- π Google Search Integration - Ground image generation with real-world references
- π¬ Multi-turn Chat - Maintain conversational context across interactions
- π Session History - Reference previous images using
lastorhistory:N
# Generate an image
"Create a serene Korean beach scene with traditional architecture"
# Edit an existing image
"Add a dramatic T-Rex appearing on the beach, people reacting with surprise"- Node.js 18+
- One of: Claude Desktop, Claude Code, VSCode, Cursor, or Windsurf
- Google AI API Key (Get it here)
First, clone and build the project:
git clone https://github.com/YCSE/nanobanana-mcp.git
cd nanobanana-mcp
npm install
npm run build
# Configure API Key
cp .env.example .env
# Edit .env and add your GOOGLE_AI_API_KEYThen choose your platform:
Edit your Claude Desktop config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"nanobanana-mcp": {
"command": "node",
"args": ["/absolute/path/to/nanobanana-mcp/dist/index.js"],
"env": {
"GOOGLE_AI_API_KEY": "your_api_key_here"
}
}
}
}Restart Claude Desktop after adding the configuration.
# After building, install to Claude Code
source .env && claude mcp add nanobanana-mcp "node" "dist/index.js" \
-e "GOOGLE_AI_API_KEY=$GOOGLE_AI_API_KEY"Install the Continue extension and add to ~/.continue/config.json:
{
"models": [
// Your existing models
],
"mcpServers": {
"nanobanana-mcp": {
"command": "node",
"args": ["/absolute/path/to/nanobanana-mcp/dist/index.js"],
"env": {
"GOOGLE_AI_API_KEY": "your_api_key_here"
}
}
}
}Add to your Cursor settings file ~/.cursor/config.json:
{
"mcpServers": {
"nanobanana-mcp": {
"command": "node",
"args": ["/absolute/path/to/nanobanana-mcp/dist/index.js"],
"env": {
"GOOGLE_AI_API_KEY": "your_api_key_here"
}
}
}
}Add to your Windsurf configuration file ~/.windsurf/config.json:
{
"mcpServers": {
"nanobanana-mcp": {
"command": "node",
"args": ["/absolute/path/to/nanobanana-mcp/dist/index.js"],
"env": {
"GOOGLE_AI_API_KEY": "your_api_key_here"
}
}
}
}Generate 2K images from text descriptions with session-based consistency.
{
prompt: string; // Image description
output_path?: string; // Optional save path (default: ~/Documents/nanobanana_generated/)
conversation_id?: string; // Session ID for image history
use_image_history?: boolean; // Use previous images for style/character consistency
reference_images?: string[]; // Manual reference images for consistency
enable_google_search?: boolean; // Enable Google Search for real-world grounding
}Example - Basic:
"Generate a cyberpunk cityscape at sunset with flying cars"
Example - With Consistency:
// First image
{ prompt: "A cute red-hat cat", conversation_id: "cat-session" }
// Second image - maintains same character
{ prompt: "The same cat taking a nap", conversation_id: "cat-session", use_image_history: true }Edit existing images using natural language. Supports session history references.
{
image_path: string; // Path, or "last", or "history:N"
edit_prompt: string; // Edit instructions
output_path?: string; // Optional save path
conversation_id?: string; // Session ID for accessing history
reference_images?: string[]; // Additional style references
enable_google_search?: boolean; // Enable Google Search
}Example - File Path:
"Remove the background and make it transparent"
Example - History Reference:
// Edit the most recent image in the session
{ image_path: "last", edit_prompt: "Change hat color to blue", conversation_id: "cat-session" }
// Edit a specific image from history
{ image_path: "history:0", edit_prompt: "Add sunglasses", conversation_id: "cat-session" }Chat with Gemini for general queries.
{
message: string; // Your message
conversation_id?: string; // Optional conversation ID
system_prompt?: string; // Optional system instructions
}View generated/edited images in a session.
{
conversation_id: string; // Session to view
}Response includes:
- Image index and reference (
history:0,history:1, etc.) - File paths
- Original prompts
- Timestamps
Reset conversation history.
{
conversation_id: string; // Conversation to clear
}NanoBanana MCP uses different Gemini models optimized for each task:
| Tool | Model | Purpose |
|---|---|---|
gemini_generate_image |
gemini-3-pro-image-preview |
High-quality 2K image generation |
gemini_edit_image |
gemini-3-pro-image-preview |
Image editing with consistency |
gemini_chat |
gemini-2.5-flash-image-preview |
Multi-turn conversation |
To switch between model variants (e.g., nanobanana vs nanobanana-pro), edit the model constants in src/index.ts:
// For image generation (line ~428)
const model = 'gemini-3-pro-image-preview'; // Pro version (current)
// const model = 'gemini-2.5-flash-image-preview'; // Flash version (faster, lower quality)
// For image editing (line ~659)
const model = 'gemini-3-pro-image-preview'; // Pro version (current)
// const model = 'gemini-2.5-flash-image-preview'; // Flash versionAfter editing, rebuild the project:
npm run buildModel Comparison:
| Aspect | Flash (2.5) | Pro (3.0) |
|---|---|---|
| Speed | Faster | Slower |
| Quality | Good | Higher |
| Resolution | 1K | 2K |
| Consistency | Basic | Better |
| Cost | Lower | Higher |
- Generate placeholder images for web development
- Create app icons and assets
- Analyze UI/UX screenshots
- Generate test data images
- Edit images with text commands
- Generate blog illustrations
- Create social media visuals
- Batch process image modifications
- Rapid prototyping with generated visuals
- Style transfer and variations
- Color scheme analysis
- Accessibility checking
Images are automatically saved to:
- Generated images:
~/Documents/nanobanana_generated/generated_[timestamp].png - Edited images:
~/Documents/nanobanana_generated/[original_name]_edited_[timestamp].png
All images are saved in PNG format for maximum quality.
# Run in development mode with hot reload
npm run dev
# Build for production
npm run build
# Type checking
npm run typechecknanobanana-mcp/
βββ src/
β βββ index.ts # MCP server implementation
βββ dist/ # Compiled JavaScript
βββ .env # API configuration
βββ claude-mcp # CLI management tool
βββ package.json
- API keys are stored locally in
.env - Never commit
.envto version control - All image operations happen locally
- No data is stored on external servers
# Check installation
./claude-mcp status
# Rebuild if needed
npm run build- Verify API key is valid
- Check API quota at Google AI Studio
- Ensure output directory has write permissions
- Restart Claude Desktop/Code
- Check config file syntax
- Verify absolute paths in configuration
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
MIT License - see LICENSE file for details.
If you find this project useful, please consider giving it a star βοΈ
- Anthropic for Claude and MCP
- Google for Gemini API
- Model Context Protocol community
- π Report Issues
- π¬ Discussions
- π Documentation
Made with β€οΈ for the Claude community