comfy_load_workflow
Load saved workflows from the ComfyUI library by name to retrieve workflow JSON and metadata for AI image generation tasks.
Instructions
Load a saved workflow from the MCP library by name. Returns the workflow JSON and metadata.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/tools/workflows.ts:93-129 (handler)Main handler function that executes the comfy_load_workflow tool by loading the workflow data and returning it as JSON, with error handling.export async function handleLoadWorkflow(input: LoadWorkflowInput) { try { const data = loadWorkflowFromLibrary(input.name); return { content: [{ type: "text", text: JSON.stringify({ name: data.name, workflow: data.workflow, description: data.description, tags: data.tags, created_at: data.created_at, updated_at: data.updated_at }, null, 2) }] }; } catch (error: any) { if (error.message.includes('not found')) { return { content: [{ type: "text", text: JSON.stringify(ComfyUIErrorBuilder.fileNotFound(input.name), null, 2) }], isError: true }; } return { content: [{ type: "text", text: JSON.stringify(ComfyUIErrorBuilder.executionError(error.message), null, 2) }], isError: true }; } }
- src/utils/filesystem.ts:196-207 (helper)Helper function that performs the actual file reading and parsing of the workflow JSON from the library directory.export function loadWorkflowFromLibrary(name: string): any { const config = getConfig(); const libraryPath = getFullPath(config.paths.workflow_library); const filePath = join(libraryPath, `${name}.json`); if (!existsSync(filePath)) { throw new Error(`Workflow not found: ${name}`); } const data = readFileSync(filePath, 'utf-8'); return JSON.parse(data); }
- src/types/tools.ts:94-96 (schema)Zod schema defining the input for the tool: requires a 'name' string.export const LoadWorkflowSchema = z.object({ name: z.string() });
- src/server.ts:97-101 (registration)Registration of the tool in the listTools response, specifying name, description, and input schema.{ name: 'comfy_load_workflow', description: 'Load a saved workflow from the MCP library by name. Returns the workflow JSON and metadata.', inputSchema: zodToJsonSchema(LoadWorkflowSchema) as any, },
- src/server.ts:167-168 (registration)Dispatch case in the CallToolRequestHandler that routes to the handler function.case 'comfy_load_workflow': return await handleLoadWorkflow(args as any);