Sponsored by Deepsite.site

Gemini Nanobanana Mcp

Created By
Junhan22 months ago
Generate images from text with Claude! Simply type "Draw a cute cat" and get instant AI-generated images.
Content

🎨 Gemini Nanobanana MCP

npm version License: MIT TypeScript Node.js

Generate images from text with Claude! Simply type "Draw a cute cat" and get instant AI-generated images.

A beginner-friendly Model Context Protocol (MCP) server that brings Google's Gemini 2.5 Flash Image generation directly into your Claude conversations.

Quick Start - Just 3 Steps

1️⃣ Get Your API Key (1 minute)

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click "Create API key" → Copy the key

2️⃣ Install in Your Claude Client (2 minutes)

Claude Desktop (Windows)
  1. Open Notepad
  2. Copy this code and replace YOUR_API_KEY with your actual key:
{
  "mcpServers": {
    "gemini-nanobanana-mcp": {
      "command": "npx",
      "args": ["gemini-nanobanana-mcp@latest"],
      "env": {
        "GEMINI_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}
  1. Save as: %APPDATA%/Claude/claude_desktop_config.json
  2. Restart Claude Desktop
Claude Desktop (Mac)
  1. Open Terminal (search "Terminal" in Spotlight)
  2. Run this command (replace YOUR_API_KEY):
cat > ~/Library/Application\ Support/Claude/claude_desktop_config.json << 'EOF'
{
  "mcpServers": {
    "gemini-nanobanana-mcp": {
      "command": "npx",
      "args": ["gemini-nanobanana-mcp@latest"],
      "env": {
        "GEMINI_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}
EOF
  1. Restart Claude Desktop
Claude Code (Easiest!)

Just run this one command in your terminal (replace YOUR_API_KEY):

claude mcp add gemini-nanobanana-mcp -s user -e GEMINI_API_KEY="YOUR_API_KEY" -- npx -y gemini-nanobanana-mcp@latest
Cursor
  1. Go to Cursor SettingsMCPAdd new MCP Server
  2. Fill in:
    • Name: gemini-nanobanana-mcp
    • Command: npx
    • Args: gemini-nanobanana-mcp@latest
    • Environment Variables: GEMINI_API_KEY = YOUR_API_KEY
  3. Restart Cursor

3️⃣ Start Creating! (0 minutes)

Try these in Claude:

  • "Generate a cute puppy playing in a garden"
  • "Create a beautiful sunset over mountains"
  • "Draw a red sports car"
  • "Make an abstract colorful painting"

Your images automatically save to ~/Downloads/gemini-images/


See It In Action

Basic Usage

You: Generate a cozy coffee shop interior
Claude: [Generating image...]
Image generated and saved to: ~/Downloads/gemini-images/generate-2025-01-09-14-30-45.png
Size: 1.2MB | Format: PNG

Custom Save Location

You: Create a sunset landscape and save it as ./my-sunset.png
Claude: Image saved to: ./my-sunset.png

What You Can Do

Text-to-Image Generation

Create any image you can imagine from a text description.

Examples:

  • "A majestic dragon flying over a medieval castle"
  • "Modern minimalist living room with plants"
  • "Vintage bicycle on a cobblestone street"

Image Editing

Edit existing images with natural language instructions.

How to use:

  • Upload an image to Claude
  • Say: "Make this image black and white"
  • Or: "Add a sunset background to this photo"

Image Composition

Combine multiple images into one creative composition.

How to use:

  • Upload 2-10 images to Claude
  • Say: "Combine these images into a collage"
  • Or: "Blend these photos together artistically"

Style Transfer

Apply the artistic style of one image to another.

How to use:

  • Upload two images: a content image and a style reference
  • Say: "Apply the style of the second image to the first"

Configuration Options

Environment Variables
VariableDefaultDescription
GEMINI_API_KEYRequiredYour Google AI Studio API key
AUTO_SAVEtrueAutomatically save images when no path specified
DEFAULT_SAVE_DIR~/Downloads/gemini-imagesDefault directory for saved images
LOG_LEVELinfoLogging level (error, warn, info, debug)

Example with custom settings:

{
  "mcpServers": {
    "gemini-nanobanana-mcp": {
      "command": "npx",
      "args": ["gemini-nanobanana-mcp@latest"],
      "env": {
        "GEMINI_API_KEY": "your-api-key",
        "AUTO_SAVE": "true",
        "DEFAULT_SAVE_DIR": "~/Pictures/AI-Images",
        "LOG_LEVEL": "debug"
      }
    }
  }
}
Disable Auto-Save

To only save when you explicitly request it:

{
  "env": {
    "GEMINI_API_KEY": "your-api-key",
    "AUTO_SAVE": "false"
  }
}

Then images will only appear in the chat without saving to disk.


Instant Image Preview (Claude Code)

Want images to open automatically after generation? Set up Claude Code hooks for instant Quick Look previews!

One-Click Setup (Mac)

# Clone this repo and run the installer
git clone https://github.com/nanobanana/nanobanana-mcp.git
cd nanobanana-mcp
bash hooks/install.sh

What You Get

  • Instant Preview: Generated images open automatically in Quick Look
  • Zero Manual Work: No more finding and opening files
  • Smart Detection: Only triggers for nanobanana image tools
  • Press Space to Close: Standard Quick Look controls

Full setup guide: hooks/README.md


Troubleshooting

❌ "GEMINI_API_KEY not set" error

Solution:

  1. Double-check you replaced YOUR_API_KEY with your actual API key
  2. Make sure there are no extra spaces around the key
  3. Restart your Claude client completely
  4. Verify your API key works at Google AI Studio
"No such file or directory" error

Solution:

  1. Install Node.js from nodejs.org (choose LTS version)
  2. Restart your terminal/Claude client
  3. Try the installation again
Images not generating

Checklist:

  • API key correctly set?
  • Internet connection working?
  • Restart Claude after configuration?
  • Try a simple prompt: "Generate a blue circle"
Images not saving automatically

Solution: Check your configuration has AUTO_SAVE: "true" (default behavior). If you want to disable auto-save, set it to "false".

Hook setup not working

Common fixes:

  1. Make sure you're using Claude Code (not Claude Desktop)
  2. Run the installer from the nanobanana-mcp directory
  3. Restart Claude Code after installation
  4. Check hooks/README.md for detailed troubleshooting

Tips for Better Images

Prompt Writing Tips

  • Be specific: "A golden retriever puppy" vs "A dog"
  • Include style: "in watercolor style", "photorealistic", "cartoon style"
  • Add details: "with blue eyes", "in a sunny garden", "wearing a red collar"
  • Set the mood: "cozy", "dramatic", "peaceful", "energetic"

Technical Details

  • Supported formats: PNG, JPEG, WebP, GIF
  • Default output: PNG format
  • Image size: Optimized for quality and reasonable file size
  • Rate limits: Managed automatically with retry logic

🚀 Advanced Features

🔗 HTTP Mode (for integrations)

Run as an HTTP server instead of stdio:

MCP_TRANSPORT=http MCP_HTTP_PORT=8080 npx gemini-nanobanana-mcp@latest

Access at http://localhost:8080/mcp

📊 Debug Logging

Enable detailed logging:

{
  "env": {
    "GEMINI_API_KEY": "your-key",
    "LOG_LEVEL": "debug"
  }
}

💡 Need Help?


🤝 Contributing

Found a bug? Have a feature idea? Contributions are welcome!

  1. Fork the repository
  2. Create your feature branch
  3. Make your changes
  4. Submit a pull request

📄 License

MIT License - feel free to use this in your own projects!


⭐ If this helped you, please star the repository on GitHub!

Built with ❤️ for the Claude community

Server Config

{
  "mcpServers": {
    "gemini-nanobanana-mcp": {
      "command": "npx",
      "args": [
        "gemini-nanobanana-mcp@latest"
      ],
      "env": {
        "GEMINI_API_KEY": "your-api-key",
        "AUTO_SAVE": "true",
        "DEFAULT_SAVE_DIR": "~/Pictures/AI-Images",
        "LOG_LEVEL": "debug"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Amap Maps高德地图官方 MCP Server
WindsurfThe new purpose-built IDE to harness magic
Serper MCP ServerA Serper MCP Server