home / mcp / comfyui mcp server

ComfyUI MCP Server

Provides an MCP server to drive a local ComfyUI instance via natural language prompts for image generation.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "matthewsnow2-comfyui-mcp": {
      "command": "/path/to/comfyui-mcp-server/.venv/bin/comfyui-mcp",
      "args": [],
      "env": {
        "COMFYUI_URL": "http://127.0.0.1:8188",
        "COMFYUI_OUTPUT_DIR": "~/comfyui-output",
        "COMFYUI_DEFAULT_MODEL": "sd_xl_base_1.0.safetensors",
        "COMFYUI_DEFAULT_STEPS": "20",
        "COMFYUI_DEFAULT_WIDTH": "1024",
        "COMFYUI_DEFAULT_HEIGHT": "1024",
        "COMFYUI_DEFAULT_CFG_SCALE": "7.0"
      }
    }
  }
}

You can run an MCP server that lets you control a local ComfyUI instance through natural language. This enables you to compose prompts, select models, adjust image size and steps, and generate images from conversations, making it easy to work with Stable Diffusion, SDXL, and other models without writing manual API calls.

How to use

To use this MCP server, start the local server process and connect it with your Claude Desktop setup. You will interact with the server using natural language prompts. For example, you can ask the assistant to generate an image from a prompt, request a model list, or look up details about a previous generation. The MCP server translates your requests into actions against your local ComfyUI instance and returns the resulting image files and metadata.

How to install

Prerequisites include Python 3.11 or newer and a locally running ComfyUI instance (default URL is http://127.0.0.1:8188) with at least one checkpoint model installed.

Step by step commands to set up the MCP server locally:

git clone https://github.com/MatthewSnow2/comfyui-mcp-server.git
cd comfyui-mcp-server

python -m venv .venv
source .venv/bin/activate   # Linux/macOS
# .venv\Scripts\activate    # Windows

pip install -e ".[dev]"

Configuration

Configure the MCP server by creating an environment file and adjusting defaults. You will primarily set the ComfyUI URL and default model in the environment file.

cp .env.example .env

# Edit .env to customize settings, for example:
# COMFYUI_URL=http://127.0.0.1:8188
# COMFYUI_OUTPUT_DIR=~/comfyui-output
# COMFYUI_DEFAULT_MODEL=sd_xl_base_1.0.safetensors
# COMFYUI_DEFAULT_STEPS=20
# COMFYUI_DEFAULT_WIDTH=1024
# COMFYUI_DEFAULT_HEIGHT=1024
# COMFYUI_DEFAULT_CFG_SCALE=7.0

MCP server command and environment

The MCP server is intended to be run as a local stdio server. The runtime command is the path to the executed MCP script inside the virtual environment, and you can pass environment variables to configure its behavior.

Command to start the MCP server for ComfyUI:

/path/to/comfyui-mcp-server/.venv/bin/comfyui-mcp

Environment variables to set (examples):
COMFYUI_URL=http://127.0.0.1:8188
COMFYUI_DEFAULT_MODEL=sd_xl_base_1.0.safetensors

Tools exposed by the MCP server

You can access the following tools through Claude Desktop or your MCP client: generate_image, list_models, get_queue_status, and get_generation.

Development

If you want to run tests or linting, use the standard Python project workflow and test suite as described in the source. To run the server directly for development, you can execute the server module.

Available tools

generate_image

Generate an image from a text prompt with options for model, size, steps, and CFG scale.

list_models

List all available checkpoint models installed in ComfyUI.

get_queue_status

Return the current ComfyUI queue status with pending, running, and completed counts.

get_generation

Retrieve details of a previous generation by its prompt ID.