Replicate Flux生成器
用于复制通量模型的MCP。通过提示生成图像。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"image-generation-mcp": {
"args": [
"/Users/{USERNAME}/{PATH_TO}/replicate-flux-mcp/build/index.js"
],
"command": "npx",
"env": {
"REPLICATE_API_TOKEN": "YOUR REPLICATE API TOKEN"
}
},
"replicate-flux-mcp": {
"args": [
"-y",
"replicate-flux-mcp"
],
"command": "env REPLICATE_API_TOKEN=YOUR_TOKEN npx"
}
}
}
该服务需要配置环境变量:REPLICATE_API_TOKEN
服务介绍
复制 Flux MCP
复制 Flux MCP 是一个先进的模型上下文协议 (MCP) 服务器,它使 AI 助手能够生成高质量的图像和矢量图形。通过 Replicate API 利用 Black Forest Labs 的 Flux Schnell 模型 生成光栅图像,并利用 Recraft 的 V3 SVG 模型 生成矢量图形。
📑 目录
🚀 开始使用 & 集成
设置过程
-
获取 Replicate API 令牌
- 在 Replicate 注册
- 在账户设置中创建一个 API 令牌
-
选择您的集成方法
- 根据您首选的 MCP 客户端,选择以下集成选项之一
-
请求您的 AI 助手生成图像
- 简单地自然提问:“你能生成一幅宁静的山景日落图像吗?”
- 或者更具体一些:“请创建一幅展示平静山景的图像,前景中有湖水反射出日落的颜色”
-
探索高级功能
- 尝试不同的参数设置以获得定制结果
- 使用
generate_svg试验 SVG 生成 - 使用批量图像生成或变体生成功能
Cursor 集成
方法 1:使用 mcp.json
- 在项目目录中创建或编辑
.cursor/mcp.json文件:
{
"mcpServers": {
"replicate-flux-mcp": {
"command": "env REPLICATE_API_TOKEN=YOUR_TOKEN npx",
"args": ["-y", "replicate-flux-mcp"]
}
}
}
- 将
YOUR_TOKEN替换为您的实际 Replicate API 令牌 - 重启 Cursor 以应用更改
方法 2:手动模式
- 打开 Cursor 并进入设置
- 导航到 "MCP" 或 "模型上下文协议" 部分
- 点击 "添加服务器" 或等效按钮
- 在适当字段中输入以下命令:
env REPLICATE_API_TOKEN=YOUR_TOKEN npx -y replicate-flux-mcp
- 将
YOUR_TOKEN替换为您的实际 Replicate API 令牌 - 保存设置,如果需要的话重启 Cursor
Claude 桌面集成
- 在配置目录中创建或编辑
mcp.json文件:
{
"mcpServers": {
"replicate-flux-mcp": {
"command": "npx",
"args": ["-y", "replicate-flux-mcp"],
"env": {
"REPLICATE_API_TOKEN": "YOUR TOKEN"
}
}
}
}
- 将
YOUR_TOKEN替换为您的实际 Replicate API 令牌 - 重启 Claude 桌面应用以使更改生效
Smithery 集成
此 MCP 服务器作为托管服务在 Smithery 上提供,允许您无需自己设置服务器即可使用它。
- 访问 Smithery 并创建一个帐户(如果您还没有的话)
- 导航到 Replicate Flux MCP 服务器页面
- 点击“添加到工作区”将服务器添加到您的 Smithery 工作区
- 配置您的 MCP 客户端(Cursor、Claude 桌面版等)以使用您的 Smithery 工作区 URL
有关如何将 Smithery 与您的 MCP 客户端一起使用的更多信息,请访问 Smithery 文档。
Glama.ai 集成
此 MCP 服务器也作为托管服务在 Glama.ai 上提供,为您提供另一种无需本地设置即可使用的选项。
- 访问 Glama.ai 并创建一个帐户(如果您还没有的话)
- 前往 Replicate Flux MCP 服务器页面
- 点击“安装服务器”将其添加到您的工作区
- 配置您的 MCP 客户端以使用您的 Glama.ai 工作区
欲了解更多信息,请访问 Glama.ai MCP 服务器文档。
🌟 功能亮点
- 🖼️ 高质量图像生成 - 使用先进的 AI 模型 Flux Schnell 创建令人惊叹的图片
- 🎨 支持矢量图形 - 通过 Recraft V3 SVG 模型生成专业的 SVG 矢量图形
- 🤖 AI 助手集成 - 无缝启用像 Claude 这样的 AI 助手来生成视觉内容
- 🎛️ 高级自定义 - 通过控制宽高比、质量、分辨率等参数精细调整生成效果
- 🔌 通用 MCP 兼容性 - 与所有 MCP 客户端兼容,包括 Cursor、Claude 桌面版、Cline 和 Zed
- 🔒 安全本地处理 - 所有请求都在本地处理,增强隐私和安全性
- 🔍 全面的历史记录管理 - 跟踪、查看并检索完整的生成历史
- 📊 批量处理 - 从单个请求中的不同提示生成多张图片
- 🔄 变体探索 - 为同一概念创建并比较多个解释
- ✏️ 提示工程 - 通过专门的提示修改微调图片变化
📚 文档
可用工具
generate_image
基于文本提示使用 Flux Schnell 模型生成图片。
{
prompt: string; // Required: Text description of the image to generate
seed?: number; // Optional: Random seed for reproducible generation
go_fast?: boolean; // Optional: Run faster predictions with optimized model (default: true)
megapixels?: "1" | "0.25"; // Optional: Image resolution (default: "1")
num_outputs?: number; // Optional: Number of images to generate (1-4) (default: 1)
aspect_ratio?: string; // Optional: Aspect ratio (e.g., "16:9", "4:3") (default: "1:1")
output_format?: string; // Optional: Output format ("webp", "jpg", "png") (default: "webp")
output_quality?: number; // Optional: Image quality (0-100) (default: 80)
num_inference_steps?: number; // Optional: Number of denoising steps (1-4) (default: 4)
disable_safety_checker?: boolean; // Optional: Disable safety filter (default: false)
}
generate_multiple_images
基于一组提示使用 Flux Schnell 模型生成多张图片。
{
prompts: string[]; // Required: Array of text descriptions for images to generate (1-10 prompts)
seed?: number; // Optional: Random seed for reproducible generation
go_fast?: boolean; // Optional: Run faster predictions with optimized model (default: true)
megapixels?: "1" | "0.25"; // Optional: Image resolution (default: "1")
aspect_ratio?: string; // Optional: Aspect ratio (e.g., "16:9", "4:3") (default: "1:1")
output_format?: string; // Optional: Output format ("webp", "jpg", "png") (default: "webp")
output_quality?: number; // Optional: Image quality (0-100) (default: 80)
num_inference_steps?: number; // Optional: Number of denoising steps (1-4) (default: 4)
disable_safety_checker?: boolean; // Optional: Disable safety filter (default: false)
}
generate_image_variants
根据单一提示生成同一图片的多个变体。
{
prompt: string; // Required: Text description for the image to generate variants of
num_variants: number; // Required: Number of image variants to generate (2-10, default: 4)
prompt_variations?: string[]; // Optional: List of prompt modifiers to apply to variants (e.g., ["in watercolor style", "in oil painting style"])
variation_mode?: "append" | "replace"; // Optional: How to apply variations - 'append' adds to base prompt, 'replace' uses variations directly (default: "append")
seed?: number; // Optional: Base random seed. Each variant will use seed+variant_index
go_fast?: boolean; // Optional: Run faster predictions with optimized model (default: true)
megapixels?: "1" | "0.25"; // Optional: Image resolution (default: "1")
aspect_ratio?: string; // Optional: Aspect ratio (e.g., "16:9", "4:3") (default: "1:1")
output_format?: string; // Optional: Output format ("webp", "jpg", "png") (default: "webp")
output_quality?: number; // Optional: Image quality (0-100) (default: 80)
num_inference_steps?: number; // Optional: Number of denoising steps (1-4) (default: 4)
disable_safety_checker?: boolean; // Optional: Disable safety filter (default: false)
}
generate_svg
基于文本提示生成 SVG 图形。
根据文本提示使用 Recraft V3 SVG 模型生成一个 SVG 矢量图像。
{
prompt: string; // Required: Text description of the SVG to generate
size?: string; // Optional: Size of the generated SVG (default: "1024x1024")
style?: string; // Optional: Style of the generated image (default: "any")
// Options: "any", "engraving", "line_art", "line_circuit", "linocut"
}
prediction_list
从 Replicate 获取您的最近预测列表。
{
limit?: number; // Optional: Maximum number of predictions to return (1-100) (default: 50)
}
get_prediction
获取有关特定预测的详细信息。
{
predictionId: string; // Required: ID of the prediction to retrieve
}
可用资源
imagelist
浏览使用 Flux Schnell 模型生成的图像历史记录。
svglist
浏览使用 Recraft V3 SVG 模型生成的 SVG 图像历史记录。
predictionlist
浏览所有您的 Replicate 预测历史记录。
💻 开发
- 克隆仓库:
git clone https://github.com/yourusername/replicate-flux-mcp.git
cd replicate-flux-mcp
- 安装依赖项:
npm install
- 启动开发模式:
npm run dev
- 构建项目:
npm run build
- 连接到客户端:
{
"mcpServers": {
"image-generation-mcp": {
"command": "npx",
"args": [
"/Users/{USERNAME}/{PATH_TO}/replicate-flux-mcp/build/index.js"
],
"env": {
"REPLICATE_API_TOKEN": "YOUR REPLICATE API TOKEN"
}
}
}
}
⚙️ 技术细节
技术栈
- 模型上下文协议 SDK - 为核心 MCP 功能提供工具和资源管理
- Replicate API - 提供访问最先进的 AI 图像生成模型
- TypeScript - 确保类型安全并利用现代 JavaScript 特性
- Zod - 实现运行时类型验证,以确保稳健的 API 交互
配置
可以通过修改 src/config/index.ts 中的 CONFIG 对象来配置服务器:
const CONFIG = {
serverName: "replicate-flux-mcp",
serverVersion: "0.1.2",
imageModelId: "black-forest-labs/flux-schnell",
svgModelId: "recraft-ai/recraft-v3-svg",
pollingAttempts: 25,
pollingInterval: 2000, // ms
};
🔍 故障排除
常见问题
身份验证错误
- 确保环境中的
REPLICATE_API_TOKEN正确设置 - 通过直接测试 Replicate API 来验证令牌是否有效
安全过滤器触发
- 模型内置的安全过滤器可能会阻止某些提示
- 尝试修改您的提示以避免潜在的问题内容
超时错误
- 对于较大的图像或繁忙的服务器,您可能需要增加配置中的
pollingAttempts或pollingInterval - 默认设置应适用于大多数情况
🤝 贡献
欢迎贡献!请按照以下步骤进行贡献:
- 分叉仓库
- 创建您的功能分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 打开拉取请求
对于功能请求或 bug 报告,请创建一个 GitHub 问题。如果您喜欢这个项目,请考虑给仓库加星!
📄 许可证
此项目根据 MIT 许可证发布 - 详情请参阅 LICENSE 文件。
🔗 资源
- 模型上下文协议文档
- Replicate API 文档
- Flux Schnell 模型
- Recraft V3 SVG 模型
- MCP TypeScript SDK
- Smithery 文档
- Glama.ai MCP 服务器
🎨 示例
| 多个提示 | 提示变体 |
|---|---|
这里有一些如何使用这些工具的例子:
使用 generate_multiple_images 进行批量图像生成
一次创建多个具有不同提示的独特图像:
{
"prompts": [
"A red sports car on a mountain road",
"A blue sports car on a beach",
"A vintage sports car in a city street"
]
}
使用 generate_image_variants 创建图像变体
使用种子创建同一概念的不同解释:
{
"prompt": "A futuristic city skyline at night",
"num_variants": 4,
"seed": 42
}
或者通过提示修饰符探索风格变化:
{
"prompt": "A character portrait",
"prompt_variations": [
"in anime style",
"in watercolor style",
"in oil painting style",
"as a 3D render"
]
}
由 Yaroslav Boiko 用❤️制作