testmo_get_run
Retrieve details of a specific test run by ID, optionally including related entities.
Instructions
Get details of a specific test run.
Args: run_id: The test run ID. expands: Related entities to include.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes | ||
| expands | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- testmo/tools/runs.py:36-51 (handler)Handler function for the testmo_get_run MCP tool. Calls the Testmo API GET /runs/{run_id} to fetch a specific test run's details. Uses the mcp.tool() decorator for registration.
@mcp.tool() async def testmo_get_run( run_id: int, expands: list[str] | None = None, ) -> dict[str, Any]: """Get details of a specific test run. Args: run_id: The test run ID. expands: Related entities to include. """ params: dict[str, Any] = {} if expands: params["expands"] = ",".join(expands) result = await _request("GET", f"/runs/{run_id}", params=params if params else None) return result.get("result", result) - testmo/tools/runs.py:36-36 (registration)Registration via @mcp.tool() decorator on the FastMCP instance defined in testmo/server.py.
@mcp.tool() - testmo/tools/runs.py:37-51 (schema)Input schema/type annotations: run_id (int, required), expands (list[str] optional), returns dict[str, Any].
async def testmo_get_run( run_id: int, expands: list[str] | None = None, ) -> dict[str, Any]: """Get details of a specific test run. Args: run_id: The test run ID. expands: Related entities to include. """ params: dict[str, Any] = {} if expands: params["expands"] = ",".join(expands) result = await _request("GET", f"/runs/{run_id}", params=params if params else None) return result.get("result", result) - testmo/client.py:9-49 (helper)Helper function _get_client() creates the HTTP client used by _request() to call the Testmo API. Configuration comes from testmo/config.py.
def _get_client() -> httpx.AsyncClient: if not TESTMO_URL: raise ValueError("TESTMO_URL environment variable not set") if not TESTMO_API_KEY: raise ValueError("TESTMO_API_KEY environment variable not set") return httpx.AsyncClient( base_url=f"{TESTMO_URL}/api/v1/", headers={ "Authorization": f"Bearer {TESTMO_API_KEY}", "Content-Type": "application/json", "Accept": "application/json", }, timeout=httpx.Timeout(REQUEST_TIMEOUT), ) 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()