ClaudeCodeMod

All shelves / MCP servers

Nanobanana Mcp Server

zhongweili/nanobanana-mcp-server · 362 stars · Python · MIT

MCP server AI image generation MCP server powered by Google Gemini, with smart model selection and 4K output

Install

In your shell
uvx nanobanana-mcp-server@latest

These repos do not share one command. When an entry shows a command, it was copied as published. Check the repo's README before you run it.

Open the repo

Files

README.md

Nano Banana MCP Server 🍌

A production-ready Model Context Protocol (MCP) server that provides AI-powered image generation capabilities through Google's Gemini models with intelligent model selection.

⭐ NEW: Nano Banana 2 — Gemini 3.1 Flash Image! 🍌🚀

Nano Banana 2 (gemini-3.1-flash-image-preview) is now the default model — delivering Pro-level quality at Flash speed:

  • 🍌 Flash Speed + 4K Quality: Up to 3840px at Gemini 2.5 Flash latency
  • 🌐 Google Search Grounding: Real-world knowledge for factually accurate images
  • 🎯 Subject Consistency: Up to 5 characters and 14 objects per scene
  • ✍️ Precision Text Rendering: Crystal-clear text placement in images
  • 🏆 Gemini 3 Pro Image still available for maximum reasoning depth

✨ Features

  • 🎨 Multi-Model AI Image Generation: Three Gemini models with intelligent automatic selection
  • 🍌 Gemini 3.1 Flash Image (NB2): Default model — 4K resolution at Flash speed with grounding
  • 🏆 Gemini 3 Pro Image: Maximum reasoning depth for the most complex compositions
  • ⚡ Gemini 2.5 Flash Image: Legacy Flash model for high-volume rapid prototyping
  • 🤖 Smart Model Selection: Automatically routes to NB2 or Pro based on your prompt
  • 📐 Aspect Ratio Control ⭐ NEW: Specify output dimensions (1:1, 16:9, 9:16, 21:9, and more)
  • 📋 Smart Templates: Pre-built prompt templates for photography, design, and editing
  • 📁 File Management: Upload and manage files via Gemini Files API
  • 🔍 Resource Discovery: Browse templates and file metadata through MCP resources
  • 🛡️ Production Ready: Comprehensive error handling, logging, and validation
  • ⚡ High Performance: Optimized architecture with intelligent caching

🚀 Quick Start

Prerequisites

  1. Google Gemini API Key - Get one free here
  2. Python 3.11+ (for development only)

Installation

Option 1: From MCP Registry (Recommended) This server is available in the Model Context Protocol Registry. Search for "nanobanana" or use the MCP name below with your MCP client.

mcp-name: io.github.zhongweili/nanobanana-mcp-server

Option 2: Using uvx

uvx nanobanana-mcp-server@latest

Option 3: Using pip

pip install nanobanana-mcp-server

🔧 Configuration

Authentication Methods

Nano Banana supports two authentication methods via NANOBANANA_AUTH_METHOD:

  1. API Key (api_key): Uses GEMINI_API_KEY. Best for local development and simple deployments.
  2. Vertex AI ADC (vertex_ai): Uses Google Cloud Application Default Credentials. Best for production on Google Cloud (Cloud Run, GKE, GCE).
  3. Automatic (auto): Defaults to API Key if present, otherwise tries Vertex AI.

#### 1. API Key Authentication (Default)

Set GEMINI_API_KEY environment variable.

#### 2. Vertex AI Authentication (Google Cloud)

Required environment variables:

  • NANOBANANA_AUTH_METHOD=vertex_ai (or auto)
  • GCP_PROJECT_ID=your-project-id
  • GCP_REGION=global (default; required for Gemini 3 Pro Image and NB2. Use us-central1 only for the legacy 2.5 Flash Image model.)

Prerequisites:

  • Enable Vertex AI API: gcloud services enable aiplatform.googleapis.com
  • Grant IAM Role: roles/aiplatform.user to the service account.

Claude Desktop

#### Option 1: Using Published Server (Recommended)

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  }
}

#### Option 2: Using Local Source (Development)

If you are running from source code, point to your local installation:

{
  "mcpServers": {
    "nanobanana-local": {
      "command": "uv",
      "args": ["run", "python", "-m", "nanobanana_mcp_server.server"],
      "cwd": "/absolute/path/to/nanobanana-mcp-server",
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  }
}

#### Option 3: Using Vertex AI (ADC)

To authenticate with Google Cloud Application Default Credentials (instead of an API Key):

{
  "mcpServers": {
    "nanobanana-adc": {
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "NANOBANANA_AUTH_METHOD": "vertex_ai",
        "GCP_PROJECT_ID": "your-project-id",
        "GCP_REGION": "global"
      }
    }
  }
}

