get_scan_results
Retrieve detailed results of a completed scan by specifying its unique ID, enabling efficient analysis and reporting of vulnerabilities.
Instructions
Get the results of a completed scan
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scan_id | Yes | ID of the scan to get results for |
Implementation Reference
- src/tools/scans.ts:179-223 (handler)The primary handler for the 'get_scan_results' tool. Validates the scan_id argument, fetches results via getScanResults helper, handles errors, formats output using formatScanResults, and returns MCP-formatted content.export const getScanResultsToolHandler = async (args: Record<string, unknown>) => { try { // Validate arguments const scanId = validateScanId(args.scan_id); // Get scan results const results = await getScanResults(scanId); // Check if there was an error if ('error' in results) { return { content: [ { type: 'text', text: `Error: ${results.error}` } ], isError: true }; } // Format the results const formattedResults = formatScanResults(results); return { content: [ { type: 'text', text: formattedResults } ] }; } catch (error) { const mcpError = handleNessusApiError(error); return { content: [ { type: 'text', text: `Error: ${mcpError.message}` } ], isError: true }; } };
- src/tools/scans.ts:164-177 (schema)The input schema definition for the 'get_scan_results' tool, specifying the required scan_id parameter.export const getScanResultsToolSchema = { name: 'get_scan_results', description: 'Get the results of a completed scan', inputSchema: { type: 'object', properties: { scan_id: { type: 'string', description: 'ID of the scan to get results for' } }, required: ['scan_id'] } };
- src/index.ts:103-104 (registration)Tool dispatch registration in the main CallToolRequestSchema handler switch statement.case 'get_scan_results': return await getScanResultsToolHandler(args);
- src/index.ts:75-84 (registration)Tool schema registration in the ListToolsRequestSchema handler, where getScanResultsToolSchema is listed among available tools.tools: [ listScanTemplatesToolSchema, startScanToolSchema, getScanStatusToolSchema, getScanResultsToolSchema, listScansToolSchema, getVulnerabilityDetailsToolSchema, searchVulnerabilitiesToolSchema ] };
- src/nessus-api.ts:98-105 (helper)Core helper function called by the tool handler to retrieve scan results from Nessus API (mock or real).export const getScanResults = async (scanId: string) => { if (config.useMock) { return getMockScanResults(scanId); } // Real API implementation would go here throw new Error("Real API not implemented"); };