flux-replicate-mcp

flux-replicate-mcp

A simple MCP server for generating images using Flux models via the Replicate API.

Category
Visit Server

README

Flux Replicate MCP Server

Generated with Flux 2 Pro via this MCP server

A simple Model Context Protocol (MCP) server for generating images using Flux models via the Replicate API.

✨ Simplicity First

This server has been designed with simplicity as the primary goal:

  • Minimal setup - Just add your API key and start generating images
  • Zero configuration - Works out of the box with sensible defaults
  • Platform-aware - Automatically organizes your images in the right place
  • Essential features only - Image generation that just works, without complexity
  • Easy integration - Drop into any MCP client with a single command

šŸš€ Quick Start

Global Installation (Recommended)

The easiest way to get started is with npx or bunx - no installation required!

# Set your Replicate API token
export REPLICATE_API_TOKEN="r8_your_token_here"

# Run with npx (Node.js)
npx flux-replicate-mcp

# OR run with bunx (Bun)
bunx flux-replicate-mcp

CLI Arguments

The server supports comprehensive CLI configuration:

# Basic usage with API key
flux-replicate-mcp --api-key r8_your_token_here

# Full configuration example
flux-replicate-mcp \
  --api-key r8_your_token_here \
  --model flux-1.1-pro \
  --format jpg \
  --quality 95 \
  --working-directory ~/MyImages

# Get help
flux-replicate-mcp --help

Available CLI Arguments:

  • --api-key/-k/--replicate-api-key: Replicate API token (required)
  • --model/-m: Default model (flux-2-pro, flux-2-max, flux-2-flex, flux-2-dev, flux-2-klein, flux-1.1-pro, flux-pro, flux-schnell, flux-ultra)
  • --format/-f: Output format (jpg, png, webp)
  • --quality/-q: Quality setting (1-100)
  • --working-directory/-d/--dir: Custom working directory
  • --help/-h: Show help message

šŸ“– Complete Installation Guide →

Local Development

  1. Install Dependencies
bun install
  1. Configure Environment
cp .env.example .env
# Edit .env and add your REPLICATE_API_TOKEN
  1. Build and Run
bun run build
bun run start

The server will automatically create a platform-specific working directory for your generated images:

  • Windows: %USERPROFILE%\Documents\FluxImages
  • macOS: ~/Pictures/FluxImages
  • Linux: ~/Pictures/FluxImages (fallback: ~/flux-images)

šŸ”§ Configuration

All configuration is done via environment variables or CLI arguments:

Variable CLI Argument Required Default Description
REPLICATE_API_TOKEN --api-key āœ… - Your Replicate API token
FLUX_DEFAULT_MODEL --model āŒ flux-2-pro Default model
FLUX_OUTPUT_FORMAT --format āŒ jpg Default output format
FLUX_OUTPUT_QUALITY --quality āŒ 80 Default quality for lossy formats (1-100)
FLUX_WORKING_DIRECTORY --working-directory āŒ Platform-specific Custom working directory

šŸŽØ Supported Models

Flux 2 Series (Recommended)

Model Cost per Image Speed Quality Best For
flux-2-pro $0.030 Medium Highest Professional work, detailed images (default)
flux-2-max $0.080 Slow Ultra High Premium quality, final outputs
flux-2-flex $0.060 Medium High Flexible, general purpose
flux-2-dev $0.012 Fast Good Development, experimentation
flux-2-klein $0.003 Fast Good Quick iterations, budget-friendly

Flux 1 Series

Model Cost per Image Speed Quality Best For
flux-1.1-pro $0.040 Medium Highest Professional work, detailed images
flux-pro $0.040 Medium High General purpose, balanced quality
flux-schnell $0.003 Fast Good Quick iterations, testing
flux-ultra $0.060 Slow Ultra High Premium quality, final outputs

šŸ› ļø Available Tools

generate_image

Generate images using Flux models with cost tracking.

Parameters:

  • prompt (required): Text description of the image to generate
  • output_path (optional): Absolute file path for the generated image. If not provided, auto-generated filename will be used in server working directory.
  • model (optional): Flux model to use (default: flux-2-pro)
  • width (optional): Image width in pixels (default: 1024)
  • height (optional): Image height in pixels (default: 768)
  • quality (optional): Image quality for lossy formats (1-100, default: 80)

