run_workflow_from_file
Execute workflows directly from a specified file path using the ComfyUI MCP Server for streamlined image generation and processing.
Instructions
Run a workflow from a file.
Args:
file_path: The absolute path to the file to run.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- src/server.py:44-60 (handler)The handler function for the 'run_workflow_from_file' MCP tool, including the @mcp.tool() decorator for registration. It loads a JSON workflow from the specified file path, initializes a ComfyUI client, and executes the workflow asynchronously.@mcp.tool() async def run_workflow_from_file(file_path: str) -> Any: """Run a workflow from a file. Args: file_path: The absolute path to the file to run. """ with open(file_path, "r", encoding="utf-8") as f: workflow = json.load(f) auth = os.environ.get("COMFYUI_AUTHENTICATION") comfy = ComfyUI( url=f'http://{os.environ.get("COMFYUI_HOST", "localhost")}:{os.environ.get("COMFYUI_PORT", 8188)}', authentication=auth ) images = await comfy.process_workflow(workflow, {}, return_url=os.environ.get("RETURN_URL", "true").lower() == "true") return images