
Image Generation MCP Server
io.github.pvliesdonk由 GitHub 帳號 pvliesdonk 發布v1.12.1更新於 Oct 24, 2026
MCP server for AI image generation via OpenAI, Stable Diffusion (SD WebUI), or placeholders.
概覽
本機 MCP 伺服器,讓助理透過 OpenAI、Google Gemini、Stable Diffusion WebUI 或佔位提供者產生、轉換、瀏覽與儲存 AI 圖像。
- 可以做什麼
- 透過 OpenAI、Gemini、SD WebUI 或零成本佔位提供者產生圖像,支援依關鍵字自動選擇提供者,長時間任務可在背景執行並輪詢狀態。查詢伺服器版本、提供者能力與棄用警告,方便在請求前選擇模型或提供者。列出可用提供者與模型及其風格設定和棄用提示。儲存可重複使用的風格簡報,供後續請求套用。以畫廊檢視瀏覽近期產生的結果。對既有圖像進行縮放、裁切、重新編碼或替換背景等轉換。
- 適用情境
- 當你希望助理依提示詞產生或編輯圖像、在本機保留結果畫廊並重複使用已儲存的風格,且需要在付費雲端服務與自架 Stable Diffusion 之間選擇時使用。
- 執行需求
- 以本機 Python 套件(uvx 或 pip)或 Docker 映像執行。實際產生需要 OpenAI 或 Google Gemini 的 API 金鑰,或可連線的 SD WebUI 位址;佔位提供者不需任何金鑰。除非將 IMAGE_GENERATION_MCP_READ_ONLY 設為 false,否則寫入類工具會被隱藏。HTTP 部署可加上 bearer 或 OIDC 驗證。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Image Generation MCP Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Image Generation MCP
[CI] [codecov] [PyPI] [Python] [License] [Docker] [Docs] [llms.txt] [Template]
Multi-provider image generation MCP server built on FastMCP. Generate images from Claude Desktop, Claude Code, or any MCP client using OpenAI, Google Gemini, Stable Diffusion (SD WebUI), or a zero-cost placeholder provider.
Documentation | Config wizard | PyPI | Docker
Features
- Multi-provider: OpenAI (
gpt-image-2,gpt-image-1.5,dall-e-3), Google Gemini (gemini-3.1-flash-image,gemini-3-pro-image,gemini-3.1-flash-lite-image), SD WebUI (Stable Diffusion / Forge / reForge), and a zero-cost placeholder for testing. - Per-model style metadata: every model carries a
style_profile(strengths, prompt grammar, lifecycle);list_providersincludes a top-levelwarningsarray for deprecated models. See Model Catalog. - Keyword-based auto-selection:
provider="auto"routes by prompt content (text/logo → OpenAI, photoreal/anime → SD WebUI, draft → placeholder). - CDN-style image transforms:
image://{id}/view?format=webp&width=512&crop_x=...resizes / re-encodes / crops on demand without re-generating. - Hybrid background tasks: long-running SD generations run with
task=True(poll for status); short OpenAI calls stream progress in the foreground. - MCP Apps gallery + viewer: interactive UI surfaces (browse generated images, edit / crop / rotate) for clients that support
app:resources. - Production deployment: Docker (multi-arch),
.deb/.rpmwith hardened systemd, OIDC + bearer auth, persistent EventStore for HTTP session resumability.
What you can do with it
With this server mounted in an MCP client, you can ask:
- "Generate a coffee mug product photo on a worn oak table, 16:9, no text." Routes to
gpt-image-1.5for typography-aware photorealism. - "Create three concept-art variations of a cyberpunk alley at dusk." Composes
generate_imagewithprovider="sd_webui"and a stylised checkpoint likedreamshaperXL. - "Crop this image to a 1:1 square centred on the subject and resize to 512px." Uses
image://{id}/view?width=512&height=512&crop_x=...resource transforms. - "Show me my recent generations." Browses the gallery via the
image://listresource and the MCP Apps gallery viewer. - "Save this style as 'cyberpunk-night' so I can apply it to future requests." Uses the style library, whose markdown briefs the LLM interprets per-provider.
- "Replace the background of my last photo with a sunset sky." Uses
transform_imagewith the galleryimage_idas a reference (image-to-image via Gemini).
Installation
From PyPI
If you add optional extras via the PROJECT-EXTRAS-START / PROJECT-EXTRAS-END sentinels in pyproject.toml, document them below:
Example: pip install image-generation-mcp[all].
From source
Docker
To run the newest merged code instead of the newest release, use the rolling edge tag. It is rebuilt on every merge to main and carries no version identity. See Image tags for the full tag list.
A compose.yml ships at the repo root as a starting point. Copy .env.example to .env, edit, and docker compose up -d.
To attach a remote Python debugger (development only; the protocol is unauthenticated), see Remote debugging.
Linux packages (.deb / .rpm)
Download .deb or .rpm packages from the GitHub Releases page. Both install a hardened systemd unit; env configuration is sourced from /etc/image-generation-mcp/env (copy from the shipped /etc/image-generation-mcp/env.example).
Claude Desktop (.mcpb bundle)
Download the .mcpb bundle from the GitHub Releases page and double-click to install, or run:
Claude Desktop prompts for required env vars via a GUI wizard, with no manual JSON editing needed.
For manual Claude Desktop configuration and setup options, see Claude Desktop deployment.
Release channels
Artifacts ship on three channels. Each row lists exactly what that channel publishes.
Pre-releases reach PyPI so that a candidate's .mcpb bundle installs: the bundle points at PyPI rather than carrying the code. Ordinary installers never see them, because a PEP 440 resolver skips pre-releases unless the requirement pins one or you pass --pre. Ask for a candidate by name with pip install image-generation-mcp==X.Y.ZrcN. PyPI spells it in the PEP 440 canonical form, while tags use SemVer. Rolling pointers are ordering-aware, so a patch release cut from an old release/X.Y branch never moves latest-style tags back to older content, and a candidate for an already-released version never moves rc. See Release process for the full model.
Quick start
For library usage (embedding the domain logic without the MCP transport), import from the image_generation_mcp package directly. See the project's domain modules under src/image_generation_mcp/ for entry points.
Server info
The server registers a built-in get_server_info tool (via fastmcp_pvl_core.register_server_info_tool) so operators can confirm the deployed version with a single MCP call. The default response carries server_name, server_version, and core_version. Servers that talk to a remote upstream wire upstream version reporting inside the DOMAIN-UPSTREAM-START / DOMAIN-UPSTREAM-END sentinel in src/image_generation_mcp/server.py; see CLAUDE.md for the wiring pattern.
Configuration
Core environment variables shared across all fastmcp-pvl-core-based services:
Domain-specific variables go below under Domain configuration.
Authentication
Callers authenticate via a bearer token or OIDC (mutually exclusive). See the Authentication guide for setup, mapped multi-subject tokens, OIDC, and troubleshooting.
Post-scaffold checklist
After copier copy and gh repo create --push:
- Fill in the DOMAIN blocks (every section marked with a
DOMAINsentinel comment) in this README and inCLAUDE.md. TheGENERATED-ENV-TABLE-*regions are not DOMAIN blocks; the config generator owns them and rewrites them on every run. - Configure GitHub secrets (see below).
- Install dev + docs tooling:
uv sync --all-extras --all-groups. - Install pre-commit hooks:
uv run pre-commit install. - Run the gate locally:
uv run pytest -x -q && uv run ruff check --fix . && uv run ruff format . && uv run mypy src/ tests/. - Push the first commit. CI should be green.
GitHub secrets
CI workflows reference three repository secrets. Configure them via Settings → Secrets and variables → Actions or with gh secret set:
Dependency updates are handled by Renovate (
renovate.yml), which reusesRELEASE_TOKEN. It maintainsuv.lockand auto-merges patch/minor bumps once theCI Successcheck is green;bootstrap.ymlenables auto-merge and applies the repository rulesets (.github/rulesets/) on first push. See Repository Protection for the per-branch posture and bypass model. GitHub Actions are updated in the copier template and arrive viacopier update, not per-repo.
GITHUB_TOKEN is auto-provided; no action needed.
Local development
The PR gate (matches CI):
Pre-commit runs a subset of the gate on each commit; see .pre-commit-config.yaml for details, or CLAUDE.md for the full Hard PR Acceptance Gates.
Troubleshooting
Moving a scaffolded project
uv sync creates .venv/bin/* scripts with absolute shebangs pointing at the venv Python. If you move the repo after scaffolding (mv /old/path /new/path), uv run pytest fails with ModuleNotFoundError: No module named 'fastmcp' because the stale shebang resolves to a different interpreter than the venv's site-packages.
Fix:
uv run python -m pytest also works as a one-shot workaround (bypasses the stale entry-script shim).
uv.lock refresh after copier update
When copier update introduces new dependencies (such as a new extra added to pyproject.toml.jinja), the CI install step runs uv sync --locked, which fails against a stale lockfile. Run uv lock locally and commit the refreshed uv.lock alongside accepting the copier-update PR.
CI installs with --locked (and the review workflow with --frozen) so no job ever rewrites uv.lock in its own workspace: a job that re-locks hides the drift it just repaired, and a dirty workspace breaks any later git checkout in the same job. Lockfile drift then shows up as a red install step with a clear message, not as a silent mutation.
Links
Domain configuration
Domain environment variables use the IMAGE_GENERATION_MCP_ prefix:
The create_download_link / create_upload_link tools and the /transfer/{token} route register only on an HTTP or SSE transport with BASE_URL set, and store link tokens in IMAGE_GENERATION_MCP_KV_STORE_URL; the IMAGE_GENERATION_MCP_TRANSFER_* knobs above tune link lifetime and upload limits. Security: IMAGE_GENERATION_MCP_ALLOW_LOCAL_FILE_INPUT grants callers server-filesystem read access via reference-image paths; enable it only for trusted callers or local single-user deployments.
Domain-config fields are composed inside src/image_generation_mcp/config.py between the CONFIG-FIELDS-START / CONFIG-FIELDS-END sentinels; env reads go through fastmcp_pvl_core.env(_ENV_PREFIX, "SUFFIX", default) so naming stays consistent, and field invariants go in __post_init__ between the CONFIG-VALIDATE-START / CONFIG-VALIDATE-END sentinels. Each field's metadata help and tags generate the table above directly, so keep them accurate and complete.
Key design decisions
- Multi-provider with capability discovery, not feature flags. Each provider's
discover_capabilities()reports its actual supported aspect ratios / qualities / formats / negative-prompt support at startup; routing logic asks the capability surface, not a hard-coded enum. New providers slot in by satisfying the protocol, with no router edits needed. (Seedocs/decisions/0001-…,0002-…,0007-….) - Per-model
style_profilemetadata, surfaced vialist_providers. Closed-list providers (OpenAI, Gemini, placeholder) use exact-key lookup; SD WebUI uses a regex-ordered pattern table. Profiles include lifecycle flags (current/legacy/deprecated) and feed an auto-built top-levelwarningsarray. (Seedocs/decisions/0009-….) - Hybrid background tasks. Short calls (OpenAI ~5 s) stream progress in-line; long calls (SD WebUI 30-180 s) run as background tasks with
check_generation_statuspolling; clients pick the mode viatask=True. (Seedocs/decisions/0005-….) - Image asset model: content-addressed registry + sidecar JSON metadata + on-demand transforms. Generated images keep their full-resolution original;
image://{id}/view?format=webp&width=512&crop_x=…resources do format conversion / resize / crop on demand without re-generating. Transforms are cached. (Seedocs/decisions/0006-….) - Style library. User-saved markdown briefs (with YAML frontmatter for tags / aspect ratio / quality) that the LLM interprets per-provider, not copy-pasted verbatim. Distinct from per-model
style_profile: style library is the brief;style_profiledescribes the model. (Seedocs/decisions/0008-…and0009-…for disambiguation.) - Composes
fastmcp_pvl_core.ServerConfig, never inherits. Domain config goes betweenCONFIG-FIELDS-START/CONFIG-FIELDS-ENDsentinels; env reads route throughfastmcp_pvl_core.env(...)to keep prefix naming consistent.
來源:README.md,提交 d417419
工具
0版本歷史
1- v1.12.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分