Skip to main content
Glama
ntk148v

alertmanager-mcp-server

get_silences

Retrieve silences from Alertmanager with optional filtering and pagination using count and offset parameters.

Instructions

Get list of all silences

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo
countNo
offsetNo

Implementation Reference

  • Main handler for the get_silences MCP tool. Fetches all silences from Alertmanager's /api/v2/silences endpoint with optional filter, validates pagination params, and returns paginated results.
    @mcp.tool(description="Get list of all silences")
    async def get_silences(filter: Optional[str] = None,
                           count: int = DEFAULT_SILENCE_PAGE,
                           offset: int = 0):
        """Get list of all silences
    
        Parameters
        ----------
        filter
            Filtering query (e.g. alertname=~'.*CPU.*')"),
        count
            Number of silences to return per page (default: 10, max: 50).
        offset
            Number of silences to skip before returning results (default: 0).
            To paginate through all results, make multiple calls with increasing
            offset values (e.g., offset=0, offset=10, offset=20, etc.).
    
        Returns
        -------
        dict
            A dictionary containing:
            - data: List of Silence objects for the current page
            - pagination: Metadata about pagination (total, offset, count, has_more)
              Use the 'has_more' flag to determine if additional pages are available.
        """
        # Validate pagination parameters
        count, offset, error = validate_pagination_params(
            count, offset, MAX_SILENCE_PAGE)
        if error:
            return {"error": error}
    
        params = None
        if filter:
            params = {"filter": filter}
    
        # Get all silences from the API
        all_silences = make_request(
            method="GET", route="/api/v2/silences", params=params)
    
        # Apply pagination and return results
        return paginate_results(all_silences, count, offset)
  • Pagination configuration constants for get_silences: default page size (10) and max page size (50), configurable via env vars.
    # Pagination defaults and limits (configurable via environment variables)
    DEFAULT_SILENCE_PAGE = int(os.environ.get(
        "ALERTMANAGER_DEFAULT_SILENCE_PAGE", "10"))
    MAX_SILENCE_PAGE = int(os.environ.get("ALERTMANAGER_MAX_SILENCE_PAGE", "50"))
    DEFAULT_ALERT_PAGE = int(os.environ.get(
        "ALERTMANAGER_DEFAULT_ALERT_PAGE", "10"))
    MAX_ALERT_PAGE = int(os.environ.get("ALERTMANAGER_MAX_ALERT_PAGE", "25"))
    DEFAULT_ALERT_GROUP_PAGE = int(os.environ.get(
        "ALERTMANAGER_DEFAULT_ALERT_GROUP_PAGE", "3"))
    MAX_ALERT_GROUP_PAGE = int(os.environ.get(
        "ALERTMANAGER_MAX_ALERT_GROUP_PAGE", "5"))
  • MCP tool registration decorator for get_silences.
    @mcp.tool(description="Get list of all silences")
  • Validates pagination parameters (count and offset) against max count limit.
    def validate_pagination_params(count: int, offset: int, max_count: int) -> tuple[int, int, Optional[str]]:
        """Validate and normalize pagination parameters.
    
        Parameters
        ----------
        count : int
            Requested number of items per page
        offset : int
            Requested offset for pagination
        max_count : int
            Maximum allowed count value
    
        Returns
        -------
        tuple[int, int, Optional[str]]
            A tuple of (normalized_count, normalized_offset, error_message).
            If error_message is not None, the parameters are invalid and should
            return an error to the caller.
        """
        error = None
    
        # Validate count parameter
        if count < 1:
            error = f"Count parameter ({count}) must be at least 1."
        elif count > max_count:
            error = (
                f"Count parameter ({count}) exceeds maximum allowed value ({max_count}). "
                f"Please use count <= {max_count} and paginate through results using the offset parameter."
            )
    
        # Validate offset parameter
        if offset < 0:
            error = f"Offset parameter ({offset}) must be non-negative (>= 0)."
    
        return count, offset, error
  • Helper that applies slicing-based pagination to a list and returns data with pagination metadata.
    def paginate_results(items: List[Any], count: int, offset: int) -> Dict[str, Any]:
        """Apply pagination to a list of items and generate pagination metadata.
    
        Parameters
        ----------
        items : List[Any]
            The full list of items to paginate
        count : int
            Number of items to return per page (must be >= 1)
        offset : int
            Number of items to skip (must be >= 0)
    
        Returns
        -------
        Dict[str, Any]
            A dictionary containing:
            - data: List of items for the current page
            - pagination: Metadata including total, offset, count, requested_count, and has_more
        """
        total = len(items)
        end_index = offset + count
        paginated_items = items[offset:end_index]
        has_more = end_index < total
    
        return {
            "data": paginated_items,
            "pagination": {
                "total": total,
                "offset": offset,
                "count": len(paginated_items),
                "requested_count": count,
                "has_more": has_more
            }
        }
Behavior1/5

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

No annotations are provided, yet the description fails to disclose any behavioral traits such as pagination, filtering, or that it returns a list. The description is too minimal to convey behavior.

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

Conciseness3/5

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

The description is extremely short (5 words), which is concise but lacks necessary detail. It states the purpose without elaboration, making it barely adequate.

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

Completeness1/5

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

Given 0% schema coverage and no output schema, the description is insufficient. It fails to explain output format, pagination, or how filtering works, leaving the agent with significant gaps.

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?

Schema coverage is 0% (no parameter descriptions), and the description adds no information about the parameters 'filter', 'count', or 'offset'. The parameter names are somewhat self-explanatory, but the description should clarify their usage.

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 'Get list of all silences' clearly states the action (list) and resource (silences), and the plural form distinguishes it from the sibling 'get_silence' (singular). However, it does not explicitly mention the list nature or pagination.

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 on when to use this tool versus siblings like 'get_silence' or 'post_silence'. The description does not provide context on prerequisites or alternatives.

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