Skip to main content
Glama
PagerDuty MCP Server

PagerDuty MCP Server

by wpfleger96

PagerDuty MCP 服务器

向 LLM 公开 PagerDuty API 功能的服务器。该服务器旨在以编程方式使用,并具有结构化的输入和输出。

PyPI 下载 Python 版本 GitHub 贡献者 PyPI 版本 执照

概述

PagerDuty MCP 服务器提供了一组用于与 PagerDuty API 交互的工具。这些工具旨在供 LLM 使用,用于对 PagerDuty 资源(例如事件、服务、团队和用户)执行各种操作。

Related MCP server: Logseq MCP Server

安装

来自 PyPI

pip install pagerduty-mcp-server

来自源

# Clone the repository
git clone https://github.com/wpfleger96/pagerduty-mcp-server.git
cd pagerduty-mcp-server

# Install dependencies
brew install uv
uv sync

要求

  • Python 3.13 或更高版本

  • PagerDuty API 密钥

配置

PagerDuty MCP 服务器需要在环境中设置 PagerDuty API 密钥:

PAGERDUTY_API_KEY=your_api_key_here

用法

作为鹅扩展

{
  "type": "stdio",
  "enabled": true,
  "args": [
    "run",
    "python",
    "-m",
    "pagerduty_mcp_server"
  ],
  "commandInput": "uv run python -m pagerduty_mcp_server",
  "timeout": 300,
  "id": "pagerduty-mcp-server",
  "name": "pagerduty-mcp-server",
  "description": "pagerduty-mcp-server",
  "env_keys": [
    "PAGERDUTY_API_KEY"
  ],
  "cmd": "uv"
}

作为独立服务器

uv run python -m pagerduty_mcp_server

响应格式

所有 API 响应都遵循一致的格式:

{
  "metadata": {
    "count": <int>,  // Number of results
    "description": "<str>"  // A short summary of the results
  },
  <resource_type>: [ // Always pluralized for consistency, even if one result is returned
    {
      ...
    },
    ...
  ],
  "error": {  // Only present if there's an error
    "message": "<str>",  // Human-readable error description
    "code": "<str>"  // Machine-readable error code
  }
}

错误处理

当发生错误时,响应将包含具有以下结构的错误对象:

{
  "metadata": {
    "count": 0,
    "description": "Error occurred while processing request"
  },
  "error": {
    "message": "Invalid user ID provided",
    "code": "INVALID_USER_ID"
  }
}

常见的错误场景包括:

  • 无效的资源 ID(例如,user_id、team_id、service_id)

  • 缺少必需参数

  • 参数值无效

  • API 请求失败

  • 响应处理错误

参数验证

  • 所有 ID 参数必须是有效的 PagerDuty 资源 ID

  • 日期参数必须是有效的 ISO8601 时间戳

  • 列表参数(例如, statuses 、 team_ids )必须包含有效值

  • 列表参数中的无效值将被忽略

  • 必需参数不能为None或空字符串

  • 对于list_incidents中的statuses ,只有triggered 、 acknowledged和resolved是有效值

  • 对于事件的urgency ,只有high和low是有效值

  • limit参数可用于限制列表操作返回的结果数

速率限制和分页

  • 服务器遵守 PagerDuty 的速率限制

  • 服务器自动为您处理分页

  • limit参数可用于控制列表操作返回的结果数量

  • 如果没有指定限制,服务器默认返回最多 {pagerduty_mcp_server.utils.RESPONSE_LIMIT} 个结果

示例用法

from pagerduty_mcp_server import incidents
from pagerduty_mcp_server.utils import RESPONSE_LIMIT

# List all incidents (including resolved) for the current user's teams
incidents_list = incidents.list_incidents()

# List only active incidents
active_incidents = incidents.list_incidents(statuses=['triggered', 'acknowledged'])

# List incidents for specific services
service_incidents = incidents.list_incidents(service_ids=['SERVICE-1', 'SERVICE-2'])

# List incidents for specific teams
team_incidents = incidents.list_incidents(team_ids=['TEAM-1', 'TEAM-2'])

# List incidents within a date range
date_range_incidents = incidents.list_incidents(
    since='2024-03-01T00:00:00Z',
    until='2024-03-14T23:59:59Z'
)

# List incidents with a limit on the number of results
limited_incidents = incidents.list_incidents(limit=10)

# List incidents with the default limit
default_limit_incidents = incidents.list_incidents(limit=RESPONSE_LIMIT)

用户上下文

许多函数接受current_user_context参数(默认为True ),该参数会根据此上下文自动过滤结果。当current_user_context为True时,您无法使用某些过滤参数,因为它们会与自动过滤功能冲突:

  • 对于所有资源类型:

    • user_ids不能与current_user_context=True一起使用

  • 对于事件:

    • team_ids和service_ids不能与current_user_context=True一起使用

  • 对于服务:

    • team_ids不能与current_user_context=True一起使用

  • 对于升级策略:

    • team_ids不能与current_user_context=True一起使用

  • 对于值班人员:

    • user_ids不能与current_user_context=True一起使用

    • 仍可使用schedule_ids按特定时间表进行筛选

    • 该查询将显示与当前用户团队相关的所有升级策略的待命情况

    • 这对于回答诸如“我的团队目前谁值班?”之类的问题很有用。

    • 当前用户的 ID 不用作过滤器,因此您将看到所有值班的团队成员

发展

运行测试

请注意,大多数测试都需要与 PagerDuty API 建立实际连接,因此您需要在运行完整测试套件之前在环境中设置PAGERDUTY_API_KEY 。

uv run pytest

仅运行单元测试(即不需要在环境中设置PAGERDUTY_API_KEY测试):

uv run pytest -m unit

仅运行集成测试:

uv run pytest -m integration

