ComfyUI MCP Server

ComfyUI MCP Server

Enables orchestration of ComfyUI workflows through natural language by discovering workflow templates, applying mutations, and submitting prompts to running ComfyUI instances. Provides asset validation and lightweight tooling for AI image generation experimentation.

Category
访问服务器

README

ComfyUI MCP Server

An experimental Model Context Protocol (MCP) server that orchestrates ComfyUI workflows. The runtime discovers workflow templates, validates model assets, lets you tweak high-level parameters, and submits prompts to a running ComfyUI instance.

  • Workflow discovery – load JSON templates from a directory hierarchy and expose human-readable summaries.
  • Asset cataloguing – scan checkpoints, LoRAs, VAEs, text encoders, and embeddings so MCP clients can target valid resources.
  • High-level mutations – update prompts, samplers, LoRA stacks, and resolution bounds without hand editing graph JSON.
  • Execution tooling – run workflows through the ComfyUI API with optional live streaming of prompt updates.

Prerequisites

  • Python 3.11+
  • A running ComfyUI instance reachable over HTTP (defaults to http://127.0.0.1:8188)
  • Access to the workflow JSON templates and any model asset directories you plan to expose

Installation

  1. Clone the repository

    git clone https://github.com/<your-org>/ComfyUI_MCP.git
    cd ComfyUI_MCP
    
  2. Create an isolated environment (recommended)

    python -m venv .venv
    source .venv/bin/activate
    # or use uv: uv venv
    
  3. Install the package

    pip install -e .
    # or: uv pip install --editable .
    

This installs two console scripts:

  • comfyui-mcp – helper CLI for inspecting assets and workflows
  • comfyui-mcp-serve – FastMCP runtime that exposes MCP tools over stdio, SSE, or streamable HTTP

Configuration

Configuration is provided via a TOML file. Start by copying the example file and customising the values:

cp config.example.toml ~/.config/comfyui-mcp.toml

Example configuration

# ~/.config/comfyui-mcp.toml
base_url = "http://127.0.0.1:8188"
# default_workflow = "basic_workflow"

[directories]
# Each value maps to a ComfyUI model API endpoint or folder name that can be
# queried remotely. Supply fully qualified endpoints ("/models/checkpoints")
# or the folder alias returned by ``GET /models`` ("checkpoints", "vae", etc.).
checkpoints = "/models/checkpoints"
loras = "/models/loras"
vaes = "/models/vae"
text_encoders = "/models/clip"
embeddings = "/models/embeddings"

[default_bounds]
cfg_min = 1.0
cfg_max = 20.0
steps_min = 1
steps_max = 150
width_min = 128
width_max = 2048
height_min = 128
height_max = 2048

[feature_toggles]
# enable_streaming controls live prompt updates when executing workflows
enable_streaming = true
# enable_batch_execution toggles multi-workflow prompts (experimental)
enable_batch_execution = false
# watch_workflows rescan templates when files on disk change
watch_workflows = false

Environment overrides

Environment variables prefixed with COMFYUI_MCP_ override configuration values at runtime. Common examples:

  • COMFYUI_MCP_CONFIG – path to the TOML file (used by the runtime launcher)
  • COMFYUI_MCP_BASE_URL – override the ComfyUI HTTP endpoint
  • COMFYUI_MCP_DIRECTORIES_CHECKPOINTS – point to a different checkpoints folder
  • COMFYUI_MCP_FEATURES_WATCH_WORKFLOWS – toggle template reloading without editing the config file

CLI usage

Inspect templates and assets before wiring the server into an MCP client:

# List discovered workflow templates
comfyui-mcp list --config ~/.config/comfyui-mcp.toml --json

# Describe a template including semantic roles and graph metadata
comfyui-mcp describe basic_workflow --config ~/.config/comfyui-mcp.toml --json

# Enumerate checkpoints, LoRAs, VAEs, text encoders, and embeddings
comfyui-mcp assets --config ~/.config/comfyui-mcp.toml --json

CLI flags allow ad-hoc overrides without editing your TOML file:

comfyui-mcp list \
  --base-url http://localhost:8188 \
  --workflows-path ~/comfyui-mcp/workflows \
  --directory checkpoints=~/models/StableDiffusion \
  --json

Running the MCP server

Use comfyui-mcp-serve to expose the workflow tools to MCP clients. Choose a transport based on your integration target.

# stdio transport (ideal for IDE plugins / Cursor)
COMFYUI_MCP_CONFIG=~/.config/comfyui-mcp.toml \
  comfyui-mcp-serve --transport stdio

# Streamable HTTP transport (FastMCP HTTP gateway)
COMFYUI_MCP_CONFIG=~/.config/comfyui-mcp.toml \
  comfyui-mcp-serve --transport streamable-http --host 0.0.0.0 --port 8000

Optional flags:

  • --instructions – override the instruction string advertised to MCP clients
  • --host/--port – adjust bindings for HTTP/SSE transports

The runtime validates configured asset directories on startup and will exit with descriptive errors if any paths are missing or unreadable.


IDE / agent integration

Many MCP-aware tools (Cursor, Claude Desktop, Windsurf, etc.) accept a JSON manifest describing available servers. The snippet below embeds the ComfyUI MCP server alongside other backends using the same structure as Cursor's mcpServers configuration.

{
  "mcpServers": {
    "comfyui-control": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "--with",
        "aiohttp",
        "--with",
        "orjson",
        "--with",
        "python-dotenv",
        "--with",
        "pydantic",
        "comfyui-mcp-serve",
        "--transport",
        "stdio"
      ],
      "env": {
        "COMFYUI_MCP_CONFIG": "/data/comfy_ui_mcp/config.toml",
        "PYTHONUNBUFFERED": "1"
      }
    }
  }
}

Adjust the COMFYUI_MCP_CONFIG path and any Python dependency flags to match your environment. When Cursor or another MCP client launches, it will spawn comfyui-mcp-serve over stdio using the configuration you supplied.

If you prefer to mirror the repository's bundled mcp.json, copy the file and tweak the command, transport, or environment variables as needed for your setup.


Repository layout

  • src/comfyui_mcp/ – server implementation, CLI, and FastMCP runtime glue
  • workflows/ – example workflow templates discovered by default
  • docs/ – additional design notes and reference material
  • tests/ – unit tests for asset discovery and workflow mutation helpers

Contributing

Bug reports and pull requests are welcome! Please include reproduction steps and relevant ComfyUI versions when filing issues.


License

Distributed under the MIT license. See LICENSE (or the top-level repository metadata) for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选