get_statistics
Retrieve database statistics including record count, date range, and last update information 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 that implements the core logic of the 'get_statistics' tool by getting a database connection, calling the get_stats helper, and returning the statistics as JSON.def tool_get_statistics() -> str: conn = get_connection() stats = get_stats(conn) return json.dumps(stats, indent=2)
- src/mcp_server/server.py:55-63 (registration)Registration of the 'get_statistics' tool in the MCP server's list_tools method, defining its name, description, and input schema.Tool( name="get_statistics", description="Get database stats (count, date range, last update)", inputSchema={ "type": "object", "properties": {}, "required": [] } )
- src/mcp_server/server.py:58-62 (schema)Input schema definition for the 'get_statistics' tool, specifying an empty object since no parameters are required.inputSchema={ "type": "object", "properties": {}, "required": [] }
- src/database/db.py:78-94 (helper)Helper function that computes database statistics including total CVE count, date range of CVEs, 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 }