返回市场
舒适界面_MCP

舒适界面_MCP

作者:orion4d6 星标更新:2025-10-20

项目介绍

🧠 用于ComfyUI的MCP服务器(Alpha-1版)

<img width="2208" height="1235" alt="image" src="https://gips2.baidu.com/it/u=246272515,1585966918&fm=3081&app=3081&f=PNG?w=2208&h=1235" />

该项目通过兼容MCP(模型上下文协议)的服务器来提供ComfyUI服务。

它允许:

  • 通过连接器从ChatGPT控制ComfyUI(开发模式);
  • 通过WebSocket扩展在Chrome中控制ComfyUI界面。
<img width="517" height="645" alt="image" src="https://gips3.baidu.com/it/u=3132290619,3098774478&fm=3081&app=3081&f=PNG?w=517&h=645" />

即将推出:本地Gradio接口支持Ollama和Google CLI


⚙️ 安装

1️⃣ 克隆仓库

git clone https://github.com/orion4d/ComfyUI_mcp.git

2️⃣ 创建虚拟环境

python -m venv venv
# Linux / Mac
source venv/bin/activate
# Windows
venv\Scripts\activate

3️⃣ 安装依赖

pip install -r requirements.txt

🔐 密钥生成与配置

python generate_key.py

此脚本:

  • 生成MCP_API_KEY(用于ChatGPT)
  • 生成WEBSOCKET_TOKEN(用于Chrome扩展)
  • 自动创建.env.env.example

🚀 启动服务器

python server.py

服务器默认启动于: http://127.0.0.1:8000


🌐 接口点

🔧 暴露的MCP工具

  • list_workflows, save_workflow, load_workflow
  • read_custom_node, write_custom_node
  • queue_prompt, get_history
  • create_custom_node_template, list_custom_subdir
  • ui_click_element, ui_fill_input, ui_get_current_workflow

🧩 调试路由

  • /debug/health → 系统信息、版本、工具
  • /ws → Chrome扩展的WebSocket

🧱 使用示例

从ChatGPT(自定义GPT)

  • 认证:X-API-Key → 你的MCP_API_KEY
  • 可调用:list_workflows, queue_prompt, read_custom_node

从Chrome(MCP扩展)

  • WebSocket URL:ws://127.0.0.1:8000/ws
  • Token:WEBSOCKET_TOKEN

🧠 ComfyUI集成

客户端(ComfyUIClient)通过HTTP与本地的ComfyUI通信:

  • URL:http://127.0.0.1:8188
  • 支持UI和API工作流
  • 自动转换通过_convert_ui_to_api()

测试连接

curl http://127.0.0.1:8000/debug/health

📘 MCP-ComfyUI命令

🗂️ 命令结构

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

🧠 执行 & 队列

  • /queue_prompt → 执行一个工作流
  • /get_queue_status → 获取队列状态
  • /get_history → 获取提示历史
  • /cancel_prompt → 取消一个提示
  • /interrupt_execution → 中断当前执行

⚙️ 系统 & 模型

  • /get_system_stats → 获取GPU、RAM、版本信息
  • /list_models → 列出可用模型
  • /model_info → 获取模型详情

🧩 工作流

  • /save_workflow → 保存一个工作流
  • /load_workflow → 加载一个工作流
  • /list_workflows → 列出所有工作流
  • /inspect_workflow → 分析工作流结构

🖼️ 图像 & 文件

  • /list_output_images → 查看生成的图像
  • /get_image → 获取图像
  • /upload_image → 上传输入图像

🔧 自定义节点

  • /create_custom_node_template → 创建节点模板
  • /write_custom_node → 写入节点文件
  • /read_custom_node → 读取节点代码
  • /list_custom_subdir → 探索自定义目录
  • /autodoc_nodes → 生成所有自定义节点文档

🖥️ 界面(Chrome UI)

  • /ui_click_element → 模拟点击
  • /ui_fill_input → 填充文本字段
  • /ui_get_current_workflow → 获取显示的工作流

📂 MCP_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"}

🧭 典型用途

  • 导出生成的结果或图像以供检查。
  • 导入脚本、工作流JSON或数据集。
  • 自动化MCP与ComfyUI之间的交换。

完整路径: ComfyUI/output/MCP_exchange/

其他命令(工作流、模型、节点)作用于其他地方;此组命令仅限于交换文件管理。