Configuration file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Claude Code (VS Code Extension)

Install and configure in VS Code:

  1. Install the Claude Code extension
  2. Open Command Palette (Cmd/Ctrl + Shift + P)
  3. Run "Claude Code: Add MCP Server"
  4. Configure:
   {
     "name": "nanobanana",
     "command": "uvx",
     "args": ["nanobanana-mcp-server@latest"],
     "env": {
       "GEMINI_API_KEY": "your-gemini-api-key-here"
     }
   }

Cursor

Add to Cursor's MCP configuration:

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  }
}

OpenAI Codex

Add to ~/.codex/config.toml (global) or .codex/config.toml (project-scoped):

[mcp_servers.nanobanana]
command = "uvx"
args = ["nanobanana-mcp-server@latest"]

[mcp_servers.nanobanana.env]
GEMINI_API_KEY = "your-gemini-api-key-here"

Or add via the CLI:

codex mcp add

Codex supports both the CLI and VSCode extension using the same config.toml. Once added, Codex can call generate_image, edit_image, and upload_file tools directly in your coding sessions.

Note: The Codex config file is shared by the CLI and the IDE extension. A TOML syntax error will break both simultaneously, so validate your edits carefully.

Continue.dev (VS Code/JetBrains)

Add to your config.json:

{
  "mcpServers": [
    {
      "name": "nanobanana",
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  ]
}

Open WebUI

Configure in Open WebUI settings:

{
  "mcp_servers": {
    "nanobanana": {
      "command": ["uvx", "nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  }
}

Gemini CLI / Generic MCP Client

# Set environment variable
export GEMINI_API_KEY="your-gemini-api-key-here"

# Run server in stdio mode
uvx nanobanana-mcp-server@latest

# Or with pip installation
python -m nanobanana_mcp_server.server

🤖 Model Selection

Nano Banana supports three Gemini models with intelligent automatic selection:

🍌 NB2 — Nano Banana 2 (Gemini 3.1 Flash Image) ⭐ DEFAULT

Flash speed with Pro-level quality — the best of both worlds

  • Quality: Production-ready 4K output
  • Resolution: Up to 4K (3840px)
  • Speed: ~2-4 seconds per image (Flash-class latency)
  • Special Features:
  • 🌐 Google Search Grounding: Real-world knowledge for factually accurate images
  • 🎯 Subject Consistency: Up to 5 characters and 14 objects per scene
  • ✍️ Precision Text Rendering: Clear, well-placed text in images
  • Best for: Almost everything — production assets, marketing, photography, text overlays
  • model_tier: "nb2" (or "auto" — NB2 is the auto default)

🏆 Pro Model — Nano Banana Pro (Gemini 3 Pro Image)

Maximum reasoning depth for the most demanding compositions

  • Quality: Highest available
  • Resolution: Up to 4K (3840px)
  • Speed: ~5-8 seconds per image
  • Special Features:
  • 🧠 Advanced Reasoning: Configurable thinking levels (LOW/HIGH)
  • 🌐 Google Search Grounding: Real-world knowledge integration
  • 📐 Media Resolution Control: Fine-tune vision processing detail
  • Best for: Complex narrative scenes, intricate compositions, maximum reasoning required
  • model_tier: "pro"

⚡ Flash Model (Gemini 2.5 Flash Image)

Legacy model for high-volume rapid iteration

  • Speed: Very fast (2-3 seconds)
  • Resolution: Up to 1024px
  • Best for: High-volume generation, quick drafts where 4K is not needed
  • model_tier: "flash"

🤖 Automatic Selection (Recommended)

By default, the server uses AUTO mode which routes to NB2 unless Pro's deeper reasoning is clearly needed:

Pro Model Selected When:

  • Strong quality keywords: "4K", "professional", "production", "high-res", "HD"
  • High thinking level requested: thinking_level="HIGH"
  • Multi-image conditioning with multiple input images

Facts

Kind
MCP server
Repo
zhongweili/nanobanana-mcp-server
Group
Uncategorized
Stars
362
License
MIT
Language
Python
Last push
2026-10-07
Forks
116

More on this shelf

  1. 1Everythingmodelcontextprotocol/serversThis MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.85.8k
  2. 2Fetchmodelcontextprotocol/serversA Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.85.8k
  3. 3Gitmodelcontextprotocol/serversA Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.85.8k
  4. 4Memorymodelcontextprotocol/serversA basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across chats.85.8k
  5. 5Sequential Thinkingmodelcontextprotocol/serversAn MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.85.8k
  6. 6Timemodelcontextprotocol/serversA 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.85.8k