Skip to main content
Glama

list_model_folders

Lists available model folder types to identify valid directories for retrieving AI models in ComfyUI workflows.

Instructions

List available model folder types.

    Returns a list of valid folder names for list_models().
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main execution logic for the 'list_model_folders' tool. It fetches the list of model folders from the ComfyUI API endpoint '/models'.
    @mcp.tool()
    def list_model_folders(ctx: Context = None) -> list:
        """List available model folder types.
    
        Returns a list of valid folder names for list_models().
        """
        if ctx:
            ctx.info("Listing model folders...")
        try:
            return comfy_get("/models")
        except Exception as e:
            return [f"Error: {e}"]
  • Registers the discovery tools (including 'list_model_folders') by calling register_discovery_tools(mcp) in the register_all_tools function.
    register_discovery_tools(mcp)
  • Top-level registration of all tools, which chains to the discovery tools registration including 'list_model_folders'.
    register_all_tools(mcp)
  • Function that defines and registers the 'list_model_folders' tool along with other discovery tools using @mcp.tool() decorators.
    def register_discovery_tools(mcp):
        """Register discovery tools."""
    
        @mcp.tool()
        def list_nodes(
            filter: str = Field(default=None, description="Filter by name (e.g., 'fal', 'image')"),
            category: str = Field(default=None, description="Filter by category"),
            ctx: Context = None,
        ) -> list:
            """List available ComfyUI nodes.
    
            Args:
                filter: Optional string to match node names (case-insensitive)
                category: Optional category filter (exact match)
    
            Returns a sorted list of node class names.
            Use this to discover available nodes for workflow building.
            """
            if ctx:
                ctx.info(f"Listing nodes{' matching: ' + filter if filter else ''}...")
    
            try:
                nodes = get_cached_nodes()
                result = []
    
                for name, info in nodes.items():
                    if filter and filter.lower() not in name.lower():
                        continue
                    if category and info.get("category", "").lower() != category.lower():
                        continue
                    result.append(name)
    
                return sorted(result)
            except Exception as e:
                return [f"Error: {e}"]
    
        @mcp.tool()
        def get_node_info(
            node_name: str = Field(description="Exact node class name"),
            ctx: Context = None,
        ) -> dict:
            """Get detailed info about a node.
    
            Args:
                node_name: Node class name (e.g., 'RemoteCheckpointLoader_fal')
    
            Returns node information including:
            - input: Required and optional inputs with types
            - output: Output types
            - category: Node category
            - description: What the node does
    
            Use this to understand how to configure a node in a workflow.
            """
            if ctx:
                ctx.info(f"Fetching info for: {node_name}")
    
            try:
                result = comfy_get(f"/object_info/{node_name}")
                if node_name in result:
                    data = result[node_name]
                    data["name"] = node_name  # Ensure name is set
                    info = NodeInfo(**data)
                    return info.model_dump()
                return ErrorResponse.not_found(
                    f"Node '{node_name}'",
                    suggestion="Use list_nodes() to see available nodes",
                ).model_dump()
            except Exception as e:
                return ErrorResponse.unavailable(str(e)).model_dump()
    
        @mcp.tool()
        def list_models(
            folder: str = Field(
                default="checkpoints",
                description="Model folder: checkpoints, loras, vae, embeddings",
            ),
            ctx: Context = None,
        ) -> list:
            """List available models in a folder.
    
            Args:
                folder: Model folder name. Options:
                    - checkpoints: Full model checkpoints
                    - loras: LoRA fine-tuning files
                    - vae: VAE decoders
                    - embeddings: Text embeddings
                    - controlnet: ControlNet models
                    - upscale_models: Upscaling models
                    - clip_vision: CLIP vision encoders
    
            Returns list of model filenames in the folder.
            """
            if ctx:
                ctx.info(f"Listing models in: {folder}")
            try:
                return comfy_get(f"/models/{folder}")
            except HTTPError as e:
                if e.code == 404:
                    return []
                return [f"Error: {e}"]
            except Exception as e:
                return [f"Error: {e}"]
    
        @mcp.tool()
        def list_model_folders(ctx: Context = None) -> list:
            """List available model folder types.
    
            Returns a list of valid folder names for list_models().
            """
            if ctx:
                ctx.info("Listing model folders...")
            try:
                return comfy_get("/models")
            except Exception as e:
                return [f"Error: {e}"]
    
        @mcp.tool()
        def list_embeddings(ctx: Context = None) -> list:
            """List available text embeddings.
    
            Returns list of embedding names that can be used in prompts.
            """
            if ctx:
                ctx.info("Listing embeddings...")
            try:
                return get_embeddings()
            except Exception as e:
                return [f"Error: {e}"]
    
        @mcp.tool()
        def list_extensions(ctx: Context = None) -> list:
            """List loaded ComfyUI extensions.
    
            Returns list of installed extension names (custom node packs).
            Use this to verify which custom nodes are available (e.g., fal.ai connector).
            """
            if ctx:
                ctx.info("Listing extensions...")
            try:
                return comfy_get("/extensions")
            except Exception as e:
                return [f"Error: {e}"]
    
        @mcp.tool()
        def refresh_nodes(ctx: Context = None) -> str:
            """Refresh the node cache.
    
            Call this after installing new custom nodes to see them in list_nodes().
            """
            if ctx:
                ctx.info("Refreshing node cache...")
            clear_node_cache()
            try:
                nodes = get_cached_nodes()
                return f"Cache refreshed. {len(nodes)} nodes available."
            except Exception as e:
                return f"Error refreshing cache: {e}"
    
        @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}"]
Behavior3/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. It describes the return value ('list of valid folder names') and its purpose for 'list_models()', which adds useful context. However, it lacks details on behavioral traits such as rate limits, error handling, or whether it's a read-only operation (though implied by 'List'), leaving some gaps in transparency.

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

Conciseness5/5

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

The description is extremely concise and front-loaded: the first sentence states the purpose, and the second adds context about the return value. Every sentence earns its place with no wasted words, making it efficient and well-structured for quick understanding.

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's simplicity (0 parameters, no output schema, no annotations), the description is adequate but has gaps. It explains the purpose and return value's use for 'list_models()', but doesn't detail the return format (e.g., list structure or data types) or potential errors. For a no-param tool, this is minimally viable but could be more complete.

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 tool has 0 parameters, and schema description coverage is 100% (empty schema). The description doesn't need to add parameter details, so it naturally compensates by focusing on output semantics. A baseline of 4 is appropriate as the description adds value without redundancy, though it doesn't fully explain the return format (e.g., structure of the list).

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: 'List available model folder types.' This is a specific verb ('List') and resource ('model folder types'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_models' or 'list_nodes', which prevents a perfect score.

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

Usage Guidelines3/5

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

The description implies usage by stating the return value helps 'list_models()', suggesting it's a prerequisite or helper for that tool. However, it doesn't provide explicit guidance on when to use this vs. alternatives like 'list_models' or 'list_nodes', nor does it specify exclusions or prerequisites beyond the implied relationship.

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

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