TY

tan-yong-sheng/cloudflare-image-mcp

Developer tools
5 stars 47 forks Quality 70 Trend 33

OpenAI-compatible image generation API + Streamable HTTP MCP server powered by Cloudflare Workers AI.

Overview

OpenAI-compatible image generation API + Streamable HTTP MCP server powered by Cloudflare Workers AI. - : /v1/images/generations + /v1/images/edits endpoints - : HTTP transport with SSE (streamable) - : FLUX, SDXL, Stable Diffusion, and more - : Text-to-image, image-to-image (masked edits supported) - : React SPA for image generation and provider credentials - : Auto-expiring image storage with CDN 1. to your Cloudflare account (takes 5 minutes): 👉 2. Note your worker URL after deployment: 3. If you set API_KEYS during deployment, you'll need the key for authentication. Below are the configuration guides for different MCP clients. This server uses (not stdio) since it runs on Cloudflare Workers. This server implements the . Configure your client with: - : HTTP/SSE (streamable) - : https://your-worker.workers.dev/mcp - (if API_KEYS set): send Authorization: Bearer YOUR_KEY header

README

Cloudflare Image MCP

OpenAI-compatible image generation API + Streamable HTTP MCP server powered by Cloudflare Workers AI.

🌟 Features

  • OpenAI-Compatible API: /v1/images/generations + /v1/images/edits endpoints
  • MCP Protocol Support: HTTP transport with SSE (streamable)
  • 10 Image Generation Models: FLUX, SDXL, Stable Diffusion, and more
  • Multiple Tasks: Text-to-image, image-to-image (masked edits supported)
  • Web Frontend: React SPA for image generation and provider credentials
  • R2 Storage: Auto-expiring image storage with CDN

📦 What’s Included

cloudflare-image-mcp/
├── workers/           # Cloudflare Worker (API + MCP)
├── client/            # React SPA (Vite + Tailwind + TanStack Query)
└── e2e/               # Playwright E2E tests

🚀 Quick Start

Prerequisites

  1. Deploy this MCP server to your Cloudflare account (takes 5 minutes): 👉 Deployment Guide

  2. Note your worker URL after deployment:

    https://cloudflare-image-workers..workers.dev
    
  3. If you set API_KEYS during deployment, you’ll need the key for authentication.

MCP Client Configuration

Below are the configuration guides for different MCP clients. This server uses HTTP/SSE transport (not stdio) since it runs on Cloudflare Workers.


📖 Usage

OpenAI-Compatible API

curl -X POST "https://your-worker.workers.dev/v1/images/generations" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{
    "model": "@cf/black-forest-labs/flux-1-schnell",
    "prompt": "A beautiful sunset over mountains",
    "n": 1,
    "size": "1024x1024"
  }'

And it can be used for OpenWebUI’s image generation feature and image edits feature:

MCP Tools

Available Tools:

  • list_models - List all available models
  • describe_model - Get model parameters and limits
  • run_model - Generate images

Connect via MCP:

{
  "mcpServers": {
    "image-gen": {
      "url": "https://your-worker.workers.dev/mcp"
    }
  }
}

Web Frontend

Open your worker URL in a browser for an interactive UI. The frontend is a React single-page app deployed as Workers Static Assets: the Worker owns the API routes and hands the client’s build output to the browser. /admin opens the provider credentials workbench.


🎨 Supported Models

📋 Detailed Model Specifications → — Full parameter reference, feature comparison, and capability matrix.

Model Tasks Provider Hosted By
FLUX.1 [schnell] text-to-image Black Forest Labs Cloudflare
FLUX.2 [klein] text-to-image, image-to-image Black Forest Labs Cloudflare
FLUX.2 [dev] text-to-image, image-to-image Black Forest Labs Cloudflare
SDXL Base 1.0 text-to-image, image-to-image (img2img + masked edits) Stability AI Cloudflare
SDXL Lightning text-to-image ByteDance Cloudflare
Dreamshaper 8 LCM text-to-image, image-to-image (img2img) Lykon Cloudflare
Lucid Origin text-to-image Leonardo.AI Cloudflare
Phoenix 1.0 text-to-image Leonardo.AI Cloudflare
SD 1.5 Img2Img image-to-image (img2img) Runway ML Cloudflare
SD 1.5 Inpainting image-to-image (requires mask) Runway ML Cloudflare
Agnes Image 2.5 Flash text-to-image, image-to-image Agnes AI Agnes AI
Agnes Image 2.1 Flash text-to-image, image-to-image Agnes AI Agnes AI
Agnes Image 2.0 Flash text-to-image, image-to-image Agnes AI Agnes AI

Provider = who built the model. Hosted By = who actually serves the inference API (and bills for it): Cloudflare Workers AI for the @cf/* models, Agnes AI’s own OpenAI-compatible endpoint for agnes-image-*. Cloudflare’s ids are namespaced (@cf/{provider}/{model}); the Agnes id is the bare upstream model name, which is what the transport sends.


📚 Documentation

Document Description
Deployment Guide Step-by-step deployment instructions
Credentials Setup Environment variables and API tokens
MCP Guide MCP protocol and tools reference
API Reference REST endpoints documentation

🧪 Testing

# Run E2E tests against staging/production
npm run test:e2e:staging
npm run test:e2e:production

🔧 Development

# Type check
npm run build

# Run E2E tests
npm run test:e2e:staging

📝 License

MIT


Built with:

View the full README on GitHub

Install

This server does not publish a one-line install command.

Open the repository installation guide New to MCP? Start with the mcpskill.org guide →

Configuration

{ "mcpServers": { "cloudflare-image": { "url": "https://your-worker.workers.dev/mcp" } } }