FLUX Image Generator (Black Forest Lab) MCP server

Provides a bridge to Black Forest Lab's FLUX model for generating images with customizable parameters like dimensions and safety settings through natural language requests
Back to servers
Setup instructions
Provider
Model Context Protocol
Release date
Mar 25, 2025
Language
TypeScript
Stats
1 star

This MCP server allows you to generate images using Black Forest Lab's FLUX model through the Model Context Protocol (MCP). It provides tools for creating images from text prompts with customizable settings, including size, seed values, and safety filters.

Prerequisites

Installation

From Source

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Create a .env file based on .env.example and add your API key:
BFL_API_KEY=your_api_key_here
  1. Build the project:
npm run build

Using npm

npm install -g @modelcontextprotocol/server-flux-image-generator

Starting the Server

Start the MCP server with:

npm start

Integrating with MCP Clients

To use this server with MCP clients (such as Claude), add the following configuration:

{
  "mcpServers": {
    "flux-image-generator": {
      "command": "mcp-server-flux-image-generator",
      "env": {
        "BFL_API_KEY": "your_api_key_here"
      }
    }
  }
}

Available Tools

generateImage

Creates an image based on a text prompt with fully customizable settings.

Parameters:

  • prompt (string, required): Text description of the image
  • width (number, optional, default: 1024): Width in pixels
  • height (number, optional, default: 1024): Height in pixels
  • promptUpsampling (boolean, optional, default: false): Enhance detail by upsampling the prompt
  • seed (number, optional): Random seed for reproducible results
  • safetyTolerance (number, optional, default: 3): Content moderation level (1-5)

Example:

{
  "prompt": "A serene lake at sunset with mountains in the background",
  "width": 1024,
  "height": 768,
  "promptUpsampling": true,
  "seed": 12345,
  "safetyTolerance": 3
}

quickImage

A simplified tool for quick image generation with default settings.

Parameters:

  • prompt (string, required): Text description of the image

Example:

{
  "prompt": "A futuristic cityscape with flying cars"
}

batchGenerateImages

Generates multiple images from a list of prompts.

Parameters:

  • prompts (array of strings, required): List of text prompts (maximum 10)
  • width (number, optional, default: 1024): Width of the images
  • height (number, optional, default: 1024): Height of the images

Example:

{
  "prompts": [
    "A serene lake at sunset",
    "A futuristic cityscape",
    "A magical forest with glowing plants"
  ],
  "width": 1024,
  "height": 768
}

Response Format

Standard responses include image URLs and local file paths:

{
  "image_url": "https://storage.example.com/generated_image.jpg",
  "local_path": "/path/to/output/flux_1234567890.png"
}

Batch responses include information about all requested images:

{
  "total": 3,
  "successful": 2,
  "failed": 1,
  "results": [
    {
      "prompt": "A serene lake at sunset",
      "success": true,
      "image_url": "https://storage.example.com/image1.jpg",
      "local_path": "/path/to/output/flux_batch_1234567890_0.png"
    },
    {
      "prompt": "A futuristic cityscape",
      "success": true,
      "image_url": "https://storage.example.com/image2.jpg",
      "local_path": "/path/to/output/flux_batch_1234567890_1.png"
    },
    {
      "prompt": "Prohibited content",
      "success": false,
      "error": "Content policy violation"
    }
  ]
}

Error responses include an error flag and message:

{
  "error": true,
  "message": "Error description"
}

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 "flux-image-generator" '{"command":"mcp-server-flux-image-generator","env":{"BFL_API_KEY":"your_api_key_here"}}'

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": {
        "flux-image-generator": {
            "command": "mcp-server-flux-image-generator",
            "env": {
                "BFL_API_KEY": "your_api_key_here"
            }
        }
    }
}

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": {
        "flux-image-generator": {
            "command": "mcp-server-flux-image-generator",
            "env": {
                "BFL_API_KEY": "your_api_key_here"
            }
        }
    }
}

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