Image generation and editing using the FLUX.1 Kontext [Max] model via the Replicate API, featuring advanced text rendering and contextual understanding.
A Model Context Protocol (MCP) server that provides access to FLUX.1 Kontext [Max] - the frontier image generation model through the Replicate API. This server enables high-quality image generation with advanced text rendering capabilities and superior contextual understanding.
š Repository: https://github.com/PierrunoYT/replicate-flux-kontext-max-mcp-server
š Ready to use! Pre-built executable included - no compilation required.
ā Enhanced Reliability: Server handles missing API tokens gracefully without crashes and includes robust error handling.
images
directoryr8_
)git clone https://github.com/PierrunoYT/replicate-flux-kontext-max-mcp-server.git
cd replicate-flux-kontext-max-mcp-server
The server is pre-built, but if you want to modify it:
npm install
npm run build
Best option for portability - works on any machine with Node.js:
{
"mcpServers": {
"replicate-flux-kontext-max": {
"command": "npx",
"args": [
"-y",
"https://github.com/PierrunoYT/replicate-flux-kontext-max-mcp-server.git"
],
"env": {
"REPLICATE_API_TOKEN": "r8_your-replicate-api-token-here"
}
}
}
}
Benefits:
If you prefer to install locally, use the path helper:
npm run get-path
This will output the complete MCP configuration with the correct absolute path.
Add to ~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) or %APPDATA%\Claude\claude_desktop_config.json
(Windows):
{
"mcpServers": {
"replicate-flux-kontext-max": {
"command": "node",
"args": ["path/to/replicate-flux-kontext-max-mcp-server/build/index.js"],
"env": {
"REPLICATE_API_TOKEN": "r8_your-replicate-api-token-here"
}
}
}
}
Add to your MCP settings file at:
C:\Users\[username]\AppData\Roaming\Kilo-Code\MCP\settings\mcp_settings.json
{
"mcpServers": {
"replicate-flux-kontext-max": {
"command": "node",
"args": ["path/to/replicate-flux-kontext-max-mcp-server/build/index.js"],
"env": {
"REPLICATE_API_TOKEN": "r8_your-replicate-api-token-here"
},
"disabled": false,
"alwaysAllow": []
}
}
}
flux_kontext_max_generate
Generate images using FLUX.1 Kontext [Max] with real-time processing via Replicate.
Parameters:
prompt
(required): Text description of the image to generate, or instruction on how to edit the given imageinput_image
(optional): Image to use as reference. Must be jpeg, png, gif, or webp. Can be a URL or base64 data URIseed
(optional): Random seed for reproducible generationaspect_ratio
(optional): "match_input_image", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "4:5", "5:4", "21:9", "9:21", "2:1", "1:2" (default: "match_input_image")output_format
(optional): "jpg" or "png" (default: "jpg")safety_tolerance
(optional): Safety level 0-6 (default: 2)Response includes:
flux_kontext_max_generate_async
Generate images using FLUX.1 Kontext [Max] with async prediction tracking for monitoring progress.
Parameters: Same as flux_kontext_max_generate
Use this tool when:
Features:
flux_kontext_max_cancel_prediction
Cancel a running prediction by its ID.
Parameters:
prediction_id
(required): The ID of the prediction to cancelUse this tool when:
flux_kontext_max_get_prediction
Get the status and details of a prediction by its ID.
Parameters:
prediction_id
(required): The ID of the prediction to checkResponse includes:
The Replicate FLUX.1 Kontext [Max] MCP server automatically downloads generated images to your local machine. Here's the complete process:
downloadImage
):async function downloadImage(url: string, filename: string): Promise<string> {
// 1. Parse the URL and determine HTTP/HTTPS client
const parsedUrl = new URL(url);
const client = parsedUrl.protocol === 'https:' ? https : http;
// 2. Create 'images' directory if it doesn't exist
const imagesDir = path.join(process.cwd(), 'images');
if (!fs.existsSync(imagesDir)) {
fs.mkdirSync(imagesDir, { recursive: true });
}
// 3. Create file write stream
const filePath = path.join(imagesDir, filename);
const file = fs.createWriteStream(filePath);
// 4. Download and pipe to file
client.get(url, (response) => {
response.pipe(file);
// Handle completion and errors
});
}
generateImageFilename
):function generateImageFilename(prompt: string, index: number, seed?: number): string {
// Creates safe filename: flux_kontext_max_prompt_seed_index_timestamp.jpg
const safePrompt = prompt
.toLowerCase()
.replace(/[^a-z0-9\s]/g, '') // Remove special characters
.replace(/\s+/g, '_') // Replace spaces with underscores
.substring(0, 50); // Limit length
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const seedStr = seed ? `_${seed}` : '';
return `flux_kontext_max_${safePrompt}${seedStr}_${index}_${timestamp}.jpg`;
}
your-project/
āāā images/ # Auto-created directory
ā āāā flux_kontext_max_mountain_landscape_123456_1_2025-06-24T18-30-45-123Z.jpg
ā āāā flux_kontext_max_cute_robot_789012_1_2025-06-24T18-31-20-456Z.jpg
ā āāā ...
flux_kontext_max_
.jpg
or .png
based on output_formatThe server returns both local and remote information:
Successfully generated 1 image(s) using FLUX.1 Kontext [Max] via Replicate:
Prompt: "a serene mountain landscape with text 'FLUX' painted in white"
Aspect Ratio: 1:1
Output Format: jpg
Safety Tolerance: 2
Seed: 1234567890
Generated Images:
Image 1:
Local Path: /path/to/project/images/flux_kontext_max_a_serene_mountain_landscape_1234567890_1_2025-06-24T18-30-45-123Z.jpg
Original URL: https://replicate.delivery/pbxt/...
Filename: flux_kontext_max_a_serene_mountain_landscape_1234567890_1_2025-06-24T18-30-45-123Z.jpg
Images have been downloaded to the local 'images' directory.
Generate a photorealistic image of a golden retriever playing in a field of sunflowers with the text "HAPPY DOG" written in bold letters
Generate an image with:
- Prompt: "A minimalist logo design for a tech startup, clean lines, with 'STARTUP' text"
- Aspect ratio: 16:9
- Output format: png
- Seed: 12345
Generate an image of "A futuristic cityscape at night with neon lights and flying cars, large billboard displaying 'FUTURE CITY 2025'"
with aspect ratio 21:9 and seed 12345 for reproducible results
Create an image of a vintage bookstore with multiple book spines showing titles like "The Art of Code", "Digital Dreams", and "Future Stories" clearly readable
Edit this image to add a rainbow in the sky
Input image: https://example.com/landscape.jpg
Edit the image with:
- Prompt: "Add a donut next to the flour on the counter"
- Input image: https://replicate.delivery/pbxt/example.png
- Output format: png
Add the text "SALE 50% OFF" in bold red letters to this storefront image
Input image: https://example.com/storefront.jpg
Use flux_kontext_max_generate_async to start generation, then use flux_kontext_max_get_prediction with the returned prediction ID to monitor progress
Use flux_kontext_max_cancel_prediction with the prediction ID if you need to stop generation
black-forest-labs/flux-kontext-max
on Replicaterun()
and prediction-based predictions.create()
process.exit()
calls that caused connection dropsāāā src/
ā āāā index.ts # Main MCP server implementation
āāā build/ # Compiled JavaScript (ready to use)
āāā test-server.js # Server testing utility
āāā get-path.js # Configuration path helper
āāā example-mcp-config.json # Example configuration
āāā package.json # Project metadata and dependencies
āāā tsconfig.json # TypeScript configuration
npm run build
- Compile TypeScript to JavaScriptnpm run dev
- Watch mode for developmentnpm run start
- Start the server directlynpm run test
- Test server startup and basic functionalitynpm run get-path
- Get configuration path for your systemsrc/
directorynpm run build
to compilenpm run test
This runs a basic connectivity test that verifies:
This server uses the Replicate platform, which charges per image generation. Check Replicate pricing for current rates.
Typical costs (as of 2024):
build/index.js
is correct and absolutenode --version
npm run test
If you need to rebuild the server:
npm install
npm run build
Use the helper script to get the correct path:
npm run get-path
For issues with:
MIT License - see LICENSE file for details.
npm run test
flux_kontext_max_cancel_prediction
and flux_kontext_max_get_prediction
flux_kontext_max_edit
and flux_kontext_max_edit_async
for image editingconnects QGIS Desktop to Claude AI through the MCP. This integration enables prompt-assisted project creation, layer loading, code execution, and more.
An iOS mobile automation server using Appium and WebDriverAgent, built with clean architecture and SOLID principles.
Provides access to OpenTelemetry traces and metrics through Logfire.
Perform virtual try-ons using the HeyBeauty API.
MCP Server for automated reverse engineering with IDA Pro.
An unofficial MCP server plugin for remote control of Unreal Engine using AI tools.
Open-source tool for collaborative editing, versioning, evaluating, and releasing prompts.
A Python server providing Retrieval-Augmented Generation (RAG) functionality. It indexes various document formats and requires a PostgreSQL database with pgvector.
Provides API documentation from Apifox projects as a data source for AI programming tools that support MCP.
A platform-agnostic server for scalable mobile automation and development across iOS, Android, simulators, and emulators.