Skip to main content
Glama

testmo_get_folders_recursive

Retrieve a folder and all descendant subfolders as a nested tree with a single API call, eliminating the need for multiple requests.

Instructions

Get a folder and all descendant subfolders as a nested tree in a single call.

Args: project_id: The project ID. folder_id: The root folder ID to start recursion from.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
folder_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the testmo_get_folders_recursive tool. It fetches all folders via _get_all_folders helper, builds a folder map, collects the subtree IDs for the given root folder, builds a nested tree structure, and returns the total folder count and tree.
    @mcp.tool()
    async def testmo_get_folders_recursive(
        project_id: int,
        folder_id: int,
    ) -> dict[str, Any]:
        """Get a folder and all descendant subfolders as a nested tree in a single call.
    
        Args:
            project_id: The project ID.
            folder_id: The root folder ID to start recursion from.
        """
        all_folders = await _get_all_folders(project_id)
        folder_map = _build_folder_map(all_folders)
        if folder_id not in folder_map:
            return {"error": f"Folder {folder_id} not found in project {project_id}"}
        subtree_ids = _collect_subtree(all_folders, folder_id)
        tree = _build_folder_tree(all_folders, subtree_ids, folder_id, folder_map)
        return {"total_folders": len(subtree_ids), "tree": tree}
  • The tool is registered via the @mcp.tool() decorator on line 157, which registers it with the FastMCP server instance from testmo/server.py.
    @mcp.tool()
    async def testmo_get_folders_recursive(
  • Helper function _collect_subtree: given all folders and a root_id, returns a set of all folder IDs in the subtree (inclusive) by traversing parent-child relationships.
    def _collect_subtree(all_folders: list[dict[str, Any]], root_id: int) -> set[int]:
        """Return set of folder IDs in the subtree rooted at root_id (inclusive)."""
        children_map: dict[int, list[int]] = defaultdict(list)
        for f in all_folders:
            children_map[f.get("parent_id") or 0].append(f["id"])
        result = {root_id}
        stack = [root_id]
        while stack:
            current = stack.pop()
            for child_id in children_map.get(current, []):
                result.add(child_id)
                stack.append(child_id)
        return result
  • Helper function _build_folder_map: builds a dict mapping folder_id to folder object for quick lookups.
    def _build_folder_map(all_folders: list[dict[str, Any]]) -> dict[int, dict[str, Any]]:
        return {f["id"]: f for f in all_folders}
  • Helper function _build_folder_tree: given all folders, a set of subtree IDs, a root_id, and a folder map, builds a nested dict tree with full_path and children.
    def _build_folder_tree(
        all_folders: list[dict[str, Any]],
        subtree_ids: set[int],
        root_id: int,
        folder_map: dict[int, dict[str, Any]],
    ) -> dict[str, Any] | None:
        children_map: dict[int, list[dict[str, Any]]] = defaultdict(list)
        for f in all_folders:
            if f["id"] not in subtree_ids:
                continue
            children_map[f.get("parent_id") or 0].append(f)
    
        def build_node(folder: dict[str, Any]) -> dict[str, Any]:
            node = {**folder}
            node["full_path"] = _get_folder_path(folder["id"], folder_map)
            node["children"] = [
                build_node(child) for child in children_map.get(folder["id"], [])
            ]
            return node
    
        if root_id not in folder_map:
            return None
        return build_node(folder_map[root_id])
Behavior2/5

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

No annotations are provided, so the description must convey behavioral traits. It only mentions returning a nested tree, lacking details on authentication needs, error handling, rate limits, or recursion depth limitations. This is insufficient for safe usage.

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: one sentence stating the purpose followed by a clear parameter list. Every element serves a purpose with no superfluous text.

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 presence of an output schema, return value details are not needed. However, the description lacks context about recursion limits, error cases (e.g., missing folder), and performance implications, which are important for a recursive operation.

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

Parameters3/5

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

The description provides brief explanations for both parameters ('project_id' and 'folder_id: The root folder ID to start recursion from'), adding meaning beyond the schema's titles. However, schema coverage is 0%, and the explanations are minimal, not covering constraints or formatting.

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

Purpose5/5

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

The description clearly states the verb 'Get', the resource 'folder and all descendant subfolders', and the output format 'nested tree in a single call'. It distinguishes from siblings like testmo_get_folder (single folder) and testmo_list_folders (list top-level).

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 use for retrieving a folder hierarchy but does not explicitly state when to use this vs alternatives like testmo_get_folder or testmo_list_folders. No when-not-to-use or prerequisite conditions are provided.

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/strelec00/testmo-mcp'

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