Get Database Stats
get_statsRetrieve overall API statistics and service health to monitor the SearchCAIE MCP Server's status.
Instructions
Get overall API statistics and service health.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_stats"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server.py:985-1016 (handler)The get_stats tool handler. Registered via @mcp.tool decorator on line 985, it calls the /stats and /health API endpoints and returns overall API statistics and service health including total questions, papers indexed, total marks, years, and health status.
@mcp.tool(title="Get Database Stats", tags={"search", "core"}) def get_stats() -> dict[str, Any]: """Get overall API statistics and service health.""" try: stats = _api_get("/stats") except Exception as exc: logger.error("get_stats failed: %s", exc, exc_info=True) return _error_from_exception(exc, "/stats") health_payload: Optional[dict[str, Any]] = None try: health_data = _api_get("/health") if isinstance(health_data, dict): health_payload = health_data except Exception: health_payload = None years = stats.get("years", []) if isinstance(stats, dict) else [] if not isinstance(years, list): years = [] return { "ok": True, "api_base": API_BASE, "totals": { "total_questions": stats.get("total_questions", 0) if isinstance(stats, dict) else 0, "papers_indexed": stats.get("papers_indexed", 0) if isinstance(stats, dict) else 0, "total_marks": stats.get("total_marks", 0) if isinstance(stats, dict) else 0, }, "years": years, "health": health_payload, } - mcp_server.py:985-985 (registration)Registration of get_stats as an MCP tool via the @mcp.tool decorator with title 'Get Database Stats' and 'search'/'core' tags.
@mcp.tool(title="Get Database Stats", tags={"search", "core"})