Skip to main content
Glama

NanoBananaMCP

PyPI version PyPI downloads Python 3.10+ License: MIT MCP

一个用于 AI 图像生成和编辑的 Model Context Protocol (MCP) 服务器,通过 AceDataCloud API 使用 Google 的 Nano Banana 模型。

直接从 Claude、VS Code 或任何兼容 MCP 的客户端生成和编辑 AI 图像。

功能

  • 图像生成 - 根据文本提示创建高质量图像

  • 图像编辑 - 修改现有图像或组合多张图像

  • 虚拟试穿 - 为照片中的人物穿上服装

  • 产品植入 - 将产品放置在逼真的场景中

  • 任务跟踪 - 监控生成进度并获取结果

Related MCP server: MCP Banana Image

工具参考

工具

描述

nanobanana_generate_image

使用 Google 的 Nano Banana 模型根据文本提示生成 AI 图像。

nanobanana_edit_image

根据文本提示使用 AI 编辑或组合图像。

nanobanana_get_task

查询图像生成或编辑任务的状态和结果。

nanobanana_get_tasks_batch

一次查询多个图像生成/编辑任务。

快速入门

1. 获取您的 API 令牌

  1. 在 AceDataCloud 平台 注册

  2. 前往 API 文档页面

  3. 点击 “Acquire” 获取您的 API 令牌

  4. 复制令牌以供下方使用

2. 使用托管服务器(推荐)

AceDataCloud 托管了一个受管理的 MCP 服务器 —— 无需本地安装。

端点: https://nanobanana.mcp.acedata.cloud/mcp

所有请求都需要 Bearer 令牌。请使用第 1 步中的 API 令牌。

Claude.ai

通过 OAuth 直接在 Claude.ai 上连接 —— 无需 API 令牌:

  1. 前往 Claude.ai 设置 → 集成 → 添加更多

  2. 输入服务器 URL:https://nanobanana.mcp.acedata.cloud/mcp

  3. 完成 OAuth 登录流程

  4. 开始在对话中使用这些工具

Claude Desktop