Examples:

Auto-generated filename with cost tracking:

{
  "prompt": "A serene mountain landscape at sunset"
}

Response includes: file path, generation time, model used, and cost ($0.040 for flux-1.1-pro)

Custom absolute path:

{
  "prompt": "Professional product photo of a smartphone",
  "output_path": "/absolute/path/to/smartphone.png",
  "model": "flux-pro",
  "width": 1024,
  "height": 1024,
  "quality": 95
}

Fast iteration with flux-schnell:

{
  "prompt": "Quick concept art of a robot",
  "model": "flux-schnell",
  "output_path": "/home/user/images/robot_concept.jpg"
}

Only $0.003 per image - perfect for rapid prototyping

Output Organization:

  • Auto-generated: Files saved with descriptive names based on prompt and timestamp in server working directory
  • Custom path: output_path must be an absolute path for the generated image
  • Path validation: Relative paths are rejected to ensure compatibility across client/server environments
  • Directory creation: Output directories are automatically created if they don't exist
  • Cost tracking: Every generation shows the cost and model used

šŸŽÆ Design Philosophy

This server follows the principle: "Simple enough to understand in 30 minutes, powerful enough to generate great images"

What's Included

  • āœ… Core image generation with Core Flux models
  • āœ… Image processing and format conversion
  • āœ… Platform-specific working directories
  • āœ… CLI argument support with comprehensive help
  • āœ… Cost tracking for budget awareness
  • āœ… Basic error handling and logging
  • āœ… MCP protocol compliance

šŸ”— MCP Integration

Claude Desktop (Recommended)

Add to your Claude Desktop MCP configuration:

{
  "mcpServers": {
    "flux-replicate": {
      "command": "npx",
      "args": ["flux-replicate-mcp"],
      "env": {
        "REPLICATE_API_TOKEN": "your_token_here"
      }
    }
  }
}

Cursor Integration

Method 1: Using mcp.json

Create or edit .cursor/mcp.json in your project directory:

{
  "mcpServers": {
    "flux-replicate": {
      "command": "env REPLICATE_API_TOKEN=YOUR_TOKEN npx",
      "args": ["-y", "flux-replicate-mcp"]
    }
  }
}

Method 2: Manual Configuration

  1. Open Cursor Settings → MCP section
  2. Add server with command: env REPLICATE_API_TOKEN=YOUR_TOKEN npx -y flux-replicate-mcp
  3. Restart Cursor

Other MCP Clients

The server works with any MCP-compatible client:

  • Cline: Use the same npx command
  • Zed: Add to MCP configuration
  • Custom clients: Use the MCP SDK

šŸ“– Complete Integration Guide →

🚨 Error Handling

The server uses simple error codes with helpful messages:

  • AUTH: Authentication/API key issues
  • API: Replicate API errors
  • VALIDATION: Invalid input parameters
  • PROCESSING: Image processing failures

All errors are logged as structured JSON to stderr for MCP compatibility.

šŸ’° Cost Management

Track your spending with built-in cost reporting:

  • Each generation shows the exact cost
  • Model pricing clearly displayed
  • Choose models based on budget vs quality needs
  • Use flux-2-klein for cheap iterations ($0.003)
  • Use flux-2-max for premium results ($0.080)

šŸ“¦ Installation & Usage

Global Installation

# Install globally
npm install -g flux-replicate-mcp

# Or use directly with npx
npx flux-replicate-mcp --api-key YOUR_TOKEN

# Or use with bunx
bunx flux-replicate-mcp --api-key YOUR_TOKEN

Package Information

  • Package Name: flux-replicate-mcp
  • Binaries: flux-replicate-mcp, flux-replicate-mcp-server
  • Dependencies: 3 runtime dependencies
  • Size: ~600KB unpacked

šŸ“ Development

Build

bun run build

Development Mode

bun run dev

Publish to npm

# Build and publish
bun run build
npm publish

šŸ¤ Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

šŸ“ž Support

šŸ“„ License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured