MCP Banana Image

MCP Banana Image

AI-powered image generation MCP server with 16 specialized tools for generating, editing, analyzing, and processing images using Google's Nano Banana 2 model. Supports custom API endpoints and integrates with AI coding assistants via natural language.

Category
访问服务器

README

<p align="center"> <img src="assets/mcp-banana-image.webp" alt="MCP Banana Image" width="400"/> </p>

<h1 align="center">MCP Banana Image</h1>

<p align="center"> <strong>AI-Powered Image Generation MCP Server using Google Nano Banana 2 with custom endpoint</strong> </p>

<p align="center"> <a href="https://www.npmjs.com/package/mcp-banana-image"> <img src="https://img.shields.io/npm/v/mcp-banana-image?style=flat-square&color=yellow" alt="npm version"/> </a> <a href="https://www.npmjs.com/package/mcp-banana-image"> <img src="https://img.shields.io/npm/dm/mcp-banana-image?style=flat-square&color=green" alt="npm downloads"/> </a> <a href="https://github.com/trigidigital/mcp-banana-image/blob/main/LICENSE"> <img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="license"/> </a> <a href="https://nodejs.org/"> <img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen?style=flat-square" alt="node version"/> </a> <a href="#"> <img src="https://img.shields.io/badge/TypeScript-5.0-blue?style=flat-square&logo=typescript" alt="TypeScript"/> </a> <a href="#"> <img src="https://img.shields.io/badge/MCP-1.0-purple?style=flat-square" alt="MCP SDK"/> </a> </p>

<p align="center"> <a href="#features">Features</a> • <a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#tools-reference">Tools</a> • <a href="#custom-api-endpoint">Custom API Endpoint</a> • <a href="#docker-deployment">Docker</a> • <a href="#troubleshooting">Troubleshooting</a> </p>


Overview

MCP Banana Image is a Model Context Protocol (MCP) server that brings AI-powered image generation capabilities to your favorite AI coding assistants. Built with Google's Nano Banana 2 (gemini-3.1-flash-image) for image generation and gemini 3 flash for text enhancement, it offers 16 specialized tools for image generation, editing, analysis, and processing - all through a simple natural language interface.

Highlights

  • 16 Specialized Tools - From simple generation to advanced style transfer
  • Custom API Endpoint Support - Use with Cliproxyapi or other Gemini API proxies
  • Intelligent Prompt Enhancement - Automatically optimizes your prompts for better results
  • Dual Transport - STDIO (default) and HTTP (Streamable HTTP Transport)
  • Docker Ready - Deploy as HTTP server with Docker

Features

Category Features
Generation AI image generation, logos, icons, products, social media, UGC, infographics, character sets
Editing Image editing, background removal, image blending, style transfer
Analysis AI-powered image analysis with descriptions, alt-text, tags, and OCR
Processing Format conversion, resizing, compression
Quality 2K/4K resolution, 10 aspect ratios, 4 output formats, smart compression
Consistency Character consistency, style transfer, reference image support
Integration Google Search grounding, world knowledge, platform-specific optimization

Requirements

Installation

Claude Code

claude mcp add mcp-banana-image \
  --env GEMINI_API_KEY=your_api_key \
  --env GEMINI_BASE_URL=https://generativelanguage.googleapis.com \
  --env IMAGE_OUTPUT_DIR=/path/to/output \
  --env SKIP_PROMPT_ENHANCEMENT=false \
  -- npx -y mcp-banana-image

Add --scope user for global installation.

Cursor

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "mcp-banana-image": {
      "command": "npx",
      "args": ["-y", "mcp-banana-image"],
      "env": {
        "GEMINI_API_KEY": "your_api_key",
        "GEMINI_BASE_URL": "https://generativelanguage.googleapis.com",
        "IMAGE_OUTPUT_DIR": "/path/to/output",
        "SKIP_PROMPT_ENHANCEMENT": "false"
      }
    }
  }
}

Codex

Add to ~/.codex/config.toml:

[mcp_servers.mcp-banana-image]
command = "npx"
args = ["-y", "mcp-banana-image"]

[mcp_servers.mcp-banana-image.env]
GEMINI_API_KEY = "your_api_key"
GEMINI_BASE_URL = "https://generativelanguage.googleapis.com"
IMAGE_OUTPUT_DIR = "/path/to/output"
SKIP_PROMPT_ENHANCEMENT = "false"

OpenCode

