
命令行
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.
cd pagerduty-mcp-server brew install uv uv sync
The PagerDuty MCP Server requires a PagerDuty API token. You can provide this in two ways:
Option 1: Environment Variable
export PAGERDUTY_API_TOKEN=your_api_token_here
Option 2: .env File (Recommended)
Create a .env
file in the project root:
echo "PAGERDUTY_API_TOKEN=your_api_token_here" > .env
The server will automatically load environment variables from the .env
file if present.
In Goose:
pagerduty-mcp-server
).uvx pagerduty-mcp-server
pagerduty: args: - pagerduty-mcp-server bundled: null cmd: uvx description: '' enabled: true env_keys: - PAGERDUTY_API_TOKEN envs: {} name: pagerduty timeout: 300 type: stdio
{ "mcpServers": { "pagerduty-mcp-server": { "command": "uvx", "args": ["pagerduty-mcp-server"], "env": { "PAGERDUTY_API_TOKEN": <PAGERDUTY_API_TOKEN> } } } }
uv run path/to/repo/pagerduty-mcp-server/.venv/bin/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 operationsMany 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 schedulesThe test suite includes both unit tests and integration tests. Integration tests require a real connection to the PagerDuty API, while unit tests can run without API access.
The pytest-cov
args are optional, use them to include a test coverage report in the output.
To run all tests (integration tests will be automatically skipped if PAGERDUTY_API_TOKEN
is not set):
uv run pytest [--cov=src --cov-report=term-missing]
To run only unit tests (no API token required):
uv run pytest -m unit [--cov=src --cov-report=term-missing]
To run only integration tests (requires PAGERDUTY_API_TOKEN
set in environment):
uv run pytest -m integration [--cov=src --cov-report=term-missing]
To run only parser tests:
uv run pytest -m parsers [--cov=src --cov-report=term-missing]
To run only tests related to a specific submodule:
uv run pytest -m <client|escalation_policies|...> [--cov=src --cov-report=term-missing]
npx @modelcontextprotocol/inspector uv run path/to/repo/pagerduty-mcp-server/.venv/bin/pagerduty-mcp-server
Tool Documentation - Detailed information about available tools including parameters, return types, and example queries