> ## 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.

# Flux MCP 對接指南

> flux MCP 服务器集成

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

## 功能概覽

Flux MCP Server 提供以下核心功能：

* **文本生成圖像** — 透過文本提示詞生成高品質圖像
* **圖像編輯** — 基於文本指令編輯已有圖像
* **多模型支援** — 支援 Flux Pro、Flux Dev、Flux Schnell、Flux Kontext 等多種模型
* **模型查詢** — 查看所有可用模型及其能力
* **任務查詢** — 監控生成進度並取得結果

## 前置準備

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

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

## 安裝配置

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

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

### 方式二：原始碼安裝

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

安裝完成後，即可使用 `mcp-flux-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": {
    "flux": {
      "command": "mcp-flux-pro",
      "env": {
        "XHuoAPI_API_TOKEN": "你的API Token"
      }
    }
  }
}
```

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

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

儲存配置後重新啟動 Claude Desktop，即可在對話中使用 Flux 相關工具。

## 在 VS Code / Cursor 中使用

在專案根目錄建立 `.vscode/mcp.json`：

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

或者使用 `uvx`：

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

## 可用工具列表

| 工具名                    | 說明              |
| ---------------------- | --------------- |
| `flux_generate_image`  | 透過文本提示詞生成圖像     |
| `flux_edit_image`      | 基於文本指令編輯已有圖像    |
| `flux_get_task`        | 查詢單一任務狀態        |
| `flux_get_tasks_batch` | 批次查詢任務狀態        |
| `flux_list_models`     | 列出所有可用模型及其能力    |
| `flux_list_actions`    | 列出所有可用工具和工作流程範例 |

## 使用範例

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

* 「幫我用 Flux 生成一張賽博朋克風格的城市夜景」
* 「把這張照片的背景改成海灘」
* 「用 Flux Kontext Pro 模型編輯這張圖片，把衣服顏色改成紅色」
* 「列出所有可用的 Flux 模型」

## 更多資訊

* GitHub 倉庫：[XHuoAPI/FluxMCP](https://github.com/XHuoAPI/FluxMCP)
* PyPI 套件：[mcp-flux-pro](https://pypi.org/project/mcp-flux-pro/)
* API 文件：[Flux 圖像生成 API](https://api.xhuoapi.ai/documents/flux)
