list_workflows
Discover and list workflow files in a directory, supporting JSON and DSL formats with optional glob pattern filtering to manage ComfyUI workflows.
Instructions
List workflow files in a directory.
Discovers workflow files (.json and .dsl) in the specified directory. Supports glob patterns for filtering.
Args: directory: Directory to search (default: "workflows") pattern: Glob pattern for filtering (default: "*" for all files)
Returns: List of workflow info dicts with name, size, modified time
Examples: list_workflows() list_workflows("workflows", "*.json") list_workflows("../dsl/examples/dsl")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | workflows | |
| pattern | No | * |
Implementation Reference
- comfy_mcp/mcp/server.py:185-237 (handler)The handler function decorated with @mcp.tool that implements the list_workflows tool. It lists .json and .dsl workflow files in a directory, supports glob patterns, validates paths for security, and returns metadata for each file.@mcp.tool def list_workflows(directory: str = "workflows", pattern: str = "*") -> list[dict]: """List workflow files in a directory. Discovers workflow files (.json and .dsl) in the specified directory. Supports glob patterns for filtering. Args: directory: Directory to search (default: "workflows") pattern: Glob pattern for filtering (default: "*" for all files) Returns: List of workflow info dicts with name, size, modified time Examples: list_workflows() list_workflows("workflows", "*.json") list_workflows("../dsl/examples/dsl") """ try: base = Path(directory) # Allow listing in dsl/examples without validation if "examples" in str(directory): search_path = base else: search_path = validate_path(str(base)) if not search_path.exists(): raise ToolError(f"Directory not found: {directory}") # Find workflow files workflows = [] for ext in [".json", ".dsl"]: for path in search_path.glob(f"{pattern}{ext}"): if path.is_file(): stat = path.stat() workflows.append({ "name": path.name, "path": str(path), "size": stat.st_size, "modified": stat.st_mtime, "format": ext[1:] # Remove leading dot }) # Sort by name workflows.sort(key=lambda w: w["name"]) return workflows except Exception as e: raise ToolError(f"Error listing workflows: {e}")