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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。