get_summary_statistics
Retrieve aggregated security metrics including total issues, patches, and repositories to analyze organizational security posture.
Instructions
Get aggregated summary statistics across the organization. Includes total issues, patches, repositories, and key metrics.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function for the 'get_summary_statistics' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Fetches summary statistics from the ZeroPath API endpoint 'stats/summary' and formats the response.@mcp.tool() def get_summary_statistics() -> str: """ Get aggregated summary statistics across the organization. Includes total issues, patches, repositories, and key metrics. """ response, error = make_api_request("stats/summary") if error: return error if response.status_code == 200: return process_stats_response(response.json(), "Summary Statistics") 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}"
- Helper function called by get_summary_statistics to process and format the raw API response into a readable, structured text output.def process_stats_response(raw_response, title): """Process stats response into readable format.""" # Handle list response directly if isinstance(raw_response, list): result = f"=== {title} ===\n\n" for i, item in enumerate(raw_response, 1): if isinstance(item, dict): result += f"Item {i}:\n" for k, v in item.items(): formatted_key = ''.join(' ' + c if c.isupper() else c for c in str(k)).strip().title() result += f" {formatted_key}: {v}\n" result += "\n" else: result += f" - {item}\n" return result if isinstance(raw_response, dict) and "error" in raw_response: return f"Error: {raw_response['error']}" result = f"=== {title} ===\n\n" def format_value(key, value, indent=0): """Format a key-value pair with proper indentation.""" prefix = " " * indent if isinstance(value, dict): output = f"{prefix}{key}:\n" for k, v in value.items(): output += format_value(k, v, indent + 1) return output elif isinstance(value, list): output = f"{prefix}{key}:\n" for i, item in enumerate(value): if isinstance(item, dict): output += f"{prefix} Item {i + 1}:\n" for k, v in item.items(): output += format_value(k, v, indent + 2) else: output += f"{prefix} - {item}\n" return output else: # Format the key nicely (camelCase to Title Case) formatted_key = ''.join(' ' + c if c.isupper() else c for c in key).strip().title() return f"{prefix}{formatted_key}: {value}\n" for key, value in raw_response.items(): result += format_value(key, value) return result