> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/agentic-access/agentic-gateway/mcp-server/pagerduty.md).

# PagerDuty MCP server

Install the PagerDuty integration and its MCP server so agents behind the P0 AI Gateway can request scoped access to your PagerDuty account.

The **PagerDuty** integration lets agents behind the [AI Gateway](https://docs.p0.dev/agentic-access/agentic-gateway.md) request OAuth scopes in your PagerDuty account, such as `incidents.read`. For each grant, P0's connector gets a PagerDuty token that holds only the approved scopes and stores it in your Google Secret Manager. The gateway calls PagerDuty's hosted MCP server with that token. The token acts as your PagerDuty app, not as a PagerDuty user.

{% hint style="info" %}
The PagerDuty integration is in preview. Functionality and configuration may change.
{% endhint %}

Setup has four parts, in this order:

1. Install the PagerDuty account in P0, which deploys P0's connector in a Google Cloud project.
2. Create a Scoped OAuth app in PagerDuty and give P0 its credentials.
3. Add the PagerDuty MCP server to your gateway.
4. Write the policies that decide which agents get which scopes.

## Prerequisites

* A registered [Gateway](https://docs.p0.dev/agentic-access/agentic-gateway/gateway.md) component, with the gateway deployed in your environment. The gateway must be able to reach `https://mcp.pagerduty.com` (US accounts) or `https://mcp.eu.pagerduty.com` (EU accounts), and Google Secret Manager.
* The [Google Cloud](https://docs.p0.dev/integrations/resource-integrations/google-cloud.md) integration installed for your Google Cloud organization.
* The [Google Secret Manager](https://docs.p0.dev/integrations/resource-integrations/google-secret-manager.md) integration installed on the Google Cloud project where the connector will run, and permission to apply Terraform in that project.
* [GCP Workload Identity Federation](https://docs.p0.dev/agentic-access/credential-sources/gcp-wif.md) installed for that same project. The gateway uses it to read each grant's token.
* A PagerDuty user who can register apps under **Integrations** > **App Registration**.

## Install the account in P0

1. Navigate to **Integrations** on [p0.app](https://p0.app), select **PagerDuty**, and choose the **Credential provisioning** component.
2. Click **Add Account**, and enter an identifier for it, such as `acme-prod`. Agents and policies use this name for the account. Use letters, digits, and hyphens.
3. Fill in the account details, then click **Next**:
   * **PagerDuty region**: **US** or **EU**, the region that hosts the account.
   * **Account subdomain**: the subdomain in the account's URL, such as `acme` in `acme.pagerduty.com` or `acme.eu.pagerduty.com`. Use lowercase letters, digits, and hyphens.
   * **Secret manager provider**: choose **Google Secret Manager**, then the **Installation** for the project where the connector will run.
4. P0 generates a Terraform configuration. Copy it into your Terraform project, `apply` it, then click **Next**.

   The configuration creates:

   * A Cloud Run service, `p0-connector-pagerduty-ai`, that runs P0's connector under its own service account, `p0-pagerduty`.
   * A secret for the PagerDuty app's client secret, `p0_install_pagerduty_<identifier>_client-secret`, which only the connector can read.
   * Permission for the connector to create and manage the secrets that hold grant tokens. Their names start with `p0_access-token_pagerduty_<identifier>_`, and the connector can touch no other secret.
   * Bindings that let P0's Google Cloud service account call the connector and read its URL. The connector accepts calls from that service account only.
   * The Cloud Run, Secret Manager, IAM, and Resource Manager APIs, turned on in the project.

   When you click **Next**, P0 checks that the connector is deployed. A new Cloud Run service can take a minute to start. If the check fails, wait a minute and click **Next** again.

{% hint style="warning" %}
Install each PagerDuty account in its own Google Cloud project. The Terraform for a second account in the same project conflicts with the first.
{% endhint %}

## Create the PagerDuty app

1. **Register an app** in PagerDuty under **Integrations** > **App Registration**. Give it OAuth 2.0 functionality of type **Scoped OAuth**.
2. **Choose the app's scopes.** Give it only the scopes that agents may request, plus `users.read`, which the PagerDuty MCP server requires. A token can hold no scope that the app lacks.
3. **Store the client secret.** Set `PD_CLIENT_SECRET` to the app's client secret, and run the command P0 shows:

   ```bash
   printf '%s' "$PD_CLIENT_SECRET" | gcloud secrets versions add \
     p0_install_pagerduty_<identifier>_client-secret \
     --project=<project-id> --data-file=-
   ```

   P0 never sees the client secret: only your connector reads it.
4. **Enter the Client ID** of the app in P0.
5. Review the summary and click **Finish**. The account now appears with the state **Installed**.

## Add the PagerDuty MCP server

You can add the PagerDuty MCP server once at least one account is installed. P0 offers one server per region, **PagerDuty (US)** and **PagerDuty (EU)**, and lists each one only when an account in that region is installed.

1. Follow the shared steps in [MCP server](https://docs.p0.dev/agentic-access/agentic-gateway/mcp-server.md#add-an-mcp-server) to name the server and choose its gateway. On the configuration screen, set the following fields, then click **Finish**:
   * **Credential source**: choose **Vaulted credential**.
   * **Definition**: choose **P0**, then select **PagerDuty (US)** or **PagerDuty (EU)**.
2. The server now appears with the state **Installed**.

One PagerDuty MCP server serves every account you install in its region. Each grant names the account it is for.

## How agents request access

An agent requests access with the server's `access` tool. It names the account by its P0 identifier, and one or more PagerDuty scopes. P0 adds `users.read` to every token. The agent's `list` tool shows the installed accounts and every scope that PagerDuty's MCP server supports, including scopes your app may not hold.

Once a request is approved, access usually works within 5 seconds, and can take up to 30 seconds. Agents see every PagerDuty tool whether or not their scopes cover it. PagerDuty refuses a call that the token's scopes don't cover. Tools that need a current user, such as looking up the calling user, fail, because the token acts as the app.

A request fails if the PagerDuty app doesn't hold every requested scope. The error names the missing scopes.

See [Requesting access](https://docs.p0.dev/agentic-access/using-the-gateway/requesting-access.md) for how agents submit and use requests.

{% hint style="info" %}
When access ends, P0 deletes the secret that holds the token, so the gateway can no longer use it. PagerDuty can't revoke a single app token, so a token that was already issued stays valid until it expires, one day after it was issued.
{% endhint %}

## Write policies for PagerDuty

Match PagerDuty requests in an [Agentic access policies](https://docs.p0.dev/agentic-access/agentic-access-policies.md) with `service: pagerduty-ai` and `accessType: permission`. Two filters narrow them:

* `account`: the account, keyed on `name`, the identifier you gave the account in P0.
* `policy`: the scope, keyed on `name`. A rule covers a request only if it matches every scope in it.

Patterns are regular expressions, so a rule can match one scope (`^incidents\.read$`), every scope for one resource (`^incidents\..*$`), or every read scope (`^.*\.read$`).

For example, auto-approve read-only scopes for one agent, but only in the `acme-prod` account:

```yaml
- requestor:
    type: agentic
    actor:
      type: agent-client
      clientId: oncall-agent
    subject:
      type: any
  resource:
    type: integration
    service: pagerduty-ai
    accessType: permission
    filters:
      account:
        effect: keep
        key: name
        pattern: ^acme-prod$
      policy:
        effect: keep
        key: name
        pattern: ^.*\.read$
  approval:
    - type: persistent
```

## Next steps

* Define the [Agentic access policies](https://docs.p0.dev/agentic-access/agentic-access-policies.md) that determine which agents and users may request PagerDuty access.
