Skip to main content

Python MCP server for AI-powered image generation using Google Gemini models - A complete port of nanobanana

Project description

nanobanana-py

Python MCP server for AI-powered image generation using Google Gemini models.

A complete port of nanobanana (TypeScript) to Python.

Features

  • 7 Image Generation Tools:

    • generate_image - Text to image with styles and variations
    • edit_image - Edit existing images
    • restore_image - Restore/enhance images
    • generate_icon - App icons, favicons, UI elements
    • generate_pattern - Seamless patterns and textures
    • generate_story - Sequential story images
    • generate_diagram - Technical diagrams and flowcharts
  • Dual Model Support: Flash (fast) and Pro (high quality)

  • Batch Generation: Generate multiple variations in parallel

  • Reference Images: Use existing images as references

  • Multiple Resolutions: 1K, 2K, 4K output options

Installation

Via uvx (Recommended)

uvx nanobanana-py

Via pip

pip install nanobanana-py

Via pipx

pipx install nanobanana-py

Configuration

Environment Variable

Get your API key from Google AI Studio.

export NANOBANANA_GEMINI_API_KEY="your-api-key-here"

Optional Environment Variables

# Use a different model (default: gemini-2.5-flash-image)
export NANOBANANA_MODEL="gemini-3-pro-image-preview"

# Set custom output directory
export NANOBANANA_OUTPUT_DIR="/path/to/output"

# Enable debug logging
export NANOBANANA_DEBUG="1"

Claude Code Integration

Add to your .mcp.json:

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-py"],
      "env": {
        "NANOBANANA_GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Or with local installation:

{
  "mcpServers": {
    "nanobanana": {
      "command": "nanobanana-py"
    }
  }
}

Tools

generate_image

Generate single or multiple images from text prompts.

Parameters:

  • prompt (required): Image description
  • files: Reference image paths (1-13)
  • filename: Output filename
  • output_count: Number of variations (1-8)
  • styles: Artistic styles (photorealistic, watercolor, sketch, etc.)
  • variations: Variation types (lighting, angle, mood, etc.)
  • format: Output format (grid, separate)
  • seed: Seed for reproducibility
  • resolution: 1K, 2K, or 4K
  • preview: Auto-open in viewer

edit_image

Edit an existing image based on a text prompt.

Parameters:

  • prompt (required): Edit description
  • file (required): Input image path
  • filename: Output filename
  • resolution: 1K, 2K, or 4K
  • preview: Auto-open in viewer

restore_image

Restore or enhance an existing image.

Parameters:

  • prompt (required): Restoration description
  • file (required): Input image path
  • filename: Output filename
  • resolution: 1K, 2K, or 4K
  • preview: Auto-open in viewer

generate_icon

Generate app icons in multiple sizes.

Parameters:

  • prompt (required): Icon description
  • sizes: Icon sizes (16, 32, 64, 128, 256, 512, 1024)
  • type: app-icon, favicon, ui-element
  • style: flat, skeuomorphic, minimal, modern
  • format: png, jpeg
  • background: transparent, white, black
  • corners: rounded, sharp

generate_pattern

Generate seamless patterns and textures.

Parameters:

  • prompt (required): Pattern description
  • size: Tile size (e.g., "256x256")
  • type: seamless, texture, wallpaper
  • style: geometric, organic, abstract, floral, tech
  • density: sparse, medium, dense
  • colors: mono, duotone, colorful
  • repeat: tile, mirror

generate_story

Generate a sequence of related images.

Parameters:

  • prompt (required): Story description
  • steps: Number of images (2-8)
  • type: story, process, tutorial, timeline
  • style: consistent, evolving
  • transition: smooth, dramatic, fade

generate_diagram

Generate technical diagrams and flowcharts.

Parameters:

  • prompt (required): Diagram description
  • type: flowchart, architecture, network, database, wireframe, mindmap, sequence
  • style: professional, clean, hand-drawn, technical
  • layout: horizontal, vertical, hierarchical, circular
  • complexity: simple, detailed, comprehensive

Development

# Clone the repository
git clone https://github.com/aspect-apps/nanobanana-py.git
cd nanobanana-py

# Install dependencies
uv sync

# Install with dev dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Format code
uv run ruff format src/
uv run ruff check src/ --fix

License

MIT

Credits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanobanana_py-0.1.0.tar.gz (133.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanobanana_py-0.1.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file nanobanana_py-0.1.0.tar.gz.

File metadata

  • Download URL: nanobanana_py-0.1.0.tar.gz
  • Upload date:
  • Size: 133.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanobanana_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b3a7c625cd9fbf38e8c34618e434d5b2caf7cbf6b08d7ac71f4c62ebe388e517
MD5 ad031d2cafa3a0de79a6405e69a96b60
BLAKE2b-256 2e678a0ab15466e3d26048ff8cd6090151fd66c70054d03195481cce860ac261

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanobanana_py-0.1.0.tar.gz:

Publisher: publish.yml on yazelin/nanobanana-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nanobanana_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nanobanana_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanobanana_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 554c778bf6a7483b7c009060f5da5463fa808738d8a76711ffb3fb4827c12fdf
MD5 1b0cd18281ef680d1defbe3d417ca530
BLAKE2b-256 9b7b844514dbc283c7c177d9aefd767a98e7ce7ca88eb30380239220534510a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanobanana_py-0.1.0-py3-none-any.whl:

Publisher: publish.yml on yazelin/nanobanana-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page