Skip to main content
Glama

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
NameRequiredDescriptionDefault
scanIdYesThe 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 }; } });
  • 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." );
  • 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();
  • 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": {}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DMontgomery40/pentest-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server