Get the FREE Ultimate OpenClaw Setup Guide →

comfyui

lightweight Python-based MCP (Model Context Protocol) server for local ComfyUI

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio joenorton-comfyui-mcp-server python server.py \
  --env PORT="9000 (default MCP port; adjust if needed)" \
  --env COMFYUI_PORT="8188 (default ComfyUI port; ensure ComfyUI is running)"

How to use

The ComfyUI MCP Server exposes a local MCP interface that delegates execution to a local ComfyUI instance. After starting ComfyUI and launching the MCP server, clients can connect to http://127.0.0.1:9000/mcp and issue tools such as generate_image, view_image, regenerate, and a suite of management and workflow tools. This setup supports iterative image, audio, and video generation through a conversational workflow, with server-side defaults and optional asset provenance.

Once connected, you can operate in two modes: direct tool usage and agent integration. In direct usage, you can call tools to generate assets, inspect results, and manage jobs. For AI agents, create a project-scoped .mcp.json file pointing to the local MCP endpoint, enabling seamless tool calls like generate_image, list_assets, get_job, and publish_asset. The server also supports stateful iteration via regenerate, explicit asset identity for reliable follow-ups, and optional image viewing through view_image to provide inline feedback to the agent.

How to install

Prerequisites:

  • Python 3.8+ installed locally
  • Lua-based or Python-based dependencies if required by ComfyUI (as per ComfyUI installation)
  • A local ComfyUI instance running (preferred port 8188 as in the quick start)

Installation steps:

  1. Clone the repository and install dependencies
git clone https://github.com/joenorton/comfyui-mcp-server.git
cd comfyui-mcp-server
pip install -r requirements.txt
  1. Ensure ComfyUI is installed and running locally (in a separate terminal)
cd <ComfyUI_dir>
python main.py --port 8188
  1. Start the MCP server
python server.py

The MCP server will listen at http://127.0.0.1:9000/mcp by default.

  1. (Optional) Run the test client to verify
python test_client.py

Prerequisites recap: Python environment ready, ComfyUI running on the expected port, and network access to localhost for both services.

Additional notes

Tips and caveats:

  • If you change the ComfyUI port, ensure both ComfyUI and server.py are aligned (the default is 8188 for ComfyUI and 9000 for MCP).
  • The MCP server supports stateful iteration via regenerate and asset identity via get_asset_metadata; this helps maintain consistent prompts across steps.
  • Publish-related features require a functioning publish workflow in ComfyUI; ensure workflows exist in the workflows/ directory for automatic exposure.
  • If an agent client expects a different MCP type, you can switch the type field in your .mcp.json to http or streamable-http as needed.
  • Test client and test prompts can be used to validate defaults configured via config files, environment variables, or set_defaults calls.

Related MCP Servers

Sponsor this space

Reach thousands of developers