NanoBanana MCP Server
Enables image generation and editing via the Google Gemini API, supporting text-to-image, multi-image input, batch processing at reduced cost, and aspect ratio control.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NanoBanana MCP Server generate a photo of a cat wearing a hat, aspect ratio 1:1"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
NanoBanana MCP Server
An MCP (Model Context Protocol) server that connects to the Google Gemini API to generate and edit images using the Nano Banana Pro image generation model.
Features
Text-to-Image Generation — Describe an image and get it generated via the Gemini API.
Image Editing — Provide one or more existing images and a text instruction to edit or transform them.
Multi-Image Input — Send multiple images for blending, style transfer, collages, and more.
Batch Mode — Submit many prompts at once at 50% reduced cost. Jobs run async and results are polled/downloaded automatically.
Aspect Ratio Control — Force output to a specific aspect ratio (1:1, 16:9, 9:16, etc.).
File Output — Save generated images directly to disk with key-based filenames.
Job Tracking — Batch jobs are persisted to
data/batch_jobs.jsonwith full state, input JSONL, and output references.
Related MCP server: Gemini Flash Image MCP Server
Prerequisites
Node.js >= 18
A Google Gemini API key — get one at Google AI Studio
Installation
git clone https://github.com/slackermafia/NanoBanana-MCP-Server.git
cd NanoBanana-MCP-Server
npm installConfiguration
Set your Gemini API key as an environment variable:
export GEMINI_API_KEY="your-api-key-here"Claude Desktop / Cowork
Add this to your MCP server configuration:
{
"mcpServers": {
"nanobanana": {
"command": "node",
"args": ["/absolute/path/to/NanoBanana-MCP-Server/src/index.js"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}Tools
gemini_generate_image
Generate an image from a text prompt (synchronous, single image).
Parameter | Type | Required | Description |
| string | Yes | Detailed description of the image to create |
| string | No | Output aspect ratio (e.g. |
| string | No | Gemini model ID (default: |
| string | No | File path to save the generated image |
gemini_edit_image
Edit one or more images using a text instruction (synchronous).
Parameter | Type | Required | Description |
| string | Yes | Text instruction describing the edit |
| string | No* | Comma-separated list of file paths to input images |
| string | No* | JSON array of |
| string | No | Output aspect ratio |
| string | No | Gemini model ID |
| string | No | File path to save the edited image |
* You must provide at least one image via image_paths or image_base64_list.
gemini_batch_submit
Submit a batch of image generation requests at 50% reduced cost. Jobs run asynchronously (typically completes within 24 hours).
Parameter | Type | Required | Description |
| string | Yes | JSON array of request objects (see below) |
| string | Yes | Directory where completed images will be saved |
| string | No | Gemini model ID |
| string | No | Human-readable name for the batch job |
Each request object in the requests array:
{
"key": "pink-flamingo",
"prompt": "A neon pink flamingo sign on a dark wall",
"aspect_ratio": "1:1",
"image_paths": "/optional/reference/image.jpg"
}The key is used as the output filename — so "pink-flamingo" produces pink-flamingo.jpg. This is how you match input prompts to output images.
A JSONL input file is saved to data/ for debugging, and the job ID is tracked in data/batch_jobs.json.
gemini_batch_status
Check the status of pending batch jobs.
Parameter | Type | Required | Description |
| string | No | Specific batch ID (e.g. |
Returns the current state of each job: JOB_STATE_PENDING, JOB_STATE_RUNNING, JOB_STATE_SUCCEEDED, JOB_STATE_FAILED, or JOB_STATE_CANCELLED.
gemini_batch_results
Download and save images from completed batch jobs.
Parameter | Type | Required | Description |
| string | No | Specific batch ID. Omit to process all completed jobs. |
| string | No | Override the output directory from submission time. |
Downloads the output JSONL from Gemini, decodes each image, and saves it using the key as the filename. Also saves the raw output JSONL to data/ for debugging.
Batch Workflow
1. Submit batch → gemini_batch_submit (creates JSONL, uploads, starts job)
2. Wait → Job runs async on Google's side (up to 24h, usually faster)
3. Check status → gemini_batch_status (poll for completion)
4. Download results → gemini_batch_results (saves images to output_dir as {key}.jpg)A Cowork scheduled task (nanobanana-batch-poll) can be set up to automatically poll every hour and download results when jobs complete.
File Structure
NanoBanana-MCP-Server/
├── src/
│ ├── index.js # MCP server with all 5 tools
│ └── batch.js # Batch API helpers, JSONL builder, job tracking
├── data/
│ ├── batch_jobs.json # Tracked batch jobs (state, IDs, paths)
│ ├── batch_input_*.jsonl # Input JSONL files (for debugging)
│ └── batch_output_*.jsonl # Output JSONL files (for debugging)
├── package.json
└── README.mdSupported Aspect Ratios
1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
License
MIT
Available Tools
6 toolsgemini_batch_resultsBatch ResultsA
Download and save images from a completed batch job.
Checks the batch status, retrieves the output JSONL from Gemini, decodes each image, and saves them to the specified output directory using the key as the filename.
Args:
batch_name (string, required): The batch ID (e.g. "batches/abc123").
output_dir (string, required): Directory where images will be saved.
Returns:
List of saved image paths (key → file path) and any errors.
Inputs: batch_name (required), output_dir (required).
gemini_batch_statusBatch StatusARead-onlyIdempotent
Check the status of a batch image generation job.
Args:
batch_name (string, required): The batch ID to check (e.g. "batches/abc123").
Returns:
state: BATCH_STATE_PENDING, BATCH_STATE_RUNNING, BATCH_STATE_SUCCEEDED, BATCH_STATE_FAILED, etc.
output_file: The Gemini Files API reference for downloading results (when succeeded).
stats: Request count and success count.
Timing: create time, end time.
Inputs: batch_name (required).
gemini_batch_submitBatch SubmitA
Submit a batch of image generation requests to the Gemini API at 50% reduced cost.
Builds a JSONL file, uploads it to the Gemini Files API, and submits a batch job. The job processes asynchronously (usually completes within minutes). Returns the batch ID — the caller is responsible for tracking it (e.g. in Supabase).
Args:
requests (string, required): JSON array of request objects. Each object must have:
key (string): Unique identifier for this request (used as output filename)
prompt (string): The image generation prompt
aspect_ratio (string, optional): Aspect ratio for this image
image_paths (string, optional): Comma-separated input image paths for editing (slow — base64 encodes each) Example: [{"key":"sunset-cat","prompt":"A cat watching a sunset","aspect_ratio":"16:9"}]
file_uris (string, optional): Comma-separated Gemini Files API URIs of pre-uploaded reference images (e.g. "files/abc123,files/def456"). These are shared across ALL requests in the batch. Use gemini_upload_image first to get URIs. Much faster than image_paths for large batches.
model (string, optional): Gemini model ID. Defaults to "gemini-3.1-flash-image-preview".
image_size (string, optional): Output image resolution. Values: "1K" (1024px), "2K" (2048px), "4K" (4096px). Defaults to "2K".
display_name (string, optional): Human-readable name for the batch job.
Returns:
The batch name/ID, request count, and model used.
Inputs: requests (required), model, file_uris, image_size, +1 more.
gemini_edit_imageEdit ImageA
Edit or transform one or more images using a text instruction, powered by the Google Gemini Nano Banana image model.
Supports single or multiple input images. Provide file paths and/or base64-encoded image data along with a text instruction.
Args:
prompt (string, required): A text instruction describing the edit (e.g. "Remove the background", "Combine these two images").
image_paths (string, optional): Comma-separated list of file paths to input images on disk. Example: "/path/to/img1.png,/path/to/img2.jpg"
image_base64_list (string, optional): JSON array of objects with "data" and "mimeType" fields for base64-encoded images. Example: [{"data":"base64...","mimeType":"image/png"}]
aspect_ratio (string, optional): Aspect ratio for the output image. Supported: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
model (string, optional): Gemini model ID. Defaults to "gemini-3.1-flash-image-preview".
output_path (string, optional): File path to save the edited image.
Returns:
The edited image as an embedded image block (and optionally saved to disk).
Any text the model returns alongside the image.
Examples:
prompt: "Change the car color to red" with one image
prompt: "Combine these two photos into a collage" with two images
prompt: "Apply the style of the first image to the second image" with two images
Inputs: prompt (required), model, image_size, image_paths, +3 more.
gemini_generate_imageGenerate ImageB
Generate an image from a text prompt using the Google Gemini Nano Banana image generation model.
Args:
prompt (string, required): A detailed description of the image to generate.
aspect_ratio (string, optional): Aspect ratio for the output image. Supported: 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
model (string, optional): Gemini model ID to use. Defaults to "gemini-3.1-flash-image-preview".
output_path (string, optional): File path to save the generated image.
Returns:
The generated image as an embedded image block (and optionally saved to disk).
Any text the model returns alongside the image.
Examples:
"A photorealistic golden retriever surfing a wave at sunset"
"An isometric pixel-art castle on a floating island"
Inputs: prompt (required), model, image_size, output_path, +1 more.
gemini_upload_imageUpload ImageA
Upload one or more images to the Gemini Files API and return their file URIs.
Use this to pre-upload reference images before calling gemini_batch_submit. Uploaded files persist for 48 hours on Google's servers. Pass the returned URIs to batch_submit via the file_uris field to avoid slow base64 encoding.
Args:
image_paths (string, required): Comma-separated list of local file paths to upload. Example: "/path/to/ref1.jpg,/path/to/ref2.png"
Returns:
A list of file URIs (e.g. "files/abc123") mapped to each input path.
Inputs: image_paths (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: batch submission, status checking, result downloading, single image generation, single image editing, and image upload. No overlap or confusion possible.
All tools use the consistent pattern 'gemini_<verb>_<noun>' with snake_case (e.g., gemini_batch_submit, gemini_edit_image). No deviations or mixed conventions.
6 tools cover both single and batch image operations plus upload and editing, which is well-scoped for the server's purpose. Not too few or too many.
Core workflows (generate, edit, batch submit/status/results, upload) are covered. Minor gaps like deleting batches or listing all batches are missing but not critical for typical usage.
Maintenance
Related MCP Connectors
Image generation, image editing and text/image-to-video with credit quotes and connection budgets.
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Generate, edit and upscale images with references, batch jobs, cost previews and original downloads.
Generate and edit images: article covers, pet portraits, product shots. Each call spends credits.
Related MCP Servers
- AlicenseAqualityFmaintenanceEnables image generation and editing using Google Gemini AI with support for multiple aspect ratios, context images, custom styles, and watermark overlays. Optimized for creating social media content with automatic file saving and flexible output configuration.24MIT
- AlicenseAqualityDmaintenanceEnables text-to-image generation, image editing, and multi-image composition using Google's Gemini 2.5 Flash Image API. Supports flexible aspect ratios and character consistency across generations.1MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables image generation using Google's Gemini 2 API with customizable parameters like aspect ratio, number of samples, and person generation settings.509 npm-
- AlicenseNot gradedqualityDmaintenanceEnables generating, editing, and manipulating images using Google Gemini Flash 2.5 through natural language prompts. Supports text-to-image generation, image editing, multi-image composition, and batch processing with direct file management.4MIT