Skip to main content
Glama

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.json with full state, input JSONL, and output references.

Related MCP server: Gemini Flash Image MCP Server

Prerequisites

Installation

git clone https://github.com/slackermafia/NanoBanana-MCP-Server.git
cd NanoBanana-MCP-Server
npm install

Configuration

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

prompt

string

Yes

Detailed description of the image to create

aspect_ratio

string

No

Output aspect ratio (e.g. 16:9, 1:1, 9:16)

model

string

No

Gemini model ID (default: gemini-3-pro-image-preview)

output_path

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

prompt

string

Yes

Text instruction describing the edit

image_paths

string

No*

Comma-separated list of file paths to input images

image_base64_list

string

No*

JSON array of {"data","mimeType"} objects

aspect_ratio

string

No

Output aspect ratio

model

string

No

Gemini model ID

output_path

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

requests

string

Yes

JSON array of request objects (see below)

output_dir

string

Yes

Directory where completed images will be saved

model

string

No

Gemini model ID

display_name

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

batch_name

string

No

Specific batch ID (e.g. batches/abc123). Omit to check all.

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

batch_name

string

No

Specific batch ID. Omit to process all completed jobs.

output_dir

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.md

Supported 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 tools
gemini_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 StatusA
Read-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

    A4.1/5.0

    Scored across 6 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers