cancelScan
Stop an active security scan in the Pentest MCP server by providing its scan ID to halt ongoing penetration testing operations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scanId | Yes | The ID of the scan to cancel |
Implementation Reference
- src/index.ts:1049-1062 (registration)Registration and handler implementation for the 'cancelScan' MCP tool. It cancels an active Nmap scan by killing the associated child process using the provided scanId.server.tool("cancelScan", cancelScanToolSchema.shape, async ({ scanId } /*, extra */) => { const activeScan = activeScans.get(scanId); if (!activeScan) { return { content: [{ type: "text", text: `Error: No active scan found with ID: ${scanId}` }], isError: true }; } try { activeScan.process.kill(); activeScan.progress.status = 'cancelled'; activeScans.delete(scanId); return { content: [{ type: "text", text: `Successfully cancelled scan ${scanId}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error: Failed to cancel scan: ${error.message}` }], isError: true }; } });
- src/index.ts:1044-1048 (schema)Zod schema defining the input parameters for the cancelScan tool (requires 'scanId' string).const cancelScanToolSchema = z.object({ scanId: z.string().describe("The ID of the scan to cancel") }).describe( "Stop an Nmap scan that is currently running. Pass the scanId returned when the scan was started." );
- src/index.ts:79-80 (helper)Global Map tracking active scans by scanId, storing the nmap process and progress info. Used by cancelScan handler.const activeScans: Map<string, {process: any, progress: ScanProgress}> = new Map();
- src/index.ts:68-76 (helper)TypeScript interface defining ScanProgress structure used to track scan status, updated during scan and cancellation.interface ScanProgress { scanId: string; target: string; startTime: number; progress: number; // 0-100 status: 'initializing' | 'scanning' | 'analyzing' | 'complete' | 'failed' | 'cancelled'; currentStage?: string; estimatedTimeRemaining?: number; }
- src/index.ts:605-613 (registration)Tool capability declaration including 'cancelScan' in the MCP server capabilities object."setMode": {}, "generateWordlist": {}, "cancelScan": {}, "createClientReport": {}, "nmapScan": {}, "runJohnTheRipper": {}, "runHashcat": {}, "gobuster": {}, "nikto": {}