Skip to main content
Glama
driosalido
by driosalido

list_active_alerts

Retrieve current Kubernetes alerts requiring attention by filtering out suppressed notifications to focus on active issues.

Instructions

List only active (non-suppressed) alerts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The implementation of the `list_active_alerts` tool, which fetches data from the Karma API, filters for alerts with a state of 'active', and returns a formatted list of these alerts.
    async def list_active_alerts() -> str:
        """List only active (non-suppressed) alerts"""
        try:
            async with httpx.AsyncClient() as client:
                response = await client.post(
                    f"{KARMA_URL}/alerts.json",
                    headers={"Content-Type": "application/json"},
                    json={},
                )
    
                if response.status_code == 200:
                    data = response.json()
    
                    active_alerts = []
                    grids = data.get("grids", [])
    
                    for grid in grids:
                        for group in grid.get("alertGroups", []):
                            # Get group labels (contains alertname)
                            group_labels_dict = {}
                            for label in group.get("labels", []):
                                group_labels_dict[label.get("name", "")] = label.get(
                                    "value", ""
                                )
    
                            alertname = group_labels_dict.get("alertname", "unknown")
    
                            for alert in group.get("alerts", []):
                                alert_state = alert.get("state", "unknown")
    
                                # Only include active alerts (not suppressed)
                                if alert_state.lower() == "active":
                                    # Convert alert labels to dict
                                    alert_labels_dict = {}
                                    for label in alert.get("labels", []):
                                        alert_labels_dict[label.get("name", "")] = (
                                            label.get("value", "")
                                        )
    
                                    active_alerts.append(
                                        {
                                            "name": alertname,
                                            "state": alert_state,
                                            "severity": resolve_severity(
                                                group_labels_dict, alert_labels_dict
                                            ),
                                            "namespace": alert_labels_dict.get(
                                                "namespace", "N/A"
                                            ),
                                            "instance": alert_labels_dict.get(
                                                "instance", "N/A"
                                            ),
                                            "starts_at": alert.get("startsAt", "N/A"),
                                        }
                                    )
    
                    if not active_alerts:
                        return "No active alerts found."
    
                    # Format output
                    result = "Active Alerts (Non-Suppressed)\n"
                    result += "=" * 50 + "\n\n"
    
                    # Group by alert name
                    alert_groups = {}
                    for alert in active_alerts:
                        name = alert["name"]
                        if name not in alert_groups:
                            alert_groups[name] = []
                        alert_groups[name].append(alert)
    
                    for alertname, alerts in sorted(alert_groups.items()):
                        result += f"🔥 {alertname} ({len(alerts)} instance{'s' if len(alerts) > 1 else ''})\n"
                        result += f"   Severity: {alerts[0]['severity']}\n"
    
                        # Show details for each instance
                        for alert in alerts[:5]:  # Limit to 5 instances to avoid clutter
                            result += f"   • {alert['instance']} ({alert['namespace']})\n"
    
                        if len(alerts) > 5:
                            result += f"   • ... and {len(alerts) - 5} more\n"
    
                        result += "\n"
    
                    result += f"Total Active Alerts: {len(active_alerts)}"
                    return result
                else:
                    return f"Error fetching alerts: code {response.status_code}"
    
        except Exception as e:
            return f"Error connecting to Karma: {str(e)}"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool returns (active alerts). It lacks behavioral details such as pagination, rate limits, authentication requirements, or whether it's read-only/destructive. The description doesn't contradict annotations (none exist), but it's insufficient for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and uses a parenthetical for clarification, making it appropriately sized for a no-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no parameters, an output schema exists (which handles return values), and the description states the filtering scope, it's minimally adequate. However, with no annotations and multiple sibling tools, more context on differentiation and behavioral traits would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, earning a baseline score of 4 for not adding unnecessary information beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List') and resource ('active alerts'), with the parenthetical '(non-suppressed)' providing useful clarification. However, it doesn't explicitly differentiate from sibling tools like 'list_alerts' or 'get_alerts_by_state', which would require more specific comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for 'only active (non-suppressed) alerts' but provides no explicit guidance on when to use this tool versus alternatives like 'list_alerts' or 'get_alerts_by_state'. No prerequisites, exclusions, or comparative context are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/driosalido/mcp-karma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server