@metabrain-labs/comfyui-mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +179 -0
- package/.github/workflows/ci.yml +63 -0
- package/.husky/pre-commit +11 -0
- package/LICENSE +21 -0
- package/README-en.md +635 -0
- package/README.md +656 -0
- package/__tests__/services/task/execution.test.ts +272 -0
- package/__tests__/services/task/wait.test.ts +220 -0
- package/__tests__/types/result.test.ts +227 -0
- package/__tests__/utils/mcp-helpers.test.ts +137 -0
- package/__tests__/utils/special-node-handler.test.ts +186 -0
- package/comfyui-mcp-server-skill/SKILL.md +43 -0
- package/comfyui-mcp-server-skill/references/api-json.md +323 -0
- package/comfyui-mcp-server-skill/references/catalog.md +251 -0
- package/comfyui-mcp-server-skill/rules/api-json.md +94 -0
- package/comfyui-mcp-server-skill/rules/catalog.md +93 -0
- package/comfyui-mcp-server-skill/rules/comfyui.md +158 -0
- package/configs/inspector/dev.json +11 -0
- package/configs/inspector/prod.json +9 -0
- package/docs/en/content/public/inspector-example.png +0 -0
- package/docs/en/content/public/workflow_name_example.png +0 -0
- package/docs/en/content/public/workflow_parameter_example.png +0 -0
- package/docs/en/md/Project-Advantages.md +75 -0
- package/docs/zh-CN/content/public/inspector-example.png +0 -0
- package/docs/zh-CN/content/public/workflow_name_example.png +0 -0
- package/docs/zh-CN/content/public/workflow_parameter_example.png +0 -0
- package/docs/zh-CN/md/why-us.md +51 -0
- package/example.json +26 -0
- package/jest.config.js +45 -0
- package/locales/en.json +150 -0
- package/locales/zh.json +150 -0
- package/package.json +68 -0
- package/src/api/api.ts +123 -0
- package/src/api/http.ts +70 -0
- package/src/constants/common.ts +38 -0
- package/src/constants/index.ts +1 -0
- package/src/hooks/websocket.ts +93 -0
- package/src/i18n.ts +40 -0
- package/src/index.ts +268 -0
- package/src/scripts/comfy-ui/list-history.ts +31 -0
- package/src/scripts/comfy-ui/run-ws.ts +23 -0
- package/src/scripts/ws/send-feature-flags.ts +23 -0
- package/src/server-stdio.ts +23 -0
- package/src/services/business.ts +194 -0
- package/src/services/dynamic-tool.ts +303 -0
- package/src/services/index.ts +19 -0
- package/src/services/storage/asset-storage.ts +48 -0
- package/src/services/storage/index.ts +2 -0
- package/src/services/storage/workflow-storage.ts +192 -0
- package/src/services/task/execution.ts +69 -0
- package/src/services/task/fetch.ts +131 -0
- package/src/services/task/index.ts +3 -0
- package/src/services/task/wait.ts +294 -0
- package/src/services/workflow/executor.ts +134 -0
- package/src/services/workflow/index.ts +1 -0
- package/src/tools/handlers/core-manual.ts +28 -0
- package/src/tools/handlers/index.ts +22 -0
- package/src/tools/handlers/interrupt-prompt.ts +35 -0
- package/src/tools/handlers/list-models.ts +51 -0
- package/src/tools/handlers/mount-workflow.ts +88 -0
- package/src/tools/handlers/prompt-result.ts +35 -0
- package/src/tools/handlers/prompts.ts +61 -0
- package/src/tools/handlers/queue-custom-prompt.ts +164 -0
- package/src/tools/handlers/queue-prompt.ts +170 -0
- package/src/tools/handlers/save-custom-workflow.ts +67 -0
- package/src/tools/handlers/save-task-assets.ts +82 -0
- package/src/tools/handlers/system-status.ts +30 -0
- package/src/tools/handlers/task-detail.ts +35 -0
- package/src/tools/handlers/tool-status-map.ts +33 -0
- package/src/tools/handlers/upload-assets.ts +82 -0
- package/src/tools/handlers/workflow-api.ts +46 -0
- package/src/tools/handlers/workflows-catalog.ts +79 -0
- package/src/tools/index.ts +101 -0
- package/src/types/common.ts +74 -0
- package/src/types/dynamic-tool.ts +85 -0
- package/src/types/enums/result.ts +29 -0
- package/src/types/execute.ts +24 -0
- package/src/types/object-info.ts +43 -0
- package/src/types/result.ts +126 -0
- package/src/types/task.ts +118 -0
- package/src/types/workflow.ts +111 -0
- package/src/types/ws.ts +80 -0
- package/src/utils/format.ts +134 -0
- package/src/utils/mcp-helpers.ts +110 -0
- package/src/utils/special-node-handler.ts +36 -0
- package/src/utils/workflow-converter.ts +140 -0
- package/src/utils/ws.ts +219 -0
- package/tsconfig.json +18 -0
package/.env
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# ! THE FOLLOWING ANNOTATED CONFIGURATION ITEMS ARE FEATURES NOT SUPPORTED IN THE CURRENT VERSION BUT HAVE BEEN ADDED TO THE TODO LIST.
|
|
2
|
+
# ! 下述注释起来的配置项均为当前版本不支持但已列入todo-list中的功能
|
|
3
|
+
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# ComfyUI MCP Server - Configuration
|
|
6
|
+
# 配置文件说明:
|
|
7
|
+
# [User Config] 用户配置 —— 根据您的部署环境修改此区块
|
|
8
|
+
# [System Config] 系统配置 —— 保持默认即可,无需修改
|
|
9
|
+
# =============================================================================
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# [User Config] 用户配置
|
|
14
|
+
# Modify this section based on your deployment environment.
|
|
15
|
+
# 根据您的部署环境修改以下内容。
|
|
16
|
+
# =============================================================================
|
|
17
|
+
|
|
18
|
+
# Language for MCP tool descriptions.
|
|
19
|
+
# MCP 工具描述的显示语言。可选值:en(英文)| zh(中文)
|
|
20
|
+
LOCALE=en
|
|
21
|
+
|
|
22
|
+
# -----------------------------------------------------------------------------
|
|
23
|
+
# ComfyUI Server Connection / ComfyUI 服务器连接
|
|
24
|
+
# -----------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
# Full URL of your ComfyUI server. No trailing slash.
|
|
27
|
+
# ComfyUI 服务器的完整地址,末尾不加斜杠。
|
|
28
|
+
COMFY_UI_SERVER_IP="http://192.168.0.171:8188"
|
|
29
|
+
|
|
30
|
+
# Host (without protocol) and port. Used separately for WebSocket connections.
|
|
31
|
+
# 主机名(不含协议头)和端口号,WebSocket 连接时单独使用。
|
|
32
|
+
COMFY_UI_SERVER_HOST="192.168.0.171"
|
|
33
|
+
COMFY_UI_SERVER_PORT="8188"
|
|
34
|
+
|
|
35
|
+
# -----------------------------------------------------------------------------
|
|
36
|
+
# Sync Mode / 同步模式
|
|
37
|
+
# -----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
# Controls how the server detects workflow updates from ComfyUI.
|
|
40
|
+
# 控制服务器检测 ComfyUI 工作流更新的方式。
|
|
41
|
+
#
|
|
42
|
+
# timed — Background loop polls ComfyUI at a fixed interval. (default)
|
|
43
|
+
# 后台循环以固定间隔轮询 ComfyUI。(默认)
|
|
44
|
+
#
|
|
45
|
+
# push — ComfyUI plugin sends real-time save events; long fallback poll as safety net.
|
|
46
|
+
# Requires COMFY_UI_INSTALL_PATH (must be on same machine as ComfyUI).
|
|
47
|
+
# ComfyUI 插件实时推送保存事件;兜底长轮询作为安全网。
|
|
48
|
+
# 需要配置 COMFY_UI_INSTALL_PATH(需与 ComfyUI 同机部署)。
|
|
49
|
+
#
|
|
50
|
+
# manual — No background loop. Refresh only when tools are called
|
|
51
|
+
# (get_workflows_catalog / mount_workflow / queue_prompt).
|
|
52
|
+
# 无后台循环,仅在调用工具时按需刷新
|
|
53
|
+
# (get_workflows_catalog / mount_workflow / queue_prompt)。
|
|
54
|
+
#
|
|
55
|
+
# SYNC_MODE=manual
|
|
56
|
+
|
|
57
|
+
# Polling interval in seconds for timed mode.
|
|
58
|
+
# timed 模式的轮询间隔(秒)。
|
|
59
|
+
# SYNC_POLL_INTERVAL_SECONDS=3
|
|
60
|
+
|
|
61
|
+
# Fallback polling interval in seconds for push mode (safety net for missed events).
|
|
62
|
+
# push 模式的兜底轮询间隔(秒),用于捕捉遗漏的推送事件。
|
|
63
|
+
# SYNC_EVENT_FALLBACK_INTERVAL_SECONDS=300
|
|
64
|
+
|
|
65
|
+
# Cooldown in seconds between manual mode refreshes.
|
|
66
|
+
# Prevents excessive ComfyUI API calls when tools are called in quick succession.
|
|
67
|
+
# manual 模式两次刷新之间的冷却时间(秒),防止工具短时间内连续调用时频繁请求 ComfyUI API。
|
|
68
|
+
# ONDEMAND_REFRESH_COOLDOWN_SECONDS=30
|
|
69
|
+
|
|
70
|
+
# -----------------------------------------------------------------------------
|
|
71
|
+
# Push Mode Plugin / 推送模式插件(仅 SYNC_MODE=push 时需要)
|
|
72
|
+
# -----------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
# Absolute path to your LOCAL ComfyUI installation root directory.
|
|
75
|
+
# Required when SYNC_MODE=push: MCP Server will automatically deploy a lightweight
|
|
76
|
+
# backend plugin that pushes workflow save events in real-time.
|
|
77
|
+
# Leave blank if ComfyUI runs on a remote machine or if using timed/manual mode.
|
|
78
|
+
#
|
|
79
|
+
# 本地 ComfyUI 安装目录的绝对路径。
|
|
80
|
+
# 使用 SYNC_MODE=push 时必填:MCP Server 会自动部署一个超轻量推送插件,
|
|
81
|
+
# 实现工作流保存后的实时推送通知。
|
|
82
|
+
# 若 ComfyUI 部署在远端机器上,或使用 timed/manual 模式,请留空。
|
|
83
|
+
#
|
|
84
|
+
# Windows 示例 / Example: COMFY_UI_INSTALL_PATH=C:/ComfyUI
|
|
85
|
+
# Linux 示例 / Example: COMFY_UI_INSTALL_PATH=/home/user/ComfyUI
|
|
86
|
+
# COMFY_UI_INSTALL_PATH=
|
|
87
|
+
|
|
88
|
+
# -----------------------------------------------------------------------------
|
|
89
|
+
# Workflow Marker Patterns / 工作流标识符正则表达式
|
|
90
|
+
# -----------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
# Regex identifying the workflow name node (title of a PrimitiveStringMultiline node).
|
|
93
|
+
# Must contain ONE capture group that extracts the MCP tool name.
|
|
94
|
+
# Default matches titles like "==my_workflow=="
|
|
95
|
+
# 工作流名称节点的标识正则(PrimitiveStringMultiline 节点的 title)。
|
|
96
|
+
# 必须含一个捕获组提取工具名,默认匹配 ==名称== 格式。
|
|
97
|
+
WORKFLOW_NAME_REGEX="==(.+?)=="
|
|
98
|
+
|
|
99
|
+
# Regex identifying configurable parameter nodes.
|
|
100
|
+
# Must contain ONE capture group that extracts the parameter description.
|
|
101
|
+
# Default matches titles like "=>prompt text"
|
|
102
|
+
# 参数节点的标识正则,必须含一个捕获组提取参数描述,默认匹配 =>描述 格式。
|
|
103
|
+
WORKFLOW_PARAM_REGEX="^=>"
|
|
104
|
+
|
|
105
|
+
# =============================================================================
|
|
106
|
+
# [System Config] 系统配置
|
|
107
|
+
# Internal settings — change only if you know what you are doing.
|
|
108
|
+
# 内部运行参数,通常无需修改。
|
|
109
|
+
# =============================================================================
|
|
110
|
+
|
|
111
|
+
# -----------------------------------------------------------------------------
|
|
112
|
+
# MCP Server / MCP 服务地址
|
|
113
|
+
# -----------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
# MCP server bind address and listening port.
|
|
116
|
+
# MCP 服务器的监听地址和端口(MCP 客户端连接此处)。
|
|
117
|
+
MCP_SERVER_URL="http://192.168.0.192:8189/mcp"
|
|
118
|
+
MCP_SERVER_IP="192.168.0.192"
|
|
119
|
+
MCP_SERVER_PORT="8189"
|
|
120
|
+
|
|
121
|
+
# -----------------------------------------------------------------------------
|
|
122
|
+
# Logging / 日志配置
|
|
123
|
+
# -----------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
# Minimum log level written to stderr.
|
|
126
|
+
# 输出到 stderr 的最低日志级别。
|
|
127
|
+
# DEBUG | INFO | WARNING | ERROR (default: INFO)
|
|
128
|
+
# LOG_LEVEL=INFO
|
|
129
|
+
|
|
130
|
+
# Optional absolute path for a log file.
|
|
131
|
+
# When set, logs are written to BOTH stderr and this file.
|
|
132
|
+
# Leave blank to disable file logging.
|
|
133
|
+
# 可选:日志文件的绝对路径。填写后同时输出到 stderr 和文件。留空则不开启文件日志。
|
|
134
|
+
# LOG_FILE=
|
|
135
|
+
|
|
136
|
+
# Log file rotation size. Default: 10 MB
|
|
137
|
+
# 日志文件切割大小,默认 10 MB。
|
|
138
|
+
# LOG_ROTATE=10 MB
|
|
139
|
+
|
|
140
|
+
# Number of rotated log files to retain. Default: 7
|
|
141
|
+
# 保留历史日志文件个数,默认 7。
|
|
142
|
+
# LOG_RETAIN=7
|
|
143
|
+
|
|
144
|
+
# -----------------------------------------------------------------------------
|
|
145
|
+
# Tool Name Overrides / 工具名称覆盖(可选)
|
|
146
|
+
# -----------------------------------------------------------------------------
|
|
147
|
+
# Override the MCP tool names registered with the host.
|
|
148
|
+
# Useful when the host enforces naming conventions or to avoid conflicts.
|
|
149
|
+
# Leave commented out to use the defaults shown below.
|
|
150
|
+
#
|
|
151
|
+
# 覆盖注册到 MCP Host 的工具名称。
|
|
152
|
+
# 可用于满足 Host 的命名规范或避免冲突,留空则使用默认值。
|
|
153
|
+
|
|
154
|
+
# ---- GetCoreManual | 获取项目核心手册
|
|
155
|
+
# TOOL_NAME_GET_CORE_MANUAL=get_core_manual
|
|
156
|
+
# ---- GetWorkflowCatalog | 获取工作流目录
|
|
157
|
+
# TOOL_NAME_GET_WORKFLOWS_CATALOG=get_workflows_catalog
|
|
158
|
+
# ---- GetWorkAPI | 获取工作流详情
|
|
159
|
+
# TOOL_NAME_GET_WORKFLOW_API=get_workflow_API
|
|
160
|
+
# ---- MountWorkflow | 挂载工作流
|
|
161
|
+
# TOOL_NAME_MOUNT_WORKFLOW=mount_workflow
|
|
162
|
+
# ---- ExecuteWorkflow | 执行指定工作流
|
|
163
|
+
# TOOL_NAME_QUEUE_PROMPT=queue_prompt
|
|
164
|
+
# ---- ExecuteCustomWorkflow | 执行自定义工作流
|
|
165
|
+
# TOOL_NAME_QUEUE_CUSTOM_PROMPT=queue_custom_prompt
|
|
166
|
+
# ---- SaveCustomWorkflow | 保存自定义工作流
|
|
167
|
+
# TOOL_NAME_SAVE_CUSTOM_WORKFLOW=save_custom_workflow
|
|
168
|
+
# ---- SaveTaskAssets | 保存生成资产
|
|
169
|
+
# TOOL_NAME_SAVE_TASK_ASSETS=save_task_assets
|
|
170
|
+
# ---- UploadAssets | 上传文件
|
|
171
|
+
# TOOL_NAME_UPLOAD_ASSETS=upload_assets
|
|
172
|
+
# ---- InterruptPrompt | 取消任务
|
|
173
|
+
# TOOL_NAME_INTERRUPT_PROMPT=interrupt_prompt
|
|
174
|
+
# ---- GetPromptResult | 获取任务结果
|
|
175
|
+
# TOOL_NAME_GET_PROMPT_RESULT=get_prompt_result
|
|
176
|
+
# ---- GetSystemStatus | 获取系统状态
|
|
177
|
+
# TOOL_NAME_GET_SYSTEM_STATUS=get_system_status
|
|
178
|
+
# ---- ListModels | 检索模型文件
|
|
179
|
+
# TOOL_NAME_LIST_MODELS=list_models
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master, develop]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Test (Node ${{ matrix.node-version }})
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
node-version: [18.x, 20.x, 22.x]
|
|
17
|
+
fail-fast: false
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
24
|
+
uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version: ${{ matrix.node-version }}
|
|
27
|
+
cache: 'npm'
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: npm ci
|
|
31
|
+
|
|
32
|
+
- name: Run type check
|
|
33
|
+
run: npm run type-check
|
|
34
|
+
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: npm run test:ci
|
|
37
|
+
|
|
38
|
+
- name: Upload coverage to Codecov
|
|
39
|
+
if: matrix.node-version == '20.x'
|
|
40
|
+
uses: codecov/codecov-action@v4
|
|
41
|
+
with:
|
|
42
|
+
file: ./coverage/lcov.info
|
|
43
|
+
fail_ci_if_error: false
|
|
44
|
+
|
|
45
|
+
build:
|
|
46
|
+
name: Build Check
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
|
|
49
|
+
steps:
|
|
50
|
+
- name: Checkout code
|
|
51
|
+
uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Setup Node.js
|
|
54
|
+
uses: actions/setup-node@v4
|
|
55
|
+
with:
|
|
56
|
+
node-version: '20.x'
|
|
57
|
+
cache: 'npm'
|
|
58
|
+
|
|
59
|
+
- name: Install dependencies
|
|
60
|
+
run: npm ci
|
|
61
|
+
|
|
62
|
+
- name: Check TypeScript compilation
|
|
63
|
+
run: npx tsc --noEmit
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
echo "🔍 Running pre-commit checks..."
|
|
2
|
+
|
|
3
|
+
# Run type checking
|
|
4
|
+
echo "📦 Running TypeScript type check..."
|
|
5
|
+
npm run type-check || exit 1
|
|
6
|
+
|
|
7
|
+
# Run tests (only related files with lint-staged, or full test if no staged files match)
|
|
8
|
+
echo "🧪 Running tests..."
|
|
9
|
+
npx lint-staged || exit 1
|
|
10
|
+
|
|
11
|
+
echo "✅ Pre-commit checks passed!"
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MetaBrain-Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|