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.
npm install
.env
file based on .env.example
and add your API key:BFL_API_KEY=your_api_key_here
npm run build
npm install -g @modelcontextprotocol/server-flux-image-generator
Start the MCP server with:
npm start
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"
}
}
}
}
Creates an image based on a text prompt with fully customizable settings.
Parameters:
prompt
(string, required): Text description of the imagewidth
(number, optional, default: 1024): Width in pixelsheight
(number, optional, default: 1024): Height in pixelspromptUpsampling
(boolean, optional, default: false): Enhance detail by upsampling the promptseed
(number, optional): Random seed for reproducible resultssafetyTolerance
(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
}
A simplified tool for quick image generation with default settings.
Parameters:
prompt
(string, required): Text description of the imageExample:
{
"prompt": "A futuristic cityscape with flying cars"
}
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 imagesheight
(number, optional, default: 1024): Height of the imagesExample:
{
"prompts": [
"A serene lake at sunset",
"A futuristic cityscape",
"A magical forest with glowing plants"
],
"width": 1024,
"height": 768
}
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"
}
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.
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 > 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"
}
}
}
}
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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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