图像生成 MCP 服务器
使用 Replicate 的black-forest-labs/flux-schnell模型生成图像的MCP(模型上下文协议)服务器实现。
理想情况下与 Cursor 的 MCP 功能一起使用,但可以与任何 MCP 客户端一起使用。
特征
根据文本提示生成图像
可配置图像参数(分辨率、宽高比、质量)
将生成的图像保存到指定目录
完全符合 MCP 协议
错误处理和验证
先决条件
Node.js 16+
复制 API 令牌
适用于 MCP 的 TypeScript SDK
设置
克隆存储库
安装依赖项:
npm install通过更新
apiToken常量,直接在src/imageService.ts代码中添加您的 Replicate API 令牌:// No environment variables are used since they can't be easily set in cursor const apiToken = "your-replicate-api-token-here";**注意:**如果与 Claude 一起使用,您可以在根目录中创建一个
.env文件并在那里设置您的 API 令牌:REPLICATE_API_TOKEN=your-replicate-api-token-here然后构建项目:
npm run build
用法
与游标一起使用:
前往“设置”
选择功能
向下滚动到“MCP 服务器”
点击“添加新的 MCP 服务器”
将类型设置为“命令”
将命令设置为:
node ./path/to/dist/server.js
API 参数
范围 | 类型 | 必需的 | 默认 | 描述 |
| 细绳 | 是的 | - | 图像生成的文字提示 |
| 细绳 | 是的 | - | 保存生成的图像的服务器目录路径 |
| 布尔值 | 不 | 错误的 | 启用更快的生成模式 |
| 细绳 | 不 | “1” | 分辨率质量(“1”、“2”、“4”) |
| 数字 | 不 | 1 | 生成的图像数量(1-4) |
| 细绳 | 不 | “1:1” | 宽高比(“1:1”、“4:3”、“16:9”) |
| 细绳 | 不 | “webp” | 图像格式(“webp”、“png”、“jpeg”) |
| 数字 | 不 | 80 | 压缩质量(1-100) |
| 数字 | 不 | 4 | 去噪步数(4-20) |
示例请求
示例响应
错误处理
服务器处理以下错误类型:
验证错误(无效参数)
API 错误(重复 API 问题)
服务器错误(文件系统、权限)
未知错误(意外问题)
每个错误响应包括:
错误代码
人类可读的消息
详细错误信息
执照
国际学习中心
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
使用户能够使用 Replicate 的模型从文本提示生成图像,具有可配置的参数和完全的 MCP 协议兼容性。
Related Resources
Related MCP Servers
- Asecurity-licenseAqualityA Model Context Protocol server that provides image generation capabilities using the Ideogram API, allowing users to create images from text prompts with customizable parameters.Last updated -15
- Asecurity-licenseAqualityA MCP server that enables Claude and other MCP-compatible assistants to generate images from text prompts using Together AI's image generation models.Last updated -4MIT License
- -security-license-qualityProvides image generation capabilities using the Flux Schnell model on Replicate, allowing users to create images from text prompts.Last updated -1MIT License
- -security-license-qualityProvides image generation capabilities for Claude using the Replicate Flux model, allowing users to create images from text prompts with customizable parameters like aspect ratio and output format.Last updated -3840MIT License