Flux图像生成器-MCP
一个MCP服务器,它基于文本提示使用Black Forest Lab的FLUX模型生成图像,允许自定义图像尺寸、提示超采样、安全设置和批量生成。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"flux-image-generator": {
"command": "mcp-server-flux-image-generator",
"env": {
"BFL_API_KEY": "your_api_key_here"
}
}
}
}
该服务需要配置环境变量:BFL_API_KEY
服务介绍
FLUX 图像生成器 MCP 服务器
这是一个使用 Black Forest Lab 的 FLUX 模型生成图像的 MCP(Model Context Protocol)服务器。使用最新的 MCP SDK (v1.7.0)。
特性
- 基于文本提示生成图像
- 自定义图像尺寸、提示上采样和安全设置
- 本地保存生成的图像
- 从多个提示批量生成图像
先决条件
- Node.js (v18.0.0 或更高版本)
- Black Forest Lab API 密钥(在 https://api.bfl.ml 获取)
安装
从源代码安装
- 克隆此仓库
- 安装依赖项:
npm install
- 根据
.env.example创建一个.env文件,并添加您的 Black Forest Lab API 密钥:
BFL_API_KEY=your_api_key_here
- 构建项目:
npm run build
使用 npm 安装
npm install -g @modelcontextprotocol/server-flux-image-generator
使用
启动 MCP 服务器
使用以下命令启动服务器:
npm start
对于带有自动重新编译功能的开发环境:
npm run watch
与 MCP 客户端集成
要将此服务器与 MCP 客户端(如 Claude)一起使用,请在客户端配置中添加以下内容:
{
"mcpServers": {
"flux-image-generator": {
"command": "mcp-server-flux-image-generator",
"env": {
"BFL_API_KEY": "your_api_key_here"
}
}
}
}
可用工具
generateImage
基于文本提示生成图像,并提供可自定义的设置。
参数:
prompt(字符串,必填):要生成图像的文本描述width(数字,可选,默认值: 1024):图像宽度(像素)height(数字,可选,默认值: 1024):图像高度(像素)promptUpsampling(布尔值,可选,默认值: false):通过上采样提示来增强细节seed(数字,可选):用于生成可重复结果的随机种子safetyTolerance(数字,可选,默认值: 3):内容审核容忍度(1-5)
示例:
{
"prompt": "A serene lake at sunset with mountains in the background",
"width": 1024,
"height": 768,
"promptUpsampling": true,
"seed": 12345,
"safetyTolerance": 3
}
quickImage
一个简化工具,用于快速生成默认设置的图像。
参数:
prompt(字符串,必填):要生成图像的文本描述
示例:
{
"prompt": "A futuristic cityscape with flying cars"
}
batchGenerateImages
从提示列表生成多张图像。
参数:
prompts(字符串数组,必填):文本提示列表(最多 10 个)width(数字,可选,默认值: 1024):图像宽度height(数字,可选,默认值: 1024):图像高度
示例:
{
"prompts": [
"A serene lake at sunset",
"A futuristic cityscape",
"A magical forest with glowing plants"
],
"width": 1024,
"height": 768
}
输出格式
所有工具返回的响应格式如下:
{
"image_url": "https://storage.example.com/generated_image.jpg",
"local_path": "/path/to/output/flux_1234567890.png"
}
对于错误:
{
"error": true,
"message": "Error description"
}
批量工具返回:
{
"total": 3,
"successful": 2,
"failed": 1,
"results": [
{
"prompt": "A serene lake at sunset",
"success": true,
"image_url": "https://storage.example.com/image1.jpg",
"local_path": "/path/to/output/flux_batch_1234567890_0.png"
},
{
"prompt": "A futuristic cityscape",
"success": true,
"image_url": "https://storage.example.com/image2.jpg",
"local_path": "/path/to/output/flux_batch_1234567890_1.png"
},
{
"prompt": "Prohibited content",
"success": false,
"error": "Content policy violation"
}
]
}
许可证
MIT