cancel_scan
Cancel a running scan using the scan ID to stop the process immediately on the nuclei-server MCP Server.
Instructions
Cancel a running scan
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scanId | Yes | Scan ID to cancel |
Input Schema (JSON Schema)
{
"properties": {
"scanId": {
"description": "Scan ID to cancel",
"type": "string"
}
},
"required": [
"scanId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:220-237 (handler)The handler logic for the 'cancel_scan' tool. It retrieves the scan by ID, checks if it's running, kills the associated child process, updates the scan status to 'canceled', and returns a confirmation message.if (request.params.name === "cancel_scan") { const { scanId } = request.params.arguments as { scanId: string }; const scan = scans[scanId]; if (!scan) { return { content: [{ type: "text", text: `Scan ${scanId} not found` }], isError: true }; } if (scan.status !== "running" || !scan.process) { return { content: [{ type: "text", text: `Scan ${scanId} is not running` }], isError: true }; } scan.process.kill(); scans[scanId].progress = 0; scan.status = "canceled"; return { content: [{ type: "text", text: `Scan ${scanId} has been canceled` }] }; }
- src/index.ts:68-109 (registration)The tool registration in the ListToolsRequestSchema handler, where 'cancel_scan' is listed along with its schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "start_scan", description: "Start a new nuclei scan", inputSchema: { type: "object", properties: { target: { type: "string", description: "Target URL or IP address" }, template: { type: "string", description: "Template to use for scanning" }, rateLimit: { type: "number", description: "Rate limit per second" }, templatesDir: { type: "string", description: "Directory with templates" }, severity: { type: "string", enum: ["info", "low", "medium", "high", "critical"] }, timeout: { type: "number", description: "Timeout in seconds" }, concurrency: { type: "number", description: "Concurrent requests" }, proxyUrl: { type: "string", description: "Proxy URL (e.g., socks5://127.0.0.1:1080)" }, proxyType: { type: "string", enum: ["http", "socks5"] }, }, required: ["target"], }, }, { name: "cancel_scan", description: "Cancel a running scan", inputSchema: { type: "object", properties: { scanId: { type: "string", description: "Scan ID to cancel" }, }, required: ["scanId"], }, }, ], }; });
- src/index.ts:96-106 (schema)The schema definition for the 'cancel_scan' tool, including input schema for the scanId parameter.{ name: "cancel_scan", description: "Cancel a running scan", inputSchema: { type: "object", properties: { scanId: { type: "string", description: "Scan ID to cancel" }, }, required: ["scanId"], }, },