opc-image-gen-mcp
v1.0.0
Published
MCP server wrapping Stable Diffusion WebUI API — text-to-image, image-to-image, model listing for AI agents
Maintainers
Readme
🎨 opc-image-gen-mcp
MCP Server wrapping Stable Diffusion WebUI API (164K+ stars) — AI image generation for agents
Overview
opc-image-gen-mcp connects to a running Stable Diffusion WebUI (AUTOMATIC1111) instance via its REST API, enabling AI agents to generate images from text prompts, transform images with img2img, and list available models.
Tools
| Tool | Description |
|------|-------------|
| txt2img | Generate images from text prompts with full parameter control |
| img2img | Transform existing images using prompts and denoising strength |
| models_list | List all available Stable Diffusion model checkpoints |
Prerequisites
A running Stable Diffusion WebUI with --api flag:
# Clone and launch SD WebUI
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
./webui.sh --api --listenSet the API URL:
export SD_API_URL=http://localhost:7860Installation
npm install opc-image-gen-mcpUsage
As an MCP server
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["opc-image-gen-mcp"],
"env": { "SD_API_URL": "http://localhost:7860" }
}
}
}Example: txt2img
Input: { "prompt": "a beautiful sunset over mountains, oil painting", "steps": 30, "width": 768, "height": 512 }
Output: Image saved: ./output/txt2img_1700000000.pngExample: img2img
Input: { "input_image": "./photo.jpg", "prompt": "make it a watercolor painting", "denoising_strength": 0.6 }
Output: Image saved: ./output/img2img_1700000000.pngExample: models_list
Input: {}
Output: [{ title: "v1-5-pruned-emaonly", model_name: "v1-5-pruned-emaonly", ... }]Features
- Full SD parameter control — Steps, CFG scale, seed, resolution, sampler
- txt2img + img2img — Both generation modes with base64 image handling
- Model discovery — List all installed checkpoints automatically
- Configurable endpoint — Connect to any SD WebUI instance via
SD_API_URL
License
MIT