Add to your opencode.json in your project root or ~/.config/opencode/config.json for global config:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "mcp-banana-image": {
      "type": "local",
      "command": ["npx", "-y", "mcp-banana-image"],
      "enabled": true,
      "environment": {
        "GEMINI_API_KEY": "your_api_key",
        "GEMINI_BASE_URL": "https://generativelanguage.googleapis.com",
        "IMAGE_OUTPUT_DIR": "/path/to/output",
        "SKIP_PROMPT_ENHANCEMENT": "false"
      }
    }
  }
}

With Cliproxy custom endpoint:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "mcp-banana-image": {
      "type": "local",
      "command": ["npx", "-y", "mcp-banana-image"],
      "enabled": true,
      "environment": {
        "GEMINI_API_KEY": "your_cliproxy_api_key",
        "GEMINI_BASE_URL": "https://yourdomain.com",
        "IMAGE_OUTPUT_DIR": "/path/to/output"
      }
    }
  }
}

To use the tool, add use mcp-banana-image to your prompts or add this to your AGENTS.md:

When you need to generate, edit, or analyze images, use `mcp-banana-image` tools.

Custom API Endpoint

MCP Banana Image supports custom Gemini API endpoints, allowing you to use alternative API providers like Cliproxy or your own proxy servers.

Using with Cliproxy

Cliproxy is a Gemini API proxy service that provides enhanced reliability, rate limiting, and additional features.

Configuration Example (Claude Code with Cliproxy)

claude mcp add mcp-banana-image \
  --env GEMINI_API_KEY=your_cliproxy_api_key \
  --env GEMINI_BASE_URL=https://yourdomain.com \
  --env IMAGE_OUTPUT_DIR=/path/to/output \
  -- npx -y mcp-banana-image

Configuration Example (manual json)

{
  "mcpServers": {
    "mcp-banana-image": {
      "command": "npx",
      "args": ["-y", "mcp-banana-image"],
      "env": {
        "GEMINI_API_KEY": "your_cliproxy_api_key",
        "GEMINI_BASE_URL": "https://yourdomain.com",
        "IMAGE_OUTPUT_DIR": "/path/to/output"
      }
    }
  }
}

Security Notes

  • Production: Only HTTPS endpoints are allowed
  • Development: HTTP/localhost endpoints are permitted for testing
  • The endpoint URL is validated before use to prevent SSRF attacks

Tools Reference

MCP Banana Image provides 16 specialized tools organized by category:

Image Generation Tools

Tool Description Key Features
generate_image Generate images from text prompts Auto prompt enhancement, style presets, aspect ratios
generate_image_pro Advanced generation with full control All parameters exposed, reference images, character consistency
generate_logo Generate professional logos Business name/tagline, 8 styles, transparent backgrounds, color branding
generate_icon Generate icons, avatars, stickers 6 styles (flat, outlined, 3D), multiple sizes (16-512px)
generate_product E-commerce product photography 5 style presets, platform compliance (Amazon, Shopee, Tokopedia), 6 categories
generate_social_media Platform-optimized social content 9 platforms, auto aspect ratios, text-safe zones
generate_ugc Authentic user-generated content 7 scenarios, 10 settings, smartphone aesthetic
generate_infographic AI-powered infographics 4 styles, 4 layouts, brand colors, icon hints
generate_character_set Consistent character series Poses, expressions, 5 art styles, sprite sheet output

Image Editing Tools

Tool Description Key Features
edit_image Edit images with natural language Add/remove elements, change backgrounds, enhance
remove_background Remove image backgrounds Transparent PNG output, AI-powered segmentation
blend_images Blend multiple images 4 modes (seamless, collage, double-exposure, overlay), 2-4 images
style_transfer Apply artistic styles Single/multiple references, style strength control, element preservation

Image Processing Tools

Tool Description Key Features
convert_image Format conversion PNG, JPEG, WebP, AVIF, compression presets
resize_image Resize images Exact dimensions, 5 fit modes, aspect preservation

Analysis Tools

Tool Description Key Features
analyze_image AI-powered image analysis Descriptions, alt-text, tags, OCR, moderation

Usage Examples

Basic Image Generation

"Generate a mountain landscape at sunset"

Logo Generation

generate_logo businessName='TechStart' tagline='Innovation Made Simple' style='modern'

Product Photography

generate_product productDescription='handmade leather wallet' style='premium' platform='amazon'

Social Media Content

generate_social_media content='summer sale announcement' platform='instagram-post'

User-Generated Content

generate_ugc description='person enjoying morning coffee' scenario='lifestyle' setting='home'

Character Set Generation

generate_character_set characterDescription='friendly robot mascot' poses=['front', 'waving'] style='cartoon'

