Skip to main content
Glama
ntk148v

alertmanager-mcp-server

get_silence

Retrieve details of an alert silence by providing its unique identifier. Use this to inspect silence configurations and status.

Instructions

Get a silence by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
silence_idYes

Implementation Reference

  • Tool registration via @mcp.tool decorator for get_silence
    @mcp.tool(description="Get a silence by its ID")
    async def get_silence(silence_id: str):
        """Get a silence by its ID
    
        Parameters
        ----------
        silence_id : str
            The ID of the silence to be retrieved.
    
        Returns
        -------
        dict:
            The Silence object from Alertmanager instance.
        """
        return make_request(method="GET", route=url_join("/api/v2/silences/", silence_id))
  • Handler function get_silence - makes GET request to /api/v2/silences/{silence_id}
    @mcp.tool(description="Get a silence by its ID")
    async def get_silence(silence_id: str):
        """Get a silence by its ID
    
        Parameters
        ----------
        silence_id : str
            The ID of the silence to be retrieved.
    
        Returns
        -------
        dict:
            The Silence object from Alertmanager instance.
        """
        return make_request(method="GET", route=url_join("/api/v2/silences/", silence_id))
  • make_request helper that actually executes the HTTP request
    def make_request(method="GET", route="/", **kwargs):
        """Make HTTP request and return a requests.Response object.
    
        Parameters
        ----------
        method : str
            HTTP method to use for the request.
        route : str
            (Default value = "/")
            This is the url we are making our request to.
        **kwargs : dict
            Arbitrary keyword arguments.
    
    
        Returns
        -------
        dict:
            The response from the Alertmanager API. This is a dictionary
            containing the response data.
        """
        try:
            route = url_join(config.url, route)
            auth = (
                requests.auth.HTTPBasicAuth(config.username, config.password)
                if config.username and config.password
                else None
            )
    
            # Add X-Scope-OrgId header for multi-tenant setups
            # Priority: 1) Request header from caller (via ContextVar), 2) Static config tenant
            headers = kwargs.get("headers", {})
    
            tenant_id = _current_scope_org_id.get() or config.tenant_id
    
            if tenant_id:
                headers["X-Scope-OrgId"] = tenant_id
            if headers:
                kwargs["headers"] = headers
    
            response = requests.request(
                method=method.upper(), url=route, auth=auth, timeout=60, **kwargs
            )
            response.raise_for_status()
            result = response.json()
    
            # Ensure we always return something (empty list is valid but might cause issues)
            if result is None:
                return {"message": "No data returned"}
            return result
        except requests.exceptions.RequestException as e:
            return {"error": str(e)}
  • url_join helper used to construct the API route with silence_id
    def url_join(base: str, path: str) -> str:
        """Join a base URL with a path, preserving the base URL's path component.
    
        Unlike urllib.parse.urljoin, this function preserves the path in the base URL
        when the path argument starts with '/'. This is useful for APIs hosted at
        subpaths (e.g., http://localhost:8080/alertmanager).
    
        Examples
        --------
        >>> url_join("http://localhost:8080/alertmanager", "/api/v2/alerts")
        'http://localhost:8080/alertmanager/api/v2/alerts'
    
        >>> url_join("http://localhost:8080/alertmanager/", "/api/v2/alerts")
        'http://localhost:8080/alertmanager/api/v2/alerts'
    
        >>> url_join("http://localhost:8080", "/api/v2/alerts")
        'http://localhost:8080/api/v2/alerts'
    
        Parameters
        ----------
        base : str
            The base URL which may include a path component
        path : str
            The path to append, which may or may not start with '/'
    
        Returns
        -------
        str
            The combined URL with both base path and appended path
        """
        # Remove trailing slash from base if present
        base = base.rstrip('/')
    
        # Remove leading slash from path if present
        path = path.lstrip('/')
    
        # Combine with a single slash
        return f"{base}/{path}"
Behavior2/5

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

No annotations are provided, so the description should disclose behavioral traits. It only states 'Get', which implies read-only, but does not mention potential errors, return value, auth requirements, or side effects.

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 one short sentence with no waste. While concise, it could be structured better by including parameter details.

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

Completeness2/5

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

Given no output schema or annotations, the description lacks information about return values and potential errors. For a simple retrieval tool, it is not complete enough to fully guide an agent.

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

Parameters1/5

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

With 0% schema description coverage, the description should compensate. It does not add any meaning to the 'silence_id' parameter beyond what the parameter name provides.

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

Purpose5/5

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

The description 'Get a silence by its ID' uses a specific verb and resource, clearly indicating the action on a single silence. This distinguishes it from sibling tools like get_silences (list) and delete_silence (delete).

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

Usage Guidelines3/5

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

The description implies usage when you have a specific silence ID, but it provides no explicit guidance on when to use this tool versus alternatives, nor any caveats or prerequisites.

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/ntk148v/alertmanager-mcp-server'

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