Skip to main content
Glama
driosalido
by driosalido

create_silence

Suppress specific alerts in Kubernetes clusters by creating temporary silences with configurable duration and matchers.

Instructions

Create a new silence for specific alerts

Args: cluster: Target cluster name (e.g., 'teddy-prod') alertname: Name of the alert to silence duration: Duration of silence (e.g., '2h', '30m', '1d') comment: Comment explaining why the alert is being silenced matchers: Additional matchers in format 'key=value,key2=value2' (optional)

Returns: Silence creation result with silence ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clusterYes
alertnameYes
durationNo2h
commentNoSilenced via MCP
matchersNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'create_silence' tool handler implementation. Note: It is currently a placeholder for the actual API interaction.
    async def create_silence(
        cluster: str,
        alertname: str,
        duration: str = "2h",
        comment: str = "Silenced via MCP",
        matchers: str = "",
    ) -> str:
        """Create a new silence for specific alerts
    
        Args:
            cluster: Target cluster name (e.g., 'teddy-prod')
            alertname: Name of the alert to silence
            duration: Duration of silence (e.g., '2h', '30m', '1d')
            comment: Comment explaining why the alert is being silenced
            matchers: Additional matchers in format 'key=value,key2=value2' (optional)
    
        Returns:
            Silence creation result with silence ID
        """
        try:
            # First, get the Alertmanager URL for this cluster
            async with httpx.AsyncClient() as client:
                response = await client.post(
                    f"{KARMA_URL}/alerts.json",
                    json={},
                    headers={"Content-Type": "application/json"},
                    timeout=10.0,
                )
    
                if response.status_code != 200:
                    return (
                        f"Error fetching cluster information: code {response.status_code}"
                    )
    
                data = response.json()
                upstreams = data.get("upstreams", {}).get("instances", [])
    
                # Find the Alertmanager for this cluster
                alertmanager_url = None
                for upstream in upstreams:
                    if cluster.lower() in upstream.get("cluster", "").lower():
                        # For now, we'll need to use the publicURI
                        # In production, you might need to handle authentication
                        alertmanager_url = upstream.get("publicURI")
                        break
    
                if not alertmanager_url:
                    return f"Could not find Alertmanager for cluster: {cluster}"
    
                # Parse duration
                import re
                from datetime import datetime, timedelta
    
                # Parse duration string (e.g., '2h', '30m', '1d')
                duration_match = re.match(r"(\d+)([hdm])", duration.lower())
                if not duration_match:
                    return "Invalid duration format. Use format like '2h', '30m', or '1d'"
    
                amount = int(duration_match.group(1))
                unit = duration_match.group(2)
    
                if unit == "h":
                    delta = timedelta(hours=amount)
                elif unit == "m":
                    delta = timedelta(minutes=amount)
                elif unit == "d":
                    delta = timedelta(days=amount)
                else:
                    return f"Unsupported time unit: {unit}"
    
                starts_at = datetime.utcnow()
                ends_at = starts_at + delta
    
                # Build matchers
                silence_matchers = [
                    {
                        "name": "alertname",
                        "value": alertname,
                        "isRegex": False,
                        "isEqual": True,
                    }
                ]
    
                # Add additional matchers if provided
                if matchers:
                    for matcher_str in matchers.split(","):
                        if "=" in matcher_str:
                            key, value = matcher_str.split("=", 1)
                            silence_matchers.append(
                                {
                                    "name": key.strip(),
                                    "value": value.strip(),
                                    "isRegex": False,
                                    "isEqual": True,
                                }
                            )
    
                # Create silence request
                {
                    "matchers": silence_matchers,
                    "startsAt": starts_at.isoformat() + "Z",
                    "endsAt": ends_at.isoformat() + "Z",
                    "createdBy": "karma-mcp",
                    "comment": comment,
                }
    
                # Note: Actually creating the silence requires direct Alertmanager API access
                # which may need authentication. This is a placeholder for the actual implementation
                return f"""
    āš ļø Silence Creation Request Prepared:
    
    šŸ“ Cluster: {cluster}
    šŸ”• Alert: {alertname}
    ā±ļø Duration: {duration} (until {ends_at.strftime("%Y-%m-%d %H:%M UTC")})
    šŸ’¬ Comment: {comment}
    šŸ·ļø Matchers: {len(silence_matchers)} configured
    
    Note: Direct Alertmanager API integration is required to complete this action.
    The Alertmanager endpoint would be: {alertmanager_url}/api/v2/silences
    
    To manually create this silence, you can use the Karma UI or Alertmanager API directly.
    """
    
        except Exception as e:
            return f"Error creating silence: {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 for behavioral disclosure. It mentions that the tool creates a silence and returns a result with a silence ID, but lacks critical details: whether this requires specific permissions, if the silence is reversible (e.g., via 'delete_silence'), what happens if the alert doesn't exist, rate limits, or side effects on alerting systems.

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

Conciseness4/5

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

The description is well-structured with clear sections (Args, Returns) and uses bullet-like formatting. It's appropriately sized for a 5-parameter tool, though the 'Args' and 'Returns' labels are slightly redundant with schema/output schema. Every sentence adds value, with no fluff.

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 5 parameters with 0% schema coverage and no annotations, the description does a fair job explaining parameters and mentions a return value. However, as a mutation tool (create) with siblings like 'delete_silence', it lacks context on permissions, idempotency, error conditions, and integration with the alerting workflow. The existence of an output schema helps but doesn't fully compensate.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It provides semantic meaning for all 5 parameters (cluster, alertname, duration, comment, matchers) with examples and notes optionality, which adds value beyond the bare schema. However, it doesn't explain parameter interactions (e.g., how matchers combine with alertname) or constraints (e.g., valid duration formats beyond examples).

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 ('Create a new silence') and the target ('for specific alerts'), which is a specific verb+resource combination. However, it doesn't explicitly differentiate this tool from its sibling 'delete_silence' beyond the obvious create/delete distinction, nor does it mention other alert management siblings like 'list_silences'.

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?

No guidance is provided on when to use this tool versus alternatives. While the purpose is clear, there's no mention of prerequisites (e.g., needing alert details first), when silencing is appropriate versus other alert actions, or how it relates to siblings like 'delete_silence' or 'list_silences'.

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