Integrations
Leverages Cloudflare Workers to securely process image generation requests through Black Forest Labs' Flux model
Provides access to Black Forest Labs' Flux model for high-quality image generation based on text prompts
Utilizes TypeScript 4.9+ for type safety and modern JavaScript features in the MCP implementation
Flux Cloudflare MCP
A powerful Model Context Protocol (MCP) server that provides AI assistants with the ability to generate images using Black Forest Labs' Flux model via a Cloudflare Worker API.
Installation • Features • Usage • Documentation • Contributing
🌟 Features
- 🖼️ High-Quality Image Generation: Access to Flux, a state-of-the-art image generation model
- 🤖 Seamless AI Integration: Enable AI assistants like Claude to generate images directly
- 🎛️ Customizable Parameters: Control aspect ratio, inference steps, and more
- 🔌 MCP Compatible: Works with any MCP client (Cursor, Claude Desktop, Cline, Zed, etc.)
- 🔒 Local Processing: All requests are processed securely through the Cloudflare Worker
- 💬 Chat Completions: Get text completions using the same API
📦 Installation
Direct Usage with NPX
From Source
🚀 Setting Up Your Flux API
This MCP server requires a Flux API endpoint to function. You have two options for setting up the API:
Option 1: Deploy using snakeying/flux-api-worker (Recommended)
snakeying/flux-api-worker provides a simple and efficient Cloudflare Worker for accessing the Flux model:
- Fork the flux-api-worker repository
- Deploy it to Cloudflare Workers:
- Create a new Worker in your Cloudflare dashboard
- Connect it to your forked repository
- Set up the required environment variables:
API_KEY
: Your chosen API key for authenticationCF_ACCOUNT_ID
: Your Cloudflare account IDCF_API_TOKEN
: Your Cloudflare API token with Workers AI accessFLUX_MODEL
: The Flux model to use (default: "@cf/black-forest-labs/flux-1-schnell")
- Once deployed, your API will be available at
https://your-worker-name.your-subdomain.workers.dev
- Use this URL as your
FLUX_API_URL
and your chosen API key asFLUX_API_TOKEN
Option 2: Deploy using aigem/cf-flux-remix
For a more feature-rich implementation with a web UI, you can use aigem/cf-flux-remix:
- Follow the installation instructions in the cf-flux-remix repository
- Once deployed, your API will be available at your deployed URL
- Use this URL as your
FLUX_API_URL
and your configured API key asFLUX_API_TOKEN
📚 Documentation
Available Tools
generate_image
Generates an image based on a text prompt using the Flux model.
🔧 Usage
Cursor Integration
Method 1: Using mcp.json
- Create or edit the
.cursor/mcp.json
file in your project directory:
- Replace
YOUR_TOKEN
with your actual Flux API token andYOUR_API_URL
with your API URL - Restart Cursor to apply the changes
Method 2: Using Cursor MCP Settings
- Open Cursor and go to Settings
- Navigate to the "MCP" or "Model Context Protocol" section
- Click "Add Server" or equivalent
- Enter the following command in the appropriate field:
- Replace
YOUR_TOKEN
with your actual Flux API token andYOUR_API_URL
with your API URL - Save the settings and restart Cursor if necessary
Claude Desktop Integration
env FLUX_API_TOKEN=YOUR_TOKEN FLUX_API_URL=YOUR_API_URL npx -y flux-cloudflare-mcp
💻 Local Development
- Clone the repository:
- Install dependencies:
- Build the project:
🛠 Technical Stack
- Model Context Protocol SDK - Core MCP functionality
- Cloudflare Workers - Serverless API for image generation
- TypeScript - Type safety and modern JavaScript features
- Zod - Runtime type validation
⚙️ Configuration
The server requires the following environment variables:
FLUX_API_TOKEN
: Your API token for authentication with the Flux APIFLUX_API_URL
: The URL of your deployed Flux API (from snakeying/flux-api-worker or aigem/cf-flux-remix)
🔍 Troubleshooting
Common Issues
Authentication Error
- Ensure your
FLUX_API_TOKEN
is correctly set in the environment - Verify your token is valid by testing it with the Flux API directly
API Connection Issues
- Check that your Flux API (Cloudflare Worker) is running and accessible
- Ensure your network allows connections to Cloudflare Workers
Safety Filter Triggered
- The model has a built-in safety filter that may block certain prompts
- Try modifying your prompt to avoid potentially problematic content
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Resources
- Model Context Protocol Documentation
- Cloudflare Workers Documentation
- Flux Model Documentation
- MCP TypeScript SDK
- snakeying/flux-api-worker - Simple Flux API implementation
- aigem/cf-flux-remix - Feature-rich Flux API with web UI
This server cannot be installed
An MCP server that enables AI assistants to generate images using Black Forest Labs' Flux model via Cloudflare Workers.