
Nanobanana Mcp Server
io.github.zhongweili由 GitHub 帳號 zhongweili 發布v1.0.0更新於 Oct 24, 2026
An MCP server that provides image generation and editing capabilities
概覽
本機 MCP 伺服器,讓助理用 Google Gemini 影像模型生成與編輯圖片,並存到本機磁碟。
- 可以做什麼
- 依文字提示生成圖片,可自動或指定模型、解析度、長寬比與搜尋依據
- 編輯既有圖片,並支援以多張輸入圖片作為條件
- 透過 Gemini Files API 上傳與管理檔案
- 以 MCP 資源瀏覽提示詞範本與檔案中繼資料
- 將結果存到指定檔案路徑、目錄或預設輸出資料夾
- 適用情境
- 適合在對話中讓助理直接產出或修改圖片,例如行銷素材、產品照、社群尺寸與草稿,不必離開聊天用戶端。
- 執行需求
- 以 Python 套件在本機執行(uvx 或 pip)。需要 GEMINI_API_KEY 中的 Google Gemini API 金鑰,或改用 Vertex AI 應用程式預設憑證並設定 NANOBANANA_AUTH_METHOD、GCP_PROJECT_ID 與 GCP_REGION。可選 IMAGE_OUTPUT_DIR 指定預設儲存資料夾;需要連線至 Google API 的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Nanobanana Mcp Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
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
- Google Gemini API Key - Get one free here
- 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
Option 3: Using pip
🔧 Configuration
Authentication Methods
Nano Banana supports two authentication methods via NANOBANANA_AUTH_METHOD:
- API Key (
api_key): UsesGEMINI_API_KEY. Best for local development and simple deployments. - Vertex AI ADC (
vertex_ai): Uses Google Cloud Application Default Credentials. Best for production on Google Cloud (Cloud Run, GKE, GCE). - 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(orauto)GCP_PROJECT_ID=your-project-idGCP_REGION=global(default; required for Gemini 3 Pro Image and NB2. Useus-central1only for the legacy 2.5 Flash Image model.)
Prerequisites:
- Enable Vertex AI API:
gcloud services enable aiplatform.googleapis.com - Grant IAM Role:
roles/aiplatform.userto the service account.
Claude Desktop
Option 1: Using Published Server (Recommended)
Add to your claude_desktop_config.json:
Option 2: Using Local Source (Development)
If you are running from source code, point to your local installation:
Option 3: Using Vertex AI (ADC)
To authenticate with Google Cloud Application Default Credentials (instead of an API Key):
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:
- Install the Claude Code extension
- Open Command Palette (
Cmd/Ctrl + Shift + P) - Run "Claude Code: Add MCP Server"
- Configure:
Cursor
Add to Cursor's MCP configuration:
OpenAI Codex
Add to ~/.codex/config.toml (global) or .codex/config.toml (project-scoped):
Or add via the CLI:
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:
Open WebUI
Configure in Open WebUI settings:
Gemini CLI / Generic MCP Client
🤖 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
NB2 Model Selected When (default):
- Standard requests, everyday image generation
- Speed keywords: "quick", "draft", "sketch", "rapid"
- High-volume batch generation (
n > 2)
Usage Examples
📐 Aspect Ratio Control
Control the output image dimensions with the aspect_ratio parameter:
Supported Aspect Ratios:
1:1- Square (Instagram, profile pictures)4:3- Classic photo format3:4- Portrait orientation16:9- Widescreen (YouTube thumbnails, presentations)9:16- Mobile portrait (phone wallpapers, stories)21:9- Ultra-wide cinematic2:3,3:2,4:5,5:4- Various photo formats
Note: Aspect ratio works with both Flash and Pro models. For best results with specific aspect ratios at high resolution, use the Pro model with resolution="4k".
📁 Output Path Control ⭐ NEW!
Control where generated images are saved with the output_path parameter:
Three modes of operation:
- Specific file path - Save to an exact file location:
- Directory path - Use auto-generated filename in a specific directory:
- Default location - Uses IMAGE_OUTPUT_DIR or ~/nanobanana-images:
Multiple images (n > 1): When generating multiple images with a file path, images are automatically numbered:
- First image:
/path/to/image.png - Second image:
/path/to/image_2.png - Third image:
/path/to/image_3.png
Precedence Rules:
output_pathparameter (if provided) - highest priorityIMAGE_OUTPUT_DIRenvironment variable~/nanobanana-images(default fallback)
IMAGE_OUTPUT_DIR is used only when output_path is omitted. A relative output_path such as images/sunset.png is resolved from the server process working directory, not from IMAGE_OUTPUT_DIR. ~/... expands to the home directory. A trailing slash selects directory mode even when that directory does not exist yet (outputs/), and the server creates it and generates the filename.
⚙️ Environment Variables
Configuration options:
🐛 Troubleshooting
Common Issues
"GEMINI_API_KEY not set"
- Add your API key to the MCP server configuration in your client
- Get a free API key at Google AI Studio
"Server failed to start"
- Ensure you're using the latest version:
uvx nanobanana-mcp-server@latest - Check that your client supports MCP (Claude Desktop 0.10.0+)
"Permission denied" errors
- The server creates images in
~/nanobanana-imagesby default - Ensure write permissions to your home directory
Development Setup
For local development:
📄 License
MIT License - see LICENSE for details.
🆘 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
來源:README.md,提交 369a30f
工具
0版本歷史
1- v1.0.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分