PagerDuty集成
STDIO为LLM提供PagerDuty API功能服务
为LLM提供PagerDuty API功能服务
A server that exposes PagerDuty API functionality to LLMs. This server is designed to be used programmatically, with structured inputs and outputs.
The PagerDuty MCP Server provides a set of tools for interacting with the PagerDuty API. These tools are designed to be used by LLMs to perform various operations on PagerDuty resources such as incidents, services, teams, and users.
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
The PagerDuty MCP Server requires a PagerDuty API key to be set in the environment:
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
All API responses follow a consistent format:
{ "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 } }
When an error occurs, the response will include an error object with the following structure:
{ "metadata": { "count": 0, "description": "Error occurred while processing request" }, "error": { "message": "Invalid user ID provided", "code": "INVALID_USER_ID" } }
Common error scenarios include:
statuses
, team_ids
) must contain valid valuesNone
or empty stringsstatuses
in list_incidents
, only triggered
, acknowledged
, and resolved
are valid valuesurgency
in incidents, only high
and low
are valid valueslimit
parameter can be used to restrict the number of results returned by list operationslimit
parameter can be used to control the number of results returned by list operationsfrom 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)
Many functions accept a current_user_context
parameter (defaults to True
) which automatically filters results based on this context. When current_user_context
is True
, you cannot use certain filter parameters as they would conflict with the automatic filtering:
user_ids
cannot be used with current_user_context=True
team_ids
and service_ids
cannot be used with current_user_context=True
team_ids
cannot be used with current_user_context=True
team_ids
cannot be used with current_user_context=True
user_ids
cannot be used with current_user_context=True
schedule_ids
can still be used to filter by specific schedulesNote that most tests require a real connection to PagerDuty API, so you'll need to set PAGERDUTY_API_KEY
in the environment before running the full test suite.
uv run pytest
To run only unit tests (i.e. tests that don't require PAGERDUTY_API_KEY
set in the environment):
uv run pytest -m unit
To run only integration tests:
uv run pytest -m integration
To run only parser tests:
uv run pytest -m parsers
To run only tests related to a specific submodule:
uv run pytest -m <client|escalation_policies|...>
npx @modelcontextprotocol/inspector uv run python -m pagerduty_mcp_server
This project uses Conventional Commits for automated releases. Commit messages determine version bumps:
feat:
→ minor version (1.0.0 → 1.1.0)fix:
→ patch version (1.0.0 → 1.0.1)BREAKING CHANGE:
→ major version (1.0.0 → 2.0.0)The CHANGELOG.md, GitHub releases, and PyPI packages are updated automatically.
Tool Documentation - Detailed information about available tools including parameters, return types, and example queries