Image Generation MCP Server
Integrates with Cloudflare R2 object storage to upload selected generated images and return permanent public URLs, with support for custom domains and free egress.
Integrates with Google Gemini for AI image generation, allowing text prompts to produce image variations via the Gemini API, including use of its free tier.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Image Generation MCP Server
A Model Context Protocol (MCP) server for AI image generation. Generate images from text prompts directly in Claude Code or any MCP-compatible client, with automatic cloud storage upload and cost tracking.
Why This Exists
Content creators need images. Getting them usually means:
Opening a separate tool (Midjourney, DALL-E, etc.)
Generating variations
Downloading the one you want
Uploading to your hosting
Getting the URL back into your workflow
This MCP server reduces that to a single conversation:
You: Generate an image of a serene mountain landscape at dawn
Claude: [generates 3 variations, shows previews]
Which one works best?
You: The second one
Claude: Done! https://images.yourdomain.com/2026/02/mountain-dawn.jpgDemo
https://github.com/user-attachments/assets/61ae6cbe-6379-4a0d-811c-e9352698dd87
Related MCP server: free-ai-image-gen-tools-gateway
Features
Multi-provider support: Gemini (free tier!), Fal.ai — more providers coming soon
Cloud storage: Cloudflare R2 (free egress), local storage
Cost tracking: Per-generation costs, monthly budgets, alerts
Generation history: SQLite-backed, queryable via MCP tools
Preview → Select workflow: Generate variations, pick the best, auto-upload
Quick Start
1. Install
# Clone the repo
git clone https://github.com/maheshcr/image-gen-mcp.git
cd image-gen-mcp
# Install dependencies
npm install
# Build
npm run build2. Configure (Interactive Wizard)
npm run setupThe wizard will guide you through:
Choosing an image provider (with links to get API keys)
Configuring storage (local or cloud)
Optional budget limits
╭─────────────────────────────────────────────────────────╮
│ Image Generation MCP - Setup Wizard │
╰─────────────────────────────────────────────────────────╯
━━━ Step 1/3: Image Provider ━━━
Choose your image generation provider:
────────────────────────────────────────
1. Gemini (https://ai.google.dev/)
2. Fal.ai (https://fal.ai/)
Select [1-2]: 1
Get your API key at: https://ai.google.dev/
Enter your Gemini API key: ********If you prefer manual setup:
mkdir -p ~/.config/image-gen-mcp
cp config.example.yaml ~/.config/image-gen-mcp/config.yaml
# Edit config.yaml with your settingsSee config.example.yaml for all options.
3. Set Environment Variables (if not using wizard)
# For Gemini (recommended - has free tier)
export GOOGLE_API_KEY="your-api-key"
# For Fal.ai
export FAL_API_KEY="your-api-key"
# For Cloudflare R2
export R2_ENDPOINT="https://xxx.r2.cloudflarestorage.com"
export R2_ACCESS_KEY="your-access-key"
export R2_SECRET_KEY="your-secret-key"4. Add to Claude Code
claude mcp add image-gen "node /path/to/image-gen-mcp/dist/server.js"Or add to ~/.claude/settings.json:
{
"mcpServers": {
"image-gen": {
"command": "node",
"args": ["/path/to/image-gen-mcp/dist/server.js"]
}
}
}5. Restart Claude Code
# Restart to load the new MCP server
claudeMCP Tools
generate_images
Generate images with AI. Returns preview URLs for selection.
Parameters:
Parameter | Type | Default | Description |
| string | required | The image generation prompt |
| string | - | What to avoid in the image |
| number | 3 | Number of variations (1-4) |
| string | "16:9" | "1:1", "16:9", "9:16", "4:3" |
| string | - | Context hint (e.g., "blog header") |
Returns:
{
"generation_id": "uuid",
"images": [
{ "index": 0, "preview_url": "...", "local_path": "..." },
{ "index": 1, "preview_url": "...", "local_path": "..." }
],
"cost": 0.02,
"model_used": "gemini-2.0-flash-exp"
}select_image
Select an image and upload to permanent storage.
Parameters:
Parameter | Type | Default | Description |
| string | required | From generate_images response |
| number | required | Which image to select (0-indexed) |
| string | auto | Custom filename (optional) |
Returns:
{
"permanent_url": "https://images.yourdomain.com/2026/02/image.jpg",
"markdown": ""
}list_generations
List recent generations.
Parameters:
Parameter | Type | Default | Description |
| number | 10 | Number of generations to return |
get_costs
Get cost tracking information.
Parameters:
Parameter | Type | Default | Description |
| string | "month" | "day", "week", "month", "all" |
Returns:
{
"total": 2.50,
"generation_count": 45,
"by_provider": { "gemini": 2.50 },
"budget_remaining": 7.50
}configure
View or update settings from within Claude Code.
Parameters:
Parameter | Type | Description |
| boolean | Show current configuration |
| string | Switch provider: gemini, fal |
| string | Set default model |
| number | Set monthly budget in USD |
| number | Default variations per generation (1-4) |
| string | Default aspect ratio |
Examples:
"Show my current config" → configure()
"Switch to Fal.ai" → configure({ provider: "fal" })
"Set budget to $20/month" → configure({ budget_limit: 20 })
"Generate 2 images by default" → configure({ count: 2 })Supported Providers
Provider | Models | Pricing | Links |
Gemini | gemini-2.0-flash-exp | Free tier available | |
Fal.ai | Flux Schnell, Flux Dev, SDXL | ~$0.01-0.03/image |
More providers (Together.ai, Replicate, HuggingFace) are on the roadmap.
Supported Storage
Provider | Egress Cost | Links |
Cloudflare R2 | Free egress | |
Local | N/A | For development/testing |
Configuration Reference
See config.example.yaml for full configuration options.
Provider Configuration
provider:
name: gemini # gemini | fal
api_key: ${API_KEY} # Use env var reference
default_model: ... # Provider-specific model ID
fallback_provider: fal # Optional fallbackStorage Configuration
storage:
name: r2 # r2 | local
bucket: my-images # Bucket name (r2/b2)
endpoint: ... # S3-compatible endpoint
access_key: ... # S3 access key
secret_key: ... # S3 secret key
public_url_prefix: ... # Public URL for serving images
path_template: "{year}/{month}/{filename}"Budget Configuration
budget:
monthly_limit: 10.00 # USD, 0 for unlimited
alert_threshold: 0.8 # Alert at 80%
alert_method: log # log | webhookDevelopment
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Watch mode for development
npm run devProject Structure
image-gen-mcp/
├── src/
│ ├── server.ts # MCP server entry point
│ ├── tools/ # MCP tool implementations
│ ├── providers/ # Image generation providers
│ ├── storage/ # Storage backends
│ ├── db/ # SQLite generation store
│ └── config/ # Configuration loading
├── tests/
├── config.example.yaml
└── package.jsonTroubleshooting
"MCP server not responding"
Check the server runs standalone:
node dist/server.jsVerify config path:
~/.config/image-gen-mcp/config.yamlCheck environment variables are set
"API key invalid"
Verify the key is correct
Check the env var is exported (not just in .env)
For Gemini, ensure the API is enabled in Google Cloud Console
"Upload failed"
Verify R2 credentials
Check bucket exists and is accessible
Verify
public_url_prefixmatches your R2 custom domain
Contributing
Contributions welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Submit a pull request
License
MIT - see LICENSE
Acknowledgments
Model Context Protocol by Anthropic
Fal.ai for fast image generation
Cloudflare R2 for free egress storage
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
Generate images, video, audio and short films with 140+ AI models from any MCP client.
Generate images with any major model — one API key, one prepaid balance, one MCP.
Direct AI video, image, music and storyboard production from any MCP client.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI image and video generation, editing, and history tracking inside MCP clients using OpenAI, Google Gemini, and Veo models, with flexible API key or cookie-based configuration.121MIT
- FlicenseNot gradedqualityCmaintenanceEnables MCP clients to generate images through multiple free/low-cost providers with automatic failover, plus session history, provider status, and configuration tools.-
- AlicenseNot gradedqualityAmaintenanceEnables users to generate and edit images from any MCP client by automatically enriching short requests with composition, lighting, and camera details before sending them to Gemini, OpenAI, or BytePlus Seedream. Supports quality presets, aspect ratios, multiple input images for editing, and provider switching per request.1,225 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables any MCP client to create and edit images from natural-language requests, automatically enriching short prompts with composition, lighting, and camera details while supporting Gemini, OpenAI, and BytePlus Seedream with fast, balanced, or quality presets.1,225 npmMIT