Skip to content

Haervwe/comfyui-mcp

Repository files navigation

ComfyUI MCP Server

A dynamic MCP (Model Context Protocol) server that lets you expose ComfyUI workflows as tools for LLMs. Ships with a web admin UI for configuring tools without writing any code.

Features

  • Zero hardcoded tools — all tools are loaded dynamically from user-defined workflow configurations
  • Web Admin UI — upload ComfyUI API workflows, name tools, map node inputs to parameters, configure output types
  • Multi-media output — handles images, audio, video, and generic files
  • Per-tool output delivery — choose between inline base64 binary or URL-based delivery for each tool
  • Persistent configuration — tool definitions saved as JSON files, survive restarts
  • Optional API key auth — protect the admin UI with a simple API key
  • ComfyUI health monitoring — real-time connection status in the UI

Quick Start

# Install with uv
uv venv
uv pip install -e .

# Run the server
uv run comfyui-mcp

# Or with environment variables
COMFYUI_URL=http://localhost:8188 COMFYUI_API_KEY=your_key_here uv run comfyui-mcp

Open http://localhost:4206/ui to access the admin dashboard.

The MCP endpoint is available at http://localhost:4206/mcp.

Configuration

All configuration is via environment variables:

Variable Default Description
COMFYUI_URL http://localhost:8188 ComfyUI HTTP API endpoint
COMFYUI_API_KEY (empty) Bearer token for ComfyUI auth
ADMIN_API_KEY (empty) API key for admin UI access
DATA_DIR ./data Directory for persisted tool definitions
HOST 0.0.0.0 Server bind address
PORT 4206 Server port
MAX_WAIT_TIME 600 Default max wait for ComfyUI jobs (seconds)

How It Works

  1. Export your ComfyUI workflow in API format (enable Dev Mode in ComfyUI → Save API Format)
  2. Upload it via the admin UI at /ui
  3. Name your tool and write a description (the LLM sees this)
  4. Map parameters — click on any node input to expose it as a tool parameter
  5. Configure output — set the output type (image/audio/video) and delivery method
  6. Save — the tool is immediately available via MCP

MCP Client Configuration

Add this to your MCP client configuration:

{
  "mcpServers": {
    "comfyui": {
      "url": "http://localhost:4206/mcp"
    }
  }
}

Architecture

┌─────────────────────────────────────────┐
│            FastMCP Server               │
│  ┌───────────────────────────────────┐  │
│  │ Dynamic Tool Registry             │  │
│  │  tool1(prompt, steps) → ComfyUI   │  │
│  │  tool2(tags, lyrics) → ComfyUI    │  │
│  └───────────────────────────────────┘  │
│  ┌───────────────────────────────────┐  │
│  │ Admin UI (/ui)                     │  │
│  │  - Tool CRUD                       │  │
│  │  - Workflow upload                 │  │
│  │  - Parameter mapping               │  │
│  └───────────────────────────────────┘  │
│  ┌───────────────────────────────────┐  │
│  │ ComfyUI Client                     │  │
│  │  - HTTP submission                 │  │
│  │  - WebSocket tracking              │  │
│  │  - Output download                 │  │
│  └───────────────────────────────────┘  │
└─────────────────────────────────────────┘
         ↕ MCP Protocol (/mcp)
    ┌──────────┐
    │ LLM/Agent│
    └──────────┘

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors