testmo_search_cases
Search for test cases in a project using filters like query, folder, tags, and state to locate specific cases.
Instructions
Search for test cases with filters (query, folder, tags, state).
Args: project_id: The project ID. query: Search query (searches name and description). folder_id: Filter by folder ID. tags: Filter by tags. state_id: Filter by state (1=Draft, 2=Review, 3=Approved, 4=Active, 5=Deprecated). page: Page number (default: 1). per_page: Results per page (default: 100). Valid: 25, 50, 100.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| query | No | ||
| folder_id | No | ||
| tags | No | ||
| state_id | No | ||
| page | No | ||
| per_page | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- testmo/tools/cases.py:310-340 (handler)The main handler for the testmo_search_cases tool. It accepts optional filters (query, folder_id, tags, state_id) and pagination params, builds a query param dict, and delegates to the shared _request helper to call the Testmo API GET /projects/{id}/cases.
@mcp.tool() async def testmo_search_cases( project_id: int, query: str | None = None, folder_id: int | None = None, tags: list[str] | None = None, state_id: int | None = None, page: int = 1, per_page: int = 100, ) -> dict[str, Any]: """Search for test cases with filters (query, folder, tags, state). Args: project_id: The project ID. query: Search query (searches name and description). folder_id: Filter by folder ID. tags: Filter by tags. state_id: Filter by state (1=Draft, 2=Review, 3=Approved, 4=Active, 5=Deprecated). page: Page number (default: 1). per_page: Results per page (default: 100). Valid: 25, 50, 100. """ params: dict[str, Any] = {"page": page, "per_page": per_page} if query: params["query"] = query if folder_id is not None: params["folder_id"] = folder_id if tags: params["tags"] = ",".join(tags) if state_id is not None: params["state_id"] = state_id return await _request("GET", f"/projects/{project_id}/cases", params=params) - testmo/client.py:25-49 (helper)Reusable HTTP request helper used by testmo_search_cases to make the actual API call to Testmo, handling auth, errors, and response parsing.
async def _request( method: str, endpoint: str, data: dict[str, Any] | None = None, params: dict[str, Any] | None = None, ) -> dict[str, Any]: async with _get_client() as client: response = await client.request( method=method, url=endpoint, json=data, params=params, ) if response.status_code == 204: return {"success": True} if response.status_code >= 400: try: error_body = response.json() except Exception: error_body = response.text raise RuntimeError( f"Testmo API error {response.status_code}: " f"{json.dumps(error_body) if isinstance(error_body, dict) else error_body}" ) return response.json() - testmo/tools/cases.py:310-310 (registration)The @mcp.tool() decorator registers testmo_search_cases as an MCP tool on the FastMCP server instance.
@mcp.tool()