该项目通过兼容MCP(模型上下文协议)的服务器来提供ComfyUI服务。
它允许:
git clone https://github.com/orion4d/ComfyUI_mcp.git
python -m venv venv
# Linux / Mac
source venv/bin/activate
# Windows
venv\Scripts\activate
pip install -r requirements.txt
python generate_key.py
此脚本:
.env和.env.examplepython server.py
服务器默认启动于:
http://127.0.0.1:8000
list_workflows, save_workflow, load_workflowread_custom_node, write_custom_nodequeue_prompt, get_historycreate_custom_node_template, list_custom_subdirui_click_element, ui_fill_input, ui_get_current_workflow/debug/health → 系统信息、版本、工具/ws → Chrome扩展的WebSocketX-API-Key → 你的MCP_API_KEYlist_workflows, queue_prompt, read_custom_node等ws://127.0.0.1:8000/ws客户端(ComfyUIClient)通过HTTP与本地的ComfyUI通信:
http://127.0.0.1:8188_convert_ui_to_api()curl http://127.0.0.1:8000/debug/health
ComfyUI
│
├── 🧠 执行(引擎)
│ ├─ /queue_prompt
│ ├─ /get_queue_status
│ ├─ /cancel_prompt
│ ├─ /get_history
│ └─ /interrupt_execution
│
├── ⚙️ 系统及模型
│ ├─ /get_system_stats
│ ├─ /list_models
│ └─ /model_info
│
├── 🧩 工作流
│ ├─ /save_workflow
│ ├─ /load_workflow
│ ├─ /list_workflows
│ └─ /inspect_workflow
│
├── 🔧 自定义节点(→ ComfyUI/custom_nodes/)
│ ├─ /create_custom_node_template
│ ├─ /write_custom_node
│ ├─ /read_custom_node
│ ├─ /list_custom_subdir
│ └─ /autodoc_nodes
│
├── 🖼️ 图像
│ ├─ /upload_image
│ ├─ /get_image
│ └─ /list_output_images
│
└── 📂 MCP_exchange(→ output/MCP_exchange/)
├─ /list_exchange
├─ /read_exchange
├─ /write_exchange
└─ /delete_exchange
此目录作为MCP-ComfyUI与本地环境之间的交换空间。
以下所有命令仅与该目录交互:
output/MCP_exchange/
call_tool /MCP-ComfyUI/.../list_exchange {"limit": 200, "exts": "png,jpg,jpeg,webp,bmp,tif,tiff,txt,md,html,htm,json,js,py,css"}
call_tool /MCP-ComfyUI/.../read_exchange {"name": "文件名.txt", "as_data_url": true}
call_tool /MCP-ComfyUI/.../write_exchange {"name": "新文件.md", "content": "文件内容", "mode": "text", "overwrite": true}
可用模式:text, base64, data_url。
call_tool /MCP-ComfyUI/.../delete_exchange {"name": "要删除的文件.json"}
完整路径: ComfyUI/output/MCP_exchange/
其他命令(工作流、模型、节点)作用于其他地方;此组命令仅限于交换文件管理。