This MCP server provides text-to-image generation capabilities using Stable Diffusion WebUI API. It connects to your existing Stable Diffusion WebUI instance (such as ForgeUI or AUTOMATIC-1111) to enable image generation through the Model Context Protocol.
Before installing the image-gen MCP server, ensure you have:
--api
flag enabledgit clone https://github.com/Ichigo3766/image-gen-mcp.git
cd image-gen-mcp
npm install
npm run build
Add the server configuration to your environment. Create or modify your MCP configuration file:
{
"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"
}
}
}
}
Replace the placeholders with your actual values:
Use the generate_image
tool to create images from text prompts:
Parameters:
prompt
(required): Text description of the desired imagenegative_prompt
: Things to exclude from the imagesteps
: Number of sampling steps (default: 4, range: 1-150)width
: Image width (default: 1024, range: 512-2048)height
: Image height (default: 1024, range: 512-2048)cfg_scale
: CFG scale (default: 1, range: 1-30)sampler_name
: Sampling algorithm (default: "Euler")scheduler_name
: Scheduler algorithm (default: "Simple")seed
: Random seed (-1 for random)batch_size
: Number of images to generate (default: 1, max: 4)restore_faces
: Enable face restorationtiling
: Generate tileable imagesoutput_path
: Custom output path for the generated imageList Available Models:
Use the get_sd_models
tool to retrieve a list of available Stable Diffusion models.
Change Active Model:
Use the set_sd_model
tool to set the active Stable Diffusion model.
model_name
(required) - Name of the model to set as activeList Upscalers:
Use the get_sd_upscalers
tool to get a list of available upscaler models.
Upscale Images:
Use the upscale_images
tool to enhance image resolution.
Parameters:
images
(required): Array of image file paths to upscaleresize_mode
: 0 for multiplier mode, 1 for dimension modeupscaling_resize
: Upscale multiplier when resize_mode=0upscaling_resize_w
: Target width in pixels when resize_mode=1upscaling_resize_h
: Target height in pixels when resize_mode=1upscaler_1
: Primary upscaler modelupscaler_2
: Secondary upscaler modeloutput_path
: Custom output directory for upscaled imagesIf you encounter issues:
--api
flagTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"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"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"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"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect