load_workflow
Load a ComfyUI workflow file to inspect or modify its structure and node configuration for automation purposes.
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
| Name | Required | Description | Default |
|---|---|---|---|
| workflow_name | Yes | Workflow filename |
Implementation Reference
- The core implementation of the 'load_workflow' tool. This function is decorated with @mcp.tool(), which registers it with the MCP server when the enclosing register_workflow_tools() is executed. It loads and returns the contents of a specified workflow JSON file.@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)
- src/comfy_mcp_server/tools/__init__.py:27-27 (registration)Within register_all_tools(), this line calls register_workflow_tools(mcp), which defines and registers the load_workflow tool via its decorator.register_workflow_tools(mcp)
- src/comfy_mcp_server/__init__.py:92-92 (registration)Top-level tool registration call in the server initialization, which triggers the chain leading to 'load_workflow' registration.register_all_tools(mcp)
- Pydantic-based input schema definition for the tool, specifying the 'workflow_name' parameter with description.def load_workflow( workflow_name: str = Field(description="Workflow filename"), ctx: Context = None, ) -> dict: