comfyui-mcp

comfyui-mcp

MCP server that lets AI agents drive a remote ComfyUI instance end-to-end, including queueing workflows, viewing outputs, downloading models, and authoring graphs via ComfyScript.

Category
访问服务器

README

comfyui-mcp

A TypeScript MCP server that lets an AI agent drive a remote ComfyUI instance end-to-end — queue workflows, iterate on prompts and seeds, watch progress, view outputs as inline images, curate winners, download models, and author whole node graphs as Python — without ever touching the web canvas.

Built for and battle-tested on an NVIDIA DGX Spark (GB10, unified memory) that doubles as an LLM-serving box, which shaped some of the more interesting parts of the design (see GPU-yield handshake below).

Why

ComfyUI's node canvas is great for humans and terrible for agents. The HTTP API alone isn't enough either: workflow files live on the GPU host, outputs land on the GPU host, and model downloads need to happen on the GPU host. This server gives an agent a complete operational surface over both channels:

  • HTTP to the ComfyUI API for queueing, progress, history, and image retrieval
  • SSH to the GPU host for workflow file r/w, output listing, model downloads (via remote aria2c), and ComfyScript execution

Tool surface (16 tools)

Group Tools
Stats system_stats (RAM/VRAM, version, queue depth)
Viewing list_outputs, view_image, view_latest — images come back as MCP image blocks
Workflows list_workflows, read_workflow, write_workflow
Queueing queue_workflow (with overrides), get_progress, cancel_queue
Waiting wait_for_image — blocks until the render lands
Batching queue_batch — up to 8 prompt/seed/param variants in one call
Models list_models, download_model (Civitai + HuggingFace, token-aware)
Curation pick_top — copy winners to a named folder remotely + scp them local
Scripting run_comfyscript — author the graph as Python

The override engine

queue_workflow takes a saved workflow as a base and applies structured overrides — prompt, negative, checkpoint, seed, steps, cfg, guidance, sampler, scheduler, width, height, loras — by rewriting the graph before submission. The interesting cases:

  • LoRA injection is architecture-aware: FLUX models load via UNETLoader and take CLIP from a separate DualCLIPLoader, so injected LoRAs use LoraLoaderModelOnly with no CLIP rewire; SDXL checkpoints get the classic LoraLoader treatment. The engine detects which world it's in.
  • Unknown targets fail loudly: overriding a field the workflow has no node for returns override_target_not_found:<field> instead of silently generating the wrong thing.

Canonical starter templates for six model families (FLUX, FLUX.2, SDXL, Illustrious/anime, Qwen-Image, Z-Image Turbo) ship in templates/, generated deterministically from known-good source workflows by scripts/make_templates.py (strips LoRAs, normalizes titles, randomizes seeds, converts fixed-size upscales to relative ones so width/height overrides stay aspect-correct).

run_comfyscript — the escape hatch

JSON workflow + overrides covers routine text-to-image iteration. It does not cover a two-stage upscale pipeline, a video model with audio conditioning, or anything you'd actually need the canvas for. run_comfyscript accepts a Python snippet using ComfyScript, wraps it in the runtime preamble, executes it in the ComfyUI venv on the GPU host over SSH, and reports back only the newly created output files. Every node installed on the server (~2900 including custom nodes) is callable as a Python function, so the agent can author arbitrary graphs as code.

GPU-yield handshake

On a unified-memory box the image side and the LLM side compete for the same physical RAM, and a 35GB diffusion model colliding with a resident LLM is an OOM. Before any GPU work, src/yield.ts asks the LLM router (llama-swap) to unload its models — called from the shared queuePrompt() path so every current and future queue tool inherits it, and separately from run_comfyscript which bypasses that path. It's best-effort by design: if the router is down or slow, the server logs and proceeds rather than blocking a generation. The mirror-image policy (LLM loads freeing an idle ComfyUI) lives host-side.

Setup

npm install && npm run build

Register with your MCP client (Claude Code shown), pointing the env at your ComfyUI host:

// ~/.claude.json → mcpServers
"comfyui": {
  "command": "node",
  "args": ["/path/to/comfyui-mcp/dist/index.js"],
  "env": {
    "COMFYUI_HOST": "http://<gpu-host>:8188",
    "SPARK_SSH_ALIAS": "<ssh-alias>",            // from ~/.ssh/config
    "SPARK_COMFYUI_ROOT": "/path/to/ComfyUI",    // on the GPU host
    "SPARK_COMFYUI_PYTHON": "/path/to/venv/bin/python",
    "LLAMASWAP_HOST": "http://<gpu-host>:8089",  // optional, GPU-yield
    "CIVITAI_API_TOKEN": "${CIVITAI_API_TOKEN}", // optional, gated downloads
    "HF_TOKEN": "${HF_TOKEN}"
  }
}

SSH access to the GPU host (key-based, via the alias) is required for the workflow/model/comfyscript tools; the queue/view tools work over HTTP alone.

Testing

npm test          # 81 tests, fully offline
npm run smoke -- --live   # hits the real GPU host

Every tool handler is a pure function taking injectable deps (handleX(args, deps)), so the entire suite runs offline against fakes — no ComfyUI instance needed. The live smoke script is separate and explicit.

Docs

  • docs/realism-findings.md — empirical findings on photorealistic portrait generation and character identity consistency with FLUX.1 Krea: what actually makes a generated image read as a modern photo, which prompt signals break identity across a set, and documented demographic biases in scene priors.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选