Image Generation (Flux)

Image Generation (Flux)

🚀 图像生成 MCP 服务器

此 MCP 服务器借助 Replicate Flux 模型,为用户提供强大的图像生成功能,助力用户轻松实现各种图像创作需求。

MCP Server 徽章

smithery 徽章

🚀 快速开始

此 MCP 服务器使用 Replicate Flux 模型提供图像生成功能。下面将为你详细介绍安装、设置以及使用的步骤。

📦 安装指南

使用 Smithery 进行安装

通过 Smithery 可自动为 Claude Desktop 安装图像生成 MCP 服务器,操作命令如下:

npx -y @smithery/cli install @GongRzhe/Image-Generation-MCP-Server --client claude

方法一:NPX(无需本地设置)

直接从 npm 使用包而无需本地安装,npx 会自行处理相关操作:

# 无需安装,npx 自行处理

方法二:本地安装

若你需要进行本地安装,可参考以下命令:

# 全局安装
npm install -g @gongrzhe/image-gen-server

# 或者本地安装
npm install @gongrzhe/image-gen-server

🛠️ 设置

配置 Claude Desktop

你需要编辑 Claude Desktop 的配置文件,不同系统的配置文件路径如下:

  • 在 MacOS 上:~/Library/Application Support/Claude/claude_desktop_config.json
  • 在 Windows 上:%APPDATA%/Claude/claude_desktop_config.json

方法一:NPX 配置(推荐)

此方法可直接从 npm 运行服务器,无需本地文件,配置示例如下:

{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["@gongrzhe/image-gen-server"],
"env": {
"REPLICATE_API_TOKEN": "your-replicate-api-token",
"MODEL": "alternative-model-name"
},
"disabled": false,
"autoApprove": []
}
}
}

方法二:本地安装配置

如果你选择了本地安装,配置示例如下:

{
"mcpServers": {
"image-gen": {
"command": "node",
"args": ["/path/to/image-gen-server/build/index.js"],
"env": {
"REPLICATE_API_TOKEN": "your-replicate-api-token",
"MODEL": "alternative-model-name"
},
"disabled": false,
"autoApprove": []
}
}
}

获取你的 Replicate API Token

获取 Replicate API Token 的步骤如下:

  1. https://replicate.com 注册/登录。
  2. 前往 https://replicate.com/account/api-tokens
  3. 创建一个新的 API token。
  4. 复制该 token 并替换配置中的 your-replicate-api-token

图像

环境变量

  • REPLICATE_API_TOKEN(必填):用于身份验证的 Replicate API token。
  • MODEL(选填):指定要使用的模型,默认为 "stable-diffusion"

💻 使用示例

generate_image

该工具可生成图像并返回 URL 列表。

参数

{
"prompt": "输入你的提示词,例如:'一只飞翔的蓝鸟'",
"negative_prompt": "可选,输入负面提示词",
"width": 512,
"height": 512,
"samples": 1,
"num_images": 1
}

示例代码

const response = await fetch('http://localhost:4000/api/generate-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: "一只飞翔的蓝鸟",
negative_prompt: "",
width: 512,
height: 512,
samples: 1,
num_images: 1
})
});

const data = await response.json();
console.log(data.urls); // 输出 URL 列表

📄 许可证

此项目遵循 MIT License 进行开源。

  • 0 关注
  • 0 收藏,23 浏览
  • system 提出于 2025-10-01 07:39

相似服务问题

相关AI产品