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 서버

LLM에 PagerDuty API 기능을 제공하는 서버입니다. 이 서버는 구조화된 입력 및 출력을 통해 프로그래밍 방식으로 사용하도록 설계되었습니다.

개요

PagerDuty MCP 서버는 PagerDuty API와 상호 작용하기 위한 도구 세트를 제공합니다. 이러한 도구는 LLM이 인시던트, 서비스, 팀, 사용자 등 PagerDuty 리소스에 대한 다양한 작업을 수행하는 데 사용하도록 설계되었습니다.

설치

PyPI에서

지엑스피1

출처에서

# 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_incidentsstatuses 의 경우 triggered , acknowledgedresolved 만 유효한 값입니다.
  • 사건의 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_contextTrue 이면 자동 필터링과 충돌할 수 있으므로 특정 필터 매개변수를 사용할 수 없습니다.

  • 모든 리소스 유형에 대해:
    • 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 Commit을 사용합니다. 커밋 메시지에 따라 버전 상향 조정이 결정됩니다.

  • 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 마커로 표시됩니다.
ID: tbaec6w11c