Metadata-Version: 2.5
Name: nanobanana-imagen-mcp
Version: 1.2.0
Summary: MCP server for AI image generation using NanoBanana Pro 2 -- 4K resolution
Project-URL: Homepage, https://github.com/u2n4/gemini-media-mcp
Project-URL: Repository, https://github.com/u2n4/gemini-media-mcp
Author: u2n4
License-Expression: MIT
Keywords: 4k,ai-art,claude,gemini,image-generation,imagen,mcp,model-context-protocol,nanobanana,text-to-image
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: fastmcp<5,>=4.1.6
Requires-Dist: google-genai<3,>=2.33.0; python_version < '3.11'
Requires-Dist: google-genai<3,>=2.34.0; python_version >= '3.11'
Requires-Dist: pillow<13,>=12.3.0; python_version < '3.11'
Requires-Dist: pillow<14,>=13.0.0; python_version >= '3.11'
Requires-Dist: python-dotenv<2,>=1.2.4
Description-Content-Type: text/markdown

# NanoBanana MCP Server

<!-- mcp-name: io.github.u2n4/nanobanana-imagen-mcp -->

MCP server for AI image generation using NanoBanana Pro 2. Supports Pro (maximum quality) and Flash (fast generation) models with default 4K resolution.

Inspired by the nano-banana naming convention used across the MCP community. This is an independent implementation.

## Quick Install

```bash
pip install nanobanana-imagen-mcp
# or
uvx nanobanana-imagen-mcp --help
```

**Claude Desktop (`claude_desktop_config.json`):**

```json
{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-imagen-mcp"],
      "env": {
        "GEMINI_API_KEY": "your_key_here"
      }
    }
  }
}
```

| Variable | Description | Default |
|----------|-------------|---------|
| `GEMINI_API_KEY` | Gemini API key — required for all generation | -- |
| `IMAGE_OUTPUT_DIR` | Directory where generated images are saved | `~/nanobanana-images` |
| `NANOBANANA_DB_PATH` | SQLite database path for image metadata | `~/nanobanana-images/images.db` |

## What It Does

Generates AI images using NanoBanana Pro 2 models. Supports text-to-image generation, image editing with reference images, file uploads, and server maintenance. Produces high-quality images at up to 4K resolution.

## Tools (4)

| Tool | Description |
|------|-------------|
| `generate_image` | Generate images using NanoBanana Pro 2. Supports model selection (Pro/Flash), aspect ratio, resolution (up to 4K), negative prompts, thinking level, grounding, reference images, and batch generation. |
| `upload_file` | Upload a reference image for use in image editing or conditioning. |
| `show_output_stats` | Display statistics about generated images — count, total size, file details. |
| `maintenance` | Server maintenance and cleanup — clear caches, remove temporary files, optimize storage. |

## Models

| Model | Engine | Best For |
|-------|--------|----------|
| Pro | `gemini-3-pro-image` | Maximum quality, complex scenes, photorealism |
| Flash | `gemini-nano-banana-2.1` | Fast generation, simple scenes, quick iterations |

## Configuration

| Variable | Description | Default |
|----------|-------------|---------|
| `GEMINI_API_KEY` | Gemini API key (required) | -- |
| `IMAGE_OUTPUT_DIR` | Output directory for generated images | `~/nanobanana-images` |

## Storage

Generated image metadata is tracked in a SQLite database.

| Variable | Description | Default |
|----------|-------------|---------|
| `NANOBANANA_DB_PATH` | Path to the SQLite metadata database | `~/nanobanana-images/images.db` |

**Opt out of persistent storage** by setting `NANOBANANA_DB_PATH=:memory:`. This uses an in-memory database that is discarded when the server exits — useful for ephemeral or read-only environments. Trade-off: image history is lost on restart; the `show_output_stats` tool will show an empty database each session.

The database and output directories are created lazily on first use. The server
starts and lists its four tools without credentials. Image generation and uploads
require authentication; with no API key configured, they return a clear error
naming `GEMINI_API_KEY`.

## Claude Desktop Configuration

### From pip (recommended)

```bash
pip install nanobanana-imagen-mcp
```

```json
{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-imagen-mcp"],
      "env": {
        "GEMINI_API_KEY": "your_key_here"
      }
    }
  }
}
```

### From this repository

```json
{
  "mcpServers": {
    "nanobanana": {
      "command": "python",
      "args": ["-m", "servers.nanobanana.nanobanana_mcp_server.server"],
      "env": {
        "GEMINI_API_KEY": "your_key_here"
      },
      "cwd": "path/to/gemini-media-mcp"
    }
  }
}
```

## Features

- Default 4K resolution for maximum detail
- Pro model for complex, photorealistic scenes
- Flash model for fast iterations and simple subjects
- Reference image support for consistent multi-angle shots
- Negative prompt support for quality control
- Thinking level control for complex multi-element scenes
- Google Search grounding for real-world subjects

## License

MIT

## Credits

Inspired by the nano-banana naming convention used across the MCP community. This is an independent implementation.

## Refresh verification — 2026-11-05

Gemini paths were tested only with a fake client and never live. Both API keys
were unset for all test runs; tests block real SDK clients and HTTP requests.
`gemini-3.1-flash-image` is also listed as Stable; this server's Flash route uses
the documented preview replacement `gemini-nano-banana-2.1`.

Dependencies: `fastmcp>=4,<5`, `google-genai>=2.5.0,<3`.
Clean tool registration checked with FastMCP 4.1.6 and SDK 2.34.0.
The `ToolResult` imports now use the FastMCP 4 module path.

```bash
env -u GEMINI_API_KEY -u GOOGLE_API_KEY -u GEMINI_API_KEY_BACKUP uv run --locked pytest tests -q
```
