Skip to main content
Glama
README.md
<div align="center">

# 🍌 Nanobanana MCP

![Vibe Coded](https://img.shields.io/badge/Vibe-Coded-FF00FF?style=for-the-badge&logo=sparkles&logoColor=white)

**A powerful Model Context Protocol (MCP) server for generative AI media tasks.**

</div>

## Overview

Nanobanana MCP brings generative capabilities directly to your MCP clients (like Claude Desktop or other AI agents). It leverages Google's Gemini API to generate images, icons, patterns, diagrams, and even visual stories.

This server implements the Model Context Protocol, allowing seamless integration with any MCP-compliant tool.

## ✨ Features

- **Generate Images**: Create images from text prompts (`nanobanana_generate_image`).
- **Edit Images**: Modify existing images using text instructions (`nanobanana_edit_image`).
- **Restore Images**: Denoise and restore image quality (`nanobanana_restore_image`).
- **Generate Icons**: Create app icons and favicons in various sizes (`nanobanana_generate_icon`).
- **Generate Patterns**: Create seamless textures and tileable patterns (`nanobanana_generate_pattern`).
- **Generate Diagrams**: Create flowcharts, UML, and technical diagrams (`nanobanana_generate_diagram`).
- **Story Generation**: Generate sequential visual stories (`nanobanana_generate_story`).

## 🚀 Getting Started

### Prerequisites

- [Bun](https://bun.sh) (v1.2+ recommended)
- A Google Gemini API Key

### Installation

1. Clone the repository:

   ```bash
   git clone <repository-url>
   cd nanobanana-mcp
   ```

2. Install dependencies:

   ```bash
   bun install
   ```

3. Create a `.env` file in the root directory:
   ```bash
   cp .env.example .env # if example exists, otherwise create new
   ```

### Configuration

Set the following environment variables in your `.env` file:

| Variable           | Description                                          | Default                  |
| ------------------ | ---------------------------------------------------- | ------------------------ |
| `GEMINI_API_KEY`   | Your Google Gemini API Key (Required for generation) | `null`                   |
| `NANOBANANA_MODEL` | The Gemini model to use                              | `gemini-2.5-flash-image` |
| `OUTPUT_DIR`       | Directory to save generated assets                   | `./nanobanana-output`    |
| `LOG_LEVEL`        | Logging verbosity (info, debug, warn, error)         | `info`                   |

> **Note:** The server will fallback to a Mock Generator if no API key is provided, returning placeholder images for testing.

## 🏃‍♂️ Usage

### Running the Server

Start the MCP server directly:

```bash
bun run index.ts
```

### Integration with Claude Desktop

Add the following to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "nanobanana": {
      "command": "bun",
      "args": ["run", "/absolute/path/to/nanobanana-mcp/index.ts"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}
```

## 🛠️ Development

Run the test suite to verify functionality:

```bash
# Run unit tests
bun test

# Run specific phase tests
bun test src/phase2.test.ts
```

## 📜 License

This project is licensed under the MIT License.