Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Replicate Flux MCP

[English](README.md) | [中文](README.zh.md)

![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![TypeScript](https://img.shields.io/badge/TypeScript-4.9+-blue)
Expand All @@ -14,7 +16,7 @@
<img width="380" height="200" src="https://glama.ai/mcp/servers/ss8n1knen8/badge" />
</a>

**Replicate Flux MCP** is an advanced Model Context Protocol (MCP) server that empowers AI assistants to generate high-quality images and vector graphics. Leveraging [Black Forest Labs' Flux Schnell model](https://replicate.com/black-forest-labs/flux-schnell) for raster images and [Recraft's V3 SVG model](https://replicate.com/recraft-ai/recraft-v3-svg) for vector graphics via the Replicate API.
**Replicate Flux MCP** is an advanced Model Context Protocol (MCP) server that empowers AI assistants to generate high-quality images and vector graphics. By default it uses the free-tier models from Replicate’s **Try for Free** collection — [black-forest-labs/flux-1.1-pro](https://replicate.com/black-forest-labs/flux-1.1-pro) for raster images and [luma/reframe-video](https://replicate.com/luma/reframe-video) for SVG/video placeholder output. You can switch to higher-end models (e.g., [black-forest-labs/flux-schnell](https://replicate.com/black-forest-labs/flux-schnell) or [recraft-ai/recraft-v3-svg](https://replicate.com/recraft-ai/recraft-v3-svg)) via environment variables without code changes.

## 📑 Table of Contents

Expand All @@ -23,7 +25,8 @@
- [Cursor Integration](#cursor-integration)
- [Claude Desktop Integration](#claude-desktop-integration)
- [Smithery Integration](#smithery-integration)
- [Glama.ai Integration](#glamaai-integration)
- [Glama.ai Integration](#glamaai-integration)
- [Codex Integration](#codex-integration)
- [Features](#-features)
- [Documentation](#-documentation)
- [Available Tools](#available-tools)
Expand Down Expand Up @@ -133,6 +136,22 @@ This MCP server is also available as a hosted service on Glama.ai, providing ano

For more information, visit the [Glama.ai MCP servers documentation](https://glama.ai/mcp/servers).

### Codex Integration

Add the server to `~/.codex/config.toml`:

```toml
[mcp_servers.replicate]
command = "npx"
args = ["-y", "replicate-flux-mcp"]
env = { REPLICATE_API_TOKEN = "your-replicate-api-token", REPLICATE_IMAGE_MODEL_ID = "your-image-model-id", REPLICATE_SVG_MODEL_ID = "your-svg-model-id" }
startup_timeout_sec = 30_000
```

Replace the env values as needed. If you omit `REPLICATE_IMAGE_MODEL_ID` / `REPLICATE_SVG_MODEL_ID`, the defaults fall back to the Try for Free models so Codex can start the MCP server without paid credits.

You can browse currently free, trial-eligible models at Replicate's **Try for Free** collection: https://replicate.com/collections/try-for-free — pick any model IDs from there and drop them into the env vars above for quick experiments.

## 🌟 Features

- **🖼️ High-Quality Image Generation** - Create stunning images using Flux Schnell, a state-of-the-art AI model
Expand Down Expand Up @@ -311,19 +330,43 @@ npm run build

### Configuration

The server can be configured by modifying the `CONFIG` object in `src/config/index.ts`:
The server can be configured by modifying the `CONFIG` object in `src/config/index.ts` or by setting the `REPLICATE_IMAGE_MODEL_ID` / `REPLICATE_SVG_MODEL_ID` environment variables to override the defaults:

```javascript
const CONFIG = {
serverName: "replicate-flux-mcp",
serverVersion: "0.1.2",
imageModelId: "black-forest-labs/flux-schnell",
svgModelId: "recraft-ai/recraft-v3-svg",
// Defaults are free-tier models so npx works out of the box
imageModelId: process.env.REPLICATE_IMAGE_MODEL_ID ?? "black-forest-labs/flux-1.1-pro",
svgModelId: process.env.REPLICATE_SVG_MODEL_ID ?? "luma/reframe-video",
pollingAttempts: 25,
pollingInterval: 2000, // ms
};
```

#### Switching models (no code changes)

Use env vars when launching the server (works with `npx`, Cursor, Claude Desktop, etc.):

```bash
# Flux Schnell + Recraft SVG (paid models)
REPLICATE_IMAGE_MODEL_ID="black-forest-labs/flux-schnell" \
REPLICATE_SVG_MODEL_ID="recraft-ai/recraft-v3-svg" \
REPLICATE_API_TOKEN=YOUR_TOKEN \
npx -y replicate-flux-mcp

# Stay on Try-for-Free defaults (already default):
REPLICATE_API_TOKEN=YOUR_TOKEN npx -y replicate-flux-mcp

# Pick any other Replicate model id
REPLICATE_IMAGE_MODEL_ID="google/imagen-4" \
REPLICATE_SVG_MODEL_ID="black-forest-labs/flux-kontext-pro" \
REPLICATE_API_TOKEN=YOUR_TOKEN \
npx -y replicate-flux-mcp
```

> TIP:只需设置环境变量即可切换模型,无需修改代码或重新发布。

## 🔍 Troubleshooting

### Common Issues
Expand Down Expand Up @@ -419,4 +462,3 @@ Or explore style variations with prompt modifiers:
---

Made with ❤️ by Yaroslav Boiko

77 changes: 77 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Replicate Flux MCP

[English](README.md) | **中文**

本项目是一个 Model Context Protocol (MCP) 服务器,默认使用 Replicate “Try for Free” 集合中的免费模型:`black-forest-labs/flux-1.1-pro`(图片)和 `luma/reframe-video`(SVG/视频占位)。你可以通过环境变量切换到任意模型(如 `black-forest-labs/flux-schnell`、`recraft-ai/recraft-v3-svg`)。

> 免费模型列表:<https://replicate.com/collections/try-for-free>

## 目录
- [快速开始](#快速开始)
- [集成方式](#集成方式)
- [Cursor](#cursor)
- [Claude Desktop](#claude-desktop)
- [Smithery](#smithery)
- [Glama.ai](#glamaai)
- [Codex](#codex)
- [模型配置](#模型配置)
- [故障排查](#故障排查)

## 快速开始
1. 在 Replicate 获取 `REPLICATE_API_TOKEN`。
2. 任选集成方式运行 `npx -y replicate-flux-mcp`(记得传入 api token)。
3. 通过环境变量可即时切换模型:
```bash
REPLICATE_IMAGE_MODEL_ID="black-forest-labs/flux-schnell" \
REPLICATE_SVG_MODEL_ID="recraft-ai/recraft-v3-svg" \
REPLICATE_API_TOKEN=你的token \
npx -y replicate-flux-mcp
```

## 集成方式

### Cursor
`.cursor/mcp.json` 示例:
```json
{
"mcpServers": {
"replicate-flux-mcp": {
"command": "env",
"args": [
"REPLICATE_API_TOKEN=你的token",
"REPLICATE_IMAGE_MODEL_ID=可选",
"REPLICATE_SVG_MODEL_ID=可选",
"npx", "-y", "replicate-flux-mcp"
]
}
}
}
```

### Claude Desktop
`mcp.json` 示例略,与 README.md 相同,注意设置环境变量。

### Smithery / Glama.ai
可直接在各自的服务器市场添加 `replicate-flux-mcp`,无需本地部署。

### Codex
`~/.codex/config.toml` 示例:
```toml
[mcp_servers.replicate]
command = "npx"
args = ["-y", "replicate-flux-mcp"]
env = { REPLICATE_API_TOKEN = "your-replicate-api-token", REPLICATE_IMAGE_MODEL_ID = "your-image-model-id", REPLICATE_SVG_MODEL_ID = "your-svg-model-id" }
startup_timeout_sec = 30_000
```
不填 `REPLICATE_IMAGE_MODEL_ID` / `REPLICATE_SVG_MODEL_ID` 时会使用免费默认模型,启动即可使用。

## 模型配置
- 默认:图片 `black-forest-labs/flux-1.1-pro`,SVG `luma/reframe-video`(均在 Try for Free)。
- 覆盖:通过环境变量 `REPLICATE_IMAGE_MODEL_ID` / `REPLICATE_SVG_MODEL_ID` 设置任意 Replicate 模型。
- 免费模型列表:<https://replicate.com/collections/try-for-free>

## 故障排查
- 认证错误:确认 `REPLICATE_API_TOKEN` 有效。
- 超时:增大 `pollingAttempts` 或 `pollingInterval`(见 `src/config/index.ts`)。
- 模型不可用:确认所选模型在你的账户下可用或在 Try for Free 配额内。

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Configuration
const imageModelId = (process.env.REPLICATE_IMAGE_MODEL_ID ?? "black-forest-labs/flux-1.1-pro") as `${string}/${string}`;
const svgModelId = (process.env.REPLICATE_SVG_MODEL_ID ?? "luma/reframe-video") as `${string}/${string}`;

export const CONFIG = {
serverName: "replicate-flux-mcp",
serverVersion: "0.1.2",
imageModelId: "black-forest-labs/flux-schnell" as `${string}/${string}`,
svgModelId: "recraft-ai/recraft-v3-svg" as `${string}/${string}`,
pollingAttempts: 25,
pollingInterval: 2000, // ms
};
serverName: "replicate-flux-mcp",
serverVersion: "0.1.2",
imageModelId,
svgModelId,
pollingAttempts: 25,
pollingInterval: 2000, // ms
}