
A Model Context Protocol (MCP) server that generates images using Replicate's FLUX model and stores them in Cloudflare R2.
概览
A Model Context Protocol (MCP) server that generates images using Replicate's FLUX model and stores them in Cloudflare R2. 使用 Replicate 的 FLUX 模型生成图片并存储到 Cloudflare R2 的模型上下文协议(MCP)服务器。 - Generate images using Replicate's black-forest-labs/flux-schnell model - Store generated images in Cloudflare R2 - Return accessible image URLs - Support for custom prompts and filenames - 使用 Replicate 的 black-forest-labs/flux-schnell 模型生成图片 - 将生成的图片存储到 Cloudflare R2 - 返回可访问的图片链接 - 支持自定义提示词和文件名 - Node.js (v16 or higher) - Replicate API token - Cloudflare R2 bucket and credentials - npm or yarn - Node.js(v16 或更高版本) - Replicate API 令牌 - Cloudflare R2 存储桶和凭证 - npm 或 yarn Required environment variables in .env file: To install MCP Replicate FLUX for Claude Desktop automatically via Smithery:
README
以下为原文 README 节选,完整内容请查看原文。
MCP Replicate FLUX
A Model Context Protocol (MCP) server that generates images using Replicate’s FLUX model and stores them in Cloudflare R2.
使用 Replicate 的 FLUX 模型生成图片并存储到 Cloudflare R2 的模型上下文协议(MCP)服务器。
Features 功能特点
-
Generate images using Replicate’s black-forest-labs/flux-schnell model
-
Store generated images in Cloudflare R2
-
Return accessible image URLs
-
Support for custom prompts and filenames
-
使用 Replicate 的 black-forest-labs/flux-schnell 模型生成图片
-
将生成的图片存储到 Cloudflare R2
-
返回可访问的图片链接
-
支持自定义提示词和文件名
Prerequisites 前置要求
-
Node.js (v16 or higher)
-
Replicate API token
-
Cloudflare R2 bucket and credentials
-
npm or yarn
-
Node.js(v16 或更高版本)
-
Replicate API 令牌
-
Cloudflare R2 存储桶和凭证
-
npm 或 yarn
Environment Variables 环境变量
Required environment variables in .env file:
.env 文件中需要的环境变量:
REPLICATE_API_TOKEN=your_replicate_token
STORAGE_ENDPOINT=your_r2_endpoint
STORAGE_ACCESS_KEY=your_r2_access_key
STORAGE_SECRET_KEY=your_r2_secret_key
STORAGE_BUCKET=your_bucket_name
STORAGE_DOMAIN=your_domain
Local Installation 本地安装
Installing via Smithery
To install MCP Replicate FLUX for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @andylee20014/mcp-replicate-flux --client claude
Installing manually
Follow these steps to set up the project locally:
按照以下步骤在本地设置项目:
# Clone the repository
git clone https://github.com/andylee20014/mcp-replicate-flux.git
cd mcp-replicate-flux
# Install dependencies
npm install
# Create .env file and add your credentials
cp .env.example .env
# Edit .env with your actual credentials
Make sure your Cloudflare R2 bucket has appropriate CORS settings for public access to the uploaded images.
确保您的 Cloudflare R2 存储桶具有适当的 CORS 设置,以允许公共访问上传的图片。
Running Locally 本地运行
To start the MCP server locally:
在本地启动 MCP 服务器:
node index.js
The server will start and listen for MCP protocol messages on standard input/output.
服务器将启动并通过标准输入/输出监听 MCP 协议消息。
Usage 使用方法
The server provides a generate-image tool that accepts two parameters:
prompt: The text prompt for image generationfilename: The desired filename for the generated image
服务器提供了一个 generate-image 工具,接受两个参数:
prompt:用于生成图片的文本提示词filename:生成的图片所需的文件名
Integration Example 集成示例
Here’s an example of how to integrate with this MCP server using the MCP client library:
以下是使用 MCP 客户端库与此 MCP 服务器集成的示例:
const { McpClient } = require('@modelcontextprotocol/sdk/client/mcp.js')
async function generateImage(prompt, filename) {
const client = new McpClient()
// Connect to your running MCP server
await client.connect(yourTransport)
const result = await client.tools.call('generate-image', {
prompt,
filename
})
安装
npx -y @smithery/cli install @andylee20014/mcp-replicate-flux --client claude配置
{
"mcpServers": {
"replicate-flux": {
"command": "node",
"args": ["C:\\Users\\YourUsername\\path\\to\\mcp-replicate-flux\\index.js"],
"description": "使用Replicate的FLUX模型生成图片并存储到Cloudflare R2的MCP服务器",
"env": {
"REPLICATE_API_TOKEN": "your_replicate_token",
"STORAGE_ENDPOINT": "your_r2_endpoint",
"STORAGE_ACCESS_KEY": "your_r2_access_key",
"STORAGE_SECRET_KEY": "your_r2_secret_key",
"STORAGE_BUCKET": "your_bucket_name",
"STORAGE_DOMAIN": "your_domain"
}
}
}
}