Skip to main content
Glama
wpfleger96

PagerDuty MCP Server

by wpfleger96

get_users

Retrieve PagerDuty user details by ID or filter users based on team assignments, search queries, and contextual data for efficient user management.

Instructions

Get PagerDuty users by filters or get details for a specific user ID.

Args: user_id (str): The user 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 user_id is provided. team_ids (List[str]): Filter results to only users assigned to teams with the given IDs (optional, cannot be used with current_user_context). Not used if user_id is provided. query (str): Filter users whose names contain the search query (optional). Not used if user_id is provided. limit (int): Limit the number of results (optional). Not used if user_id is provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
current_user_contextNo
limitNo
queryNo
team_idsNo
user_idNo

Implementation Reference

  • Primary handler for the 'get_users' tool. Decorated with @mcp.tool() for registration. Validates parameters, applies current user context if specified, and delegates to helper functions users.show_user() or users.list_users().
    def get_users(
        *,
        user_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 users by filters or get details for a specific user ID.
    
        Args:
            user_id (str): The user 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 `user_id` is provided.
            team_ids (List[str]): Filter results to only users assigned to teams with the given IDs (optional, cannot be used with current_user_context). Not used if `user_id` is provided.
            query (str): Filter users whose names contain the search query (optional). Not used if `user_id` is provided.
            limit (int): Limit the number of results (optional). Not used if `user_id` is provided.
        """
        if user_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 `user_id` is provided, other filters (like team_ids, query, limit) cannot be used. See `docs://tools` for more information."
                )
    
            return users.show_user(user_id=user_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 users.list_users(team_ids=team_ids, query=query, limit=limit)
  • Helper function called by get_users for listing multiple users with filtering by team_ids, query, and limit. Interacts with PagerDuty API.
    def list_users(
        *,
        team_ids: Optional[List[str]] = None,
        query: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> Dict[str, Any]:
        """List users in PagerDuty. Exposed as MCP server tool.
    
        Args:
            team_ids (List[str]): Filter results to only users assigned to teams with the given IDs (optional)
            query (str): Filter users 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 users with their profile information including teams, contact methods, and notification rules.
    
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
    
        pd_client = create_client()
    
        params = {}
    
        if team_ids:
            params["team_ids[]"] = team_ids
        if query:
            params["query"] = query
        if limit:
            params["limit"] = limit
    
        try:
            response = pd_client.list_all(USERS_URL, params=params)
            parsed_response = [parse_user(result=result) for result in response]
            return utils.api_response_handler(
                results=parsed_response, resource_name="users"
            )
        except Exception as e:
            utils.handle_api_error(e)
  • Helper function called by get_users for retrieving a single user by ID. Interacts with PagerDuty API.
    def show_user(*, user_id: str) -> Dict[str, Any]:
        """Get detailed information about a given user. Exposed as MCP server tool.
    
        Args:
            user_id (str): The ID of the user to fetch
    
        Returns:
            See the "Standard Response Format" section in `tools.md` for the complete standard response structure.
            The response will contain a single user with detailed profile information including teams, contact methods, and notification rules.
    
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
    
        if not user_id:
            raise ValueError("User ID is required")
    
        pd_client = create_client()
    
        try:
            response = pd_client.jget(f"{USERS_URL}/{user_id}")
            try:
                user_data = response["user"]
            except KeyError:
                raise RuntimeError(
                    f"Failed to fetch user {user_id}: Response missing 'user' field"
                )
    
            return utils.api_response_handler(
                results=parse_user(result=user_data), resource_name="user"
            )
        except Exception as e:
            utils.handle_api_error(e)
  • Helper function used by get_users (and other tools) to build current user's context (team_ids etc.) for filtering.
    def build_user_context() -> Dict[str, Any]:
        """Validate and build the current user's context. Exposed as MCP server tool.
    
        See the "Standard Response Format" section in `tools.md` for the complete standard response structure.
    
        Returns:
            See the "Standard Response Format" section in `tools.md` for the complete standard response structure.
            The response will contain the current user's context in the format defined in the "build_user_context" section of `tools.md`.
    
        Raises:
            See the "Error Handling" section in `tools.md` for common error scenarios.
        """
        try:
            user = _show_current_user()
            if not user:
                raise ValueError("Failed to get current user data")
    
            context = {
                "user_id": str(user.get("id", "")).strip(),
                "name": user.get("name", ""),
                "email": user.get("email", ""),
                "team_ids": [],
                "service_ids": [],
                "escalation_policy_ids": [],
            }
    
            if not context["user_id"]:
                raise ValueError("Invalid user data: missing or empty user ID")
    
            team_ids = teams.fetch_team_ids(user=user)
            context["team_ids"] = [
                str(tid).strip() for tid in team_ids if tid and str(tid).strip()
            ]
    
            if context["team_ids"]:
                service_ids = services.fetch_service_ids(team_ids=context["team_ids"])
                context["service_ids"] = [
                    str(sid).strip() for sid in service_ids if sid and str(sid).strip()
                ]
    
            escalation_policy_ids = escalation_policies.fetch_escalation_policy_ids(
                user_id=context["user_id"]
            )
            context["escalation_policy_ids"] = [
                str(epid).strip()
                for epid in escalation_policy_ids
                if epid and str(epid).strip()
            ]
    
            return context
    
        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 describes the filtering logic and parameter dependencies, which is useful context. However, it doesn't mention important behavioral aspects like whether this is a read-only operation, authentication requirements, rate limits, pagination behavior, or what format the results return. The description adds some value but leaves significant gaps.

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. Each parameter explanation is concise and focused. While slightly longer due to comprehensive parameter coverage, every sentence earns its place by providing essential information. The structure helps with readability and understanding.

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 5 parameters with 0% schema coverage and no output schema, the description does an excellent job documenting parameters but has significant gaps elsewhere. No annotations are provided to clarify behavioral aspects, and the return format is completely undocumented. For a tool with multiple filtering options and no structured output documentation, the description should ideally mention what kind of data is returned.

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 parameter documentation. Each of the 5 parameters is clearly explained with semantics, optionality, default values, and interaction rules. The description adds substantial meaning beyond what the bare schema provides, making parameter usage understandable.

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 retrieves PagerDuty users with filtering options or specific user details. It specifies the verb 'get' and resource 'PagerDuty users', making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_users_oncall' or 'build_user_context', which would require more specific comparison.

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 guidance on parameter interactions (e.g., 'user_id' cannot be used with other filters, 'current_user_context' not used if 'user_id' is provided). It explains when certain parameters apply or don't apply, giving practical usage rules. However, it doesn't explicitly state when to choose this tool over alternatives like 'list_users_oncall' or mention any 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

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