db.get_test_results
Retrieve vulnerability test results with filtering by target, test type, and success status to analyze security assessments from bug bounty hunting tools.
Instructions
Retrieve test results with success/failure and scores
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | Filter by target | |
| testType | No | Filter by test type | |
| success | No | Filter by success status | |
| limit | No | Maximum number of results |
Implementation Reference
- src/tools/database.ts:98-111 (handler)Executes the tool logic: fetches test results via helper, computes aggregate stats (count, success/failure counts, avg score), formats ToolResult.async ({ target, testType, success, limit = 100 }: any): Promise<ToolResult> => { try { const results = await getTestResults(target, testType, success, limit); return formatToolResult(true, { testResults: results, count: results.length, successCount: results.filter((r: any) => r.success).length, failureCount: results.filter((r: any) => !r.success).length, avgScore: results.reduce((sum: number, r: any) => sum + (r.score || 0), 0) / results.length || 0, }); } catch (error: any) { return formatToolResult(false, null, error.message); } }
- src/tools/database.ts:87-97 (schema)Input schema defining optional filters for target, testType, success status, and result limit.description: 'Retrieve test results with success/failure and scores', inputSchema: { type: 'object', properties: { target: { type: 'string', description: 'Filter by target' }, testType: { type: 'string', description: 'Filter by test type' }, success: { type: 'boolean', description: 'Filter by success status' }, limit: { type: 'number', description: 'Maximum number of results', default: 100 }, }, }, },
- src/tools/database.ts:84-112 (registration)Registers the db.get_test_results MCP tool with MCP Server instance, providing description, input schema, and handler.server.tool( 'db.get_test_results', { description: 'Retrieve test results with success/failure and scores', inputSchema: { type: 'object', properties: { target: { type: 'string', description: 'Filter by target' }, testType: { type: 'string', description: 'Filter by test type' }, success: { type: 'boolean', description: 'Filter by success status' }, limit: { type: 'number', description: 'Maximum number of results', default: 100 }, }, }, }, async ({ target, testType, success, limit = 100 }: any): Promise<ToolResult> => { try { const results = await getTestResults(target, testType, success, limit); return formatToolResult(true, { testResults: results, count: results.length, successCount: results.filter((r: any) => r.success).length, failureCount: results.filter((r: any) => !r.success).length, avgScore: results.reduce((sum: number, r: any) => sum + (r.score || 0), 0) / results.length || 0, }); } catch (error: any) { return formatToolResult(false, null, error.message); } } );
- src/integrations/postgres.ts:184-225 (helper)Supporting function that builds and executes dynamic SQL query on test_results table with filters for target, testType, success; returns raw rows.export async function getTestResults( target?: string, testType?: string, success?: boolean, limit: number = 100 ): Promise<any[]> { const client = await initPostgres().connect(); try { let query = 'SELECT * FROM test_results'; const conditions: string[] = []; const params: any[] = []; let paramCount = 0; if (target) { paramCount++; conditions.push(`target = $${paramCount}`); params.push(target); } if (testType) { paramCount++; conditions.push(`test_type = $${paramCount}`); params.push(testType); } if (success !== undefined) { paramCount++; conditions.push(`success = $${paramCount}`); params.push(success); } if (conditions.length > 0) { query += ' WHERE ' + conditions.join(' AND '); } query += ' ORDER BY timestamp DESC LIMIT $' + (paramCount + 1); params.push(limit); const result: QueryResult = await client.query(query, params); return result.rows; } finally { client.release(); } }