Back to MCP directory
publicPublicdnsLocal runtime

flux-image-mcp-server

Flux Image MCP Server是一个基于Flux Schnell模型的图像生成服务,通过Replicate平台提供API接口,支持通过文本描述生成图像。

article

README

🚀 使用Flux Schnell模型通过Replicate生成图像的Flux Image MCP服务器

本MCP服务器借助Flux Schnell模型,在Replicate平台上实现图像生成功能,为用户提供便捷的图像生成服务。

🚀 快速开始

以下是使用该服务器的详细步骤:

  1. 全局安装MCP SDK
npm install -g @modelcontextprotocol/sdk@latest
  1. 克隆仓库并安装依赖
cd ~/Documents/Cline/MCP
git clone https://github.com/yourusername/flux-img-mcp.git
cd flux-img-mcp
npm install
  1. 构建服务器
npm run build
  1. 添加服务器配置到MCP设置文件 将以下配置添加到您的MCP设置文件(全局或工作区)中:
{
  "mcpServers": {
    "flux-img": {
      "command": "node",
      "args": ["/path/to/flux-img-mcp/build/index.js"],
      "env": {
        "REPLICATE_API_TOKEN": "your-replicate-api-token"
      },
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

📦 安装指南

配置要求

服务器运行需要以下环境变量:

💻 使用示例

基础用法

安装完成后,可按如下方式配置工具以生成图像:

<use_mcp_tool>
<server_name>flux-img</server_name>
<tool_name>generate_image</tool_name>
<arguments>
{
  "prompt": "A beautiful sunset over mountains"
}
</arguments>
</use_mcp_tool>

上述代码中,prompt 参数用于描述所需图像的文本。工具将返回一个JSON响应,包含以下内容:

  • status:生成请求的状态。
  • output:生成图像的URL(如果成功)。
  • error:任何错误信息(如果失败)。

📚 详细文档

开发指南

若需对服务器进行修改,可按以下步骤操作:

  1. 修改源代码:在 src/index.ts 文件中进行修改。
  2. 重建服务器:执行 npm run build 命令。
  3. 重启MCP服务器:使更改生效。

错误处理

服务器具备全面的错误处理功能,可处理以下情况:

  • 缺少API令牌。
  • 参数无效。
  • API请求失败。
  • 网络问题。

安全注意事项

  • 切勿将Replicate API令牌提交到版本控制系统。
  • 始终通过环境变量提供令牌。
  • 服务器会对所有输入参数进行验证,确保使用安全。
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