Skip to main content
Glama
wpfleger96

PagerDuty MCP Server

by wpfleger96

get_escalation_policies

Retrieve escalation policies from PagerDuty using filters like name, user, or team, or get details for a specific policy ID.

Instructions

Get PagerDuty escalation policies by filters or get details for a specific policy ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
policy_idNoThe escalation policy ID to retrieve (optional, cannot be used with any other filters).
current_user_contextNoUse current user's ID/team IDs context (default: True). Not used if `policy_id` is provided.
queryNoPolicies whose names contain the search query (optional). Not used if `policy_id` is provided.
user_idsNoPolicies that include these user IDs (optional, excludes current_user_context). Not used if `policy_id` is provided.
team_idsNoPolicies assigned to these team IDs (optional, excludes current_user_context). Not used if `policy_id` is provided.
limitNoLimit the number of results (optional). Not used if `policy_id` is provided.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler function `get_escalation_policies` decorated with @mcp.tool(). It dispatches to either `show_escalation_policy` (if policy_id is provided) or `list_escalation_policies` (with optional user context via `build_user_context`).
    @mcp.tool()
    def get_escalation_policies(
        *,
        policy_id: Optional[str] = None,
        current_user_context: bool = True,
        query: Optional[str] = None,
        user_ids: Optional[List[str]] = None,
        team_ids: Optional[List[str]] = None,
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """Get PagerDuty escalation policies by filters or get details for a specific policy ID.
    
        Args:
            policy_id (str): The escalation policy ID to retrieve (optional, cannot be used with any other filters).
            current_user_context (bool): Use current user's ID/team IDs context (default: True). Not used if `policy_id` is provided.
            query (str): Policies whose names contain the search query (optional). Not used if `policy_id` is provided.
            user_ids (List[str]): Policies that include these user IDs (optional, excludes current_user_context). Not used if `policy_id` is provided.
            team_ids (List[str]): Policies assigned to these team IDs (optional, excludes current_user_context). Not used if `policy_id` is provided.
            limit (int): Limit the number of results (optional). Not used if `policy_id` is provided.
        """
        if policy_id is not None:
            disallowed_filters_present = (
                query is not None
                or user_ids is not None
                or team_ids is not None
                or limit is not None
            )
            if disallowed_filters_present:
                raise ValueError(
                    "When `policy_id` is provided, other filters (like query, user_ids, team_ids, limit) cannot be used. See `docs://tools` for more information."
                )
    
            return escalation_policies.show_escalation_policy(policy_id=policy_id)
    
        if current_user_context:
            if user_ids is not None or team_ids is not None:
                raise ValueError(
                    "Cannot specify user_ids or team_ids when current_user_context is True. See `docs://tools` for more information."
                )
            user_context = users.build_user_context()
            user_ids = [user_context["user_id"]]
            team_ids = user_context["team_ids"]
        elif not (user_ids or team_ids):
            raise ValueError(
                "Must specify at least user_ids or team_ids when current_user_context is False. See `docs://tools` for more information."
            )
    
        return escalation_policies.list_escalation_policies(
            query=query, user_ids=user_ids, team_ids=team_ids, limit=limit
        )
  • The `parse_escalation_policy` function that transforms raw PagerDuty API escalation policy responses into a structured format with consistent field names (id, name, description, escalation_rules, services, teams).
    def parse_escalation_policy(*, result: Dict[str, Any]) -> Dict[str, Any]:
        """Parses a raw escalation policy API response into a structured format without unneeded fields.
    
        Args:
            result (Dict[str, Any]): The raw escalation policy API response
    
        Returns:
            Dict[str, Any]: A dictionary containing:
                - id (str): The policy ID
                - name (str): The policy name
                - escalation_rules (List[Dict]): List of escalation rules, each containing:
                    - id (str): Rule ID
                    - escalation_delay_in_minutes (int): Delay before escalation
                    - targets (List[Dict]): List of targets with id, type, and summary
                - services (List[Dict]): List of services with id
                - teams (List[Dict]): List of teams with id and summary
                - description (str): Policy description
    
        Note:
            If the input is None or not a dictionary, returns an empty dictionary.
            All fields are optional and will be None if not present in the input.
    
        Raises:
            KeyError: If accessing nested dictionary fields fails
        """
    
        if not result:
            return {}
    
        parsed_policy = {}
    
        # Simple fields
        simple_fields = ["id", "name", "description"]
  • The `@mcp.tool()` decorator on line 38 registers `get_escalation_policies` as an MCP tool on the FastMCP server instance.
    @mcp.tool()
    def get_escalation_policies(
  • The `list_escalation_policies` helper function that queries the PagerDuty API /escalation_policies endpoint with optional filters (query, user_ids, team_ids, limit) and returns parsed results.
    def list_escalation_policies(
        *,
        query: Optional[str] = None,
        user_ids: Optional[List[str]] = None,
        team_ids: Optional[List[str]] = None,
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """List escalation policies based on the given criteria. Exposed in `get_escalation_policies`.
    
        Args:
            query (str): Filter escalation policies whose names contain the search query (optional)
            user_ids (List[str]): Filter results to only escalation policies that include the given user IDs (optional)
            team_ids (List[str]): Filter results to only escalation policies assigned to teams with the given IDs (optional)
            limit (int): Limit the number of results returned (optional)
    
        Returns:
            See the "Standard Response Format" section in `tools.md` for the complete standard response structure.
            The response will contain a list of escalation policies in the standard format.
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
    
        pd_client = create_client()
    
        params = {}
        if query:
            params["query"] = query
        if user_ids:
            params["user_ids[]"] = user_ids
        if team_ids:
            params["team_ids[]"] = team_ids
        if limit:
            params["limit"] = limit
    
        try:
            response = pd_client.list_all(ESCALATION_POLICIES_URL, params=params)
            parsed_response = [
                parse_escalation_policy(result=result) for result in response
            ]
            return utils.api_response_handler(
                results=parsed_response, resource_name="escalation_policies"
            )
        except Exception as e:
            utils.handle_api_error(e)
  • The `show_escalation_policy` helper function that fetches a single escalation policy by ID from the PagerDuty API and returns parsed details.
    def show_escalation_policy(*, policy_id: str) -> Dict[str, Any]:
        """Get detailed information about a given escalation policy. Exposed in `get_escalation_policies`.
    
        Args:
            policy_id (str): The ID of the escalation policy to get
    
        Returns:
            See the "Standard Response Format" section in `tools.md` for the complete standard response structure.
            The response will contain a single escalation policy in the standard format.
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
    
        if not policy_id:
            raise ValueError("policy_id cannot be empty")
    
        pd_client = create_client()
    
        try:
            response = pd_client.jget(f"{ESCALATION_POLICIES_URL}/{policy_id}")
            try:
                policy_data = response["escalation_policy"]
            except KeyError:
                raise RuntimeError(
                    f"Failed to fetch escalation policy {policy_id}: Response missing 'escalation_policy' field"
                )
    
            return utils.api_response_handler(
                results=parse_escalation_policy(result=policy_data),
                resource_name="escalation_policy",
            )
        except Exception as e:
            utils.handle_api_error(e)
Behavior3/5

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

No annotations are provided, so the description carries full responsibility. It states the tool retrieves data, implying a read-only operation, but does not explicitly confirm safety or disclose behavioral traits like authorization needs or rate limits. The transparency is adequate for a simple retrieval tool.

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, front-loaded sentence that conveys the core functionality without any redundant or extraneous information. Every word earns its place.

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

Completeness4/5

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

For a retrieval tool with 6 parameters and an existing output schema, the description adequately covers the two primary modes. The parameter-specific constraints (e.g., mutual exclusivity) are detailed in the schema, so the description does not need to repeat them. Minor omission: no mention of what the response contains, but output schema fills that gap.

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?

The input schema has 100% description coverage, with each parameter's role clearly explained. The tool's description restates the two usage modes but adds no new semantic value beyond the schema. Baseline score of 3 is appropriate due to high schema coverage.

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 clearly states the action (get) and the resource (PagerDuty escalation policies), and distinguishes between two modes: listing by filters or retrieving details by specific policy ID. This effectively differentiates it from sibling tools which target different resources.

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

Usage Guidelines4/5

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

The description implies two primary use cases (filter-based listing vs. specific ID retrieval) but does not explicitly compare to sibling tools. Since sibling tools cover distinct resources, the guidance is sufficient for an agent to select this tool for escalation policy queries.

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/wpfleger96/pagerduty-mcp-server'

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