Skip to main content
Glama
wpfleger96

PagerDuty MCP Server

by wpfleger96

get_escalation_policies

Retrieve PagerDuty escalation policies by ID or filter by user/team IDs, names, or context. Use to manage and access escalation details with structured inputs and outputs.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
current_user_contextNo
limitNo
policy_idNo
queryNo
team_idsNo
user_idsNo

Implementation Reference

  • The primary handler for the 'get_escalation_policies' tool. Registered via @mcp.tool() decorator. Dispatches to helper functions based on whether a specific policy_id is provided or list filters are used. Includes input validation and user context building.
    @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
        )
  • Helper function to list escalation policies using PagerDuty API. Called by the main handler when no specific policy_id is provided. Handles filtering params, API call, parsing with parse_escalation_policy, and response formatting.
    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)
  • Helper function to retrieve a single escalation policy by ID using PagerDuty API. Called by the main handler when policy_id is provided. Handles API call, parsing, and response formatting.
    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?

With no annotations provided, the description carries the full burden. It explains the tool's dual behavior (filtering vs. specific retrieval) and parameter dependencies, which is valuable. However, it doesn't disclose important behavioral traits like whether this is a read-only operation, rate limits, authentication requirements, or what the response format looks like.

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 a clear opening sentence followed by parameter details. While efficient, the parameter explanations could be slightly more concise (e.g., repeating 'Not used if policy_id is provided' for multiple parameters). Every sentence serves a purpose in clarifying tool behavior.

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?

For a 6-parameter tool with no annotations and no output schema, the description does a good job explaining parameters and tool behavior. However, it lacks information about return values, pagination (beyond limit), error conditions, or authentication context. Given the complexity, these gaps prevent a higher score.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing detailed semantic explanations for all 6 parameters. It clarifies optionality, defaults, mutual exclusivity rules (policy_id vs. other filters), and parameter relationships (e.g., current_user_context exclusion with user_ids/team_ids). This adds significant value beyond the bare schema.

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 verb ('Get') and resource ('PagerDuty escalation policies'), and distinguishes between two modes: filtering multiple policies vs. retrieving a specific policy by ID. This specificity helps differentiate it from sibling tools like get_incidents or get_services.

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 provides clear context about when to use different parameters (policy_id vs. other filters) and mentions parameter exclusions (e.g., 'cannot be used with any other filters', 'Not used if policy_id is provided'). However, it doesn't explicitly state when to use this tool versus sibling tools like get_services or get_teams.

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

Related 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