get_statistics
Retrieve database statistics including record count, date range, and last update timestamp from the CVE vulnerability database.
Instructions
Get database stats (count, date range, last update)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_server/tools.py:68-71 (handler)The handler function implementing the 'get_statistics' tool. It obtains a database connection, calls get_stats to retrieve statistics, and serializes the result to JSON.def tool_get_statistics() -> str: conn = get_connection() stats = get_stats(conn) return json.dumps(stats, indent=2)
- src/database/db.py:78-94 (helper)Core helper function that queries the database for CVE count, date range, and last update metadata.def get_stats(conn: sqlite3.Connection) -> dict: cursor = conn.execute("SELECT COUNT(*) as total FROM cves") total = cursor.fetchone()['total'] cursor = conn.execute("SELECT MIN(published_date) as oldest, MAX(published_date) as newest FROM cves") dates = cursor.fetchone() cursor = conn.execute("SELECT value FROM metadata WHERE key = 'last_update'") last_update_row = cursor.fetchone() last_update = last_update_row['value'] if last_update_row else None return { "total_cves": total, "oldest_cve": dates['oldest'], "newest_cve": dates['newest'], "last_update": last_update }
- src/mcp_server/server.py:58-62 (schema)Input schema definition for the get_statistics tool, specifying an empty object with no required properties.inputSchema={ "type": "object", "properties": {}, "required": [] }
- src/mcp_server/server.py:55-63 (registration)Registration of the 'get_statistics' tool in the MCP server's list_tools method, including name, description, and schema.Tool( name="get_statistics", description="Get database stats (count, date range, last update)", inputSchema={ "type": "object", "properties": {}, "required": [] } )
- src/mcp_server/server.py:79-80 (registration)Tool dispatch logic in the server's call_tool method that routes requests for 'get_statistics' to the handler function.elif name == "get_statistics": result = tool_get_statistics()