Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • 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
        };
      }
    }
  • 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);
    }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Nikolaibibo/claude-comfyui-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server