Skip to main content

MCP server for LLM agents to interact with PagerDuty SaaS

Project description

PagerDuty MCP Server

A server that exposes PagerDuty API functionality to LLMs. This server is designed to be used programmatically, with structured inputs and outputs.

PagerDuty Server MCP server

PyPI Downloads Python Versions GitHub Contributors PyPI version License

Overview

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.

Installation

From PyPI

pip install pagerduty-mcp-server

From Source

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

# Install dependencies
brew install uv
uv sync

Requirements

  • Python 3.13 or higher
  • PagerDuty API key

Configuration

The PagerDuty MCP Server requires a PagerDuty API key to be set in the environment:

PAGERDUTY_API_KEY=your_api_key_here

Usage

As Goose Extension

{
  "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"
}

As Standalone Server

uv run python -m pagerduty_mcp_server

Response Format

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
  }
}

Error Handling

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:

  • Invalid resource IDs (e.g., user_id, team_id, service_id)
  • Missing required parameters
  • Invalid parameter values
  • API request failures
  • Response processing errors

Parameter Validation

  • All ID parameters must be valid PagerDuty resource IDs
  • Date parameters must be valid ISO8601 timestamps
  • List parameters (e.g., statuses, team_ids) must contain valid values
  • Invalid values in list parameters will be ignored
  • Required parameters cannot be None or empty strings
  • For statuses in list_incidents, only triggered, acknowledged, and resolved are valid values
  • For urgency in incidents, only high and low are valid values
  • The limit parameter can be used to restrict the number of results returned by list operations

Rate Limiting and Pagination

  • The server respects PagerDuty's rate limits
  • The server automatically handles pagination for you
  • The limit parameter can be used to control the number of results returned by list operations
  • If no limit is specified, the server will return up to {pagerduty_mcp_server.utils.RESPONSE_LIMIT} results by default

Example Usage

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)

User Context

Many functions support automatic filtering based on the current user's context. When current_user_context=True (default), results are filtered to only show resources the current user has access to:

  • Incidents for teams the user belongs to
  • Services the user has access to
  • Teams the user belongs to
  • Escalation policies the user is part of

When using current_user_context=True (default), you cannot use user_ids, team_ids, or service_ids parameters as they would conflict with the automatic filtering.

Development

Running Tests

Note 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 python -m integration

To run only parser tests:

uv run python -m parsers

To run only tests related to a specific submodule:

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

Debug Server with MCP Inspector

npx @modelcontextprotocol/inspector uv run python -m pagerduty_mcp_server

Contributions

Releases

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.

Documentation

Tool Documentation - Detailed information about available tools including parameters, return types, and example queries

Conventions

  • All API responses follow the standard format with metadata, resource list, and optional error
  • Resource names in responses are always pluralized for consistency
  • All functions that return a single item still return a list with one element
  • Error responses include both a message and a code
  • All timestamps are in ISO8601 format
  • Tests are marked with pytest markers to indicate their type (unit/integration), the resource they test (incidents, teams, etc.), and whether they test parsing functionality ("parsers" marker)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pagerduty_mcp_server-2.2.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pagerduty_mcp_server-2.2.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file pagerduty_mcp_server-2.2.0.tar.gz.

File metadata

  • Download URL: pagerduty_mcp_server-2.2.0.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pagerduty_mcp_server-2.2.0.tar.gz
Algorithm Hash digest
SHA256 4c59bfbd980f6e616eb1f558999aca0f23bd30c2dd7e2cf80fb21b93351c8b59
MD5 c521e2ab33ae362e9adaeea19672d586
BLAKE2b-256 9d0e89e690c67aaf205c10c99d240f74cd789078ce2666c0992a6ad97fdd63db

See more details on using hashes here.

File details

Details for the file pagerduty_mcp_server-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pagerduty_mcp_server-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40d1a3d2167043b82a16a1c3e0d4ea187e68d45251abdd7b8d53b51f55796f73
MD5 3031a0a1f5643133821928fc6d7e0abe
BLAKE2b-256 65346fa87003b360c206468679624dd6b0e3bf64f3ce831138f0054784708bea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page