mcp-comfyui
This server acts as an MCP gateway for ComfyUI, enabling image generation, editing, and processing via AI workflows.
Text-to-Image Generation: Generate images from text prompts using built-in workflows:
Sensenova(supports Chinese prompts, aspect ratio, steps, CFG, seed, batch size)Z-Image Turbo(fast Lumina2-based generation with configurable resolution, sampler, scheduler)Qwen-Image-2512 + LoRA(high-quality images with negative prompt and LoRA strength controls)
Background Removal: Remove backgrounds from images using the BiRefNet model.
Image Upscaling: Upscale images to 2K resolution using RealESRGAN + Z-Image Turbo.
Reboot ComfyUI: Remotely restart the ComfyUI service and wait for it to recover.
Batch Processing: Repeat tasks a fixed number of times (
submit_batch) or over a time duration (batch_by_time).Local Output Download: Specify an
output_dirto download generated images locally, with Markdown image links returned.Custom Workflow Support: Automatically register any
.jsonworkflow files from local directories as MCP tools, and optionally sync workflows directly from a ComfyUI instance on startup.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-comfyui generate an image of a serene mountain landscape"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
comfyui-mcp
通过 MCP (Model Context Protocol) 协议调用 ComfyUI,加载并执行 workflow:文生图、图编辑、放大、去背景等。适用于 opencode、Claude Code、Cursor 等 MCP 客户端。
快速启动
uvx --from git+https://github.com/bookandmusic/comfyui-mcp.git comfyui-mcp \
--comfyui.host 127.0.0.1:8188首次运行自动下载依赖并创建隔离虚拟环境。5 个内置 workflow 开箱即用,无需额外配置。
Related MCP server: comfyui-mcp
工具列表
内置 workflow(bundled_ 前缀)
工具名 | 说明 |
| Sensenova 文生图 |
| Z-Image Turbo 文生图 |
| Qwen-Image-2512 + LoRA 文生图 |
| BiRefNet 去背景 |
| Z-Image Turbo 2K 放大 |
附加工具
工具名 | 说明 |
| 重启 ComfyUI 服务,等待恢复后返回成功消息 |
本地 workflow
放入 --comfyui.workflow_directory 的 .json 文件会自动注册为工具,工具名为文件名中的 . 替换为 _,例如 my_workflow.json → my_workflow。
各工具共有参数
参数 | 类型 | 说明 |
| string | 图像描述(非必填,由具体 workflow 决定) |
| int | 随机种子,留空自动生成。多批时自动递增 |
| bool | 按时间轮询(分钟),与 |
| int | 重复执行次数,或 |
| string | 可选,本地目录。提供时将结果图片下载到此目录并返回 Markdown 图片链接 |
配置
comfyui-mcp 的所有配置通过命令行参数传入,不支持配置文件。启动参数如下:
启动参数
参数 | 默认值 | 说明 |
|
| ComfyUI 服务的 host:port |
|
| 本地工作流目录(sync 时也作为下载目标) |
|
| 额外工作流目录列表 |
|
| 启动时从 ComfyUI 同步所有 |
|
| HTTP 请求超时(秒) |
|
| 失败重试次数 |
|
| 队列轮询间隔(秒) |
|
| 任务最长等待时间(秒, |
|
|
|
Workflow 来源(按优先级)
1. 内置 workflow
随 wheel 打包,始终加载。工具名带 bundled_ 前缀,不与用户 workflow 冲突。
2. 本地目录
--comfyui.workflow_directory 指定的目录(默认 ~/.config/comfyui-mcp/workflows/)。放入 .json 文件,重启后自动注册。目录不存在时自动创建。
cp my-workflow.json ~/.config/comfyui-mcp/workflows/需要多个目录时:
--comfyui.additional_workflow_directories '["/path/to/dir1", "/path/to/dir2"]'3. 从 ComfyUI 同步(可选)
--comfyui.sync_from_comfyui true 启动后,MCP 调用 ComfyUI 的 /api/v2/userdata 列出所有 .json 文件并下载到本地 workflow_directory。适用于集中式 workflow 库 + 多 MCP 实例、跨机部署等场景。
uvx --from git+https://github.com/bookandmusic/comfyui-mcp.git comfyui-mcp \
--comfyui.host 127.0.0.1:8188 \
--comfyui.sync_from_comfyui true注意:同步范围包括 userdata 下所有
.json(含非 workflow 的配置如styles.json),缺少nodes字段的文件会报加载错误但不中断启动。
客户端配置
opencode
{
"mcp": {
"comfyui": {
"type": "local",
"command": [
"uvx",
"--from", "git+https://github.com/bookandmusic/comfyui-mcp.git",
"comfyui-mcp",
"--comfyui.host", "127.0.0.1:8188"
],
"enabled": true,
"timeout": 600000
}
}
}Claude Code
添加到 ~/.claude/settings.json:
{
"mcpServers": {
"comfyui": {
"command": "uvx",
"args": [
"--from", "git+https://github.com/bookandmusic/comfyui-mcp.git",
"comfyui-mcp",
"--comfyui.host", "127.0.0.1:8188"
]
}
}
}也可放在项目级 .claude/settings.local.json 中。
本地开发
git clone https://github.com/bookandmusic/comfyui-mcp.git
cd comfyui-mcp
uv sync
uv run python -m comfyui_mcp.server --comfyui.host 127.0.0.1:8188或安装为本地命令:
uv tool install .
comfyui-mcp --comfyui.host 127.0.0.1:8188License
MIT — 详见 LICENSE。
Available Tools
6 toolsbundled_image_z_image_turbo_jsonD
Comfy image generation workflow image_z_image_turbo.json
Inputs: cfg, seed, text, type, +16 more.
bundled_qwen_image_2512_with_lora_jsonD
Comfy image generation workflow qwen_image_2512_with_lora.json
Inputs: cfg, seed, type, shift, +19 more.
bundled_sensenova_jsonD
Comfy image generation workflow sensenova.json
Inputs: cfg, seed, steps, prompt, +7 more.
bundled_utility_birefnet_remove_background_jsonD
Comfy image generation workflow utility_birefnet_remove_background.json
Inputs: p_, output_dir, submit_batch, batch_by_time, +2 more.
bundled_utility_z_image_turbo_2k_upscaler_jsonD
Comfy image generation workflow utility_z_image_turbo_2k_upscaler.json
Inputs: p_, cfg, seed, type, +19 more.
reboot_comfyuiA
重启 ComfyUI 服务,等待服务恢复后返回「ComfyUI 服务已重启成功」
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a distinct name referencing a specific workflow or action (e.g., 'image_z_image_turbo_json' vs 'qwen_image_2512_with_lora_json'), making them clearly distinguishable despite similar descriptions.
The five 'bundled_*_json' tools follow a consistent pattern, but 'reboot_comfyui' breaks the convention, introducing minor inconsistency.
With 6 tools, the server covers a focused set of workflows plus a utility action, which is well-scoped and avoids bloat.
The tools offer specific workflows but lack generic workflow execution or discovery capabilities, leaving notable gaps for broader image generation tasks.
Related MCP Connectors
Remote MCP for RunComfy: ComfyUI deployments, hosted models, LoRA training. 31 tools.
Create, browse, remix, collaborate on, and run durable AI workflow nodes from MCP hosts.
Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.
Direct AI video, image, music and storyboard production from any MCP client.
Related MCP Servers
- AlicenseDqualityDmaintenanceIntegrates Jimeng AI image and video generation services through MCP protocol, enabling users to generate high-quality images and videos from text prompts with support for image mixing, reference images, and multiple AI models.337 npm53MIT
- AlicenseAqualityDmaintenanceMCP server for ComfyUI — text-to-image, variations, img2img refine, upscale, image proxy, and workflow runner.15120 npm2MIT
- AlicenseNot gradedqualityCmaintenanceA custom node plugin for ComfyUI that encapsulates workflows as templates, enabling AI assistants (Claude, Cursor) to invoke ComfyUI for multimedia generation via the MCP protocol.31MIT
- AlicenseAqualityDmaintenance通过Model Context Protocol调用本地ComfyUI实例生成图片,支持动态替换工作流中的提示词和尺寸等参数。245 PyPI23MIT