list_templates
Browse and filter available workflow templates by category, difficulty level, 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-387 (handler)The main handler function for the 'list_templates' MCP tool. Decorated with @mcp.tool for registration. Accepts optional filters for category, difficulty, and tag, then delegates to template_manager.search_templates and returns the filtered list of templates.@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}")
- Core filtering logic in TemplateManager.search_templates, directly invoked by the list_templates tool handler to apply category, tags, and difficulty filters to the full list of templates (custom and official).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 that aggregates custom templates and official templates into a unified list with metadata, used as the base for searching and filtering.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 provides metadata for official templates from Comfy-Org repo, integrated into the main template list by TemplateManager.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() ]