testmo_batch_delete_cases
Delete up to 100 test cases in a project by providing the project ID and an array of case IDs. Removes multiple cases in a single API call.
Instructions
Delete multiple test cases (max 100 per call).
Args: project_id: The project ID. case_ids: Array of test case IDs to delete (max 100).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | ||
| case_ids | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- testmo/tools/cases.py:274-307 (handler)The `testmo_batch_delete_cases` tool handler function, decorated with @mcp.tool(). It deletes multiple test cases (max 100 per call), auto-batching larger requests with rate limiting and error collection.
@mcp.tool() async def testmo_batch_delete_cases( project_id: int, case_ids: list[int], ) -> dict[str, Any]: """Delete multiple test cases (max 100 per call). Args: project_id: The project ID. case_ids: Array of test case IDs to delete (max 100). """ if len(case_ids) > MAX_CASES_PER_REQUEST: all_errors: list[str] = [] total_deleted = 0 for i in range(0, len(case_ids), MAX_CASES_PER_REQUEST): batch = case_ids[i : i + MAX_CASES_PER_REQUEST] batch_num = (i // MAX_CASES_PER_REQUEST) + 1 try: await _request( "DELETE", f"/projects/{project_id}/cases", data={"ids": batch} ) total_deleted += len(batch) except RuntimeError as e: all_errors.append(f"Batch {batch_num}: {e}") if i + MAX_CASES_PER_REQUEST < len(case_ids): await asyncio.sleep(RATE_LIMIT_DELAY) return { "total_requested": len(case_ids), "total_deleted": total_deleted, "errors": all_errors if all_errors else None, } return await _request( "DELETE", f"/projects/{project_id}/cases", data={"ids": case_ids} ) - testmo/tools/cases.py:274-274 (registration)The `@mcp.tool()` decorator registers the function as a tool on the FastMCP instance.
@mcp.tool() - testmo-mcp.py:13-20 (registration)The import `import testmo.tools.cases` triggers the `@mcp.tool()` decorators in cases.py, registering all case tools (including batch_delete) on the server.
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 - testmo/client.py:25-50 (helper)The `_request` helper function used by the handler to make HTTP DELETE requests to the Testmo API.
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/config.py:8-10 (helper)Configuration constants `MAX_CASES_PER_REQUEST` (100) and `RATE_LIMIT_DELAY` (0.5) used by the handler for batching logic.
RATE_LIMIT_DELAY = 0.5 MAX_CASES_PER_REQUEST = 100