NA

Nanana MCP Server: Gemini Nano Text-to-Image & Image-to-Image

Generate stunning images on the Nanana MCP server using Google Gemini Nano for text-to-image and image-to-image editing.

Quick Install
npx -y @nanana-app/mcp-server-nano-banana

Overview

The Nanana MCP Server is a lightweight Model Context Protocol (MCP) adapter that exposes Google Gemini Nano for image generation and image editing workflows. It implements simple HTTP endpoints compatible with MCP-style clients so you can use Gemini Nano for text-to-image (T2I) and image-to-image (I2I) tasks inside developer tools, bots, or hobby projects.

This server acts as a small bridge between your application and Gemini Nano: it accepts normalized MCP-style requests (prompt, seed, size, strength, etc.), forwards them to the configured provider, and returns a compact JSON response (base64 images, metadata). It is useful when you want a consistent, local-looking API for generating images without embedding provider-specific SDK logic across your codebase.

Features

  • Text-to-image generation using Google Gemini Nano
  • Image-to-image editing (prompt-guided edits, strength/scale controls)
  • Simple MCP-style HTTP endpoints (JSON input / JSON output)
  • Configurable provider and model options via environment variables / config file
  • Returns base64-encoded PNG/JPEG images and metadata (seed, model, size)
  • Lightweight, suitable to run locally or in a container
  • Example clients and curl snippets for quick experimentation

Installation / Configuration

Requirements: Node.js >= 18 (or configured runtime), npm/yarn, and a provider API key for Gemini Nano.

  1. Clone the repo and install:
git clone https://github.com/nanana-app/mcp-server-nano-banana.git
cd mcp-server-nano-banana
npm install
  1. Configure environment variables (example):
# .env
PORT=3000
PROVIDER=google      # or other supported provider
GEMINI_API_KEY=your_google_gemini_api_key
MODEL=gemini-nano    # default model name
LOG_LEVEL=info

Env vars explained:

VariablePurpose
PORTHTTP port to listen on
PROVIDERProvider implementation (e.g., “google”)
GEMINI_API_KEYAPI key for Google Gemini access
MODELModel identifier (default: gemini-nano)
LOG_LEVELLogging verbosity (info/debug)
  1. Start the server:
npm run start
# or for development
npm run dev

You can also run it in Docker:

docker build -t nanana-mcp .
docker run -p 3000:3000 \
  -e PROVIDER=google \
  -e GEMINI_API_KEY=your_key_here \
  -e MODEL=gemini-nano \
  nanana-mcp

Configuration file (optional):

// mcp-config.json
{
  "provider": "google",
  "model": "gemini-nano",
  "default": {
    "size": [512, 512],
    "format": "png"
  }
}

Available Tools / Resources

  • Git repository: https://github.com/nanana-app/mcp-server-nano-banana
  • Gemini docs: refer to Google Cloud / Gemini API docs for rate limits and advanced options
  • Example clients: included samples in the repo (curl scripts and Node.js client)
  • Logs: server prints request/response metadata when LOG_LEVEL=debug

Endpoints (examples)

Below are typical endpoints exposed by the MCP server. The actual path names may vary slightly; check the repo README or source for exact routes.

  • POST /v1/t2i — Text-to-image
  • POST /v1/i2i — Image-to-image (requires input image)
  • GET /health — Health check

Example request/response shapes are shown below.

Text-to-image example (curl):

curl -X POST "http://localhost:3000/v1/t2i" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A serene watercolor painting of mountains at sunrise",
    "size": [768,512],
    "seed": 12345,
    "steps": 20
  }'

Example response:

{
  "id": "req_abc123",
  "model": "gemini-nano",
  "images": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
      "format": "png",
      "seed": 12345
    }
  ],
  "meta": {
    "elapsed_ms": 1120
  }
}

Image-to-image example (curl):

curl -X POST "http://localhost:3000/v1/i2i" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Make the toy car look rusty and vintage",
    "image_b64": "<BASE64_INPUT_IMAGE>",
    "strength": 0.7,
    "size": [512,512]
  }'

Returned images are base64-encoded; consumers should decode and save as PNG/JPEG.

Use Cases

  • Rapid prototyping: Integrate a consistent T2I/I2I endpoint in a prototype without wiring provider SDKs everywhere.
  • Content generation pipeline: Batch-generate thumbnails, concept art, or backgrounds using scripted calls to /v1/t2i.
  • Assisted editing: Provide a frontend for non-technical users to upload an image and apply prompt-based edits using /v1/i2i.
  • Game asset iteration: Quickly iterate on sprites or environment art by generating variations with different prompts and seeds.
  • Chatbot attachments: Embed image generation into a chat assistant: convert user prompts to images and return them as attachments.

Notes and Best Practices

  • Respect provider rate limits and quotas; use caching for repeated prompts and consider batching requests.
  • Keep API keys secure and do not embed them in client-side code.
  • For large-scale usage, run the server behind a reverse proxy and add authentication/quota controls.
  • Tune size and steps to balance quality vs. latency and cost (larger sizes and more steps increase generation time).

For complete examples, detailed option lists, and provider-specific setup, see the GitHub repository: https://github.com/nanana-app/mcp-server-nano-banana.