comfyui-mcp 0.1.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/.mcp.json +11 -0
- package/dist/comfyui/client.d.ts +16 -0
- package/dist/comfyui/client.d.ts.map +1 -0
- package/dist/comfyui/client.js +75 -0
- package/dist/comfyui/client.js.map +1 -0
- package/dist/comfyui/events.d.ts +9 -0
- package/dist/comfyui/events.d.ts.map +1 -0
- package/dist/comfyui/events.js +40 -0
- package/dist/comfyui/events.js.map +1 -0
- package/dist/comfyui/types.d.ts +66 -0
- package/dist/comfyui/types.d.ts.map +1 -0
- package/dist/comfyui/types.js +3 -0
- package/dist/comfyui/types.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +93 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/services/mermaid-converter.d.ts +8 -0
- package/dist/services/mermaid-converter.d.ts.map +1 -0
- package/dist/services/mermaid-converter.js +235 -0
- package/dist/services/mermaid-converter.js.map +1 -0
- package/dist/services/mermaid-parser.d.ts +31 -0
- package/dist/services/mermaid-parser.d.ts.map +1 -0
- package/dist/services/mermaid-parser.js +464 -0
- package/dist/services/mermaid-parser.js.map +1 -0
- package/dist/services/model-resolver.d.ts +25 -0
- package/dist/services/model-resolver.d.ts.map +1 -0
- package/dist/services/model-resolver.js +123 -0
- package/dist/services/model-resolver.js.map +1 -0
- package/dist/services/registry-client.d.ts +28 -0
- package/dist/services/registry-client.d.ts.map +1 -0
- package/dist/services/registry-client.js +32 -0
- package/dist/services/registry-client.js.map +1 -0
- package/dist/services/skill-generator.d.ts +33 -0
- package/dist/services/skill-generator.d.ts.map +1 -0
- package/dist/services/skill-generator.js +438 -0
- package/dist/services/skill-generator.js.map +1 -0
- package/dist/services/workflow-composer.d.ts +43 -0
- package/dist/services/workflow-composer.d.ts.map +1 -0
- package/dist/services/workflow-composer.js +333 -0
- package/dist/services/workflow-composer.js.map +1 -0
- package/dist/services/workflow-executor.d.ts +15 -0
- package/dist/services/workflow-executor.d.ts.map +1 -0
- package/dist/services/workflow-executor.js +63 -0
- package/dist/services/workflow-executor.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/model-management.d.ts +3 -0
- package/dist/tools/model-management.d.ts.map +1 -0
- package/dist/tools/model-management.js +97 -0
- package/dist/tools/model-management.js.map +1 -0
- package/dist/tools/registry-search.d.ts +3 -0
- package/dist/tools/registry-search.d.ts.map +1 -0
- package/dist/tools/registry-search.js +70 -0
- package/dist/tools/registry-search.js.map +1 -0
- package/dist/tools/skill-generator.d.ts +3 -0
- package/dist/tools/skill-generator.d.ts.map +1 -0
- package/dist/tools/skill-generator.js +42 -0
- package/dist/tools/skill-generator.js.map +1 -0
- package/dist/tools/workflow-compose.d.ts +3 -0
- package/dist/tools/workflow-compose.d.ts.map +1 -0
- package/dist/tools/workflow-compose.js +180 -0
- package/dist/tools/workflow-compose.js.map +1 -0
- package/dist/tools/workflow-execute.d.ts +3 -0
- package/dist/tools/workflow-execute.d.ts.map +1 -0
- package/dist/tools/workflow-execute.js +115 -0
- package/dist/tools/workflow-execute.js.map +1 -0
- package/dist/tools/workflow-visualize.d.ts +3 -0
- package/dist/tools/workflow-visualize.d.ts.map +1 -0
- package/dist/tools/workflow-visualize.js +111 -0
- package/dist/tools/workflow-visualize.js.map +1 -0
- package/dist/utils/errors.d.ts +24 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +65 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/image.d.ts +4 -0
- package/dist/utils/image.d.ts.map +1 -0
- package/dist/utils/image.js +10 -0
- package/dist/utils/image.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export class ComfyUIError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
details;
|
|
4
|
+
constructor(message, code, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.details = details;
|
|
8
|
+
this.name = "ComfyUIError";
|
|
9
|
+
}
|
|
10
|
+
toToolResult() {
|
|
11
|
+
return {
|
|
12
|
+
isError: true,
|
|
13
|
+
content: [
|
|
14
|
+
{
|
|
15
|
+
type: "text",
|
|
16
|
+
text: JSON.stringify({
|
|
17
|
+
error: this.code,
|
|
18
|
+
message: this.message,
|
|
19
|
+
details: this.details,
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class ConnectionError extends ComfyUIError {
|
|
27
|
+
constructor(message) {
|
|
28
|
+
super(message, "CONNECTION_ERROR");
|
|
29
|
+
this.name = "ConnectionError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class WorkflowExecutionError extends ComfyUIError {
|
|
33
|
+
constructor(message, details) {
|
|
34
|
+
super(message, "WORKFLOW_EXECUTION_ERROR", details);
|
|
35
|
+
this.name = "WorkflowExecutionError";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class ValidationError extends ComfyUIError {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message, "VALIDATION_ERROR");
|
|
41
|
+
this.name = "ValidationError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class RegistryError extends ComfyUIError {
|
|
45
|
+
constructor(message, details) {
|
|
46
|
+
super(message, "REGISTRY_ERROR", details);
|
|
47
|
+
this.name = "RegistryError";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class ModelError extends ComfyUIError {
|
|
51
|
+
constructor(message, details) {
|
|
52
|
+
super(message, "MODEL_ERROR", details);
|
|
53
|
+
this.name = "ModelError";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function errorToToolResult(err) {
|
|
57
|
+
if (err instanceof ComfyUIError)
|
|
58
|
+
return err.toToolResult();
|
|
59
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
60
|
+
return {
|
|
61
|
+
isError: true,
|
|
62
|
+
content: [{ type: "text", text: message }],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGnB;IACA;IAHlB,YACE,OAAe,EACC,IAAY,EACZ,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;IAED,YAAY;QACV,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,KAAK,EAAE,IAAI,CAAC,IAAI;wBAChB,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,OAAO,EAAE,IAAI,CAAC,OAAO;qBACtB,CAAC;iBACH;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IACtD,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,0BAA0B,EAAE,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,YAAY;IAC1C,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,GAAG,YAAY,YAAY;QAAE,OAAO,GAAG,CAAC,YAAY,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
|
|
2
|
+
export declare function base64ToDataUrl(base64: string, mime: string): string;
|
|
3
|
+
export declare function arrayBufferToDataUrl(buffer: ArrayBuffer, mime: string): string;
|
|
4
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/utils/image.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE/D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,GACX,MAAM,CAER"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function arrayBufferToBase64(buffer) {
|
|
2
|
+
return Buffer.from(buffer).toString("base64");
|
|
3
|
+
}
|
|
4
|
+
export function base64ToDataUrl(base64, mime) {
|
|
5
|
+
return `data:${mime};base64,${base64}`;
|
|
6
|
+
}
|
|
7
|
+
export function arrayBufferToDataUrl(buffer, mime) {
|
|
8
|
+
return base64ToDataUrl(arrayBufferToBase64(buffer), mime);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/utils/image.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,IAAY;IAC1D,OAAO,QAAQ,IAAI,WAAW,MAAM,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAmB,EACnB,IAAY;IAEZ,OAAO,eAAe,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,MAAM;iBACJ,MAAM,SAAS,OAAO;gBACvB,MAAM,SAAS,OAAO;gBACtB,MAAM,SAAS,OAAO;iBACrB,MAAM,SAAS,OAAO;CACpC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Logs to stderr only — critical for MCP stdio transport
|
|
2
|
+
const LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
3
|
+
const currentLevel = process.env.LOG_LEVEL || "info";
|
|
4
|
+
function shouldLog(level) {
|
|
5
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel];
|
|
6
|
+
}
|
|
7
|
+
function log(level, message, data) {
|
|
8
|
+
if (!shouldLog(level))
|
|
9
|
+
return;
|
|
10
|
+
const ts = new Date().toISOString();
|
|
11
|
+
const line = data
|
|
12
|
+
? `[${ts}] [${level.toUpperCase()}] ${message} ${JSON.stringify(data)}`
|
|
13
|
+
: `[${ts}] [${level.toUpperCase()}] ${message}`;
|
|
14
|
+
process.stderr.write(line + "\n");
|
|
15
|
+
}
|
|
16
|
+
export const logger = {
|
|
17
|
+
debug: (msg, data) => log("debug", msg, data),
|
|
18
|
+
info: (msg, data) => log("info", msg, data),
|
|
19
|
+
warn: (msg, data) => log("warn", msg, data),
|
|
20
|
+
error: (msg, data) => log("error", msg, data),
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAW,CAAC;AAGrE,MAAM,YAAY,GAA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|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for ComfyUI — workflow execution, visualization, composition, registry, and skill generation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"comfyui-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsx src/index.ts",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"test:integration": "COMFYUI_INTEGRATION=true vitest run",
|
|
17
|
+
"lint": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
21
|
+
"@stable-canvas/comfyui-client": "^1.5.9",
|
|
22
|
+
"dotenv": "^16.4.7",
|
|
23
|
+
"zod": "^3.24.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.13.4",
|
|
27
|
+
"tsx": "^4.19.2",
|
|
28
|
+
"typescript": "^5.7.3",
|
|
29
|
+
"vitest": "^3.0.5"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|