添加到您的配置中(macOS 上为 ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

Cursor / Windsurf

添加到您的 MCP 配置(.cursor/mcp.json 或 .windsurf/mcp.json):

{
  "mcpServers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

VS Code (Copilot)

添加到您的 VS Code MCP 配置(.vscode/mcp.json):

{
  "servers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

或者为 VS Code 安装 Ace Data Cloud MCP 扩展,该扩展捆绑了所有 15 个 MCP 服务器,支持一键设置。

JetBrains IDEs

  1. 前往 设置 → 工具 → AI Assistant → Model Context Protocol (MCP)

  2. 点击 添加 → HTTP

  3. 粘贴:

{
  "mcpServers": {
    "nanobanana": {
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

Claude Code

Claude Code 原生支持 MCP 服务器:

claude mcp add nanobanana --transport http https://nanobanana.mcp.acedata.cloud/mcp \
  -h "Authorization: Bearer YOUR_API_TOKEN"

或者添加到您项目的 .mcp.json 中:

{
  "mcpServers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

Cline

添加到 Cline 的 MCP 设置(.cline/mcp_settings.json):

{
  "mcpServers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

Amazon Q Developer

添加到您的 MCP 配置:

{
  "mcpServers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

Roo Code

添加到 Roo Code MCP 设置:

{
  "mcpServers": {
    "nanobanana": {
      "type": "streamable-http",
      "url": "https://nanobanana.mcp.acedata.cloud/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_TOKEN"
      }
    }
  }
}

Continue.dev

添加到 .continue/config.yaml:

mcpServers:
  - name: nanobanana
    type: streamable-http
    url: https://nanobanana.mcp.acedata.cloud/mcp
    headers:
      Authorization: "Bearer YOUR_API_TOKEN"

Zed

添加到 Zed 的设置(~/.config/zed/settings.json):

{
  "language_models": {
    "mcp_servers": {
      "nanobanana": {
        "url": "https://nanobanana.mcp.acedata.cloud/mcp",
        "headers": {
          "Authorization": "Bearer YOUR_API_TOKEN"
        }
      }
    }
  }
}

cURL 测试

# Health check (no auth required)
curl https://nanobanana.mcp.acedata.cloud/health

# MCP initialize
curl -X POST https://nanobanana.mcp.acedata.cloud/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

3. 或本地运行(替代方案)

如果您更喜欢在自己的机器上运行服务器:

# Install from PyPI
pip install mcp-nanobanana-pro
# or
uvx mcp-nanobanana-pro

# Set your API token
export ACEDATACLOUD_API_TOKEN="your_token_here"

# Run (stdio mode for Claude Desktop / local clients)
mcp-nanobanana-pro

# Run (HTTP mode for remote access)
mcp-nanobanana-pro --transport http --port 8000

Claude Desktop (本地)

{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["mcp-nanobanana-pro"],
      "env": {
        "ACEDATACLOUD_API_TOKEN": "your_token_here"
      }
    }
  }
}

Docker (自托管)

docker pull ghcr.io/acedatacloud/mcp-nanobanana-pro:latest
docker run -p 8000:8000 ghcr.io/acedatacloud/mcp-nanobanana-pro:latest

客户端使用自己的 Bearer 令牌进行连接 —— 服务器会从每个请求的 Authorization 标头中提取令牌。

可用工具

图像生成

工具

描述

nanobanana_generate_image

根据文本提示生成图像

nanobanana_edit_image

使用 AI 编辑或组合图像

任务

工具

描述

nanobanana_get_task

查询单个任务状态

nanobanana_get_tasks_batch

一次查询多个任务

使用示例

根据提示生成图像

User: Create an image of a sunset over mountains

Claude: I'll generate that image for you.
[Calls nanobanana_generate_image with detailed prompt]

虚拟试穿

User: Put this shirt on this model
[Provides two image URLs]

Claude: I'll combine these images.
[Calls nanobanana_edit_image with both image URLs]

产品摄影

User: Place this product in a modern kitchen scene
[Provides product image URL]

Claude: I'll create a product scene for you.
[Calls nanobanana_edit_image with scene description]

提示词编写技巧

为了获得最佳效果,请在提示词中包含以下要素:

  • 主体: 主要焦点是什么?

  • 氛围: 图像应传达什么情绪?

  • 光照: 场景是如何照明的?

  • 相机/镜头: 什么摄影风格?(85mm 人像、广角等)

  • 质量关键词: 技术描述符(焦外成像、胶片颗粒、HDR 等)

提示词示例

A photorealistic close-up portrait of an elderly Japanese ceramicist
with deep wrinkles and a warm smile. Soft golden hour light streaming
through a window. Captured with an 85mm portrait lens, soft bokeh
background. Serene and masterful mood.

配置

环境变量

变量

描述

默认值

ACEDATACLOUD_API_TOKEN

来自 AceDataCloud 的 API 令牌

必需

ACEDATACLOUD_API_BASE_URL

API 基础 URL

https://api.acedata.cloud

ACEDATACLOUD_OAUTH_CLIENT_ID

OAuth 客户端 ID(托管模式)

—

ACEDATACLOUD_PLATFORM_BASE_URL

平台基础 URL

https://platform.acedata.cloud

NANOBANANA_REQUEST_TIMEOUT

请求超时(秒)

1800

LOG_LEVEL

日志级别

INFO

命令行选项

mcp-nanobanana-pro --help

Options:
  --version          Show version
  --transport        Transport mode: stdio (default) or http
  --port             Port for HTTP transport (default: 8000)

开发

设置开发环境

# Clone repository
git clone https://github.com/AceDataCloud/NanoBananaMCP.git
cd NanoBananaMCP

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # or `.venv\Scripts\activate` on Windows

# Install with dev dependencies
pip install -e ".[dev,test]"

运行测试

# Run unit tests
pytest

# Run with coverage
pytest --cov=core --cov=tools

# Run integration tests (requires API token)
pytest tests/test_integration.py -m integration

代码质量

# Format code
ruff format .

# Lint code
ruff check .

# Type check
mypy core tools

构建与发布

# Install build dependencies
pip install -e ".[release]"

# Build package
python -m build

# Upload to PyPI
twine upload dist/*

项目结构

NanoBanana/
├── core/                   # Core modules
│   ├── __init__.py
│   ├── client.py          # HTTP client for NanoBanana API
│   ├── config.py          # Configuration management
│   ├── exceptions.py      # Custom exceptions
│   ├── server.py          # MCP server initialization
│   ├── types.py           # Type definitions
│   └── utils.py           # Utility functions
├── tools/                  # MCP tool definitions
│   ├── __init__.py
│   ├── image_tools.py     # Image generation/editing tools
│   └── task_tools.py      # Task query tools
├── prompts/                # MCP prompt templates
│   └── __init__.py
├── tests/                  # Test suite
├── deploy/                 # Deployment configs
│   └── production/
│       ├── deployment.yaml
│       ├── ingress.yaml
│       └── service.yaml
├── .env.example           # Environment template
├── .gitignore
├── Dockerfile             # Docker image for HTTP mode
├── docker-compose.yaml    # Docker Compose config
├── LICENSE
├── main.py                # Entry point
├── pyproject.toml         # Project configuration
└── README.md

API 参考

此服务器封装了 AceDataCloud NanoBanana API:

用例

  • 人像增强 - 在同一个人身上尝试不同的服装

  • 产品场景合成 - 将白色背景的产品放置在逼真的环境中

  • 属性替换 - 更改材质、颜色或变体

  • 海报快速编辑 - 快速更改风格或主题

  • 2D 转 3D - 将图像转换为 3D 产品模型

  • 图像修复 - 修复旧照片或损坏的照片

贡献

欢迎贡献!请:

  1. Fork 本仓库

  2. 创建功能分支 (git checkout -b feature/amazing)

  3. 提交您的更改 (git commit -m 'Add amazing feature')

  4. 推送到分支 (git push origin feature/amazing)

  5. 开启 Pull Request

许可证

MIT 许可证 - 详情请参阅 LICENSE。

链接


由 AceDataCloud 用心制作

Available Tools

4 tools
nanobanana_edit_imageAInspect

Edit or combine images using AI based on a text prompt.

This allows you to modify existing images or combine multiple images together.
Perfect for virtual try-on, product placement, image enhancement, and more.

Use this when:
- You want to combine multiple images (e.g., person + clothing)
- You want to modify an existing image
- You need virtual try-on (putting clothes on a person)
- You want to place products in different scenes
- You need to change attributes (materials, colors, styles)

Common use cases:
- Portrait replacement: Try different clothing on same person
- Product scene composition: Place products in realistic environments
- Attribute replacement: Change materials, colors, or variants
- Poster editing: Rapidly change styles or themes
- 2D to 3D conversion: Convert images to 3D product mockups
- Image restoration: Restore old or damaged photos

Returns:
    Task ID, trace ID, and edited image URL.

Inputs: prompt (required), image_urls (required), callback_url. Returns: result

nanobanana_generate_imageAInspect

Generate an AI image from a text prompt using Google's Nano Banana model.

This creates high-quality images from detailed text descriptions. The more
descriptive your prompt, the better the results.

Use this when:
- You want to generate a new image from scratch
- You have a detailed description of the desired image
- You need photorealistic or artistic image generation

Prompt writing tips:
- Include: Main subject + Atmosphere + Lighting + Camera/Lens + Quality keywords
- Example: "Urban career woman, backlit sunlight, film grain, orange-gold tones, hopeful dawn"

Returns:
    Task ID, trace ID, and generated image URL.

Inputs: prompt (required), callback_url. Returns: result

nanobanana_get_taskAInspect

Query the status and result of an image generation or edit task.

Use this to check if a generation/edit is complete and retrieve the resulting
image URLs and metadata.

Use this when:
- You want to check if an image generation has completed
- You need to retrieve image URLs from a previous generation
- You want to get the full details of a generated/edited image

Returns:
    Task status and image information including URLs and prompts.

Inputs: task_id (required). Returns: result

nanobanana_get_tasks_batchAInspect

Query multiple image generation/edit tasks at once.

Efficiently check the status of multiple tasks in a single request.
More efficient than calling nanobanana_get_task multiple times.

Use this when:
- You have multiple pending generations to check
- You want to get status of several images at once
- You're tracking a batch of generations

Returns:
    Status and image information for all queried tasks.

Inputs: task_ids (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: generate_image creates new images from prompts, edit_image modifies or combines existing images, get_task retrieves single task results, and get_tasks_batch retrieves multiple task results. The descriptions reinforce these distinct roles, making tool selection unambiguous.

    Naming Consistency5/5

    All tools follow a consistent snake_case pattern with the prefix 'nanobanana_' followed by a clear verb_noun combination (edit_image, generate_image, get_task, get_tasks_batch). The naming convention is perfectly uniform across all four tools, making them predictable and easy to understand.

    Tool Count5/5

    Four tools is well-scoped for an image generation/editing server, covering core operations: generation, editing, and status retrieval (both single and batch). Each tool earns its place without redundancy, providing a complete yet manageable surface for the domain.

    Completeness4/5

    The tool set covers the essential lifecycle of image tasks: create (generate_image), modify (edit_image), and retrieve results (get_task and get_tasks_batch). A minor gap exists in lacking explicit deletion or management tools for tasks, but agents can work around this as the core workflows are fully supported.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers