home / mcp / image-gen mcp server

image-gen MCP Server

A MCP server that provides text-to-image generation capabilities using Stable Diffusion WebUI API (ForgeUI/AUTOMATIC-1111)

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "ichigo3766-image-gen-mcp": {
      "command": "node",
      "args": [
        "/path/to/image-gen-mcp/build/index.js"
      ],
      "env": {
        "SD_AUTH_PASS": "your-password",
        "SD_AUTH_USER": "your-username",
        "SD_WEBUI_URL": "http://your-sd-webui-url:7860",
        "SD_OUTPUT_DIR": "/path/to/output/directory",
        "SD_UPSCALER_1": "R-ESRGAN 4x+",
        "SD_UPSCALER_2": "None",
        "SD_RESIZE_MODE": "0",
        "SD_UPSCALE_MULTIPLIER": "4"
      }
    }
  }
}

You run an MCP server that exposes text-to-image generation powered by a Stable Diffusion WebUI instance. It lets you generate images, manage models and upscalers, and upscale existing images directly through MCP-compatible clients.

How to use

You connect to this server from an MCP client and call its tools to generate images, retrieve available models and upscalers, and upscale images. Start with generating an image by providing a prompt and optional parameters, then explore available models or perform upscaling on existing images as needed. The server handles interaction with your Stable Diffusion WebUI instance through its API.

How to install

Prerequisites you need before running the server are Node.js and access to a Stable Diffusion WebUI instance with API enabled. The WebUI must be started with the --api flag.

Step 1 — Clone the MCP server repository and navigate into it.

git clone https://github.com/Ichigo3766/image-gen-mcp.git
cd image-gen-mcp

Step 2 — Install dependencies.

npm install

Step 3 — Build the server.

npm run build

Step 4 — Add the server configuration to your environment by creating the MCP config snippet shown below and placing it in your environment where the MCP server loads its config.

{
  "mcpServers": {
    "image-gen": {
      "command": "node",
      "args": [
        "/path/to/image-gen-mcp/build/index.js"
      ],
      "env": {
        "SD_WEBUI_URL": "http://your-sd-webui-url:7860",
        "SD_AUTH_USER": "your-username",
        "SD_AUTH_PASS": "your-password",
        "SD_OUTPUT_DIR": "/path/to/output/directory",
        "SD_RESIZE_MODE": "0",
        "SD_UPSCALE_MULTIPLIER": "4",
        "SD_UPSCALE_WIDTH": "512",
        "SD_UPSCALE_HEIGHT": "512",
        "SD_UPSCALER_1": "R-ESRGAN 4x+",
        "SD_UPSCALER_2": "None"
      }
    }
  }
}

Additional notes

Configure your Stable Diffusion WebUI URL, credentials (if enabled), and output directory to suit your environment. The server will use the provided upscaling settings unless you override them per request via the MCP client.

Troubleshooting

If you encounter issues, ensure the Stable Diffusion WebUI is reachable from the MCP server host, confirm the API is enabled, and verify that the output directory exists and is writable. If authentication is enabled, double-check the credentials. When upscaling, make sure input image files exist and are readable.

Security and maintenance

Limit access to the MCP server to trusted clients, rotate API credentials periodically, and monitor the log output for errors related to image generation or model loading. Keep your dependencies up to date and review your SD model and upscaler configurations regularly.

Available tools

generate_image

Create images by providing a prompt and optional parameters such as steps, width, height, CFG scale, and seeds. Supports face restoration, tiling, and custom output paths.

get_sd_models

Return a list of available Stable Diffusion models on the connected WebUI.

set_sd_model

Set the active Stable Diffusion model by name.

get_sd_upscalers

Return a list of available upscaler models.

upscale_images

Upscale one or more images using the selected upscalers with configurable resize modes and target dimensions.