list_templates
Browse and filter available workflow templates by category, difficulty, or tags to find ready-to-use solutions for common ComfyUI tasks.
Instructions
List available workflow templates.
Discover workflow templates by category, difficulty, or tags. Templates provide ready-to-use workflows for common use cases.
Args: category: Filter by category (Generation, Enhancement, Editing, etc.) difficulty: Filter by difficulty (beginner, intermediate, advanced) tag: Filter by tag (text2img, inpainting, controlnet, etc.)
Returns: List of template metadata with names, descriptions, and parameters
Examples: list_templates() list_templates(category="Generation") list_templates(difficulty="beginner") list_templates(tag="text2img")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | ||
| difficulty | No | ||
| tag | No |
Implementation Reference
- comfy_mcp/mcp/server.py:349-388 (handler)The MCP tool handler for 'list_templates'. This function is decorated with @mcp.tool, registering it as an MCP tool. It accepts optional filters (category, difficulty, tag) and delegates to template_manager.search_templates to fetch filtered template metadata.@mcp.tool def list_templates( category: str = None, difficulty: str = None, tag: str = None ) -> list[dict]: """List available workflow templates. Discover workflow templates by category, difficulty, or tags. Templates provide ready-to-use workflows for common use cases. Args: category: Filter by category (Generation, Enhancement, Editing, etc.) difficulty: Filter by difficulty (beginner, intermediate, advanced) tag: Filter by tag (text2img, inpainting, controlnet, etc.) Returns: List of template metadata with names, descriptions, and parameters Examples: list_templates() list_templates(category="Generation") list_templates(difficulty="beginner") list_templates(tag="text2img") """ try: # Convert filters to search parameters tags = [tag] if tag else None results = template_manager.search_templates( category=category, tags=tags, difficulty=difficulty ) return results except Exception as e: raise ToolError(f"Error listing templates: {e}")
- The TemplateManager.search_templates method called by the list_templates tool handler. This performs filtering on all available templates (custom and official) based on category, tags, difficulty, query, and source.def search_templates( self, query: Optional[str] = None, category: Optional[str] = None, tags: Optional[List[str]] = None, difficulty: Optional[str] = None, source: Optional[str] = None, include_official: bool = True ) -> List[Dict[str, Any]]: """Search templates by various criteria.""" # Get all templates first all_templates = self.list_templates(include_official=include_official) results = [] for template_data in all_templates: # Check source filter if source and template_data.get("source") != source: continue # Check query match (name, description, category) if query: query_lower = query.lower() if not any([ query_lower in template_data["name"].lower(), query_lower in template_data["description"].lower(), query_lower in template_data["category"].lower(), ]): # For custom templates, also check tags if template_data.get("source") == "custom" and "tags" in template_data: if not any(query_lower in tag.lower() for tag in template_data["tags"]): continue else: continue # Check category if category and template_data["category"].lower() != category.lower(): continue # Check tags (only for custom templates) if tags and template_data.get("source") == "custom": template_tags = template_data.get("tags", []) if not any(tag.lower() in [t.lower() for t in template_tags] for tag in tags): continue # Check difficulty (only for custom templates) if difficulty and template_data.get("difficulty"): if template_data["difficulty"].lower() != difficulty.lower(): continue results.append(template_data) return results
- comfy_mcp/templates/manager.py:17-39 (helper)TemplateManager.list_templates method, which aggregates custom and official templates into a unified metadata list. Called internally by search_templates.def list_templates(self, include_official: bool = True) -> List[Dict[str, Any]]: """List all available templates with metadata.""" results = [] # Add custom templates for name, template in self.custom_templates.items(): results.append({ "name": name, "description": template.description, "category": template.category, "tags": template.tags, "difficulty": template.difficulty, "required_models": template.required_models or [], "parameters": template.parameters or {}, "source": "custom" }) # Add official templates if requested if include_official and official_manager.templates: official_templates = official_manager.list_templates() results.extend(official_templates) return results
- OfficialTemplateManager.list_templates method, which provides metadata for synced official templates from Comfy-Org/workflow_templates repo. Called by TemplateManager.list_templates.def list_templates(self) -> List[Dict[str, Any]]: """List all official templates with metadata.""" return [ { "name": name, "display_name": template.name, "description": template.description, "category": template.category, "source": "official", "preview_images": template.preview_images or [], "source_url": template.source_url, "has_dsl": template.dsl_content is not None } for name, template in self.templates.items() ]