image-mcp-server
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., "@image-mcp-serverGenerate a photo of a cozy cabin in snowy mountains at sunset."
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.
Image MCP Server
Production MCP server for image generation, editing, and local background removal. Cursor connects over a public HTTPS URL. Cursor does not send an API key, Bearer token, OAuth login, or password.
The Kie AI key stays on the server in .env.
What this is
A FastAPI process that exposes:
Streamable HTTP MCP at
/mcpGET /,GET /health,GET /health/readyGET /files/{filename}for generated assets
MCP tools:
generate_image— Kie AI text-to-image with automatic model fallbackedit_image— Kie AI Seedream V4 Editremove_background— localrembg+birefnet-general-lite(no Kie call)
Related MCP server: Photo AI Studio MCP Server
Architecture
Cursor
→ HTTPS
→ Cloudflare Tunnel
→ FastAPI / MCP (127.0.0.1:8000)
├── generate_image → Kie AI
│ nano-banana-pro → gpt-image-2-text-to-image → other models by cost_rank
├── edit_image → bytedance/seedream-v4-edit
└── remove_background → rembg / birefnet-general-lite (local ONNX)Public MCP endpoint:
https://PUBLIC_DOMAIN/mcpCapabilities
Nano Banana Pro first, then GPT Image 2, then automatic fallback
Results downloaded from Kie, converted to WebP, and re-hosted on
/filesLocal free background removal
Rate limits, concurrency semaphore, daily caps
SSRF protection on inbound image URLs
systemd + Cloudflare Tunnel installers for Ubuntu 22.04/24.04
Installation
On Ubuntu 22.04 or 24.04:
sudo bash install.shThe installer:
Installs Python 3.11+, venv, cloudflared
Copies the app to
/opt/image-mcp-serverCreates system user
image-mcpInstalls dependencies
Tries to preload
birefnet-general-liteEnables
image-mcp.serviceChecks
http://127.0.0.1:8000/healthOffers Cloudflare Quick Tunnel, Named Tunnel, or skip
If model preload fails because of network, installation still succeeds. The next process start retries the download.
Configure KIE_API_KEY
sudo nano /opt/image-mcp-server/.envSet:
KIE_API_KEY=your_real_keyRestart:
sudo systemctl restart image-mcpNever put this key in Cursor, in the MCP URL, or in git.
Quick Cloudflare Tunnel
Use this if you do not have a domain. The installer can start it, or:
sudo systemctl enable --now cloudflared-image-mcp
sudo bash /opt/image-mcp-server/get-mcp-url.shYou get a URL like:
https://xxxxx.trycloudflare.com/mcpQuick Tunnel URLs change after every cloudflared restart. After reboot or systemctl restart cloudflared-image-mcp, run get-mcp-url.sh again and update Cursor.
Also set:
PUBLIC_BASE_URL=https://xxxxx.trycloudflare.comso /files links are absolute HTTPS URLs that Kie and Cursor can fetch.
Stable Cloudflare Tunnel
Recommended production setup:
Internet → mcp.example.com → Cloudflare Tunnel → 127.0.0.1:8000sudo cloudflared tunnel login
sudo cloudflared tunnel create image-mcp
sudo cloudflared tunnel route dns image-mcp mcp.example.comCopy and edit the example config. Do not hardcode a tunnel ID from this repo:
sudo mkdir -p /etc/cloudflared
sudo cp /opt/image-mcp-server/deploy/cloudflared-config.example.yml /etc/cloudflared/config.yml
sudo nano /etc/cloudflared/config.ymlReplace IMAGE_MCP_TUNNEL_ID and mcp.example.com, then:
sudo cloudflared tunnel run image-mcpOr install Cloudflare's cloudflared systemd unit and enable it.
Then:
PUBLIC_BASE_URL=https://mcp.example.com
ENABLE_DNS_REBINDING_PROTECTION=true
MCP_ALLOWED_HOSTS=mcp.example.com,127.0.0.1,localhostsudo systemctl restart image-mcpConnect Cursor
No authentication from Cursor.
User MCP config (~/.cursor/mcp.json or Cursor Settings → MCP):
{
"mcpServers": {
"image-mcp": {
"url": "https://mcp.example.com/mcp"
}
}
}Authentication: none. Do not add headers, Bearer, API key, or OAuth.
After a Quick Tunnel restart, replace the URL with the new get-mcp-url.sh value.
MCP tools
Tool | When the model should call it |
| Create / draw / generate a new image from text |
| There is a source image and the user wants it changed |
| Transparent background / cutout / remove background |
The user does not pick Kie model IDs. The server does.
Model fallback
generate_image always starts with nano-banana-pro. If that attempt succeeds, it stops.
If Nano Banana Pro fails for a retryable reason (timeout, HTTP 429/5xx, task fail, empty result, overload), the server tries gpt-image-2-text-to-image, then the remaining enabled text-to-image models sorted by cost_rank in config/models.yaml:
nano-banana-pro
→ gpt-image-2-text-to-image
→ z-image
→ bytedance/seedream-v4-text-to-image
→ qwen3/pro-text-to-image
→ seedream/5-pro-text-to-imagePinned models run first by priority. The rest use cost_rank. Kie public pricing changes; this repo does not invent live dollar prices.
Fallback does not continue on:
missing prompt
invalid Kie API key (401/403)
insufficient Kie credits (402)
fatal server configuration errors
Adapters translate the common MCP input (prompt, aspect_ratio, quality, output_format) into each model's real Kie payload. Edit uses only bytedance/seedream-v4-edit and is never used as a text-to-image fallback.
Kie Market API used here (docs.kie.ai):
POST /api/v1/jobs/createTaskGET /api/v1/jobs/recordInfo?taskId=
WebP output
Public /files URLs are WebP. Kie may return PNG or JPEG; the server converts them locally before hosting. Background removal keeps transparency in lossless WebP.
Background removal
Local only:
rembg + birefnet-general-lite + onnxruntime CPUThe rembg session is created once at startup and reused. BRIA RMBG is not the default and is not used.
Security
Public MCP has no Cursor credential, so the server enforces:
RATE_LIMIT_PER_MINUTEMAX_CONCURRENT_GENERATIONS(asyncio.Semaphore)MAX_GENERATIONS_PER_DAYMAX_GENERATIONS_PER_IP_PER_DAY
Image URL fetch:
HTTP/HTTPS only
blocks localhost, loopback, private IPv4/IPv6, link-local, metadata endpoints
re-validates redirect targets
checks magic bytes with Pillow, not the filename
/files/{filename} only serves UUID-style names from data/outputs. Path traversal is rejected.
KIE_API_KEY is never returned in MCP results, logs, or URLs.
Logs
JSON logs include request_id, tool, model, duration_ms, success, fallback, http_status, task_id.
They do not include the API key, Authorization headers, base64 bodies, or full prompts.
sudo journalctl -u image-mcp -fUsage rows are stored in SQLite (METRICS_DB_PATH). There is no public billing dashboard.
Update
cd /path/to/this/repo
sudo rsync -a --exclude '.venv' --exclude '.env' --exclude 'data' ./ /opt/image-mcp-server/
sudo -u image-mcp /opt/image-mcp-server/.venv/bin/pip install -r /opt/image-mcp-server/requirements.txt
sudo systemctl restart image-mcp
curl -fsS http://127.0.0.1:8000/healthLocal development
Python 3.11+:
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
python -m pytest
uvicorn app.main:app --host 127.0.0.1 --port 8000Health: http://127.0.0.1:8000/health
A public Cloudflare URL is not created in a local Windows checkout. After Ubuntu install, run:
sudo bash /opt/image-mcp-server/get-mcp-url.shTroubleshooting
Symptom | What to check |
|
|
Cursor cannot connect | Confirm HTTPS |
421 from MCP | Hostname not allowed; set |
generate_image says key missing |
|
402 / insufficient credits | Top up Kie; fallback will not help |
remove_background not ready | First-time ONNX download; check disk and network, restart service |
edit from base64 fails |
|
Files 404 after a few days |
|
Uninstall:
sudo bash uninstall.sh
sudo bash uninstall.sh --purgeLicense notes
Application code is provided for this project. Third-party licenses are listed in LICENSES.md. BiRefNet code is MIT; confirm current weight terms before commercial deployment.
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate images with any major model — one API key, one prepaid balance, one MCP.
Multi-model AI image and video generator. 14 models behind one OAuth-secured MCP endpoint.
Create images & video from any MCP agent — 17 models, spend limits, one URL.
AI-powered image processing via GPU. Remove backgrounds and upscale images (2x/4x) directly from any MCP client. OAuth 2.1 authenticated, returns processed images inline with download links. Free credits on signup at maskr.io.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceMCP server for generating, editing, and processing images via multiple providers including Kilo, OpenRouter, OpenAI, and Gemini, with local tools for background removal, resizing, and cropping.19 npm3MIT
- AlicenseAqualityCmaintenanceEnables AI photo generation, editing, and video creation from MCP-compatible clients like Claude Desktop, Cursor, and Windsurf.815 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI image processing tools such as vectorization, background removal, upscaling, and logo generation from any MCP-compatible client like Claude Code or Cursor.13 npmMIT
- AlicenseAqualityBmaintenanceEnables local, CPU-only image and video manipulation—such as background removal, resizing, format conversion, thumbnails, GIF creation, and trimming—through an MCP server without API keys, GPU, or paid dependencies.8MIT