cf-image-gen MCP Server
Generates images from text prompts using Stable Diffusion via Cloudflare Workers AI.
Generates images and text using Google Gemini models through Cloudflare AI Gateway.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cf-image-gen MCP ServerCreate an image of a futuristic city skyline at night."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
cf-image-gen MCP Server
Generate images and video from text prompts using Cloudflare Workers AI (Stable Diffusion) or Google Gemini models via Cloudflare AI Gateway.
Architecture
Text Prompt → cf-image-gen MCP Server → Cloudflare AI Gateway
├── Workers AI (Stable Diffusion XL)
├── Gemini Image Models (generateContent)
└── Gemini Text Models (Interactions API)Related MCP server: pixel-surgeon-mcp
Models
Workers AI (Direct)
Model | ID | Output |
Stable Diffusion XL |
| 1024×1024 PNG |
Google Gemini (via AI Gateway)
Use google-ai-studio/{modelName} format.
Image Models (generateContent)
Model | Format | Notes |
| image/jpeg | No text, 1120 image tokens |
| image/jpeg | +157 reasoning tokens |
| image/png | Returns text + image |
Text Models (Interactions API)
Model | Notes |
| Latest text model |
Prerequisites
Node.js 18+
Cloudflare account with:
Account ID
API Token (Workers AI)
AI Gateway ID
AI Gateway Auth Token (for Gemini models)
Google AI Studio API key (for Gemini models)
Environment Variables
Variable | Required | Description |
| ✅ | Cloudflare Account ID |
| ✅ | Cloudflare API Token |
| For Gemini | AI Gateway ID |
| For Gemini | Google AI Studio API Key |
| For Gemini | AI Gateway Auth Token |
| ❌ | Output directory (default: |
Usage
Via MCP Tool
{
"prompt": "a samurai warrior standing on a mountain at sunset, pixel art style, 8-bit game aesthetic",
"model": "google-ai-studio/gemini-3.1-flash-image"
}Or with Stable Diffusion (default):
{
"prompt": "a red apple on white background"
}Example Output
Gemini 3.1 Flash Image — google-ai-studio/gemini-3.1-flash-image
Prompt: "a samurai warrior standing on a mountain at sunset, pixel art style, 8-bit game aesthetic"

How It Works
Workers AI path: Direct call to
POST /accounts/{id}/ai/run/{model}with Cloudflare API TokenAI Gateway path: Routes through
gateway.ai.cloudflare.com/v1/{account}/{gateway}/Image-capable models →
v1beta/models/{model}:generateContentwithgenerationConfig.responseModalities: ["IMAGE"]Text-only models (gemini-3-flash*) →
v1beta/interactionswith plain string input
Development
# Install dependencies
cd .opencode/mcp/cf-image-gen
npm install
# Run standalone (stdio)
# Configure in opencode.jsonc as MCP serverLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate images, videos, voiceovers, and captions from a chat prompt.
Create images and videos from prompts, with options for image mixing, reference images, and start/…
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Generate AI images, video, speech, music and presentations from Claude, ChatGPT and Cursor.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to generate images using Cloudflare Workers AI models directly through the Model Context Protocol. It supports various models like Flux and Stable Diffusion, providing seamless image generation and storage via Cloudflare R2.7Apache 2.0
- AlicenseAqualityCmaintenanceAI image and video generation, editing, and region repair via Gemini, OpenAI, and Grok1123 npm5MIT
- FlicenseNot gradedqualityBmaintenanceImage generation MCP server running on Cloudflare Workers, supporting multiple models like FLUX and SDXL with OpenAI-compatible endpoints.-
- AlicenseNot gradedqualityBmaintenanceProvides image generation tools powered by OpenRouter, running on Cloudflare Workers.26 npmMIT