jgkme/kilo-image-gen-mcp

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.

Category
访问服务器

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-backed withoutbg daemon
  • web optimization with sharp
  • deterministic prompt enhancement before generation

Features

  • generate_image for OpenRouter-first generation with response normalization
  • kilo_generate_image for Kilo Gateway routing
  • edit_image for prompt-driven image editing
  • background_remove for local cutouts and the shared local withoutBG daemon
  • resize_image and auto_crop for deterministic local transforms
  • optimize_image for web-ready re-encoding and compression
  • finalize_image for 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 supplied
  • IMAGE_MCP_DEFAULT_MODEL - default model when none is supplied
  • IMAGE_MCP_PROJECT_OUTPUT_DIR - optional project-specific output root
  • IMAGE_MCP_DEFAULT_BG_BACKEND - default local cleanup backend (rmbg, imgly, or withoutbg)
  • WITHOUTBG_DAEMON_URL - local daemon URL, defaults to http://127.0.0.1:8765
  • WITHOUTBG_AUTOSTART=1 - auto-start the shared withoutBG Docker daemon on demand
  • IMAGE_MCP_DEFAULT_BG_ALPHA_THRESHOLD - tighter default mask for logos/header assets
  • IMAGE_MCP_PROMPT_ENHANCE=0 - disable deterministic prompt enhancement
  • IMAGE_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:

  1. Generate an image
  2. Remove background if needed
  3. Inspect the cutout on multiple backgrounds
  4. Optimize the final asset for the web
  5. 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.5
  • openai/gpt-image-1
  • openai/gpt-5-image-mini
  • openai/gpt-5.4-image-2
  • x-ai/grok-imagine-image-quality
  • google/gemini-2.5-flash-image
  • google/gemini-2.5-flash-image-preview
  • google/gemini-3-pro-image-preview
  • sourceful/riverflow-v2.5-fast
  • sourceful/riverflow-v2.5-pro
  • sourceful/riverflow-v2.5-fast:free
  • sourceful/riverflow-v2-fast
  • sourceful/riverflow-v2-pro
  • recraft/recraft-v4.1-utility
  • recraft/recraft-v4.1-vector
  • recraft/recraft-v4.1-utility-pro
  • recraft/recraft-v4.1-pro-vector
  • recraft/recraft-v3
  • black-forest-labs/flux.2-pro
  • black-forest-labs/flux.2-flex

Recommended defaults:

  • Photorealistic work: microsoft/mai-image-2.5 or openai/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 cleanup
  • imgly - higher-quality local cleanup
  • withoutbg - 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 withoutbg is not running, enable WITHOUTBG_AUTOSTART=1 or start the daemon manually.
  • If the model list looks wrong, set IMAGE_MCP_DEFAULT_MODEL explicitly.
  • 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

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选