ComfyUI Connector(WorkBuddy)
为腾讯 WorkBuddy 生态开发的 ComfyUI 连接器:MCP stdio + 用户自填 Token 模式 (规范 06 / 06D 附录C),让 AI 通过自然语言运行 ComfyUI 工作流并取回生成的图片。
目录结构
comfyui/
├── connector-meta.json # 连接器元信息(type: mcp, auth_mode: token, minWorkbuddyVersion: 4.24.0)
├── mcp.json # MCP Server 连接配置(stdio,凭证经 env 注入)
├── token-schema.json # 用户自填 Token 表单(COMFY_URL + 可选 COMFY_TOKEN)
├── comfy_mcp_server/ # MCP Server(Python,官方 mcp SDK FastMCP)
│ ├── __init__.py
│ ├── __main__.py # python -m comfy_mcp_server 入口
│ └── server.py # 5 个 tool:list_checkpoints / list_samplers / run_workflow / get_status / get_image
├── skills/
│ └── SKILL.md # Skill 文件(按 05 规范,教 AI 如何使用工具)
├── icon.svg # 连接器图标
├── tests_smoke.py # 冒烟测试(MCP stdio 客户端调工具,验证错误路径)
├── pyproject.toml # hatchling 打包(PyPI 包名 workbuddy-mcp-comfyui)
└── README.md
依赖仅 mcp(v1,FastMCP)+ httpx(Python ≥ 3.10)。
工具一览
| Tool | 用途 |
|---|---|
list_checkpoints() |
列出 checkpoint 模型(GET /object_info/CheckpointLoaderSimple) |
list_samplers() |
列出采样器与调度器(GET /object_info/KSampler) |
run_workflow(workflow) |
提交 API 格式工作流(POST /prompt),返回 prompt_id,只提交不等待 |
get_status(prompt_id) |
查询进度与输出(GET /history/{id},未完成时对照 GET /queue) |
get_image(filename, subfolder?, type?) |
取回图片(GET /view),以 MCP ImageContent 返回 |
标准链路:list_checkpoints 确认模型名 → run_workflow 提交 → 轮询
get_status → 用 history outputs 里的 filename/subfolder/type 三元组调 get_image。
COMFY_TOKEN 仅在用户加了反向代理鉴权时才填;非空时 server 自动附加
Authorization: Bearer 头,原生 ComfyUI 留空。httpx 超时 30s。
本地测试
cd <项目目录>/connectors/comfyui
# 1. 语法与 JSON 校验
python3 -m py_compile comfy_mcp_server/*.py
for f in connector-meta.json mcp.json token-schema.json; do python3 -m json.tool "$f" > /dev/null && echo "$f OK"; done
# 2. 起本地构建的 server 并调用工具(ComfyUI 未运行时验证错误路径)
# server 经 uvx --from 本地目录构建;客户端复用 home-assistant/.venv 里的 mcp 包
export UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
export COMFY_URL="http://127.0.0.1:8188"
../home-assistant/.venv/bin/python tests_smoke.py
错误处理约定
- 连接失败 → 提示检查 COMFY_URL / ComfyUI 是否启动 / 网络可达性
- 401 → 仅反代鉴权场景出现,提示更新 COMFY_TOKEN
- run_workflow 400 → 摘要 ComfyUI 的 node_errors,并提示「Export (API)」导出 API 格式
- get_status 找不到任务 → 对照 /queue 区分排队中与任务不存在
- get_image 404 → 提示从 get_status 的 outputs 取有效三元组
- 缺环境变量 / 超时 / 非 200 均返回可读中文错误,不会抛栈给 AI
正式提交前 TODO
-
发布 PyPI 包:
mcp.json已按uvx workbuddy-mcp-comfyui编写,需把workbuddy-mcp-comfyui发布到 PyPI 后用户方可直接使用(骨架阶段用uvx --from <本目录>或python -m comfy_mcp_server本地运行)。 -
压测报告:按 06 规范 2.2.5 完成压测并附报告——QPS ≥ 50、P50 ≤ 500ms、 P99 ≤ 3000ms、超时率 < 1%、错误率 ≤ 0.5%(stdio 形态需覆盖基础混合调用 + 突发流量 2×QPS 30s 场景;locust/k6 均可)。
-
用真实运行的 ComfyUI 跑通全部 5 个 tool 的正路径 (list → run → 轮询 → 取图;当前仅验证了连接失败错误路径)。
-
准备一个最小 API 格式示例工作流放入 README/SKILL 示例,便于用户对照。
-
提交前对照 06D 第 13.8 提交检查清单逐项复核。
-
按灵感模块 08 规范:提交 Skill 时必须同步提交 3~5 个灵感案例(case.json + output 单文件 + cover.png 720×400)。参考 <项目目录>/playbooks/asr-feishu-pipeline/ 的 case 结构
Metadata
Release files for workbuddy-mcp-comfyui 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| workbuddy_mcp_comfyui-1.0.1.tar.gz | 8.5 kB | Without provenance | Details for workbuddy_mcp_comfyui-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| workbuddy_mcp_comfyui-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for workbuddy_mcp_comfyui-1.0.1-py3-none-any.whl |
Total release size: 18.5 kB
Release files / workbuddy_mcp_comfyui-1.0.1.tar.gz
| Download URL | workbuddy_mcp_comfyui-1.0.1.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbd7fbedebde2b7f3465dcd4725a05469dca7bf73057c44a5a495ecf512849ad
|
|
BLAKE2b-256 checksum How to use checksums |
d84e43635bb2467b451a4f3172ce96ed80f42deb50a896c6fe134dd8330cf67e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / workbuddy_mcp_comfyui-1.0.1-py3-none-any.whl
| Download URL | workbuddy_mcp_comfyui-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c95b984f9572e8411fb8c66e3847d0dd824697a10639a144963cb13b2ef3a66f
|
|
BLAKE2b-256 checksum How to use checksums |
d59fcc962b0bafa6843065e718910a79dfaf567e38ea9bcf7116fb419d094e6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for workbuddy-mcp-comfyui 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.