Skip to main content
Glama

load_workflow

Load a ComfyUI workflow file to inspect its structure or prepare it for modifications and execution.

Instructions

Load a workflow file for inspection or modification.

    Args:
        workflow_name: Workflow filename (e.g., 'my-workflow.json')

    Returns the workflow dict that can be modified and executed.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflow_nameYesWorkflow filename

Implementation Reference

  • The core handler function for the 'load_workflow' tool. It uses Pydantic Field for input schema validation, loads the specified workflow JSON file from the configured directory, handles errors like missing directory or file, and returns the workflow dictionary.
    @mcp.tool()
    def load_workflow(
        workflow_name: str = Field(description="Workflow filename"),
        ctx: Context = None,
    ) -> dict:
        """Load a workflow file for inspection or modification.
    
        Args:
            workflow_name: Workflow filename (e.g., 'my-workflow.json')
    
        Returns the workflow dict that can be modified and executed.
        """
        if not settings.workflows_dir:
            return ErrorResponse.not_configured("COMFY_WORKFLOWS_DIR").model_dump()
    
        wf_path = Path(settings.workflows_dir) / workflow_name
        if not wf_path.exists():
            return ErrorResponse.not_found(
                f"Workflow '{workflow_name}'",
                suggestion="Use list_workflows() to see available workflows",
            ).model_dump()
    
        if ctx:
            ctx.info(f"Loading workflow: {workflow_name}")
    
        with open(wf_path) as f:
            return json.load(f)
  • Within register_all_tools, this line calls register_workflow_tools(mcp), which defines and registers the load_workflow tool using @mcp.tool() decorator.
    register_workflow_tools(mcp)
  • The top-level call to register_all_tools(mcp) in the package init, which triggers the registration chain leading to load_workflow being registered.
    register_all_tools(mcp)
  • Pydantic Field defining the input schema for the workflow_name parameter of the load_workflow tool.
    workflow_name: str = Field(description="Workflow filename"),
    ctx: Context = None,

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/IO-AtelierTech/comfyui-mcp'

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