Back to MCP directory
publicPublicdnsLocal runtime

flux-schnell-mcp

基于MCP协议的Flux Schnell图片生成服务器,通过Replicate API实现AI绘图功能

article

README

🚀 基于MCP的Flux Schnell图片生成服务器

这是一个基于MCP(模型上下文协议)的服务器,可借助Replicate API调用Flux Schnell模型来生成图片,为图片生成需求提供了便捷的解决方案。

🚀 快速开始

本服务器基于MCP协议,通过Replicate API调用Flux Schnell模型,能根据用户输入的文本提示词生成相应的图片。

✨ 主要特性

  • 提供generate_image工具用于生成图片。
  • 支持自定义文本提示词,让生成的图片更符合您的需求。
  • 自动处理与Replicate API的通信,无需手动干预。
  • 具备完整的错误处理和响应机制,确保使用过程的稳定性。

📦 安装指南

前置要求

  1. Node.js (v14或更高版本)
  2. Replicate API Token
  3. MCP兼容的环境(如Claude Desktop)

获取Replicate API Token

  1. 访问 Replicate官网 并注册账号。
  2. 登录后访问 API Tokens页面
  3. 点击"Create API token"创建新的token。
  4. 复制生成的token(格式如:r8_xxxxxx)。

安装步骤

  1. 克隆项目并安装依赖:
git clone [repository-url]
cd flux-schnell-mcp
npm install
  1. 构建服务器:
npm run build

📚 详细文档

配置

Claude Desktop配置

  1. 打开配置文件:

    • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%/Claude/claude_desktop_config.json
  2. 添加服务器配置:

{
  "mcpServers": {
    "flux-schnell": {
      "command": "node",
      "args": ["/path/to/flux-schnell-mcp/build/index.js"],
      "env": {
        "REPLICATE_API_TOKEN": "your-replicate-api-token"
      },
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

VSCode Roo配置

  1. 打开配置文件:

    • Linux: ~/.vscode-remote/data/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
    • MacOS: ~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
    • Windows: %APPDATA%/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
  2. 添加与上述相同的服务器配置。

使用方法

服务器提供了一个名为generate_image的工具,可以通过MCP调用:

<use_mcp_tool>
<server_name>flux-schnell</server_name>
<tool_name>generate_image</tool_name>
<arguments>
{
  "prompt": "a beautiful sunset over the ocean, digital art style"
}
</arguments>
</use_mcp_tool>

参数说明

  • prompt: 用于生成图片的文本描述(必填)
    • 建议使用详细的描述以获得更好的生成效果。
    • 可包含风格、场景、细节等信息。

响应格式

服务器将返回Replicate API的完整响应,包括生成的图片URL和其他元数据。

调试

由于MCP服务器通过stdio通信,调试可能较为困难。推荐使用MCP Inspector

npm run inspector

Inspector将提供一个URL,可在浏览器中访问调试工具。

⚠️ 重要提示

  1. 请妥善保管您的Replicate API Token,不要将其分享给他人。
  2. 确保在配置文件中使用正确的文件路径。
  3. 生成图片可能需要一些时间,请耐心等待响应。
  4. 如遇到错误,请检查API Token是否正确以及网络连接是否正常。
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client