testmo_list_folders
List all folders in a Testmo project with their full paths by providing the project ID.
Instructions
List all folders in a Testmo project with full paths.
Args: project_id: The project ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- testmo/tools/folders.py:41-49 (handler)The main handler for the testmo_list_folders tool. Uses @mcp.tool() decorator to register as a FastMCP tool. Fetches all folders via _get_all_folders helper, then annotates them with full paths via _build_folder_paths.
@mcp.tool() async def testmo_list_folders(project_id: int) -> list[dict[str, Any]]: """List all folders in a Testmo project with full paths. Args: project_id: The project ID. """ folders = await _get_all_folders(project_id) return _build_folder_paths(folders) - testmo/tools/folders.py:9-24 (helper)Internal helper that fetches all folders with auto-pagination, calling the Testmo API at GET /projects/{project_id}/folders with page/per_page params.
async def _get_all_folders(project_id: int) -> list[dict[str, Any]]: """Fetch all folders with auto-pagination (internal helper).""" all_folders: list[dict[str, Any]] = [] page = 1 while True: result = await _request( "GET", f"/projects/{project_id}/folders", params={"page": page, "per_page": 100}, ) all_folders.extend(result.get("result", [])) if result.get("next_page") is None: break page += 1 await asyncio.sleep(RATE_LIMIT_DELAY) return all_folders - testmo/tools/folders.py:27-38 (helper)Internal helper that builds full hierarchical paths for each folder by walking up the parent chain, adding a 'full_path' key to each folder dict.
def _build_folder_paths(folders: list[dict[str, Any]]) -> list[dict[str, Any]]: """Annotate folders with full_path.""" folder_map = {f["id"]: f for f in folders} for folder in folders: path_parts = [folder["name"]] parent_id = folder.get("parent_id") while parent_id and parent_id in folder_map: parent = folder_map[parent_id] path_parts.insert(0, parent["name"]) parent_id = parent.get("parent_id") folder["full_path"] = " / ".join(path_parts) return folders - testmo-mcp.py:12-22 (registration)The tool module is imported in the main entry point (testmo-mcp.py), which triggers the @mcp.tool() decorator registration.
import testmo.tools.folders # noqa: F401 import testmo.tools.milestones # noqa: F401 import testmo.tools.cases # noqa: F401 import testmo.tools.runs # noqa: F401 import testmo.tools.attachments # noqa: F401 import testmo.tools.automation # noqa: F401 import testmo.tools.issues # noqa: F401 import testmo.tools.composite # noqa: F401 import testmo.tools.utility # noqa: F401 if __name__ == "__main__": - testmo/server.py:6-6 (registration)The FastMCP instance ('mcp') is created here, and its .tool() decorator is used in folders.py to register testmo_list_folders.
mcp = FastMCP("testmo-mcp")