Skip to main content
Glama
wpfleger96

PagerDuty MCP Server

by wpfleger96

get_services

Retrieve PagerDuty services by service ID or filter by team IDs, user context, or search query. Manage service details for efficient incident handling.

Instructions

Get PagerDuty services by filters or get details for a specific service ID.

Args: service_id (str): The service ID to retrieve (optional, cannot be used with any other filters). current_user_context (bool): Use current user's team IDs to filter (default: True). Not used if service_id is provided. team_ids (List[str]): Filter results to only services assigned to teams with the given IDs (optional, cannot be used with current_user_context). Not used if service_id is provided. query (str): Filter services whose names contain the search query (optional). Not used if service_id is provided. limit (int): Limit the number of results (optional). Not used if service_id is provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
current_user_contextNo
limitNo
queryNo
service_idNo
team_idsNo

Implementation Reference

  • The handler function for the 'get_services' MCP tool. It performs input validation, resolves user context if needed, and delegates to appropriate helper functions for listing or showing services.
    @mcp.tool()
    def get_services(
        *,
        service_id: Optional[str] = None,
        current_user_context: bool = True,
        team_ids: Optional[List[str]] = None,
        query: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """Get PagerDuty services by filters or get details for a specific service ID.
    
        Args:
            service_id (str): The service ID to retrieve (optional, cannot be used with any other filters).
            current_user_context (bool): Use current user's team IDs to filter (default: True). Not used if `service_id` is provided.
            team_ids (List[str]): Filter results to only services assigned to teams with the given IDs (optional, cannot be used with current_user_context). Not used if `service_id` is provided.
            query (str): Filter services whose names contain the search query (optional). Not used if `service_id` is provided.
            limit (int): Limit the number of results (optional). Not used if `service_id` is provided.
        """
        if service_id is not None:
            disallowed_filters_present = (
                team_ids is not None or query is not None or limit is not None
            )
            if disallowed_filters_present:
                raise ValueError(
                    "When `service_id` is provided, other filters (like team_ids, query, limit) cannot be used. See `docs://tools` for more information."
                )
    
            return services.show_service(service_id=service_id)
    
        if current_user_context:
            if team_ids is not None:
                raise ValueError(
                    "Cannot specify team_ids when current_user_context is True. See `docs://tools` for more information."
                )
            user_context = users.build_user_context()
            team_ids = user_context["team_ids"]
        elif not team_ids:
            raise ValueError(
                "Must specify at least team_ids when current_user_context is False. See `docs://tools` for more information."
            )
    
        return services.list_services(team_ids=team_ids, query=query, limit=limit)
  • Helper function that lists PagerDuty services based on team_ids, query, and limit filters. Called by the get_services handler.
    def list_services(
        *,
        team_ids: Optional[List[str]] = None,
        query: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """List existing PagerDuty services. Exposed as MCP server tool.
    
        Args:
            team_ids (List[str]): Filter results to only services assigned to teams with the given IDs (optional)
            query (str): Filter services whose names contain the search query (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 services with their configuration and team assignments.
    
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
    
        pd_client = create_client()
    
        if team_ids is not None and not team_ids:
            raise ValueError("team_ids cannot be an empty list")
    
        params = {}
        if team_ids:
            params["team_ids[]"] = (
                team_ids  # PagerDuty API expects array parameters with [] suffix
            )
        if query:
            params["query"] = query
        if limit:
            params["limit"] = limit
    
        try:
            response = pd_client.list_all(SERVICES_URL, params=params)
            parsed_response = [parse_service(result=result) for result in response]
            return utils.api_response_handler(
                results=parsed_response, resource_name="services"
            )
        except Exception as e:
            utils.handle_api_error(e)
  • Helper function that retrieves detailed information for a specific PagerDuty service by ID. Called by the get_services handler.
    def show_service(*, service_id: str) -> Dict[str, Any]:
        """Get detailed information about a given service. Exposed as MCP server tool.
    
        Args:
            service_id (str): The ID of the service to get
    
        Returns:
            See the "Standard Response Format" section in `tools.md` for the complete standard response structure.
            The response will contain a single service with detailed configuration and team information.
    
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
    
        if not service_id:
            raise ValueError("service_id cannot be empty")
    
        pd_client = create_client()
    
        try:
            response = pd_client.jget(f"{SERVICES_URL}/{service_id}")
            try:
                service_data = response["service"]
            except KeyError:
                raise RuntimeError(
                    f"Failed to fetch service {service_id}: Response missing 'service' field"
                )
    
            return utils.api_response_handler(
                results=parse_service(result=service_data), resource_name="service"
            )
        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 of behavioral disclosure. It explains the parameter interactions and default behavior (current_user_context defaults to True), which is valuable. However, it doesn't describe important behavioral aspects like whether this is a read-only operation (implied by 'Get' but not explicit), pagination behavior beyond the 'limit' parameter, authentication requirements, rate limits, or error conditions.

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 purpose statement followed by detailed parameter documentation. Every sentence serves a purpose - the first establishes the dual modes, and the parameter explanations are necessary given the 0% schema coverage. However, the parameter documentation is quite dense and could potentially be more concise while maintaining clarity.

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 the tool's moderate complexity (5 parameters with intricate interactions), no annotations, and no output schema, the description does a reasonable job but has gaps. It thoroughly documents parameters and their interactions but lacks information about return values, error handling, authentication requirements, and rate limiting. For a tool with this parameter complexity and no structured metadata, more behavioral context would be helpful.

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 comprehensive parameter documentation. It explains all 5 parameters, their data types, optionality, default values, and crucially documents the complex parameter interactions and mutual exclusivity rules that aren't captured in the schema. This adds significant value beyond what the bare schema provides.

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 tool's purpose: 'Get PagerDuty services by filters or get details for a specific service ID.' This specifies the verb ('Get'), resource ('PagerDuty services'), and two distinct modes of operation. However, it doesn't explicitly differentiate this tool from sibling tools like 'get_escalation_policies' or 'get_teams' beyond the resource type.

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 usage context by explaining the two primary modes (filter-based listing vs. specific ID retrieval) and the mutual exclusivity rules between parameters. It states 'cannot be used with any other filters' for service_id and clarifies when other parameters are 'not used if service_id is provided.' However, it doesn't explicitly mention when to use this tool versus sibling tools like 'get_escalation_policies' for related data.

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