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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'fuzzy search' which implies approximate matching behavior, but doesn't cover other important aspects like pagination, rate limits, authentication requirements, error conditions, or what 'matching templates' includes in the return. For a search tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It starts with a clear purpose statement, adds behavioral context in the second sentence, then provides arg/return documentation and examples. Every sentence adds value, though the examples could be slightly more concise. It's front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values) and only one parameter with good semantic explanation in the description, the description is moderately complete. However, with no annotations and multiple sibling tools, it should provide more behavioral context and usage differentiation. The examples help but don't fully compensate for the missing guidance on when to use this versus other template-related tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, but the description compensates well by explaining the 'query' parameter's purpose: 'Search query (searches name, description, tags).' This adds meaningful context beyond the bare schema, clarifying what fields the query targets. However, it doesn't detail query syntax, case sensitivity, or fuzzy matching rules, keeping it from a perfect score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search templates by name, description, or tags' and 'Performs fuzzy search across template metadata to find relevant workflow templates.' This specifies the verb (search), resource (templates), and scope (metadata fields). However, it doesn't explicitly differentiate from sibling tools like 'list_templates' or 'list_official_templates,' which likely have different filtering mechanisms.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools related to templates (get_template, list_templates, list_official_templates), there's no indication of when this fuzzy search is preferred over listing or retrieving specific templates. The examples show usage but don't explain context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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