$git clone https://github.com/zhongweili/nanobanana-mcp-serverA production-ready Model Context Protocol (MCP) server that provides AI-powered image generation capabilities through Google's Gemini models with intelligent model selection.
| 1 | # Nano Banana MCP Server 🍌 |
| 2 | |
| 3 | A production-ready **Model Context Protocol (MCP)** server that provides AI-powered image generation capabilities through Google's **Gemini** models with intelligent model selection. |
| 4 | |
| 5 | ## ⭐ NEW: Nano Banana 2 — Gemini 3.1 Flash Image! 🍌🚀 |
| 6 | |
| 7 | **Nano Banana 2** (`gemini-3.1-flash-image-preview`) is now the **default model** — delivering Pro-level quality at Flash speed: |
| 8 | |
| 9 | - 🍌 **Flash Speed + 4K Quality**: Up to 3840px at Gemini 2.5 Flash latency |
| 10 | - 🌐 **Google Search Grounding**: Real-world knowledge for factually accurate images |
| 11 | - 🎯 **Subject Consistency**: Up to 5 characters and 14 objects per scene |
| 12 | - ✍️ **Precision Text Rendering**: Crystal-clear text placement in images |
| 13 | - 🏆 **Gemini 3 Pro Image** still available for maximum reasoning depth |
| 14 | |
| 15 | <a href="https://glama.ai/mcp/servers/@zhongweili/nanobanana-mcp-server"> |
| 16 | <img width="380" height="200" src="https://glama.ai/mcp/servers/@zhongweili/nanobanana-mcp-server/badge" alt="nanobanana-mcp-server MCP server" /> |
| 17 | </a> |
| 18 | |
| 19 | ## ✨ Features |
| 20 | |
| 21 | - 🎨 **Multi-Model AI Image Generation**: Three Gemini models with intelligent automatic selection |
| 22 | - 🍌 **Gemini 3.1 Flash Image (NB2)**: Default model — 4K resolution at Flash speed with grounding |
| 23 | - 🏆 **Gemini 3 Pro Image**: Maximum reasoning depth for the most complex compositions |
| 24 | - ⚡ **Gemini 2.5 Flash Image**: Legacy Flash model for high-volume rapid prototyping |
| 25 | - 🤖 **Smart Model Selection**: Automatically routes to NB2 or Pro based on your prompt |
| 26 | - 📐 **Aspect Ratio Control** ⭐ NEW: Specify output dimensions (1:1, 16:9, 9:16, 21:9, and more) |
| 27 | - 📋 **Smart Templates**: Pre-built prompt templates for photography, design, and editing |
| 28 | - 📁 **File Management**: Upload and manage files via Gemini Files API |
| 29 | - 🔍 **Resource Discovery**: Browse templates and file metadata through MCP resources |
| 30 | - 🛡️ **Production Ready**: Comprehensive error handling, logging, and validation |
| 31 | - ⚡ **High Performance**: Optimized architecture with intelligent caching |
| 32 | |
| 33 | ## 🚀 Quick Start |
| 34 | |
| 35 | ### Prerequisites |
| 36 | |
| 37 | 1. **Google Gemini API Key** - [Get one free here](https://makersuite.google.com/app/apikey) |
| 38 | 2. **Python 3.11+** (for development only) |
| 39 | |
| 40 | ### Installation |
| 41 | |
| 42 | Option 1: From MCP Registry (Recommended) |
| 43 | This server is available in the [Model Context Protocol Registry](https://registry.modelcontextprotocol.io/?q=nanobanana). Search for "nanobanana" or use the MCP name below with your MCP client. |
| 44 | |
| 45 | mcp-name: io.github.zhongweili/nanobanana-mcp-server |
| 46 | |
| 47 | Option 2: Using `uvx` |
| 48 | |
| 49 | ```bash |
| 50 | uvx nanobanana-mcp-server@latest |
| 51 | ``` |
| 52 | |
| 53 | Option 3: Using `pip` |
| 54 | |
| 55 | ```bash |
| 56 | pip install nanobanana-mcp-server |
| 57 | ``` |
| 58 | |
| 59 | ## 🔧 Configuration |
| 60 | |
| 61 | ### Authentication Methods |
| 62 | |
| 63 | Nano Banana supports two authentication methods via `NANOBANANA_AUTH_METHOD`: |
| 64 | |
| 65 | 1. **API Key** (`api_key`): Uses `GEMINI_API_KEY`. Best for local development and simple deployments. |
| 66 | 2. **Vertex AI ADC** (`vertex_ai`): Uses Google Cloud Application Default Credentials. Best for production on Google Cloud (Cloud Run, GKE, GCE). |
| 67 | 3. **Automatic** (`auto`): Defaults to API Key if present, otherwise tries Vertex AI. |
| 68 | |
| 69 | #### 1. API Key Authentication (Default) |
| 70 | |
| 71 | Set `GEMINI_API_KEY` environment variable. |
| 72 | |
| 73 | #### 2. Vertex AI Authentication (Google Cloud) |
| 74 | |
| 75 | Required environment variables: |
| 76 | |
| 77 | - `NANOBANANA_AUTH_METHOD=vertex_ai` (or `auto`) |
| 78 | - `GCP_PROJECT_ID=your-project-id` |
| 79 | - `GCP_REGION=global` (default; required for Gemini 3 Pro Image and NB2. Use `us-central1` only for the legacy 2.5 Flash Image model.) |
| 80 | |
| 81 | **Prerequisites**: |
| 82 | |
| 83 | - Enable Vertex AI API: `gcloud services enable aiplatform.googleapis.com` |
| 84 | - Grant IAM Role: `roles/aiplatform.user` to the service account. |
| 85 | |
| 86 | ### Claude Desktop |
| 87 | |
| 88 | #### Option 1: Using Published Server (Recommended) |
| 89 | |
| 90 | Add to your `claude_desktop_config.json`: |
| 91 | |
| 92 | ```json |
| 93 | { |
| 94 | "mcpServers": { |
| 95 | "nanobanana": { |
| 96 | "command": "uvx", |
| 97 | "args": ["nanobanana-mcp-server@latest"], |
| 98 | "env": { |
| 99 | "GEMINI_API_KEY": "your-gemini-api-key-here" |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | ``` |
| 105 | |
| 106 | #### Option 2: Using Local Source (Development) |
| 107 | |
| 108 | I |