Replicate-Flux MCP Server
by newtype-01
A TypeScript-based MCP server for running the Flux AI image generation model on Replicate. It allows simple integration with MCP-compatible applications and customizable image generation parameters.
Last updated: N/A
Replicate-Flux MCP Server
English | 中文
A TypeScript-based MCP server for running the Flux AI image generation model on Replicate.
Features
- Generate images using the black-forest-labs/flux-dev model through Replicate
- Simple integration with any MCP-compatible application (Claude, etc.)
- Customizable image generation parameters
Quick Start
Prerequisites
- Node.js 18+ installed
- Replicate API token from https://replicate.com/account
Installation
- Clone this repository
- Install dependencies:
npm install
- Create a
.env
file with your Replicate API token:
REPLICATE_API_TOKEN=your_token_here
- Build the server:
npm run build
Running
Using Node directly
Run the server directly:
node build/index.js
Using npx
After installation, you can run the server via npx:
npx Replicate-Flux
Using Docker
Build the Docker image:
docker build -t replicate-flux .
Run the container (passing your API token):
docker run -e REPLICATE_API_TOKEN=your_token_here replicate-flux
Client Configuration
Claude and Other MCP Clients
Most MCP clients require configuration in their settings. Here are examples:
Using local installation
{
"mcpServers": {
"replicate-flux": {
"command": "/path/to/replicate-flux/build/index.js"
}
}
}
Using npx
{
"mcpServers": {
"replicate-flux": {
"command": "npx",
"args": ["Replicate-Flux"]
}
}
}
Using Docker
{
"mcpServers": {
"replicate-flux": {
"command": "docker",
"args": ["run", "--rm", "-e", "REPLICATE_API_TOKEN=your_token_here", "replicate-flux"]
}
}
}
Note: If you've already configured your environment variables in a .env
file or system-wide, you can omit the env
field in most configurations. However, for Docker, you'll still need to pass the environment variable through the container.
Environment Variables
This project requires the following environment variables:
REPLICATE_API_TOKEN
- Your Replicate API token
You can set this in a .env
file, in your system environment, or directly in your MCP client configuration.
Security Notes
- Never commit your
.env
file or any file containing API keys to version control - The
.gitignore
file is configured to exclude.env
files from Git - When deploying, set environment variables securely according to your hosting platform's instructions
Development
For development with auto-rebuild:
npm run watch
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:
npm run inspector
The Inspector will provide a URL to access debugging tools in your browser.
Replicate-Flux MCP 服务器
English | 中文
这是一个基于TypeScript的MCP服务器,用于在Replicate上运行Flux AI图像生成模型。
功能特点
- 使用Replicate上的black-forest-labs/flux-dev模型生成图像
- 与任何MCP兼容应用(如Claude等)简单集成
- 可自定义的图像生成参数
快速开始
前提条件
- 安装Node.js 18+
- 从https://replicate.com/account获取Replicate API令牌
安装
- 克隆此仓库
- 安装依赖:
npm install
- 创建一个包含Replicate API令牌的
.env
文件:
REPLICATE_API_TOKEN=你的令牌
- 构建服务器:
npm run build
运行方式
直接使用Node
直接运行服务器:
node build/index.js
使用npx
安装后,可以通过npx运行服务器:
npx Replicate-Flux
使用Docker
构建Docker镜像:
docker build -t replicate-flux .
运行容器(传入你的API令牌):
docker run -e REPLICATE_API_TOKEN=你的令牌 replicate-flux
客户端配置
Claude和其他MCP客户端
大多数MCP客户端需要在其设置中进行配置。以下是一些例子:
使用本地安装
{
"mcpServers": {
"replicate-flux": {
"command": "/path/to/replicate-flux/build/index.js"
}
}
}
使用npx
{
"mcpServers": {
"replicate-flux": {
"command": "npx",
"args": ["Replicate-Flux"]
}
}
}
使用Docker
{
"mcpServers": {
"replicate-flux": {
"command": "docker",
"args": ["run", "--rm", "-e", "REPLICATE_API_TOKEN=你的令牌", "replicate-flux"]
}
}
}
注意:如果你已经在.env
文件或系统环境中配置了环境变量,在大多数配置中可以省略env
字段。但对于Docker,你仍然需要通过容器传递环境变量。
环境变量
此项目需要以下环境变量:
REPLICATE_API_TOKEN
- 你的Replicate API令牌
你可以在.env
文件中设置、在系统环境中设置,或直接在MCP客户端配置中设置。
安全须知
- 切勿将
.env
文件或任何包含API密钥的文件提交到版本控制系统 .gitignore
文件已配置为从Git中排除.env
文件- 部署时,根据你的托管平台的说明安全地设置环境变量
开发
用于开发的自动重建:
npm run watch
调试
由于MCP服务器通过标准输入输出通信,调试可能具有挑战性。我们推荐使用MCP Inspector,可通过以下包脚本使用:
npm run inspector
Inspector将提供一个URL,让你在浏览器中访问调试工具。