jgkme/kilo-image-gen-mcp
MCP 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.
README
img-gen-mcp
img-gen-mcp is a local-first MCP server for image generation, editing, background removal, optimization, and final asset delivery.
It combines:
- OpenRouter-first image generation
- Kilo Gateway support
- OpenAI and Gemini image generation
- local background cleanup with
rmbg,imgly, and a shared Docker-backedwithoutbgdaemon - web optimization with
sharp - deterministic prompt enhancement before generation
Features
generate_imagefor OpenRouter-first generation with response normalizationkilo_generate_imagefor Kilo Gateway routingedit_imagefor prompt-driven image editingbackground_removefor local cutouts and the shared local withoutBG daemonresize_imageandauto_cropfor deterministic local transformsoptimize_imagefor web-ready re-encoding and compressionfinalize_imagefor a one-call local workflow that can remove background, trim, crop, and resize- alpha stats and multi-background inspection sheets for post-processing QA
- prompt enhancement before generation
- automatic web optimization after background removal/finalize
- debug mode via
IMAGE_MCP_DEBUG=1
Install
npm install -g img-gen-mcp
Configuration
Set these environment variables in your MCP client:
IMAGE_MCP_DEFAULT_PROVIDER- default provider when none is suppliedIMAGE_MCP_DEFAULT_MODEL- default model when none is suppliedIMAGE_MCP_PROJECT_OUTPUT_DIR- optional project-specific output rootIMAGE_MCP_DEFAULT_BG_BACKEND- default local cleanup backend (rmbg,imgly, orwithoutbg)WITHOUTBG_DAEMON_URL- local daemon URL, defaults tohttp://127.0.0.1:8765WITHOUTBG_AUTOSTART=1- auto-start the shared withoutBG Docker daemon on demandIMAGE_MCP_DEFAULT_BG_ALPHA_THRESHOLD- tighter default mask for logos/header assetsIMAGE_MCP_PROMPT_ENHANCE=0- disable deterministic prompt enhancementIMAGE_MCP_DEBUG=1- include detailed tool errors and provider payloads
Example MCP config:
{
"mcp": {
"img-gen-mcp": {
"type": "local",
"command": ["npx", "-y", "img-gen-mcp"],
"enabled": true,
"environment": {
"IMAGE_MCP_DEFAULT_PROVIDER": "openrouter",
"IMAGE_MCP_DEFAULT_MODEL": "openai/gpt-image-1",
"IMAGE_MCP_DEFAULT_BG_BACKEND": "imgly",
"WITHOUTBG_DAEMON_URL": "http://127.0.0.1:8765",
"WITHOUTBG_AUTOSTART": "1"
}
}
}
}
See docs/public/clients.md for ready-to-use examples for Kilo, Cursor, and generic MCP clients.
Workflow
The typical pipeline is:
- Generate an image
- Remove background if needed
- Inspect the cutout on multiple backgrounds
- Optimize the final asset for the web
- Save and ship the final PNG/WebP/JPEG/AVIF
Common Uses
- logos
- icons
- header artwork
- product photography
- realistic subject cutouts
- transparent PNG delivery
Models
Supported OpenRouter image models include:
microsoft/mai-image-2.5openai/gpt-image-1openai/gpt-5-image-miniopenai/gpt-5.4-image-2x-ai/grok-imagine-image-qualitygoogle/gemini-2.5-flash-imagegoogle/gemini-2.5-flash-image-previewgoogle/gemini-3-pro-image-previewsourceful/riverflow-v2.5-fastsourceful/riverflow-v2.5-prosourceful/riverflow-v2.5-fast:freesourceful/riverflow-v2-fastsourceful/riverflow-v2-prorecraft/recraft-v4.1-utilityrecraft/recraft-v4.1-vectorrecraft/recraft-v4.1-utility-prorecraft/recraft-v4.1-pro-vectorrecraft/recraft-v3black-forest-labs/flux.2-problack-forest-labs/flux.2-flex
Recommended defaults:
- Photorealistic work:
microsoft/mai-image-2.5oropenai/gpt-image-1 - Quick stylized work:
x-ai/grok-imagine-image-quality - Logos / vector-like work:
recraft/recraft-v4.1-vector - Broad prompt-following general use:
sourceful/riverflow-v2.5-pro
Background Removal Backends
rmbg- fastest lightweight local cleanupimgly- higher-quality local cleanupwithoutbg- shared Docker-backed local daemon for harder edges, fur, and transparent cutouts
Start the shared daemon once:
docker compose -f withoutbg-daemon/docker-compose.yml up -d
If WITHOUTBG_AUTOSTART=1 is set, the MCP will try to start it automatically when backend=withoutbg is used.
Web Optimization
background_remove and finalize_image automatically run a web optimization pass after cleanup.
Use optimize_image directly when you want explicit control:
- PNG for transparent cutouts
- WebP for opaque assets
- JPEG for flattened web images
- AVIF for aggressive compression
Docs
- Public docs drafts live in
docs/public/ - Wiki-ready pages live in
docs/wiki/ - Migration notes and setup details are documented there for public release
Troubleshooting
- If
withoutbgis not running, enableWITHOUTBG_AUTOSTART=1or start the daemon manually. - If the model list looks wrong, set
IMAGE_MCP_DEFAULT_MODELexplicitly. - If image generation fails with provider-specific errors, verify the provider API key in your MCP environment.
- If you need the raw response details, set
IMAGE_MCP_DEBUG=1.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.