db.get_statistics
Retrieve statistical data on vulnerability test results to analyze security assessment outcomes and track findings.
Instructions
Get statistics about test results
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/database.ts:124-137 (handler)The handler function for the 'db.get_statistics' tool. It calls getTestStatistics() to fetch data from the database and formats the result with summary statistics.async (): Promise<ToolResult> => { try { const stats = await getTestStatistics(); return formatToolResult(true, { statistics: stats, summary: { totalTests: stats.reduce((sum: number, s: any) => sum + parseInt(s.count || 0), 0), totalTypes: stats.length, }, }); } catch (error: any) { return formatToolResult(false, null, error.message); } }
- src/tools/database.ts:117-123 (schema)Input schema definition for the 'db.get_statistics' tool, which requires no input parameters.{ description: 'Get statistics about test results', inputSchema: { type: 'object', properties: {}, }, },
- src/tools/database.ts:116-138 (registration)Registration of the 'db.get_statistics' tool on the MCP server, including schema and inline handler.'db.get_statistics', { description: 'Get statistics about test results', inputSchema: { type: 'object', properties: {}, }, }, async (): Promise<ToolResult> => { try { const stats = await getTestStatistics(); return formatToolResult(true, { statistics: stats, summary: { totalTests: stats.reduce((sum: number, s: any) => sum + parseInt(s.count || 0), 0), totalTypes: stats.length, }, }); } catch (error: any) { return formatToolResult(false, null, error.message); } } );
- src/integrations/postgres.ts:227-246 (helper)Helper function that executes the SQL query to retrieve test statistics grouped by test_type from the test_results table.export async function getTestStatistics(): Promise<any> { const client = await initPostgres().connect(); try { const stats = await client.query(` SELECT COUNT(*) as total_tests, COUNT(*) FILTER (WHERE success = true) as successful_tests, COUNT(*) FILTER (WHERE success = false) as failed_tests, AVG(score) as avg_score, test_type, COUNT(*) as count FROM test_results GROUP BY test_type ORDER BY count DESC `); return stats.rows; } finally { client.release(); } }