Replicate FLUX MCP server

Integrates with Replicate's image generation API to enable fast creation of images from text prompts using the flux-schnell model, with customizable parameters for quality and format.
Back to servers
Setup instructions
Provider
ozgrozer
Release date
Feb 22, 2025
Language
TypeScript
Stats
6 stars

This MCP server implementation works with the FLUX API and Replicate. It allows you to connect your local Obsidian or other Markdown apps to AI services through the Model Context Protocol (MCP), letting you interact with AI models directly from your preferred writing environment.

Installation

Prerequisites

  • Node.js installed on your system
  • npm or yarn package manager
  • A Replicate API key
  • A FLUX API key

Setup Steps

  1. Clone the repository to your local machine:
git clone https://github.com/username/mcp-replicate-flux.git
cd mcp-replicate-flux
  1. Install dependencies:
npm install
# or
yarn install
  1. Create a .env file in the root directory with your API keys:
REPLICATE_API_TOKEN=your_replicate_api_key_here
FLUX_API_KEY=your_flux_api_key_here
  1. Start the server:
npm start
# or
yarn start

Usage

Connecting to the MCP Server

Once your server is running, it will be available at http://localhost:3000 by default. You can connect to it from any MCP-compatible client.

Configuration Options

You can configure the server by modifying the following environment variables in your .env file:

PORT=3000                        # Change the port number if needed
LOG_LEVEL=info                   # Options: debug, info, warn, error
REPLICATE_API_TOKEN=your_key     # Your Replicate API key
FLUX_API_KEY=your_key            # Your FLUX API key

Using with Obsidian

  1. Install the MCP plugin for Obsidian from the community plugins section
  2. Configure the plugin to connect to your local MCP server at http://localhost:3000
  3. Create a new note and use the MCP commands to interact with AI models

Example Commands

To generate text using your MCP server in a compatible client, you can use commands like:

/generate a short story about a space explorer

Troubleshooting

If you encounter connection issues:

  • Verify the server is running by opening http://localhost:3000/status in your browser
  • Check that your API keys are correctly set in the .env file
  • Ensure your firewall isn't blocking the port
  • Examine the server logs for any error messages

Advanced Configuration

Custom Model Selection

You can specify which model to use by adding a model parameter:

/generate with:meta/llama-3-8b-instruct a technical explanation of quantum computing

Adjusting Response Parameters

Control the output by modifying these parameters:

  • Temperature: Adjust creativity level (0.0-2.0)
  • Max Length: Limit token count in the response
  • Top P: Control diversity of generated text

Example with parameters:

/generate temperature:0.7 max_length:500 a creative marketing slogan

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "replicate-flux" '{"command":"npx","args":["-y","mcp-replicate-flux"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

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.

How to use the MCP server

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later