Model Context Protocol (MCP) server for AI-powered image generation using Azure DALL-E 3 and FLUX models
A powerful MCP server that brings professional AI image generation to LibreChat. Generate stunning images using Azure's DALL-E 3 for photorealistic content or FLUX for creative artwork, with intelligent automatic model selection based on your prompts.
Perfect for LibreChat users who want seamless image generation capabilities powered by Azure AI Foundry models.
-
π€ Dual Model Support
- DALL-E 3: Photorealistic images, portraits, and artistic content
- FLUX (FLUX.1-Kontext-pro): Creative illustrations and flexible generation
-
π§ Intelligent Model Selection
- Automatic model selection based on prompt analysis
- FLUX as default for optimal results
- DALL-E 3 when explicitly requested or optimal
-
π Multiple Image Sizes
- Square (1024x1024) - Perfect for social media
- Wide (1792x1024) - Great for banners and headers
- Tall (1024x1792) - Ideal for posters and vertical content
-
βοΈ Customization Options
- Quality settings (standard/HD) for DALL-E 3
- Style options (vivid/natural) for DALL-E 3
- Fast generation times (typically 30-60 seconds)
-
π Easy Integration
- Works seamlessly with LibreChat
- Compatible with MCP clients
- Simple configuration via environment variables
- Node.js >= 18.0.0
- Azure OpenAI API access with:
- DALL-E 3 deployment (optional)
- FLUX deployment (FLUX.1-Kontext-pro)
- LibreChat instance (for LibreChat integration)
npm install -g azure-image-generation-mcp
git clone https://github.com/malikmalikayesha/azure-image-generation-mcp.git
cd azure-image-generation-mcp
npm install
npx azure-image-generation-mcp
Create a .env
file or set environment variables:
AZURE_IMAGE_API_KEY=your_azure_api_key_here
AZURE_IMAGE_BASE_URL=https://your-endpoint.cognitiveservices.azure.com/openai/deployments
Add to your librechat.yaml
:
mcpServers:
"Image Generation":
type: stdio
command: node
args:
- /path/to/azure-image-generation-server.js
name: "Image Generation"
displayName: "Image Generation"
timeout: 180000 # 3 minutes for generation
initTimeout: 60000 # 1 minute startup
chatMenu: true # Show in chat tools
serverInstructions: |
π¨ AI Image Generation Tool
Create stunning images using DALL-E 3 or FLUX models.
Simply describe what you want to see!
env:
AZURE_IMAGE_API_KEY: "${AZURE_IMAGE_API_KEY}"
AZURE_IMAGE_BASE_URL: "${AZURE_IMAGE_BASE_URL}"
Simply ask the AI to generate an image:
"Generate an image of a serene mountain landscape at sunset"
"Create a modern minimalist logo for a tech startup"
"Draw a realistic portrait of a confident businesswoman"
"Make an abstract pattern with geometric shapes"
- Automatic (Default): The system intelligently chooses between DALL-E 3 and FLUX
- FLUX (Default): Used for most requests unless DALL-E is explicitly mentioned
- DALL-E 3: Explicitly request by mentioning "DALL-E" in your prompt
Specify additional parameters in your request:
"Generate a wide landscape image in HD quality using DALL-E"
Size: 1792x1024, Quality: HD, Model: DALL-E 3
"Create a tall poster with vivid colors"
Size: 1024x1792, Style: vivid
If using Docker with LibreChat, add to your Dockerfile:
# Install MCP SDK dependencies
RUN npm install @modelcontextprotocol/sdk@^1.17.2
# Copy Azure image generation files
COPY azure-image-generation-server.js ./
Then ensure your docker-compose.yml
includes the environment variables:
services:
api:
environment:
- AZURE_IMAGE_API_KEY=${AZURE_IMAGE_API_KEY}
- AZURE_IMAGE_BASE_URL=${AZURE_IMAGE_BASE_URL}
Generates an AI image based on a text prompt.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
prompt |
string | Yes | - | Description of the image to generate |
model |
string | No | auto |
Model selection: dall-e-3 , flux , or auto |
size |
string | No | 1024x1024 |
Image dimensions: 1024x1024 , 1792x1024 , 1024x1792 |
style |
string | No | vivid |
DALL-E style: vivid or natural |
quality |
string | No | standard |
DALL-E quality: standard or hd |
Returns a structured response with:
- Text description of the generated image
- Base64-encoded PNG image data
- Metadata (model used, size, generation time)
Images not displaying in Azure models:
- Ensure you're using LibreChat with the MCP image rendering fix (included in LibreChat v0.7.9+)
- Check that your
librechat.yaml
configuration is correct
MCP server fails to start:
- Verify environment variables are set correctly
- Check that Node.js version is >= 18.0.0
- Ensure
@modelcontextprotocol/sdk
is installed
API errors:
- Verify your Azure API key is valid
- Check that the base URL points to your Azure OpenAI endpoint
- Ensure your Azure deployment has DALL-E 3 or FLUX enabled
Generation timeout:
- Increase
timeout
value inlibrechat.yaml
(default: 180000ms) - Check your network connectivity to Azure
Enable debug logging by checking LibreChat logs:
# Docker
docker logs librechat-api
# Local
DEBUG=* npm start
"A professional headshot of a software engineer in a modern office"
"Sunset over Tokyo skyline with Mount Fuji in the distance"
"Close-up of fresh vegetables on a wooden cutting board"
"Minimalist logo design for a coffee shop called 'Bean Dreams'"
"Watercolor painting of a cottage in a flower garden"
"Abstract geometric pattern in blues and golds"
"Modern tech startup hero banner image, wide format"
"Instagram post background with pastel gradients"
"Professional LinkedIn banner for a data scientist"
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for LibreChat - Open-source ChatGPT alternative
- Uses Model Context Protocol (MCP) by Anthropic
- Powered by Azure AI Foundry models
- Issues: GitHub Issues
- LibreChat Discord: Join the community
- Documentation: LibreChat Docs
Made with β€οΈ for the LibreChat community