PagerDuty MCP Server

by wpfleger96
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides tools for interacting with the PagerDuty API, enabling operations on incidents, services, teams, and users. Supports listing, filtering, and managing PagerDuty resources with automatic context-based filtering.

PagerDuty MCP サーバー

PagerDuty API機能をLLMに公開するサーバー。このサーバーは、構造化された入出力を用いてプログラム的に使用できるように設計されています。

概要

PagerDuty MCPサーバーは、PagerDuty APIと連携するためのツールセットを提供します。これらのツールは、LLMがインシデント、サービス、チーム、ユーザーなどのPagerDutyリソースに対してさまざまな操作を実行するために使用できるように設計されています。

インストール

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タイムスタンプである必要があります
  • リストパラメータ(例: statusesteam_ids )には有効な値が含まれている必要があります
  • リストパラメータ内の無効な値は無視されます
  • 必須パラメータはNoneまたは空の文字列にすることはできません
  • list_incidentsstatusesの場合、有効な値はtriggeredacknowledgedresolvedのみです。
  • インシデントのurgencyについては、 highlowのみが有効値です
  • 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の場合、自動フィルタリングと競合するため、特定のフィルタパラメータは使用current_user_contextません。

  • すべてのリソース タイプの場合:
    • user_ids``current_user_context=Trueでは使用できません
  • インシデントの場合:
    • team_idsservice_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

貢献

リリース

このプロジェクトでは、自動リリースにConventional Commitsを使用しています。コミットメッセージによってバージョンアップが決定されます。

  • 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レスポンスは、メタデータ、リソースリスト、およびオプションのエラーを含む標準形式に従います。
  • 応答内のリソース名は一貫性を保つために常に複数形になります
  • 単一の項目を返すすべての関数は、1つの要素を持つリストを返します。
  • エラー応答にはメッセージとコードの両方が含まれます
  • すべてのタイムスタンプはISO8601形式です
  • テストには、そのタイプ(ユニット/統合)、テスト対象のリソース(インシデント、チームなど)、解析機能をテストするかどうか(「パーサー」マーカー)を示す pytest マーカーが付けられます。

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

構造化された入力と出力を使用して PagerDuty API 機能を LLM に公開し、インシデント、サービス、チーム、およびユーザーの管理を可能にするサーバー。

  1. Overview
    1. Installation
      1. From PyPI
      2. From Source
    2. Requirements
      1. Configuration
        1. Usage
          1. As Goose Extension
          2. As Standalone Server
        2. Response Format
          1. Error Handling
          2. Parameter Validation
          3. Rate Limiting and Pagination
          4. Example Usage
        3. User Context
          1. Development
            1. Running Tests
            2. Debug Server with MCP Inspector
          2. Contributions
            1. Releases
            2. Documentation
            3. Conventions
          ID: tbaec6w11c