Get the FREE Ultimate OpenClaw Setup Guide →

comfyui_mcp_server

generate_image and other workflows

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio zuojianghua-comfyui_mcp_server python D:\code\comfyui_mcp_server\server.py \
  --env COMFY_URL="http://127.0.0.1:8188/"

How to use

This MCP server provides two core capabilities for ComfyUI: image generation using the ComfyUI text-to-image workflows and prompt optimization to improve generation results. It exposes an MCP-compatible endpoint that leverages the FastMCP framework to communicate with a locally running ComfyUI instance. Users can request new images by supplying textual prompts (and optional parameters like width, height, and seed), or request optimized prompts that can yield higher-quality outputs for a given concept. The server returns both local file paths and online-accessible URLs for the generated images, along with any relevant metadata such as seed and dimensions.

How to install

Prerequisites:

  • Python 3.7+ installed
  • ComfyUI instance running and accessible at the configured COMFY_URL
  • FastMCP library installed in your Python environment
  1. Clone the MCP server repository:
git clone https://github.com/yourorg/comfyui_mcp_server.git
cd comfyui_mcp_server
  1. Create and activate a Python virtual environment (optional but recommended):
python -m venv venv
# Windows
venv\Scripts\activate.bat
# macOS/Linux
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure the server (example shown in README):
# Edit the configuration file if needed
# The example uses:
# COMFY_URL=http://127.0.0.1:8188/
  1. Run the server:
python D:\code\comfyui_mcp_server\server.py
  1. Verify the MCP endpoint is reachable using your MCP client and start issuing generate_image or optimize_image_prompt requests.

Note: If you prefer a different runtime (e.g., a Docker-based setup), adjust the mcp_config accordingly and ensure COMFY_URL points to your running ComfyUI instance.

Additional notes

Tips:

  • Ensure ComfyUI is reachable from the MCP server via the COMFY_URL you provide; firewall rules may block access.
  • The server can automatically adjust image dimensions to multiples of 8; consider specifying width/height if you have strict requirements.
  • Seed handling: a random seed is generated if not provided, which helps with output diversity.
  • If you encounter timeout errors, you may increase the timeout in the mcp_config to accommodate slower image generation times.
  • The server returns both local file paths and online URLs; you can store results or display images in a UI accordingly.

Related MCP Servers

Sponsor this space

Reach thousands of developers