Skip to main content
Glama

search_nodes

Find ComfyUI workflow nodes by name, category, or description to quickly locate the components needed for automation tasks.

Instructions

Search for nodes by name, category, or description.

    Args:
        query: Search string (searches name, category, description)

    Returns matching nodes sorted by relevance.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • The main handler function for the 'search_nodes' tool. It implements fuzzy search across node names (priority 10), categories (5), and descriptions (3), sorts by relevance score, and limits to top 50 results.
    @mcp.tool()
    def search_nodes(
        query: str = Field(description="Search query"),
        ctx: Context = None,
    ) -> list:
        """Search for nodes by name, category, or description.
    
        Args:
            query: Search string (searches name, category, description)
    
        Returns matching nodes sorted by relevance.
        """
        if ctx:
            ctx.info(f"Searching for: {query}")
    
        try:
            nodes = get_cached_nodes()
            query_lower = query.lower()
            results = []
    
            for name, info in nodes.items():
                score = 0
                # Name match (highest priority)
                if query_lower in name.lower():
                    score += 10
                # Category match
                if query_lower in info.get("category", "").lower():
                    score += 5
                # Description match
                if query_lower in info.get("description", "").lower():
                    score += 3
    
                if score > 0:
                    results.append((name, score))
    
            # Sort by score descending
            results.sort(key=lambda x: x[1], reverse=True)
            return [name for name, _ in results[:50]]  # Limit to 50 results
    
        except Exception as e:
            return [f"Error: {e}"]
  • Pydantic schema definition for the search_nodes tool inputs: required 'query' string and optional Context.
    def search_nodes(
        query: str = Field(description="Search query"),
        ctx: Context = None,
    ) -> list:
  • Call within register_all_tools() to register the discovery tools module, which includes the search_nodes tool via its @mcp.tool() decorator.
    register_discovery_tools(mcp)
  • Top-level registration of all tools during server initialization, chaining to discovery tools including search_nodes.
    register_all_tools(mcp)

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/IO-AtelierTech/comfyui-mcp'

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