> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xhuoapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Nano Banana MCP 對接指南

> nanobanana MCP 服务器集成

[MCP（Model Context Protocol）](https://modelcontextprotocol.io) 是由 Anthropic 推出的模型上下文協議，允許 AI 模型（如 Claude、GPT 等）通過標準化接口調用外部工具。通過 XHuoAPI 提供的 Nano Banana MCP Server，你可以在 Claude Desktop、VS Code、Cursor 等 AI 客戶端中直接生成和編輯 AI 圖像。

## 功能概覽

Nano Banana MCP Server 提供以下核心功能：

* **圖像生成** — 通過文本提示詞生成高質量圖像
* **圖像編輯** — 修改已有圖像或組合多張圖像
* **虛擬試衣** — 將服裝穿戴到人物照片上
* **產品植入** — 將產品置於真實場景中
* **多模型支持** — 支持 nano-banana、nano-banana-2 和 nano-banana-pro 模型
* **任務查詢** — 監控生成進度並獲取結果

## 前置準備

使用前，你需要獲取 XHuoAPI API Token：

1. 註冊或登錄 [XHuoAPI 平台](https://api.xhuoapi.ai)
2. 前往 [Nano Banana Images API](https://api.xhuoapi.ai/documents/nano-banana-images) 頁面
3. 點擊「Acquire」獲取 API Token（首次申請贈送免費額度）

## 安裝配置

### 方式一：pip 安裝（推薦）

```bash theme={null}
pip install mcp-nanobanana-pro
```

### 方式二：源碼安裝

```bash theme={null}
git clone https://github.com/XHuoAPI/NanoBananaMCP.git
cd NanoBananaMCP
pip install -e .
```

安裝完成後，即可使用 `mcp-nanobanana-pro` 命令啟動服務。

## 在 Claude Desktop 中使用

編輯 Claude Desktop 配置文件：

* **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
* **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

添加以下配置：

```json theme={null}
{
  "mcpServers": {
    "nanobanana": {
      "command": "mcp-nanobanana-pro",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

如果使用 `uvx`（無需提前安裝包）：

```json theme={null}
{
  "mcpServers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["mcp-nanobanana-pro"],
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

保存配置後重啟 Claude Desktop，即可在對話中使用 Nano Banana 相關工具。

## 在 VS Code / Cursor 中使用

在項目根目錄創建 `.vscode/mcp.json`：

```json theme={null}
{
  "servers": {
    "nanobanana": {
      "command": "mcp-nanobanana-pro",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

或者使用 `uvx`：

```json theme={null}
{
  "servers": {
    "nanobanana": {
      "command": "uvx",
      "args": ["mcp-nanobanana-pro"],
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

## 可用工具列表

| 工具名                          | 說明          |
| ---------------------------- | ----------- |
| `nanobanana_generate_image`  | 通過文本提示詞生成圖像 |
| `nanobanana_edit_image`      | 編輯或組合已有圖像   |
| `nanobanana_get_task`        | 查詢單個任務狀態    |
| `nanobanana_get_tasks_batch` | 批量查詢任務狀態    |

## 使用示例

配置完成後，你可以在 AI 客戶端中直接用自然語言調用這些功能，例如：

* 「幫我生成一張水彩風格的山水畫」
* 「把這件衣服 PS 到這個人身上」
* 「將這個產品放到一個咖啡廳場景中」
* 「用 nano-banana-pro 模型生成一張高質量人像」

## 更多信息

* GitHub 倉庫：[XHuoAPI/NanoBananaMCP](https://github.com/XHuoAPI/NanoBananaMCP)
* PyPI 包：[mcp-nanobanana-pro](https://pypi.org/project/mcp-nanobanana-pro/)
* API 文檔：[Nano Banana API](https://api.xhuoapi.ai/documents/nano-banana)
