start_scan
Initiate security scans on repositories to identify vulnerabilities and issues using SAST analysis within AI development environments.
Instructions
Start a new security scan on one or more repositories.
Args:
repository_ids: List of repository IDs to scan
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repository_ids | No |
Implementation Reference
- The handler function for the 'start_scan' MCP tool. It is registered via the @mcp.tool() decorator. The function initiates a security scan on specified repository IDs using the ZeroPath API, handles input validation, JSON parsing for list input, makes the API request, and processes the response with appropriate error handling and success message including the scan ID.@mcp.tool() def start_scan(repository_ids: list[str] = None) -> str: """ Start a new security scan on one or more repositories. Args: repository_ids: List of repository IDs to scan """ if not repository_ids: return "Error: At least one repository ID is required" # Handle case where repository_ids might be passed as a JSON string if isinstance(repository_ids, str): try: repository_ids = json.loads(repository_ids) except json.JSONDecodeError: # If it's a single ID as a string, wrap it in a list repository_ids = [repository_ids] response, error = make_api_request( "scans/start", {"repositoryIds": repository_ids} ) if error: return error if response.status_code == 200: result = response.json() scan_id = result.get("scanId", result.get("id", "unknown")) return f"Scan started successfully. Scan ID: {scan_id}" elif response.status_code == 401: return "Error: Unauthorized - check API credentials" elif response.status_code == 400: return f"Error: Bad request - {response.text}" else: return f"Error: API returned status {response.status_code}: {response.text}"