comfyui-mcp
comfyui-mcp
ComfyUI 的 MCP 服务器。在任何兼容 MCP 的客户端中通过自然语言提示词生成图像。
状态
v0.2 版本发布了核心工具,包括放大、图像代理和公共 URL 支持。当前工具集:generate_image、generate_variations、generate_with_workflow、refine_image、upscale_image、list_models、list_workflows、upload_image、generate_with_controlnet、generate_with_ip_adapter,以及工作流模板注册表。查看路线图了解后续计划。
Related MCP server: ComfyUI MCP
安装
npx (无需安装)
npx @miller-joe/comfyui-mcp --comfyui-url http://your-comfyui-host:8188npm
npm install -g @miller-joe/comfyui-mcp
comfyui-mcp --comfyui-url http://your-comfyui-host:8188Docker
docker run -p 9100:9100 \
-e COMFYUI_URL=http://your-comfyui-host:8188 \
ghcr.io/miller-joe/comfyui-mcp:latest连接 MCP 客户端
Claude Code:
claude mcp add --transport http comfyui http://localhost:9100/mcp或者将流式 HTTP 端点注册到 MCP 网关(例如 MetaMCP)以与其他服务器聚合。
配置
所有选项均可通过 CLI 标志或环境变量设置:
CLI 标志 | 环境变量 | 默认值 | 描述 |
|
|
| 绑定主机(仅限 HTTP 模式) |
|
|
| 绑定端口(仅限 HTTP 模式) |
|
| (未设置) | 通过 stdio 而非 HTTP 进行 MCP 通信。当作为 stdio 优先的 MCP 客户端(Claude Desktop, mcp-inspector)的子进程启动时使用。 |
|
|
| 此服务器内部使用的 ComfyUI HTTP URL |
|
| 与 | 返回给客户端的图像 URL 中的外部 URL。当内部 URL 无法从 MCP 客户端访问时(Docker 网络常见情况)设置此项。 |
(无标志) |
|
| 默认检查点文件名 |
传输方式
服务器默认使用流式 HTTP(非常适合 Claude Code、MetaMCP、原生 fetch)。传递 --stdio(或设置 MCP_TRANSPORT=stdio)以切换到 stdio 模式,这是 Claude Desktop 和 MCP Inspector 等 stdio 优先客户端所期望的:
# Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"comfyui": {
"command": "npx",
"args": ["-y", "@miller-joe/comfyui-mcp", "--stdio", "--comfyui-url", "http://127.0.0.1:8188"]
}
}
}返回给客户端的图像 URL
生成工具返回的图像 URL 格式为 <comfyui-public-url>/view?filename=…。如果未设置 --comfyui-public-url,URL 将使用内部的 --comfyui-url 值。
服务器还提供了一个代理端点:GET /images/<filename>?subfolder=&type=output,通过此服务器流式传输图像字节,这在客户端可以访问 MCP 服务器但无法直接访问 ComfyUI 时非常有用。
默认检查点必须与 ComfyUI models/checkpoints/ 目录中的文件匹配。可通过 COMFYUI_DEFAULT_CKPT 覆盖,或将 checkpoint 作为工具参数传递。
工具
generate_image
使用 ComfyUI 的默认 txt2img 工作流根据文本提示词生成图像。
参数:prompt (必填), negative_prompt, width, height, steps, cfg, seed, checkpoint。
generate_variations
通过改变种子生成同一提示词的多个变体。一次性返回所有图像。
参数:prompt (必填), count (2–16, 默认 4),以及与 generate_image 相同的生成参数,使用 base_seed 代替 seed。
generate_with_workflow
提交任意 ComfyUI 工作流 JSON(完整节点图)并返回生成的图像 URL。用于自定义工作流 — ControlNet、放大或任何从 ComfyUI 的 Save (API Format) 导出的内容。
参数:workflow (对象),完整的节点图。
refine_image
对源图像运行 img2img。服务器获取源 URL,将其上传到 ComfyUI,并运行由新提示词引导的去噪过程。较低的 denoise 值保留更多原始细节;较高的值赋予提示词更多自由度。
参数:prompt, source_image_url (必填), denoise (0–1, 默认 0.5),以及标准生成参数。
list_models
列出 ComfyUI 实例上可用的检查点、LoRA、采样器或调度器。
参数:kind,可选 checkpoints (默认), loras, samplers, schedulers。
list_workflows
列出随此服务器提供的内置工作流模板(当前为 txt2img, img2img, upscale, controlnet, ip_adapter)。
upload_image
将参考图像上传到 ComfyUI,以便在 img2img、ControlNet 或 IP-Adapter 工作流中使用。
参数:source_url 或 image_base64 (二选一), filename (可选), overwrite (默认 false)。
返回:存储的文件名,可用作 LoadImage 等工作流节点中的 image 输入。
generate_with_controlnet
使用 ControlNet 预处理图像(姿势骨架、深度图、Canny 边缘、法线贴图等)加上文本提示词来生成图像。
参数:prompt, control_image_url (预处理后的条件图像;此工具不运行预处理器), controlnet_model (来自 models/controlnet/ 的文件名), strength (0–2, 默认 1), start_percent / end_percent (0–1,控制采样期间 CN 何时激活),以及标准生成参数。
需要在 ComfyUI models/controlnet/ 目录中安装 ControlNet 模型。
generate_with_ip_adapter
使用参考图像作为视觉/风格/主体指南,通过 IP-Adapter 生成图像。
参数:prompt, reference_image_url, preset (例如 "STANDARD (medium strength)", "PLUS FACE (portraits)", "VIT-G (medium strength)"), weight (0–3, 默认 1), start_at / end_at (0–1),以及标准生成参数。
需要 ComfyUI-IPAdapter-plus 自定义节点包以及预设匹配的 IPAdapter 权重和 CLIP Vision 模型。
工作流模板注册表
保存复杂的工作流 JSON,稍后按名称运行。模板存储在磁盘上的 --templates-dir 下(默认为 ~/.config/comfyui-mcp/templates/<name>.json),因此它们在重启后依然存在,并且可以在不同 MCP 客户端之间移植。
工具 | 描述 |
| 将工作流 JSON 保存到命名槽位。 |
| 列出已保存的模板及其描述和最后更新时间戳。 |
| 获取存储模板的 JSON 及元数据。 |
| 删除存储的模板。 |
| 针对 ComfyUI 运行已保存的模板并返回图像 URL。 |
模板名称必须以字母数字开头。允许字符:a-z, A-Z, 0-9, -, _。最大 64 个字符。
返回格式
所有生成工具返回的图像 URL 均由 ComfyUI 实例直接提供 (http://<comfyui>/view?filename=…)。这些 URL 可以直接传递给任何接受图像 URL 的客户端。
架构
┌────────────────┐ ┌──────────────────┐ ┌──────────────┐
│ MCP client │────▶│ comfyui-mcp │────▶│ ComfyUI │
│ (Claude, etc.)│◀────│ (this server) │◀────│ instance │
└────────────────┘ └──────────────────┘ └──────────────┘
streamable HTTP HTTP REST + poll服务器是无状态的。单个 MCP 请求将工作流提交给 ComfyUI,轮询 /history/{id} 直到完成,并返回图像 URL。
开发
git clone https://github.com/miller-joe/comfyui-mcp
cd comfyui-mcp
npm install
npm run dev # hot-reload via tsx watch
npm run build # compile TS to dist/
npm run typecheck # strict type checking需要 Node 20+。
路线图
v0.2 已发布:
generate_image,generate_variations,generate_with_workflowrefine_image(来自源 URL 的 img2img)upscale_image(ESRGAN / SwinIR 风格模型放大)list_models,list_workflows,upload_image图像代理端点 (
/images/<filename>),适用于无法直接访问 ComfyUI 的客户端可配置的公共 URL,用于获取外部正确的图像 URL
工作流模板注册表 (保存/列出/获取/删除/运行)
generate_with_controlnet(需要 ComfyUI 端的 ControlNet 模型)generate_with_ip_adapter(需要 ComfyUI-IPAdapter-plus 包)
计划中:
用于长时间生成任务的 WebSocket 进度事件。
许可证
MIT © Joe Miller
支持
如果此工具为您节省了时间,请考虑支持开发:
每一笔贡献都将资助维护、文档编写和后续版本发布。
Available Tools
15 toolsdelete_workflow_templateB
Delete a saved workflow template.
Inputs: name (required).
generate_imageB
Generate an image from a text prompt using ComfyUI's default txt2img workflow. Returns one or more image URLs served directly by the ComfyUI instance.
Inputs: prompt (required), negative_prompt, width, height, +4 more.
generate_variationsB
Generate multiple variations of the same prompt by varying the seed. Useful for picking the best result or exploring a concept.
Inputs: prompt (required), count, negative_prompt, width, +5 more.
generate_with_controlnetA
Generate an image conditioned by a ControlNet preprocessed image (pose, depth, canny, etc.) plus a prompt. Requires a ControlNet model installed in ComfyUI's models/controlnet/ directory. The control_image_url must already be the preprocessed conditioning image — this tool does not run preprocessors itself.
Inputs: prompt (required), control_image_url (required), controlnet_model (required), negative_prompt, +9 more.
generate_with_ip_adapterB
Generate an image using a reference image as an IP-Adapter visual/style/subject guide. Requires the ComfyUI-IPAdapter-plus custom node pack and the preset's matching models (IPAdapter weights + CLIP vision). Weight tunes how strongly the reference guides generation.
Inputs: prompt (required), reference_image_url (required), negative_prompt, preset, +9 more.
generate_with_workflowA
Submit an arbitrary ComfyUI workflow (full node graph) and return the resulting image URLs. Use this when you need a custom workflow like ControlNet, upscaling, or a node graph exported from ComfyUI's 'Save (API Format)'.
Inputs: workflow (required).
get_workflow_templateB
Fetch a saved workflow template's JSON and metadata.
Inputs: name (required).
list_modelsA
List available models or samplers on the ComfyUI instance. Use this to discover valid values for the 'checkpoint' parameter of other tools, or to see what LoRAs and samplers are installed.
Inputs: kind.
list_workflowsA
List built-in workflow templates shipped with this MCP server. These are the named workflows that can be used as a baseline; for arbitrary workflows use generate_with_workflow.
Inputs: no named parameters.
list_workflow_templatesA
List all saved workflow templates in the registry.
Inputs: no named parameters.
refine_imageA
Refine an existing image using img2img: fetch the source image, upload it to ComfyUI, and run a denoising pass guided by the prompt. Lower denoise preserves more of the original; higher denoise gives more freedom to the prompt.
Inputs: prompt (required), source_image_url (required), denoise, negative_prompt, +4 more.
run_workflow_templateB
Run a saved workflow template against ComfyUI and return the resulting image URLs.
Inputs: name (required).
save_workflow_templateA
Save a ComfyUI workflow JSON to the server's template registry under a named slot. Overwrites are disabled by default.
Inputs: name (required), workflow (required), description, overwrite.
upload_imageA
Upload a reference image to ComfyUI for use in img2img, ControlNet, or IP-Adapter workflows. Accepts either a source URL (will be fetched) or base64-encoded image data. Returns the stored filename for use as 'image' in workflow nodes like LoadImage.
Inputs: source_url, image_base64, filename, overwrite.
upscale_imageA
Upscale an image using a loaded upscaler model (ESRGAN, SwinIR, etc.). Fetches the source image, uploads to ComfyUI, runs the upscale node, and returns the output URL. Requires at least one upscaler model in ComfyUI's models/upscale_models/ directory.
Inputs: source_image_url (required), upscale_model (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool has a clearly distinct purpose: generation methods (standard, variations, ControlNet, IP-Adapter, custom workflow), image manipulation (refine, upscale), workflow management (list, get, save, delete, run templates), and utilities (upload_image, list_models). No overlap in functionality.
All tools follow a consistent verb_noun pattern in snake_case (e.g., generate_image, list_models, save_workflow_template). No mixing of styles or ambiguous verbs.
15 tools cover the core capabilities of a ComfyUI integration (generation, conditioning, upscaling, workflow templates, and utilities) without being excessive. Each tool earns its place for a comprehensive image generation server.
The tool surface covers major workflows: txt2img, img2img, ControlNet, IP-Adapter, upscaling, and custom workflows via templates. Minor gaps like explicit inpainting/outpainting tools exist, but these can be handled through custom workflows.
Maintenance
Related MCP Connectors
AI image & video generation MCP server (16 models, DAG projects, MCP Apps UI, OAuth 2.1).
Remote MCP server for anime art, OCs, style pickers, inpainting, upscaling & anime video.
MCP server for Qwen Image 3 AI image generation
Remote MCP for RunComfy: ComfyUI deployments, hosted models, LoRA training. 31 tools.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Claude Desktop to interact with local ComfyUI installations for AI-powered image generation, including workflow management, model selection, real-time monitoring, and custom workflow execution through natural language.1418MIT
- AlicenseAqualityAmaintenanceMCP server + Claude Code plugin for ComfyUI: execute workflows, generate images, visualize pipelines as Mermaid diagrams, compose/validate workflows, manage and download models, control VRAM, and explore custom nodes. 36 tools, cross-platform, installs via npx -y comfyui-mcp.4112,767 npm971MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that connects local ComfyUI to AI agents, enabling natural language control of ComfyUI for creating workflows, generating images, and managing the queue.1-
- AlicenseAqualityDmaintenanceMCP server that provides image generation, captioning, and tagging via ComfyUI API, configurable for agent tools.43MIT