lucas120301/BFL_mcp_server
If you are the rightful owner of BFL_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Flux MCP Server is an AI-powered image generation server using Black Forest Labs' Flux models, designed for seamless integration with AI agents and optimized for Dedalus Labs deployment.
Flux MCP Server
An MCP (Model Context Protocol) server for AI-powered image generation using Black Forest Labs' Flux models. Built for seamless integration with AI agents and compatible with Dedalus Labs deployment.
Features
- AI Image Generation: Generate high-quality images using state-of-the-art Flux models
- Multiple Models: Support for different Flux model variants (flux-pro-1.1, flux-dev, flux-schnell)
- Flexible Parameters: Customizable aspect ratios, dimensions, and safety settings
- MCP Integration: Seamless integration with MCP-compatible AI agents
- Dedalus Ready: Optimized for deployment on Dedalus Labs platform
- Rate Limiting: Built-in protection for API keys and usage limits
Quick Start
Prerequisites
- Python 3.8+
- uv package manager
- Black Forest Labs API key from api.bfl.ai
Installation
-
Clone the repository:
git clone <repository-url> cd flux-mcp-main -
Install dependencies:
# Install uv package manager brew install uv # or pip install uv # Install dependencies uv sync --no-dev -
Configure API key:
# Set environment variable export BFL_API_KEY="your_api_key_here" # Or create .env file cp config/.env.example config/.env # Edit config/.env and add your API key -
Run the server:
uv run main
Available Tools
flux_generate
Generate images using Flux AI models.
Parameters:
prompt(string, required): Text description of the image to generatemodel(string, optional): Flux model to use (default: "flux-pro-1.1")aspect_ratio(string, optional): Image aspect ratio (default: "16:9")width(int, optional): Image width in pixels (default: 1024)height(int, optional): Image height in pixels (default: 1024)raw(bool, optional): Use raw mode for more creative outputs (default: false)safety_tolerance(int, optional): Safety filter level 0-10 (default: 6)prompt_upsampling(bool, optional): Enhance prompt quality (default: false)
Returns:
status: "success" or "error"image: URL to the generated image (on success)meta: Metadata about the generation (on success)message: Error message (on error)
Example Usage
# Generate a simple image
result = await flux_generate(
prompt="A beautiful sunset over mountains",
aspect_ratio="16:9"
)
# Generate with custom parameters
result = await flux_generate(
prompt="A futuristic cityscape at night",
model="flux-pro-1.1",
width=1920,
height=1080,
safety_tolerance=4,
prompt_upsampling=True
)
Supported Models
flux-pro-1.1: Latest Flux Pro model (recommended)flux-dev: Development modelflux-schnell: Fast generation model
Aspect Ratios
Common aspect ratios supported:
1:1- Square16:9- Widescreen9:16- Portrait4:3- Standard3:4- Portrait standard
Deployment
Deploy to Dedalus Labs
-
Set Environment Variables in Dedalus UI:
BFL_API_KEY: Your Black Forest Labs API key (required)
-
Deploy:
dedalus deploy . --name "flux-image-generator" -
Test:
dedalus test flux-image-generator
Local Development
# Test locally
./scripts/test-local.sh
# Deploy to Dedalus
./scripts/deploy.sh
Project Structure
flux-mcp-main/
├── main.py # Entry point (required by Dedalus)
├── pyproject.toml # Package configuration
├── src/
│ ├── main.py # MCP server implementation
│ └── flux_adapter.py # Black Forest Labs API adapter
├── config/
│ └── .env.example # Environment template
├── docs/ # Documentation
│ ├── getting-started.md
│ ├── deployment.md
│ └── api-reference.md
├── examples/ # Usage examples
│ ├── basic-usage.py
│ ├── creative-prompts.py
│ └── README.md
├── scripts/ # Deployment scripts
│ ├── deploy.sh
│ └── test-local.sh
└── tests/ # Test files
└── image_generation.py
Documentation
Examples
Check out the directory for:
- - Simple image generation
- - Advanced prompt techniques
Safety and Guidelines
- The
safety_toleranceparameter controls content filtering (0-10) - Higher values are more restrictive
- Use appropriate prompts that comply with Black Forest Labs' usage policies
- Generated images are subject to the API provider's terms of service
Troubleshooting
Common Issues
-
API Key Not Set
- Ensure
BFL_API_KEYenvironment variable is set - Check that your API key is valid and active
- Ensure
-
Generation Timeout
- Complex prompts may take longer to process
- Try simplifying your prompt or using a different model
-
Safety Filter Triggered
- Adjust
safety_toleranceparameter - Modify your prompt to be more appropriate
- Adjust
Getting Help
- Check the Black Forest Labs API Documentation
- Review error messages in the response
- Ensure your API key has sufficient credits
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see file for details.
Acknowledgments
- Black Forest Labs for the Flux AI models
- Model Context Protocol for the MCP specification
- Dedalus Labs for the deployment platform