FastMCP server template — replace this with your description
Project description
image-generation-mcp
Multi-provider image generation MCP server built on FastMCP. Generate images from Claude Desktop, Claude Code, or any MCP client using OpenAI, Stable Diffusion (A1111 WebUI), or a zero-cost placeholder provider.
Documentation | PyPI | Docker
Features
- Multi-provider architecture -- OpenAI (gpt-image-1, dall-e-3), A1111 (Stable Diffusion WebUI), and a zero-cost placeholder provider
- Keyword-based auto-selection -- automatically picks the best provider for your prompt (text/logo -> OpenAI, photorealism/anime -> A1111, test/draft -> placeholder)
- MCP tools --
generate_image(with background task support) andlist_providers - MCP resources --
info://providers,image://{id}/viewwith CDN-style transforms (format, resize, crop),image://{id}/metadata,image://list - MCP prompts --
select_provider(provider selection guidance) andsd_prompt_guide(CLIP tag format, negative prompts, BREAK syntax) - Image asset model -- content-addressed image registry with sidecar JSON metadata, thumbnail previews, and resource URI-based transforms
- Background tasks -- hybrid foreground (streaming progress) and background (polling) execution via
task=True - Read-only mode -- write tools hidden via
mcp.disable(tags={"write"})for safe read-only deployments - Authentication -- bearer token, OIDC (OAuth 2.1), and multi-auth (both simultaneously)
- Docker -- multi-arch image with
gosuprivilege dropping, configurable PUID/PGID - CI/CD -- test matrix (Python 3.11-3.14), ruff, mypy, pip-audit, gitleaks, CodeQL, semantic-release
Installation
From PyPI
# Core + MCP server
pip install image-generation-mcp[mcp]
# With OpenAI provider
pip install image-generation-mcp[all]
Available extras:
| Extra | Includes |
|---|---|
mcp |
fastmcp[tasks]>=3.0,<4 |
openai |
openai>=1.0 |
all |
fastmcp[tasks]>=3.0,<4 + openai>=1.0 |
dev |
All above + pytest, ruff, mypy, pip-audit |
docs |
mkdocs-material, mkdocstrings, mkdocs-llmstxt |
From source
git clone https://github.com/pvliesdonk/image-generation-mcp.git
cd image-generation-mcp
uv sync --extra all --extra dev
Docker
docker pull ghcr.io/pvliesdonk/image-generation-mcp:latest
Quick start
As MCP server (stdio)
# Placeholder only -- no API keys needed
IMAGE_GENERATION_MCP_READ_ONLY=false image-generation-mcp serve
# Generate your first image -- ask Claude or call via MCP client:
# generate_image(prompt="a sunset over the ocean", provider="placeholder")
# With OpenAI
IMAGE_GENERATION_MCP_READ_ONLY=false \
IMAGE_GENERATION_MCP_OPENAI_API_KEY=sk-... \
image-generation-mcp serve
As MCP server (HTTP)
IMAGE_GENERATION_MCP_READ_ONLY=false \
image-generation-mcp serve --transport http --port 8000
With Docker Compose
docker compose up -d
See Docker deployment for volumes, UID/GID, and Traefik setup.
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"image-gen": {
"command": "image-generation-mcp",
"args": ["serve"],
"env": {
"IMAGE_GENERATION_MCP_READ_ONLY": "false",
"IMAGE_GENERATION_MCP_OPENAI_API_KEY": "sk-..."
}
}
}
}
Claude Code
Add to your project's .mcp.json:
{
"mcpServers": {
"image-gen": {
"command": "image-generation-mcp",
"args": ["serve"],
"env": {
"IMAGE_GENERATION_MCP_READ_ONLY": "false"
}
}
}
}
Configuration
All environment variables use the IMAGE_GENERATION_MCP_ prefix.
Core
| Variable | Type | Default | Description |
|---|---|---|---|
IMAGE_GENERATION_MCP_SCRATCH_DIR |
Path | ~/.image-generation-mcp/images/ |
Directory for saved generated images |
IMAGE_GENERATION_MCP_READ_ONLY |
bool | true |
Hide write-tagged tools (generate_image) |
IMAGE_GENERATION_MCP_DEFAULT_PROVIDER |
str | auto |
Default provider: auto, openai, a1111, placeholder |
Providers
| Variable | Type | Default | Description |
|---|---|---|---|
IMAGE_GENERATION_MCP_OPENAI_API_KEY |
str | -- | OpenAI API key; enables OpenAI provider when set |
IMAGE_GENERATION_MCP_A1111_HOST |
str | -- | A1111 WebUI URL (e.g. http://localhost:7860); enables A1111 provider when set |
IMAGE_GENERATION_MCP_A1111_MODEL |
str | -- | A1111 checkpoint name for preset detection and override |
Authentication
| Variable | Type | Default | Description |
|---|---|---|---|
IMAGE_GENERATION_MCP_BEARER_TOKEN |
str | -- | Static bearer token; enables bearer auth when set |
IMAGE_GENERATION_MCP_BASE_URL |
str | -- | Public base URL for OIDC (e.g. https://mcp.example.com) |
IMAGE_GENERATION_MCP_OIDC_CONFIG_URL |
str | -- | OIDC discovery endpoint URL |
IMAGE_GENERATION_MCP_OIDC_CLIENT_ID |
str | -- | OIDC client ID |
IMAGE_GENERATION_MCP_OIDC_CLIENT_SECRET |
str | -- | OIDC client secret |
IMAGE_GENERATION_MCP_OIDC_JWT_SIGNING_KEY |
str | ephemeral | JWT signing key; required on Linux/Docker |
IMAGE_GENERATION_MCP_OIDC_AUDIENCE |
str | -- | Expected JWT audience claim |
IMAGE_GENERATION_MCP_OIDC_REQUIRED_SCOPES |
str | openid |
Comma-separated required scopes |
IMAGE_GENERATION_MCP_OIDC_VERIFY_ACCESS_TOKEN |
bool | false |
Verify access token as JWT instead of id token |
Server
| Variable | Type | Default | Description |
|---|---|---|---|
IMAGE_GENERATION_MCP_SERVER_NAME |
str | image-generation-mcp |
Server name shown to MCP clients |
IMAGE_GENERATION_MCP_INSTRUCTIONS |
str | (dynamic) | System instructions for LLM context |
IMAGE_GENERATION_MCP_LOG_LEVEL |
str | INFO |
Log level: DEBUG, INFO, WARNING, ERROR |
IMAGE_GENERATION_MCP_HTTP_PATH |
str | /mcp |
HTTP endpoint mount path |
CLI reference
image-generation-mcp serve [OPTIONS]
| Flag | Default | Description |
|---|---|---|
--transport |
stdio |
MCP transport: stdio, sse, or http (streamable-http) |
--host |
0.0.0.0 |
Host to bind to (HTTP transport only) |
--port |
8000 |
Port to listen on (HTTP transport only) |
--path |
/mcp |
HTTP endpoint mount path (HTTP transport only) |
-v, --verbose |
-- | Enable debug logging |
MCP tools
| Tool | Tags | Task | Parameters | Description |
|---|---|---|---|---|
generate_image |
write |
task=True |
prompt (str), provider (str, default "auto"), negative_prompt (str, optional), aspect_ratio (str, default "1:1"), quality (str, default "standard") |
Generate an image, returns thumbnail preview + resource URIs |
list_providers |
-- | -- | (none) | List available providers with availability info |
generate_image returns a thumbnail (~256px WebP) as ImageContent plus JSON metadata as TextContent with image_id, original_uri, resource_template, sizes, provider, and file path.
Supported aspect ratios: 1:1, 16:9, 9:16, 3:2, 2:3.
Supported quality levels: standard, hd.
MCP resources
| URI | MIME Type | Description |
|---|---|---|
info://providers |
application/json |
Provider capabilities and supported features |
image://{id}/view{?format,width,height,quality} |
varies | Image with optional transforms (format conversion, resize, crop) |
image://{id}/metadata |
application/json |
Sidecar JSON with generation provenance |
image://list |
application/json |
All registered images |
The image://{id}/view resource template supports CDN-style transforms:
- No parameters -- original bytes unchanged
format-- convert topng,webp, orjpegwidth+height-- center-crop to exact dimensionswidthonly orheightonly -- proportional resizequality-- compression quality for lossy formats (default 90)
MCP prompts
| Prompt | Parameters | Description |
|---|---|---|
select_provider |
(none) | Provider selection guidance -- strengths, use cases, and selection rules for each provider |
sd_prompt_guide |
(none) | Stable Diffusion prompt writing guide -- CLIP tag format, quality tags, negative prompts, BREAK syntax, aspect ratios |
Providers
| Provider | Best for | Requires |
|---|---|---|
| OpenAI | Text, logos, typography, general-purpose | IMAGE_GENERATION_MCP_OPENAI_API_KEY |
| A1111 | Photorealism, portraits, anime, artistic styles | Running A1111 WebUI + IMAGE_GENERATION_MCP_A1111_HOST |
| Placeholder | Testing, drafts, CI | Nothing (always available) |
OpenAI
Best for text rendering, logos, typography, and general-purpose generation.
- Models:
gpt-image-1(default),dall-e-3 - Formats: PNG (all models), JPEG and WebP (
gpt-image-1only) - Quality levels:
standard(mapped tohighfor gpt-image-1),hd(mapped tohigh) - Negative prompt: Appended as
"Avoid: {negative_prompt}"to the prompt - Requires:
IMAGE_GENERATION_MCP_OPENAI_API_KEY
A1111 (Stable Diffusion WebUI)
Best for photorealism, portraits, anime, and artistic styles.
- API: HTTP POST to
/sdapi/v1/txt2img - Model presets: Auto-detected from checkpoint name:
- SD 1.5 (default): 768px base, 30 steps, CFG 7.0, DPM++ 2M Karras
- SDXL: 1024px base, 35 steps, CFG 7.5, DPM++ 2M Karras
- SDXL Lightning/Turbo: 1024px base, 6 steps, CFG 2.0, DPM++ SDE Karras
- Negative prompt: Native support via
negative_promptfield - Checkpoint override: Specify
modelto overridesd_model_checkpoint - Timeout: 180s (SDXL at high res on consumer GPUs)
- Requires:
IMAGE_GENERATION_MCP_A1111_HOST
Placeholder
Zero-cost solid-color PNG generation for testing and drafts.
- No dependencies: Pure Python PNG encoder (zlib + struct)
- Color: Deterministic from MD5 hash of prompt
- Always available -- no API key or service needed
Authentication
The server supports four auth modes:
- Multi-auth -- both bearer token and OIDC configured; either credential accepted
- Bearer token -- set
IMAGE_GENERATION_MCP_BEARER_TOKEN - OIDC -- full OAuth 2.1 flow via OIDC environment variables
- No auth -- default; server accepts all connections
Auth requires --transport http (or sse). It has no effect with --transport stdio.
See Authentication guide for setup details.
Development
git clone https://github.com/pvliesdonk/image-generation-mcp.git
cd image-generation-mcp
uv sync --extra all --extra dev
uv run pytest
uv run ruff check src/ tests/
uv run mypy src/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image_generation_mcp-1.0.0.tar.gz.
File metadata
- Download URL: image_generation_mcp-1.0.0.tar.gz
- Upload date:
- Size: 231.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f03adb745c1da279ed64c29b34c5487aeab4a9ac7ac24bd724c45b700e702a5
|
|
| MD5 |
7d29b52a48a1fb714fa238826da6da53
|
|
| BLAKE2b-256 |
6bef57f6d5babdcd55b90be23c778e19d1136d0aa548f914da05f0ec3598a28f
|
Provenance
The following attestation bundles were made for image_generation_mcp-1.0.0.tar.gz:
Publisher:
release.yml on pvliesdonk/image-generation-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
image_generation_mcp-1.0.0.tar.gz -
Subject digest:
7f03adb745c1da279ed64c29b34c5487aeab4a9ac7ac24bd724c45b700e702a5 - Sigstore transparency entry: 1134191775
- Sigstore integration time:
-
Permalink:
pvliesdonk/image-generation-mcp@42bb369aa720878e1fb85ce7df2edb91edb08cc5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pvliesdonk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@42bb369aa720878e1fb85ce7df2edb91edb08cc5 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file image_generation_mcp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: image_generation_mcp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 38.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e440b5b21b5648e9fb63380ebc3172dede9e591ef98dbd4be82ecb7f25ff75a8
|
|
| MD5 |
e105907690289f07554a7bea2abf9284
|
|
| BLAKE2b-256 |
72d2175e4c45620fce5f3821fbeed3ccdd88a3fa031047f8d418649e029de537
|
Provenance
The following attestation bundles were made for image_generation_mcp-1.0.0-py3-none-any.whl:
Publisher:
release.yml on pvliesdonk/image-generation-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
image_generation_mcp-1.0.0-py3-none-any.whl -
Subject digest:
e440b5b21b5648e9fb63380ebc3172dede9e591ef98dbd4be82ecb7f25ff75a8 - Sigstore transparency entry: 1134191823
- Sigstore integration time:
-
Permalink:
pvliesdonk/image-generation-mcp@42bb369aa720878e1fb85ce7df2edb91edb08cc5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pvliesdonk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@42bb369aa720878e1fb85ce7df2edb91edb08cc5 -
Trigger Event:
workflow_dispatch
-
Statement type: