Skip to main content
Glama
Nano-Banana Pro MCP Server

Nano-Banana Pro MCP Server

by agniiva
README.md
# Nano-Banana MCP Server 🍌

> **πŸ€– This project was entirely generated by [Claude Code](https://claude.ai/code)** - an AI coding assistant that can create complete, production-ready applications from scratch.

A Model Context Protocol (MCP) server that provides AI image generation and editing capabilities using Google's **Gemini 3 Pro Image API**. Generate stunning images, edit existing ones, and iterate on your creations with simple text prompts.

## πŸš€ One-Line Install for Claude Code

```bash
npx nano-banana-pro-mcp install --key YOUR_GEMINI_API_KEY
```

That's it! Restart Claude Code and start generating images.

**Uninstall:** `npx nano-banana-pro-mcp uninstall`

<a href="https://glama.ai/mcp/servers/@ConechoAI/Nano-Banana-MCP">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/@ConechoAI/Nano-Banana-MCP/badge" alt="Nano-Banana-MCP MCP server" />
</a>

## ✨ Features

- 🎨 **Generate Images**: Create new images from text descriptions
- ✏️ **Edit Images**: Modify existing images with text prompts
- πŸ”„ **Iterative Editing**: Continue editing the last generated/edited image
- πŸ–ΌοΈ **Multiple Reference Images**: Use reference images for style transfer and guidance
- 🌍 **Cross-Platform**: Smart file paths for Windows, macOS, and Linux
- πŸ”§ **Easy Setup**: Simple configuration with API key
- πŸ“ **Auto File Management**: Automatic image saving with organized naming

## πŸ”‘ Setup

1. **Get your Gemini API key**:
   - Visit [Google AI Studio](https://aistudio.google.com/app/apikey)
   - Create a new API key
   - Copy it for configuration

2. **Configure the MCP server**:
   See configuration examples for your specific client below (Claude Code, Cursor, or other MCP clients).

## πŸ’» Usage with Claude Code

### Configuration:

Add this to your Claude Code MCP settings:

**Option A: With environment variable (Recommended - Most Secure)**
```json
{
  "mcpServers": {
    "nano-banana-pro": {
      "command": "npx",
      "args": ["-y", "nano-banana-pro-mcp"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  }
}
```

**Option B: Without environment variable**
```json
{
  "mcpServers": {
    "nano-banana-pro": {
      "command": "npx",
      "args": ["-y", "nano-banana-pro-mcp"]
    }
  }
}
```

### Usage Examples:
```
Generate an image of a sunset over mountains
```

```
Edit this image to add some birds in the sky
```

```
Continue editing to make it more dramatic
```

## 🎯 Usage with Cursor

### Configuration:

Add to your Cursor MCP configuration:

**Option A: With environment variable (Recommended)**
```json
{
  "nano-banana-pro": {
    "command": "npx",
    "args": ["-y", "nano-banana-pro-mcp"],
    "env": {
      "GEMINI_API_KEY": "your-gemini-api-key-here"
    }
  }
}
```

**Option B: Without environment variable**
```json
{
  "nano-banana-pro": {
    "command": "npx",
    "args": ["-y", "nano-banana-pro-mcp"]
  }
}
```

### Usage Examples:
- Ask Cursor to generate images for your app
- Create mockups and prototypes  
- Generate assets for your projects

## πŸ”§ For Other MCP Clients

If you're using a different MCP client, you can configure nano-banana-pro-mcp using any of these methods:

### Configuration Methods

**Method A: Environment Variable in MCP Config (Recommended)**
```json
{
  "nano-banana-pro": {
    "command": "npx",
    "args": ["-y", "nano-banana-pro-mcp"],
    "env": {
      "GEMINI_API_KEY": "your-gemini-api-key-here"
    }
  }
}
```

**Method B: System Environment Variable**
```bash
export GEMINI_API_KEY="your-gemini-api-key-here"
npx nano-banana-pro-mcp
```

**Method C: Using the Configure Tool**
```bash
npx nano-banana-pro-mcp
# The server will prompt you to configure when first used
# This creates a local .nano-banana-config.json file
```

## πŸ› οΈ Available Commands

### `generate_image`
Create a new image from a text prompt.
```typescript
generate_image({
  prompt: "A futuristic city at night with neon lights"
})
```

### `edit_image`
Edit a specific image file.
```typescript
edit_image({
  imagePath: "/path/to/image.png",
  prompt: "Add a rainbow in the sky",
  referenceImages?: ["/path/to/reference.jpg"] // optional
})
```

### `continue_editing`
Continue editing the last generated/edited image.
```typescript
continue_editing({
  prompt: "Make it more colorful",
  referenceImages?: ["/path/to/style.jpg"] // optional
})
```

### `get_last_image_info`
Get information about the last generated image.
```typescript
get_last_image_info()
```

### `configure_gemini_token`
Configure your Gemini API key.
```typescript
configure_gemini_token({
  apiKey: "your-gemini-api-key"
})
```

### `get_configuration_status`
Check if the API key is configured.
```typescript
get_configuration_status()
```

## βš™οΈ Configuration Priority

The MCP server loads your API key in the following priority order:

1. **πŸ₯‡ MCP Configuration Environment Variables** (Highest Priority)
   - Set in your `claude_desktop_config.json` or MCP client config
   - Most secure as it's contained within the MCP configuration
   - Example: `"env": { "GEMINI_API_KEY": "your-key" }`

2. **πŸ₯ˆ System Environment Variables**
   - Set in your shell/system environment
   - Example: `export GEMINI_API_KEY="your-key"`

3. **πŸ₯‰ Local Configuration File** (Lowest Priority)
   - Created when using the `configure_gemini_token` tool
   - Stored as `.nano-banana-config.json` in current directory
   - Automatically ignored by Git and NPM

**πŸ’‘ Recommendation**: Use Method 1 (MCP config env variables) for the best security and convenience.

## πŸ“ File Storage - Smart Path Resolution 🧠

Nano-Banana now features **Smart Path Resolution** to ensure images are saved correctly in any environment. It checks locations in this priority:

1.  **Environment Variable** (`NANO_BANANA_OUTPUT_DIR`) - *Highest Priority*
2.  **Current Working Directory** (`cwd`) - *If writable and non-system path (enables "Save to Project")*
3.  **Documents Folder** (`~/Documents/nano-banana-images`) - *Desktop default*
4.  **Home Directory** (`~/nano-banana-images`) - *Server fallback*
5.  **Temp Directory** - *Fail-safe*

### πŸ”§ Configuration for "Save to Project"

To have images saved directly to your project folder, add the `cwd` (Current Working Directory) setting to your MCP configuration:

```json
"nano-banana": {
  "command": "node",
  "args": ["/path/to/dist/index.js"],
  "cwd": "${workspaceFolder}", 
  "env": { ... }
}
```

### 🏳️ Overriding Output Directory

You can force a specific output directory by setting the `NANO_BANANA_OUTPUT_DIR` environment variable:

```json
"env": {
  "GEMINI_API_KEY": "...",
  "NANO_BANANA_OUTPUT_DIR": "/Users/me/Desktop/my-images"
}
```

File naming convention:
- Generated images: `generated-[timestamp]-[id].png`
- Edited images: `edited-[timestamp]-[id].png`

## 🎨 Example Workflows

### Basic Image Generation
1. `generate_image` - Create your base image
2. `continue_editing` - Refine and improve
3. `continue_editing` - Add final touches

### Style Transfer
1. `generate_image` - Create base content
2. `edit_image` - Use reference images for style
3. `continue_editing` - Fine-tune the result

### Iterative Design
1. `generate_image` - Start with a concept
2. `get_last_image_info` - Check current state
3. `continue_editing` - Make adjustments
4. Repeat until satisfied

## πŸ”§ Development

This project was created with Claude Code and follows these technologies:

- **TypeScript** - Type-safe development
- **Node.js** - Runtime environment  
- **Zod** - Schema validation
- **Google GenAI** - Image generation API
- **MCP SDK** - Model Context Protocol

### Local Development

```bash
# Clone the repository
git clone https://github.com/claude-code/nano-banana-mcp.git
cd nano-banana-mcp

# Install dependencies
npm install

# Run in development mode
npm run dev

# Build for production
npm run build

# Run tests
npm test
```

## πŸ“‹ Requirements

- Node.js 18.0.0 or higher
- Gemini API key from Google AI Studio
- Compatible with Claude Code, Cursor, and other MCP clients

## 🀝 Contributing

This project was generated by Claude Code, but contributions are welcome! Please feel free to:

- Report bugs
- Suggest new features
- Submit pull requests
- Improve documentation

## πŸ“„ License

MIT License - see [LICENSE](LICENSE) file for details.

## πŸ™ Acknowledgments

- **[Claude Code](https://claude.ai/code)** - For generating this entire project
- **Google AI** - For the powerful Gemini 3 Pro Image API
- **Anthropic** - For the Model Context Protocol
- **Open Source Community** - For the amazing tools and libraries

## πŸ“ž Support

- πŸ› **Issues**: [GitHub Issues](https://github.com/claude-code/nano-banana-mcp/issues)
- πŸ“– **Documentation**: This README and inline code comments
- πŸ’¬ **Discussions**: [GitHub Discussions](https://github.com/claude-code/nano-banana-mcp/discussions)

---

*✨ Generated with love by [Claude Code](https://claude.ai/code) - The future of AI-powered development is here!*

TDQS

A4/5.0

Scored across 6 tools

Disambiguation5/5

Each tool targets a distinct action in the image workflow: token setup, token status, new image generation, editing a known file path, iterating on the last session image, and inspecting that last image. The descriptions explicitly draw the boundaries (e.g. generate_image says 'ONLY when creating a completely new image', edit_image requires an exact file path, continue_editing uses the previous image automatically), leaving little room for misselection.

Naming Consistency4/5

All names are snake_case with a verb-first pattern (configure_, generate_, edit_, get_, continue_), which is predictable throughout. The only minor deviation is the gerund form 'continue_editing' versus the noun-object pattern of the others, but it remains readable and idiomatic.

Tool Count5/5

Six tools is a tight, well-scoped set for an image generation/editing server; every tool maps to a necessary operation (auth, config check, create, edit, iterate, inspect). There is no visible redundancy or filler.

Completeness4/5

The surface covers the core lifecycle: configure auth, verify config, generate, edit by path, iterate on the last result, and inspect that result. Minor gaps existβ€”no way to list or browse previously generated images, choose explicit output destinations, or clean up filesβ€”but agents can work around these with normal filesystem access.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues