
一个MCP(模型上下文协议)服务器实现,用于使用 Replicate 的黑森林实验室/流动-施奈尔模型生成图像。
概览
一个MCP(模型上下文协议)服务器实现,用于使用 Replicate 的黑森林实验室/流动-施奈尔模型生成图像。 理想情况下,它应与光标的MCP功能一起使用,但也可以与任何MCP客户端一起使用。 - 从文本提示生成图像 - 可配置图像参数(分辨率、宽高比、质量) - 将生成图像保存到指定目录 - 完全符合MCP协议标准 - 错误处理与验证 - Node.js 16+ - 复制API令牌 - MCP用TypeScript SDK 1. 克隆仓库 2.安装依赖:3. 通过更新 apiToken 常量,直接在代码中的 src/imageService.ts 添加你的复制 API 令牌: 如果用 Claude,你可以在根目录创建一个 .env 文件,然后在那里设置你的 API 令牌: 使用光标:1. 进入设置 2.选择功能 3.向下滚动到“MCP 服务器” 4.点击“添加新MCP服务器” 5.将类型设置为“命令” 6.将命令设置为:node ./path/to/dist/server.js 服务器处理以下错误类型:
概述(AI 翻译)
一个MCP(模型上下文协议)服务器实现,用于使用 Replicate black-forest-labs/flux-schnell 模型生成图像。
理想情况下,它应与光标的MCP功能一起使用,但也可以与任何MCP客户端一起使用。
特色
- 从文本提示生成图片
- 可配置图像参数(分辨率、宽高比、质量)
- 将生成的图像保存到指定目录
- 全面符合MCP协议
- 错误处理与验证
先修条件
- Node.js 16+
- 复制API令牌
- MCP 用 TypeScript SDK
布置
-
克隆仓库
-
安装依赖:
-
通过更新
apiToken常数,直接在代码中添加你的复制 API 令牌:
注意: 如果搭配 Claude 使用,你可以在根目录创建一个
.env文件,并在那里设置你的 API 令牌:
然后构建项目:
用途
用于光标:
- 进入设置
- 选择功能
- 向下滚动至“MCP 服务器”
- 点击“添加新的MCP服务器”
- 将类型设置为“命令”
- 将命令设置为:
node ./path/to/dist/server.js
API 参数
|参数 |类型 |必需 |默认 |描述 |
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Image Generation MCP Server
An MCP (Model Context Protocol) server implementation for generating images using Replicate’s black-forest-labs/flux-schnell model.
Ideally to be used with Cursor’s MCP feature, but can be used with any MCP client.
Features
- Generate images from text prompts
- Configurable image parameters (resolution, aspect ratio, quality)
- Save generated images to specified directory
- Full MCP protocol compliance
- Error handling and validation
Prerequisites
- Node.js 16+
- Replicate API token
- TypeScript SDK for MCP
Setup
-
Clone the repository
-
Install dependencies:
npm install -
Add your Replicate API token directly in the code at
src/imageService.tsby updating theapiTokenconstant:// No environment variables are used since they can't be easily set in cursor const apiToken = "your-replicate-api-token-here";Note: If using with Claude, you can create a
.envfile in the root directory and set your API token there:REPLICATE_API_TOKEN=your-replicate-api-token-hereThen build the project:
npm run build
Usage
To use with cursor:
- Go to Settings
- Select Features
- Scroll down to “MCP Servers”
- Click “Add new MCP Server”
- Set Type to “Command”
- Set Command to:
node ./path/to/dist/server.js
API Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | Yes | - | Text prompt for image generation |
output_dir |
string | Yes | - | Server directory path to save generated images |
go_fast |
boolean | No | false | Enable faster generation mode |
megapixels |
string | No | “1” | Resolution quality (“1”, “2”, “4”) |
num_outputs |
number | No | 1 | Number of images to generate (1-4) |
aspect_ratio |
string | No | “1:1” | Aspect ratio (“1:1”, “4:3”, “16:9”) |
output_format |
string | No | “webp” | Image format (“webp”, “png”, “jpeg”) |
output_quality |
number | No | 80 | Compression quality (1-100) |
num_inference_steps |
number | No | 4 | Number of denoising steps (4-20) |
Example Request
{
"prompt": "black forest gateau cake spelling out 'FLUX SCHNELL'",
"output_dir": "/var/output/images",
"filename": "black_forest_cake",
"output_format": "webp"
"go_fast": true,
"megapixels": "1",
"num_outputs": 2,
"aspect_ratio": "1:1"
}
Example Response
{
"image_paths": [
"/var/output/images/output_0.webp",
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →