Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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); } }
  • Input schema definition for the 'db.get_statistics' tool, which requires no input parameters.
    { description: 'Get statistics about test results', inputSchema: { type: 'object', properties: {}, }, },
  • 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); } } );
  • 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(); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/telmon95/VulneraMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server