db.get_test_results
Retrieve vulnerability test results with success/failure status and scores from bug bounty security assessments. Filter by target, test type, or success status to analyze security findings.
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)The handler function for the 'db.get_test_results' tool. It calls the getTestResults helper, computes statistics (count, successCount, failureCount, avgScore), and returns formatted 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:86-97 (schema)Input schema and description defining optional filters (target, testType, success, limit) for retrieving 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 }, }, }, },
- src/tools/database.ts:84-112 (registration)Registers the db.get_test_results tool with the MCP server, including 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)Database helper function that executes the SQL query to retrieve test results from the 'test_results' table, applying dynamic WHERE conditions based on provided filters.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(); } }
- src/index.ts:46-46 (registration)Top-level call to registerDatabaseTools which registers all database tools including 'db.get_test_results'.registerDatabaseTools(server);