cancel_scan
Stop an active Burp Suite vulnerability scan by providing its task ID. Terminate running security scans to manage resources or halt testing operations.
Instructions
Cancel a scan by task_id. May not be supported by all Burp API versions.
Args:
task_id: Task ID of the scan to cancelInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- main.py:263-277 (handler)Main handler for cancel_scan tool. Accepts a task_id, normalizes it, and makes a DELETE request to /scan/{task_id} to cancel the scan. Returns success or failure message.
@mcp.tool("cancel_scan") async def cancel_scan(task_id: str | int) -> str: """ Cancel a scan by task_id. May not be supported by all Burp API versions. Args: task_id: Task ID of the scan to cancel """ tid = _normalize_task_id(task_id) resp = await make_api_request("DELETE", f"/scan/{tid}") if resp is not None and resp.status_code in (200, 204): return f"Scan {tid} has been cancelled." return ( f"Could not cancel scan {tid}. The Burp REST API may not support DELETE /scan/{{id}}." ) - main.py:263-263 (registration)Tool registration via the @mcp.tool("cancel_scan") decorator from FastMCP framework.
@mcp.tool("cancel_scan") - main.py:94-100 (helper)Helper function to normalize task_id. Converts int to string and handles full path formats by extracting just the ID.
def _normalize_task_id(task_id: str | int) -> str: """Normalize task_id to numeric string (handles full path or ID).""" tid = str(task_id) if "/" in tid: parsed = _parse_task_id(tid) return parsed or tid return tid - main.py:43-83 (helper)Core helper function for making HTTP requests to the Burp REST API. Used by cancel_scan to send the DELETE request.
async def make_api_request( method: str, request_path: str, payload: dict[str, Any] | None = None ) -> httpx.Response | None: """ Make a request to the Burp REST API. Returns None on failure; logs the error for debugging. """ err = _validate_config() if err: logger.warning(err) return None path = request_path.lstrip("/") if BURP_REST_API_KEY: url = f"{BURP_REST_API_BASE}/{BURP_REST_API_KEY}/{BURP_REST_API_VERSION}/{path}" else: url = f"{BURP_REST_API_BASE}/{BURP_REST_API_VERSION}/{path}" async with httpx.AsyncClient() as client: try: response = await client.request( method, url, json=payload, headers=DEFAULT_HEADERS, timeout=30, ) response.raise_for_status() return response except httpx.HTTPStatusError as e: logger.warning( "Burp API HTTP error: %s %s", e.response.status_code, e.response.text[:200], ) return None except httpx.RequestError as e: logger.warning("Burp API request failed: %s", e) return None except Exception as e: logger.warning("Burp API unexpected error: %s", e) return None