comfyui-mcp 0.50.10 → 0.50.11
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/dist/comfyui/fetch.js +74 -2
- package/dist/comfyui/fetch.js.map +1 -1
- package/package.json +1 -1
package/dist/comfyui/fetch.js
CHANGED
|
@@ -108,6 +108,69 @@ function describeComfyFetchFailure(err, target) {
|
|
|
108
108
|
wrapped.code = code;
|
|
109
109
|
return wrapped;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* A last-resort ceiling on a ComfyUI HTTP call that brought no budget of its own.
|
|
113
|
+
*
|
|
114
|
+
* `comfyuiFetch` passed `init` straight to `fetch`, so a call with no signal had
|
|
115
|
+
* NO time limit at all: a host that accepts the connection and then never
|
|
116
|
+
* answers — a stalled reverse proxy, a black-holed route, a ComfyUI wedged
|
|
117
|
+
* mid-request — left it pending forever. Thirteen of the twenty-five call sites
|
|
118
|
+
* were in that state, including `/prompt`, `/queue`, `/object_info` and the
|
|
119
|
+
* Manager API. This is the same defect #1026 hit in the skill generator; that
|
|
120
|
+
* fix bounded three calls, and this bounds the rest.
|
|
121
|
+
*
|
|
122
|
+
* DELIBERATELY GENEROUS. Every caller that knows its own budget already passes a
|
|
123
|
+
* signal (8s for the template listing, and so on) and keeps it — `init.signal`
|
|
124
|
+
* always wins. This value only has to be shorter than "forever" and longer than
|
|
125
|
+
* any healthy request: `/object_info` on a large custom-node install is
|
|
126
|
+
* legitimately slow, and a ceiling that fires on a working server would be a
|
|
127
|
+
* worse bug than the one being fixed.
|
|
128
|
+
*
|
|
129
|
+
* SAFE TO APPLY BROADLY because of what does NOT come through here: uploads and
|
|
130
|
+
* `/view` go through the client library's own `fetchApi`, and model downloads
|
|
131
|
+
* have their own streaming path. Every comfyuiFetch site is a small JSON API
|
|
132
|
+
* request.
|
|
133
|
+
*/
|
|
134
|
+
const DEFAULT_COMFY_HTTP_TIMEOUT_S = 120;
|
|
135
|
+
function comfyHttpTimeoutSeconds() {
|
|
136
|
+
const raw = Number(process.env.COMFYUI_MCP_HTTP_TIMEOUT_S);
|
|
137
|
+
return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_COMFY_HTTP_TIMEOUT_S;
|
|
138
|
+
}
|
|
139
|
+
function defaultComfyTimeoutSignal() {
|
|
140
|
+
return AbortSignal.timeout(Math.round(comfyHttpTimeoutSeconds() * 1000));
|
|
141
|
+
}
|
|
142
|
+
/** True for an abort raised by AbortSignal.timeout (not a caller's own abort). */
|
|
143
|
+
function isTimeoutAbort(err) {
|
|
144
|
+
return err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError");
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Say what the ceiling did and did NOT establish.
|
|
148
|
+
*
|
|
149
|
+
* The critical distinction is the METHOD. A GET that times out learned nothing
|
|
150
|
+
* about the server's state. A POST that times out is OUTCOME UNKNOWN — `/prompt`
|
|
151
|
+
* may well have queued the render before the reply was lost — and reporting that
|
|
152
|
+
* as a failure would invite a retry that queues it twice. Neither may be
|
|
153
|
+
* described as "the server is down".
|
|
154
|
+
*/
|
|
155
|
+
function describeComfyTimeout(input, init) {
|
|
156
|
+
const target = targetOf(input);
|
|
157
|
+
const method = String(init.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
|
|
158
|
+
const seconds = comfyHttpTimeoutSeconds();
|
|
159
|
+
const mutating = method !== "GET" && method !== "HEAD";
|
|
160
|
+
const err = new Error(`No reply from ComfyUI within ${seconds}s — while requesting ${target} (${method}). ` +
|
|
161
|
+
(mutating
|
|
162
|
+
? `OUTCOME UNKNOWN: this request may already have been received and acted on, so do NOT ` +
|
|
163
|
+
`blindly re-issue it — check the server's state first (for a queued prompt, queue ` +
|
|
164
|
+
`(action:"list") and get_history (action:"list")). `
|
|
165
|
+
: `Nothing was learned about the server from this — a timeout is not a refusal and not a ` +
|
|
166
|
+
`"not found". `) +
|
|
167
|
+
`The connection was accepted but no answer arrived in time, which points at the server or ` +
|
|
168
|
+
`something between it and here rather than at the request. Confirm it is up with ` +
|
|
169
|
+
`get_system_stats (action:"health"), and raise COMFYUI_MCP_HTTP_TIMEOUT_S if this server is ` +
|
|
170
|
+
`simply slow.`);
|
|
171
|
+
err.code = "COMFYUI_HTTP_TIMEOUT";
|
|
172
|
+
return err;
|
|
173
|
+
}
|
|
111
174
|
/**
|
|
112
175
|
* `fetch` wrapper for ComfyUI HTTP requests that injects the configured generic
|
|
113
176
|
* auth header(s) (COMFYUI_AUTH_* — for self-hosted ComfyUI behind a reverse
|
|
@@ -120,9 +183,13 @@ function describeComfyFetchFailure(err, target) {
|
|
|
120
183
|
*/
|
|
121
184
|
export async function comfyuiFetch(input, init = {}) {
|
|
122
185
|
const auth = getComfyUIAuthHeaders();
|
|
186
|
+
// A CEILING, not a policy. Callers that know their own budget pass a signal
|
|
187
|
+
// and it always wins — this only covers the ones that passed none, which
|
|
188
|
+
// otherwise wait forever.
|
|
189
|
+
const signal = init.signal ?? defaultComfyTimeoutSignal();
|
|
123
190
|
let request;
|
|
124
191
|
if (Object.keys(auth).length === 0) {
|
|
125
|
-
request = fetch(input, init);
|
|
192
|
+
request = fetch(input, { ...init, signal });
|
|
126
193
|
}
|
|
127
194
|
else {
|
|
128
195
|
const headers = new Headers(init.headers);
|
|
@@ -130,12 +197,17 @@ export async function comfyuiFetch(input, init = {}) {
|
|
|
130
197
|
if (!headers.has(name))
|
|
131
198
|
headers.set(name, value);
|
|
132
199
|
}
|
|
133
|
-
request = fetch(input, { ...init, headers });
|
|
200
|
+
request = fetch(input, { ...init, headers, signal });
|
|
134
201
|
}
|
|
135
202
|
try {
|
|
136
203
|
return await request;
|
|
137
204
|
}
|
|
138
205
|
catch (err) {
|
|
206
|
+
// Our own ceiling firing is not the same event as a caller's abort, and it
|
|
207
|
+
// must not be reported as one. Only rewrite when WE supplied the signal.
|
|
208
|
+
if (init.signal === undefined && isTimeoutAbort(err)) {
|
|
209
|
+
throw describeComfyTimeout(input, init);
|
|
210
|
+
}
|
|
139
211
|
// ONLY the opaque undici failure is rewritten. An AbortError, a timeout with
|
|
140
212
|
// its own message, or anything else already says what happened, and
|
|
141
213
|
// replacing that text would be a downgrade.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/comfyui/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,4EAA4E;AAC5E,SAAS,QAAQ,CAAC,KAA6B;IAC7C,IAAI,CAAC;QACH,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,KAAK,YAAY,GAAG;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC;QAC5C,OAAQ,KAAiB,CAAC,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,IAAI,qBAAqB,GAA4B,IAAI,CAAC;AAE1D,6EAA6E;AAC7E,MAAM,UAAU,wBAAwB,CAAC,EAA2B;IAClE,qBAAqB,GAAG,EAAE,CAAC;AAC7B,CAAC;AAED,mFAAmF;AACnF,SAAS,QAAQ,CAAC,MAAc;IAC9B,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE;QACpB,IAAI,CAAC;YACH,OAAO,qBAAqB,EAAE,EAAE,IAAI,EA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,6EAA6E;QAC7E,oEAAoE;QACpE,4CAA4C;QAC5C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC;YAAE,MAAM,GAAG,CAAC;QACxC,MAAM,yBAAyB,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfyui-mcp",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.11",
|
|
4
4
|
"mcpName": "io.github.artokun/comfyui-mcp",
|
|
5
5
|
"description": "Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline), or any hosted model via an OpenAI-compatible endpoint (DeepSeek, GLM, MiMo, OpenRouter). Generate images, video & audio, author and run workflows, manage models and custom nodes; a compact tool-router mode keeps even 4B models effective, and a built-in LLM Arena benchmarks them on real ComfyUI tasks. Also a Claude Code plugin with skills, slash commands, and installer packs. Local, LAN, VPS, or Comfy Cloud.",
|
|
6
6
|
"homepage": "https://comfyui-mcp.artokun.io/docs",
|