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 "Install 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-comfyuigenerate 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。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/bookandmusic/mcp-comfyui'
If you have feedback or need assistance with the MCP directory API, please join our Discord server