get_alert_details
Retrieve comprehensive details of a specific Kubernetes alert, including its status, severity, and timeline, to support monitoring and incident analysis.
Instructions
Get detailed information about a specific alert
Args: alert_name: Name of the alert to get details for
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alert_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/karma_mcp/server.py:469-528 (handler)The main handler function for the get_alert_details MCP tool. Fetches alert data from Karma API, searches for alerts matching the given alert_name, and returns formatted details including state, severity, namespace, cluster, instance, and annotations.
@mcp.tool() async def get_alert_details(alert_name: str) -> str: """Get detailed information about a specific alert Args: alert_name: Name of the alert to get details for """ data, error = await fetch_karma_alerts() if error: return error # Find matching alerts matching_alerts = [] grids = data.get("grids", []) for grid in grids: for group in grid.get("alertGroups", []): alertname = extract_label_value(group.get("labels", []), "alertname") if alertname.lower() == alert_name.lower(): for alert in group.get("alerts", []): matching_alerts.append({"alert": alert, "group": group}) if not matching_alerts: return f"No alert found with name: {alert_name}" # Format alert details details = f"🔍 Found {len(matching_alerts)} instance(s) of {alert_name}:\n\n" for i, item in enumerate(matching_alerts, 1): alert = item["alert"] group = item["group"] metadata = extract_alert_metadata(group, alert) annotations = extract_annotations(alert) details += f"📋 Instance {i}:\n" details += f" State: {metadata['state']}\n" details += f" Severity: {metadata['severity']}\n" details += f" Namespace: {metadata['namespace']}\n" details += f" Cluster: {metadata['cluster']}\n" # Add instance if available instance = extract_label_value(alert.get("labels", []), "instance") if instance != "unknown": details += f" Instance: {instance}\n" # Add annotations if "description" in annotations: description = annotations["description"] if len(description) > 200: description = description[:200] + "..." details += f" Description: {description}\n" if "summary" in annotations: details += f" Summary: {annotations['summary']}\n" details += "\n" return details - src/karma_mcp/server.py:469-475 (registration)Registers get_alert_details as an MCP tool via the @mcp.tool() decorator on the FastMCP server instance in server.py
@mcp.tool() async def get_alert_details(alert_name: str) -> str: """Get detailed information about a specific alert Args: alert_name: Name of the alert to get details for """ - src/karma_mcp/http_server.py:369-381 (schema)JSON-RPC schema definition for get_alert_details tool in the http_server.py tools/list endpoint. Defines input schema requiring alert_name string parameter.
"name": "get_alert_details", "description": "Get specific alert details", "inputSchema": { "type": "object", "properties": { "alert_name": { "type": "string", "description": "Name of the alert to get details for", } }, "required": ["alert_name"], }, }, - src/karma_mcp/http_server.py:20-25 (registration)Imports get_alert_details from server.py into http_server.py, enabling its use across HTTP, SSE, and MCP JSON-RPC endpoints.
from .server import ( check_karma, create_silence, delete_silence, get_alert_details, get_alert_details_multi_cluster, - src/karma_mcp/server.py:71-74 (helper)Helper function used by get_alert_details to fetch alert data from the Karma API. Returns a tuple of (data, error).
return httpx.AsyncClient() async def fetch_karma_alerts():