comfy_load_workflow
Load saved workflows from the ComfyUI library by name to retrieve workflow JSON and metadata for AI image generation projects.
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)The handleLoadWorkflow function that executes the tool logic for comfy_load_workflow, loading from library and returning formatted JSON response or error.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)Supporting utility function loadWorkflowFromLibrary that reads and parses the workflow JSON from the filesystem library.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/server.ts:97-101 (registration)Registration of the comfy_load_workflow tool in the ListTools handler, including 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 switch statement that invokes the handleLoadWorkflow function.case 'comfy_load_workflow': return await handleLoadWorkflow(args as any);
- src/types/tools.ts:94-96 (schema)Zod input schema definition for the tool, requiring a 'name' string parameter.export const LoadWorkflowSchema = z.object({ name: z.string() });