Skip to main content
Glama

search_templates

Find workflow templates by searching their names, descriptions, or tags using fuzzy matching to locate relevant templates for your ComfyUI projects.

Instructions

Search templates by name, description, or tags.

Performs fuzzy search across template metadata to find relevant workflow templates.

Args: query: Search query (searches name, description, tags)

Returns: List of matching templates

Examples: search_templates("pose") search_templates("upscaling") search_templates("text to image")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • MCP tool handler for 'search_templates'. Delegates to TemplateManager.search_templates with the provided query. Includes input schema via docstring and type hints.
    @mcp.tool
    def search_templates(query: str) -> list[dict]:
        """Search templates by name, description, or tags.
        
        Performs fuzzy search across template metadata to find
        relevant workflow templates.
        
        Args:
            query: Search query (searches name, description, tags)
        
        Returns:
            List of matching templates
        
        Examples:
            search_templates("pose")
            search_templates("upscaling")
            search_templates("text to image")
        """
        try:
            results = template_manager.search_templates(query=query)
            return results
            
        except Exception as e:
            raise ToolError(f"Error searching templates: {e}")
  • Core implementation of template search logic in TemplateManager class. Performs filtering on all templates based on query, category, tags, difficulty, 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/christian-byrne/comfy-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server