仅运行解析器测试:

uv run pytest -m parsers

仅运行与特定子模块相关的测试:

uv run pytest -m <client|escalation_policies|...>

使用 MCP Inspector 调试服务器

npx @modelcontextprotocol/inspector uv run python -m pagerduty_mcp_server

贡献

发布

该项目使用常规提交进行自动发布。提交消息决定了版本更新:

  • feat: → 次要版本(1.0.0 → 1.1.0)

  • fix: →补丁版本(1.0.0→1.0.1)

  • BREAKING CHANGE: → 主要版本(1.0.0 → 2.0.0)

CHANGELOG.md、GitHub 版本和 PyPI 包会自动更新。

文档

工具文档——有关可用工具的详细信息,包括参数、返回类型和示例查询

公约

  • 所有 API 响应都遵循标准格式,包含元数据、资源列表和可选错误

  • 为了保持一致性,响应中的资源名称始终采用复数形式

  • 返回单个项目的所有函数仍返回包含一个元素的列表

  • 错误响应包括消息和代码

  • 所有时间戳均为 ISO8601 格式

  • 测试用 pytest 标记来标记,以指示其类型(单元/集成)、测试的资源(事件、团队等)以及是否测试解析功能(“解析器”标记)

Available Tools

12 tools
acknowledge_incidentB

Acknowledge a PagerDuty incident. This signals that someone is actively working on the incident.

Inputs: incident_id (required), include. Returns: object

add_incident_noteA

Add a note to a PagerDuty incident. Notes are used to record additional context, investigation progress, or resolution details.

Inputs: content (required), incident_id (required). Returns: object

build_user_contextA

Validate and build the current user's context into a dictionary with the following format: { "user_id": str, "team_ids": List[str], "service_ids": List[str], "escalation_policy_ids": List[str] } The MCP server tools use this user context to filter the following resources: - Escalation policies - Incidents - Oncalls - Services - Users

Inputs: no named parameters. Returns: object

get_escalation_policiesA

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

Call patterns:

  • Default: omit filters (uses current user's policies/teams).

  • By IDs: pass user_ids and/or team_ids (implies current_user_context=False, including overriding an explicit True).

  • By name: pass query with the default context (limited to your teams/policies); do not set current_user_context=False with only query.

Inputs: limit, query, include, team_ids, +3 more. Returns: object

get_incidentsA

Get PagerDuty incidents by filters or get details for a specific incident ID or number.

Call patterns:

  • List my/team incidents: omit ID filters (default current_user_context=True).

  • List by service/team: pass service_ids and/or team_ids (implies current_user_context=False, including overriding an explicit True). Do not also set include_notes / include_past_incidents / include_related_incidents on this list call.

  • Detail + notes: second call with only incident_id (and optional include_* flags).

  • Account-wide list: all_visible=True alone (not scoped to the current user).

Inputs: limit, since, until, include, +10 more. Returns: object

get_oncallsA

List on-call entries for schedules, policies, or time ranges.

Call patterns:

  • Default: omit exclusive filters (uses escalation policies the current user is a target of).

  • By schedule: schedule_ids may be used with the default context (intersection) or with current_user_context=False.

  • By user/policy IDs: pass user_ids and/or escalation_policy_ids (implies current_user_context=False, including overriding an explicit True).

Behavior varies by time parameters:

  1. Without since/until: Returns current on-calls Example: get_oncalls(current_user_context=False, schedule_ids=["PSCHED123"])

  2. With since/until: Returns all on-calls in range Example: get_oncalls(current_user_context=False, schedule_ids=["PSCHED123"], since="2024-03-20T00:00:00Z", until="2024-03-27T00:00:00Z")

Inputs: limit, since, until, include, +5 more. Returns: object

get_schedulesB

Get PagerDuty schedules by filters or get details for a specific schedule ID.

Inputs: limit, query, since, until, +2 more. Returns: object

get_servicesA

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

Call patterns:

  • Search by name: query="Service Name" with the default context (omit current_user_context; limited to your teams).

  • By team: pass team_ids (implies current_user_context=False, including overriding an explicit True).

  • Do not set current_user_context=False with only query; that errors because team_ids are required in False mode.

Inputs: limit, query, include, team_ids, +2 more. Returns: object

get_teamsA

Get PagerDuty teams by filters or get details for a specific team ID.

Inputs: limit, query, include, team_id. Returns: object

get_usersA

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

Call patterns:

  • Search by name: query="Name" with the default context (omit current_user_context; limited to your teams).

  • By team: pass team_ids (implies current_user_context=False, including overriding an explicit True).

  • Do not set current_user_context=False with only query; that errors because team_ids are required in False mode.

Inputs: limit, query, include, user_id, +2 more. Returns: object

list_users_oncallC

List the users on call for a schedule during the specified time range.

Inputs: schedule_id (required), since, until, include. Returns: object

resolve_incidentA

Resolve a PagerDuty incident. This marks the incident as resolved and stops any further escalations.

Inputs: incident_id (required), include. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools map cleanly to distinct PagerDuty resources or incident actions. The main ambiguity is between get_oncalls and list_users_oncall, and several get_* tools combine list and detail modes, though the descriptions make reasonable distinctions.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern using get_, list_, acknowledge_, resolve_, add_, and build_. The use of get_ for both listing and fetching details is a minor semantic issue rather than a naming inconsistency.

    Tool Count5/5

    Twelve tools is a well-scoped size for a PagerDuty incident-management MCP server. Each tool covers a distinct resource or action, with no obvious filler tools.

    Completeness3/5

    The surface covers core read operations plus acknowledge, resolve, and note actions, which supports incident triage and response. However, it lacks create/update incident operations, assignment or priority changes, and write operations for schedules, teams, and services, leaving notable lifecycle gaps.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers