> 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/datadog.md).

# Datadog MCP server

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

The **Datadog** agentic integration lets agents behind the AI Gateway, part of [P0 Runtime Access for AI](https://docs.p0.dev/readme/agentic-control-plane.md), request permissions in your Datadog organization, such as `logs_read_data`. For each grant, P0's connector creates a service access token on a Datadog service account you choose. The token holds only the approved permissions, and the connector stores it in your Google Secret Manager. The gateway calls Datadog's hosted MCP server with that token. When access ends, P0 revokes the token in Datadog.

This is a different integration from the [Datadog setup](https://docs.p0.dev/integrations/siem-integrations/datadog-setup.md), which sends P0's audit logs to Datadog. Both appear as **Datadog** on the **Integrations** page.

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

Setup has four parts, in this order:

1. Install the Datadog organization in P0, which deploys P0's connector in a Google Cloud project.
2. Create a Datadog service account and give P0 an admin key pair.
3. Add the Datadog MCP server to your gateway.
4. Write the policies that decide which agents get which permissions.

## 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.<site>`, such as `https://mcp.datadoghq.com`, 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 Datadog user who can create service accounts and assign roles.

## Install the organization in P0

1. Navigate to **Integrations** on [p0.app](https://p0.app), select **Datadog**, and choose the **Credential provisioning** component.
2. Click **Add Organization**, and enter an identifier for it, such as `acme-prod`. Agents and policies use this name for the organization. Use letters, digits, and hyphens.
3. Fill in the organization details, then click **Next**:
   * **Datadog site**: the site whose domain is in your organization's Datadog URL, such as **US5 (us5.datadoghq.com)**.
   * **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-datadog-ai`, that runs P0's connector under its own service account, `p0-datadog`.
   * A secret for your Datadog admin keys, `p0_install_datadog_<identifier>_admin-keys`, 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_datadog_<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 Datadog organization in its own Google Cloud project. The Terraform for a second organization in the same project conflicts with the first.
{% endhint %}

## Set up Datadog

1. **Create a service account** for P0 in Datadog under **Organization Settings** > **Service Accounts**. Every token P0 creates belongs to this account.
2. **Give the service account a role** that holds only the permissions agents may request, including **MCP Read**, which every Datadog MCP tool needs. A token can hold no permission that this role lacks.
3. **Store an admin key pair.** Create a Datadog API key and an application key. The application key's user needs the **Service Account Write** permission. Set `DD_API_KEY` and `DD_APP_KEY` to them, and run the command P0 shows:

   ```bash
   printf '{"apiKey":"%s","appKey":"%s"}' "$DD_API_KEY" "$DD_APP_KEY" | \
     gcloud secrets versions add p0_install_datadog_<identifier>_admin-keys \
     --project=<project-id> --data-file=-
   ```

   P0 never sees the keys: only your connector reads them.
4. **Enter the Service account ID** of the service account in P0.
5. Review the summary and click **Finish**. The organization now appears with the state **Installed**.

## Add the Datadog MCP server

You can add the Datadog MCP server once at least one organization is installed. P0 offers one server per site, such as **Datadog (US5)**, and lists each one only when an organization on that site 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 the server for your organization's site.
2. The server now appears with the state **Installed**.

One Datadog MCP server serves every organization you install on its site. Each grant names the organization it is for.

## How agents request access

An agent requests access with the server's `access` tool. It names the organization by its P0 identifier, and one or more Datadog permissions by name. Every Datadog MCP tool needs `mcp_read`, so agents include it in every request, and your policies must allow it. The agent's `list` tool shows the installed organizations and the permissions it can request, which are the permissions your service account's role holds.

Once a request is approved, access usually works within 5 to 15 seconds, and can take up to a minute. Agents see every Datadog tool whether or not their permissions cover it. Datadog refuses a call that the token's permissions don't cover.

Each agent has one token per organization. A new grant in the same organization adds its permissions to that token, and when a grant ends, P0 removes its permissions. Each token appears on your service account in Datadog, named `P0` followed by the full name of the Google Cloud secret that holds it.

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

## Write policies for Datadog

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

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

Patterns are regular expressions, so a rule can match one permission (`^logs_read_data$`), every permission for one product (`^logs_.*$`), or every read permission (`^.*_read$`).

For example, auto-approve log and monitor reads for one agent, but only in the `acme-prod` organization:

```yaml
- requestor:
    type: agentic
    actor:
      type: agent-client
      clientId: reporting-agent
    subject:
      type: any
  resource:
    type: integration
    service: datadog-ai
    accessType: permission
    filters:
      organization:
        effect: keep
        key: name
        pattern: ^acme-prod$
      policy:
        effect: keep
        key: name
        pattern: ^(mcp_read|logs_read_data|monitors_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 Datadog access.
