This MCP server generates images using Replicate's FLUX model and stores them in Cloudflare R2, providing accessible image URLs. It supports custom prompts and filenames through a simple interface.
Required environment variables in your .env
file:
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
To install automatically via Smithery for Claude Desktop:
npx -y @smithery/cli install @andylee20014/mcp-replicate-flux --client claude
# 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.
To start the MCP server locally:
node index.js
The server will listen for MCP protocol messages on standard input/output.
The server provides a generate-image
tool that accepts two parameters:
prompt
: The text prompt for image generationfilename
: The desired filename for the generated imageHere's how to integrate with this MCP server using the MCP client library:
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
})
return result
}
Example response:
{
"content": [
{ "type": "text", "text": "Image successfully generated and uploaded to Cloudflare R2" },
{ "type": "image", "url": "https://your-domain.com/filename.jpg" }
]
}
A test script is provided to verify functionality:
node test.js
The test script will:
Create a file at ~/.cursor/mcp.json
with all environment variables:
{
"mcpServers": {
"replicate-flux": {
"command": "node",
"args": ["C:\\Users\\YourUsername\\path\\to\\mcp-replicate-flux\\index.js"],
"description": "MCP server that generates images using Replicate's FLUX model",
"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"
}
}
}
}
If you prefer to manage environment variables separately:
{
"mcpServers": {
"replicate-flux": {
"command": "node",
"args": ["C:\\Users\\YourUsername\\path\\to\\mcp-replicate-flux\\index.js"]
}
}
}
When using the minimal configuration, ensure your environment variables are properly set up. After changing the configuration, restart Cursor to apply the changes.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.