Nano Banana MCP Server

Nano Banana MCP Server

Enables AI-powered image generation using Google's Gemini 2.5 Flash Image Preview model, supporting text-to-image and image-to-image generation through the MCP interface.

Category
Visit Server

README

Nano Banana MCP Server

A Model Context Protocol (MCP) server for AI-powered image generation using Google's Gemini 2.5 Flash Image Preview model. This server enables text-to-image and image-to-image generation through the MCP interface.

Features

  • Text-to-Image Generation: Generate images from text prompts
  • Image-to-Image Generation: Create variations or modifications of existing images
  • Base64 Support: Handle image data in base64 format for MCP compatibility
  • Google AI Studio Integration: Uses Google's latest Gemini 2.5 Flash Image Preview model
  • Error Handling: Comprehensive error handling and logging
  • Environment Variable Support: Secure API key management

Prerequisites

  • Python 3.7+
  • Google AI Studio API key
  • Internet connection for API calls

Installation

  1. Clone or download this repository

  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Set up your Google AI Studio API key:

    export GOOGLE_AI_STUDIO_API_KEY="your_api_key_here"
    

Configuration

MCP Configuration

Add the following to your MCP configuration file:

{
  "mcpServers": {
    "nano-banana": {
      "command": "python3",
      "args": ["nano_banana_server.py"],
      "env": {
        "GOOGLE_AI_STUDIO_API_KEY": "${GOOGLE_AI_STUDIO_API_KEY}"
      }
    }
  }
}

Environment Variables

  • GOOGLE_AI_STUDIO_API_KEY: Your Google AI Studio API key (required)

Usage

MCP Tool Function

The server provides a single MCP tool function:

generate_image_with_nano_banana

Generate images using Google's Gemini 2.5 Flash Image Preview model.

Parameters:

  • prompt (string, required): Text description of the image to generate
  • input_image_b64 (string, optional): Base64 encoded input image for variations
  • input_image_mime_type (string, optional): MIME type of input image (e.g., 'image/png', 'image/jpeg')

Returns:

  • success (boolean): Whether the generation was successful
  • generated_image_b64 (string): Base64 encoded generated image (if successful)
  • generated_image_size (integer): Size of generated image in bytes
  • model_used (string): Name of the model used ("gemini-2.5-flash-image-preview")
  • error (string): Error message (if failed)

Example Usage

Text-to-Image Generation

result = await generate_image_with_nano_banana(
    prompt="A beautiful handcrafted ceramic bowl with intricate patterns"
)

Image-to-Image Generation

result = await generate_image_with_nano_banana(
    prompt="Transform this into a watercolor painting",
    input_image_b64="iVBORw0KGgoAAAANSUhEUgAA...",  # Base64 encoded image
    input_image_mime_type="image/png"
)

Testing

Run the test function to verify the server is working:

python nano_banana_server.py

This will generate a test image and display the results.

API Reference

Classes

ImageGenerationRequest

Data class for image generation requests.

Attributes:

  • prompt (str): Text prompt for image generation
  • input_image_data (Optional[bytes]): Raw image data
  • input_image_mime_type (Optional[str]): MIME type of input image

ImageGenerationResponse

Data class for image generation responses.

Attributes:

  • success (bool): Whether generation was successful
  • generated_image_data (Optional[bytes]): Generated image data
  • error_message (Optional[str]): Error message if failed
  • model_used (str): Model name used for generation

NanoBananaMCPServer

Main server class for handling image generation.

Methods:

  • __init__(api_key: Optional[str] = None): Initialize server with API key
  • generate_image(request: ImageGenerationRequest) -> ImageGenerationResponse: Generate image from request
  • generate_image_from_base64(prompt: str, input_image_b64: Optional[str] = None, input_image_mime_type: Optional[str] = None) -> Dict[str, Any]: Generate image with base64 input

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured