Nanobanana

v1.0.0APIsstable

A security-hardened MCP server for generating and editing images using Google Gemini models. It provides tools for text-to-image creation and iterative image editing with strict input validation and secure file handling.

aiclaudeclaude-desktopgeminigoogle-ai
Share:
354
Stars
0
Downloads
0
Weekly
0/5

What is Nanobanana?

Nanobanana is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to security-hardened mcp server for generating and editing images using google gemini models. it provides tools for text-to-image creation and iterative image editing with strict input validation and sec...

A security-hardened MCP server for generating and editing images using Google Gemini models. It provides tools for text-to-image creation and iterative image editing with strict input validation and secure file handling.

This server falls under the APIs category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • A security-hardened MCP server for generating and editing im

Use Cases

Generate images with Google Gemini
AI-powered image editing
Secure image generation
zhongweili

Maintainer

LicenseMIT License
Languagepython
Versionv1.0.0
UpdatedMay 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y nanobanana-mcp-server

PIP

pip install nanobanana-mcp-server

Manual Installation

npx -y nanobanana-mcp-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Nanobanana

Nanobanana MCP Server is a security-hardened MCP server that gives AI clients the ability to generate and edit images using Google's Gemini image generation models. It exposes three tools — generate_image, edit_image, and upload_file — with strict input validation and sandboxed file handling to prevent path traversal and injection attacks. Developers use it to add text-to-image and iterative image editing capabilities to Claude Desktop or any MCP-compatible client, with support for multiple Gemini model tiers (nano, pro, flash) and configurable aspect ratios.

Prerequisites

  • Python 3.10+ with pip or uv installed
  • A Google Gemini API key (obtain at https://aistudio.google.com/app/apikey)
  • An MCP-compatible AI client such as Claude Desktop
  • Optional: A Google Cloud project with Vertex AI enabled (for Vertex AI authentication instead of API key)
1

Install the nanobanana-mcp-server package

Install via pip or uvx. The uvx method is recommended as it manages a virtual environment automatically.

# Recommended (uvx)
uvx nanobanana-mcp-server@latest

# Or via pip
pip install nanobanana-mcp-server
2

Obtain a Gemini API key

Go to https://aistudio.google.com/app/apikey, sign in with a Google account, and create a new API key. Copy the key — you will need it in the next step.

3

Configure your MCP client with the API key

Add the server to your claude_desktop_config.json. The GEMINI_API_KEY environment variable is required for API key authentication.

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here"
      }
    }
  }
}
4

Configure output directory (optional)

By default, generated images are saved to ~/nanobanana-images. Set IMAGE_OUTPUT_DIR to use a different location.

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "your-gemini-api-key-here",
        "IMAGE_OUTPUT_DIR": "/Users/you/Desktop/ai-images"
      }
    }
  }
}
5

Generate your first image

Ask your AI client to generate an image. The server supports three model tiers: nb2 (fast/cheap), flash, and pro (highest quality, supports thinking_level parameter).

Nanobanana Examples

Client configuration (Claude Desktop)

Complete claude_desktop_config.json block for nanobanana with API key authentication.

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["nanobanana-mcp-server@latest"],
      "env": {
        "GEMINI_API_KEY": "AIza...",
        "NANOBANANA_AUTH_METHOD": "api_key",
        "IMAGE_OUTPUT_DIR": "~/nanobanana-images"
      }
    }
  }
}

Prompts to try

Example prompts that use the generate_image, edit_image, and aspect ratio features.

- "Generate a professional product photo on a white background using the pro model"
- "Create a 16:9 banner image of a mountain sunset for a website header"
- "Generate 4 variations of a logo concept for a coffee shop called 'The Morning Brew'"
- "Edit the image at ~/nanobanana-images/draft.png to add dramatic lighting"
- "Create a cinematic scene of three characters in a standoff at dusk with thinking level HIGH"

Troubleshooting Nanobanana

API key error: 'GEMINI_API_KEY not set' or 'API key not valid'

Verify the GEMINI_API_KEY environment variable is set correctly in your MCP client config. Keys from Google AI Studio should start with 'AIza'. If using Vertex AI instead, set NANOBANANA_AUTH_METHOD=vertex_ai and provide GCP_PROJECT_ID and GCP_REGION — do not set GEMINI_API_KEY in this mode.

Images are not saved or cannot be found after generation

Check the IMAGE_OUTPUT_DIR value in your config. By default, images go to ~/nanobanana-images — make sure this directory exists or specify a path you have write access to. The server should create the directory automatically, but on some systems you may need to create it manually: mkdir -p ~/nanobanana-images.

Generation is slow or times out when using the pro model with thinking_level HIGH

The Gemini Pro model with high thinking level can take 30-60 seconds per image. This is expected behavior. Increase your MCP client's timeout setting if it cuts off the request. For faster results, switch to model_tier='nb2' or 'flash'.

Frequently Asked Questions about Nanobanana

What is Nanobanana?

Nanobanana is a Model Context Protocol (MCP) server that security-hardened mcp server for generating and editing images using google gemini models. it provides tools for text-to-image creation and iterative image editing with strict input validation and secure file handling. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Nanobanana?

Install via npm with the command: npx -y nanobanana-mcp-server. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).

Which AI clients work with Nanobanana?

Nanobanana works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Nanobanana free to use?

Yes, Nanobanana is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More APIs MCP Servers

Explore all apis servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "nanobanana": { "command": "npx", "args": ["-y", "nanobanana-mcp-server"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Nanobanana?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides