start_scan
Initiate a vulnerability scan on a target IP or hostname using specified scan types like basic-network-scan, web-app-scan, or compliance-scan to identify security risks.
Instructions
Start a new vulnerability scan against a target
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scan_type | Yes | Type of scan to run (basic-network-scan, web-app-scan, compliance-scan) | |
| target | Yes | Target IP address or hostname to scan |
Input Schema (JSON Schema)
{
"properties": {
"scan_type": {
"description": "Type of scan to run (basic-network-scan, web-app-scan, compliance-scan)",
"type": "string"
},
"target": {
"description": "Target IP address or hostname to scan",
"type": "string"
}
},
"required": [
"target",
"scan_type"
],
"type": "object"
}
Implementation Reference
- src/tools/scans.ts:79-111 (handler)Main handler function for the 'start_scan' MCP tool. Validates input (target and scan_type), calls the underlying startScan API function, formats the response as MCP content, and handles errors.export const startScanToolHandler = async (args: Record<string, unknown>) => { try { // Validate arguments const targetSchema = z.string().min(1); const scanTypeSchema = z.enum(['basic-network-scan', 'web-app-scan', 'compliance-scan']); const target = validateTarget(args.target); const scanType = validateScanType(args.scan_type); // Start the scan const result = await startScan(target, scanType); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; } catch (error) { const mcpError = handleNessusApiError(error); return { content: [ { type: 'text', text: `Error: ${mcpError.message}` } ], isError: true }; } };
- src/tools/scans.ts:60-77 (schema)Schema definition for the 'start_scan' tool, specifying name, description, and input schema with required target and scan_type parameters.export const startScanToolSchema = { name: 'start_scan', description: 'Start a new vulnerability scan against a target', inputSchema: { type: 'object', properties: { target: { type: 'string', description: 'Target IP address or hostname to scan' }, scan_type: { type: 'string', description: 'Type of scan to run (basic-network-scan, web-app-scan, compliance-scan)' } }, required: ['target', 'scan_type'] } };
- src/index.ts:99-100 (registration)Registration/dispatch of the 'start_scan' tool handler in the main tool call switch statement.case 'start_scan': return await startScanToolHandler(args);
- src/index.ts:75-83 (registration)Registration of the 'start_scan' tool schema in the list of available tools returned by ListToolsRequest.tools: [ listScanTemplatesToolSchema, startScanToolSchema, getScanStatusToolSchema, getScanResultsToolSchema, listScansToolSchema, getVulnerabilityDetailsToolSchema, searchVulnerabilitiesToolSchema ]
- src/nessus-api.ts:67-79 (helper)Underlying helper function called by the handler to start the scan. Currently implements mock mode creating a mock scan ID and queuing status.export const startScan = async (target: string, scanType: string) => { if (config.useMock) { const scanId = createMockScan(target, scanType); return { scan_id: scanId, status: "queued", message: "Scan queued successfully" }; } // Real API implementation would go here throw new Error("Real API not implemented"); };