Style Transfer

style_transfer referenceStyleImage='./van-gogh.jpg' contentDescription='mountain landscape' styleStrength=0.8

Image Analysis

analyze_image imagePath='/path/to/photo.jpg' analysisType='description'

Background Removal

remove_background imagePath='/path/to/product.jpg'

Image Blending

blend_images imagePaths=['./bg.jpg', './subject.png'] instruction='Place subject on background' blendMode='seamless'

Infographic Generation

generate_infographic content='5 steps to improve productivity: 1. Set goals...' style='corporate' layout='vertical'

Image Resizing

resize_image inputPath='./photo.jpg' width=800 height=600 fit='cover'

Environment Variables

Core Configuration

Variable Required Default Description
GEMINI_API_KEY Yes - Google AI or Cliproxy API key
GEMINI_BASE_URL No Google default Custom API endpoint (e.g., Cliproxy)
IMAGE_OUTPUT_DIR No ./output Output directory for generated images
SKIP_PROMPT_ENHANCEMENT No false Disable automatic prompt optimization

HTTP Transport Configuration

Variable Required Default Description
MCP_TRANSPORT No stdio Transport mode: stdio or http
MCP_API_KEY Yes (http) - API key for HTTP authentication
MCP_HTTP_PORT No 3000 HTTP server port
MCP_HTTP_HOST No 0.0.0.0 HTTP server bind address
MCP_CORS_ORIGIN No * CORS allowed origins
MCP_HTTP_TIMEOUT No 300000 HTTP request timeout in ms

Output Formats & Compression

Supported Formats

Format Description Transparency Best For
png Lossless Yes Graphics, logos, icons
jpeg Lossy No Photos, large images
webp Modern Yes Web optimization
avif Best compression Yes Modern browsers

Compression Presets

Preset Description Use Case
lossless No quality loss Archival, source files
high Minimal loss Professional work
balanced Good quality/size ratio General use
maximum Smallest file size Web optimization

Aspect Ratios

1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9

Docker Deployment

Build and Run

docker build -t mcp-banana-image .
docker-compose up

docker-compose.yml

services:
  mcp-banana-image:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - ./output:/app/output
    environment:
      - GEMINI_API_KEY=${GEMINI_API_KEY}
      - GEMINI_BASE_URL=${GEMINI_BASE_URL}
      - MCP_API_KEY=${MCP_API_KEY}
      - MCP_TRANSPORT=http

Health Check

curl http://localhost:3000/health

Response:

{
  "status": "ok",
  "timestamp": "2024-01-01T00:00:00.000Z",
  "sessions": 0
}

Architecture

flowchart TB
    subgraph Client
        A[AI Assistant]
    end

    subgraph MCP Server
        B[Transport Layer]
        C[MCP Handler]
        D[Tool Registry]
        E[16 Specialized Tools]
        F[Image Processor]
        G[File Manager]
    end

    subgraph "AI Providers"
        H[Gemini API]
        I[Cliproxy API]
    end

    A -->|STDIO/HTTP| B
    B --> C
    C --> D
    D --> E
    E -->|API Calls| H
    E -->|API Calls| I
    E --> F
    F -->|Save| G
    G --> J[(Output)]

Troubleshooting

API key not found

  • Verify GEMINI_API_KEY is set correctly
  • For Cliproxy: ensure you're using the correct Cliproxy API key
  • Check key permissions at Google AI Studio

Custom endpoint connection failed

  • Verify GEMINI_BASE_URL is correctly formatted (include full URL with protocol)
  • Ensure the endpoint is accessible from your network
  • For production: only HTTPS endpoints are allowed

Image not saved

  • Ensure IMAGE_OUTPUT_DIR is an absolute path
  • Check directory write permissions
  • Verify disk space availability

Generation timeout

  • High resolution images (4K) take longer
  • Character sets with many poses/expressions take longer
  • Consider increasing MCP_HTTP_TIMEOUT for HTTP mode
  • Check network connectivity to API endpoint

Prompt blocked by safety filters

  • Rephrase your prompt to avoid potentially sensitive content
  • The AI may reject prompts that could generate inappropriate imagery

Character consistency issues

  • Provide detailed character descriptions
  • Use reference images when available
  • Enable maintainCharacterConsistency option

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run with coverage
npm run test:coverage

# Lint and format
npm run check:all

License

MIT

Contributing

We welcome contributions! Please read our Contributing Guide for guidelines on how to submit changes.


<p align="center"> Made with ❤️ by <a href="https://trigidigital.com">Trigi Digital</a> </p>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选