Get the FREE Ultimate OpenClaw Setup Guide →

comfyui

comfyui-mcp-server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio overseer66-comfyui-mcp-server uv --directory PATH/MCP/comfyui run --with mcp --with websocket-client --with python-dotenv mcp run src/server.py:mcp \
  --env PATH="Path to your MCP comfyui directory (adjust as needed)" \
  --env RETURN_URL="true or false (Docker method requires adjusting if using binaries)" \
  --env COMFYUI_HOST="localhost" \
  --env COMFYUI_PORT="8188"

How to use

This MCP server acts as a bridge between your ComfyUI instance and MCP tooling. It exposes built‑in tools such as text_to_image, download_image, run_workflow_with_file, and run_workflow_with_json, allowing you to generate images via ComfyUI workflows and manage them through MCP commands. To get started, ensure you have a running ComfyUI server and point the MCP server at it via the recommended UV setup. You can run workflows by providing either a workflow file or a workflow JSON, and you can fetch image URLs or binary image data depending on your environment and preferences. The included run_workflow_with_file and run_workflow_with_json helpers facilitate executing complex ComfyUI pipelines, while text_to_image and download_image handle image generation and retrieval efficiently.

How to install

Prerequisites:

  • A running ComfyUI server (on host and port you’ll reference in COMFYUI_HOST and COMFYUI_PORT).
  • Node.js (if you prefer Node-based setup) or Python 3.x (recommended for UV/Docker methods).
  • Access to an MCP environment where you’ll register the comfyui MCP server.

Install steps:

  1. Install Python and dependencies (for UV method):

    • Ensure Python 3.8+ is installed.
    • Install uv (uvx) or ensure you have an appropriate Python environment: pip install uvx # if using uvx in Python environments
  2. Prepare ComfyUI and MCP workspace:

    • Clone or download the MCP comfyui server repository.
    • Ensure ComfyUI is reachable at COMFYUI_HOST:COMFYUI_PORT (adjust in src/.env).
  3. Configure environment and run with UV (recommended):

    • Edit src/.env to set: COMFYUI_HOST=localhost COMFYUI_PORT=8188
    • Run the MCP server via UV using the provided mcp.json configuration: mcp dev src/server.py OR uv run --with mcp --with websocket-client --with python-dotenv mcp run src/server.py:mcp
  4. Optional: Docker-based run

    • Build or pull the Docker image as described in the README and ensure environment variables align with your ComfyUI deployment.
    • Register the server in your mcp.json using the docker command and port mappings described in the docs.
  5. Verify:

    • Confirm the MCP server registers as comfyui and that you can call built-in tools via MCP to generate and retrieve images from ComfyUI workflows.

Additional notes

Tips and common issues:

  • The ComfyUI server must be reachable from the MCP host. If you run Docker, consider using host.docker.internal or the host's IP in COMFYUI_HOST.
  • When using Docker, enabling RETURN_URL=false will return image data as bytes; adjust your client handling accordingly and be mindful of payload size limits.
  • If you add new workflows/tools, you may need to rebuild and redeploy Docker images to make those tools available.
  • Ensure the .env in ComfyUI is correctly configured to point to the running ComfyUI instance (HOST and PORT).
  • For debugging, you can run python src/test_comfyui.py to validate ComfyUI connectivity and python src/server.py to verify MCP integration.

Related MCP Servers

Sponsor this space

Reach thousands of developers