> 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/gitguardian.md). Agents can also search and read this documentation through its [MCP server](https://docs.p0.dev/~gitbook/mcp).

# GitGuardian MCP server

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

The **GitGuardian** 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 scopes in your GitGuardian workspace, such as `incidents:read`. For each agent, P0's connector creates a GitGuardian API token that holds only the approved scopes, and stores it in your secret manager. The gateway calls GitGuardian's hosted MCP server with that token. When access ends, P0 revokes the token in GitGuardian.

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

Setup has four parts, in this order:

1. Create a connector member in GitGuardian and its admin token.
2. Install the workspace in P0, which deploys P0's connector in AWS or Google Cloud, and store the admin token.
3. Add the GitGuardian 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 your secret manager and GitGuardian's MCP server: `https://mcp.gitguardian.com` for a US workspace, or `https://mcp.eu1.gitguardian.com` for an EU workspace.
* One of these, with permission to apply Terraform where it's installed. P0's connector runs there, and grant tokens are stored there.
  * On AWS:
    * The [AWS Secrets Manager](https://docs.p0.dev/integrations/resource-integrations/aws-secrets-manager.md) integration installed on an AWS account. The connector runs there on AWS Lambda. Applying its Terraform also needs Docker and the AWS CLI, signed in to that account, to copy P0's connector image into your Amazon ECR.
    * [AWS OIDC](https://docs.p0.dev/agentic-access/credential-sources/aws-oidc.md) installed for that same account. The gateway uses it to read each grant's token.
  * On Google Cloud:
    * 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. The connector runs there on Cloud Run.
    * [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 GitGuardian workspace, and a GitGuardian admin who can invite members.

## Set up GitGuardian

1. **Create a connector member** for P0. Invite a new member to the workspace with the **Member** access level, and use it for P0 only. A shared team mailbox works well for its email address. On a paid plan, you can use a service account instead.
2. **Create the admin token.** Signed in as the connector member, go to **API** > **Personal access tokens** and create a token with every scope you can select, and no expiry. P0 uses it only to create and revoke the agents' tokens, and needs `api_tokens:read` and `api_tokens:write` at least. Keep the token for the install below.
3. **Note the workspace ID.** It is the number in your GitGuardian dashboard URL, such as `123456` in `https://dashboard.gitguardian.com/workspace/123456/`.

Every agent token belongs to the connector member, so GitGuardian shows every agent's action as that member. On the free plan, the connector member also takes a seat.

## Install the workspace in P0

1. Navigate to **Integrations** on [p0.app](https://p0.app), select **GitGuardian**, and choose the **Credential provisioning** component.
2. Click **Add Workspace**, and enter the workspace ID. Agents and policies use this ID for the workspace.
3. Fill in the workspace details, then click **Next**:
   * **Region**: **US** for `dashboard.gitguardian.com`, or **EU** for `dashboard.eu1.gitguardian.com`.
   * **Secret manager provider**: choose where the connector will run.
     * **AWS Secrets Manager**: choose the installation for the AWS account, and enter the region that stores the secrets.
     * **Google Secret Manager**: choose the installation for the project.
4. P0 generates a Terraform configuration. Copy it into your Terraform project and `apply` it.

   On AWS, the configuration creates:

   * An Amazon ECR repository with a copy of P0's connector image, and a Lambda function, `p0-connector-gitguardian-ai-aws`, that runs it with its own IAM role.
   * A secret for the admin token, `p0/install/gitguardian/<workspace-id>/admin-token`, 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/gitguardian/<workspace-id>/`, and the connector can touch no other secret.
   * A policy on P0's IAM role in the account that lets P0 invoke the function.

   On Google Cloud, it creates:

   * A Cloud Run service, `p0-connector-gitguardian-ai`, that runs P0's connector under its own service account, `p0-gitguardian`.
   * A secret for the admin token, `p0_install_gitguardian_<workspace-id>_admin-token`, 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_gitguardian_<workspace-id>_`, 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.
5. **Store the admin token.** Set `GITGUARDIAN_ADMIN_TOKEN` to it, and run the command P0 shows. On AWS:

   ```bash
   printf '%s' "$GITGUARDIAN_ADMIN_TOKEN" | \
     aws secretsmanager put-secret-value \
     --secret-id p0/install/gitguardian/<workspace-id>/admin-token \
     --region <secrets-region> --secret-string file:///dev/stdin
   ```

   On Google Cloud:

   ```bash
   printf '%s' "$GITGUARDIAN_ADMIN_TOKEN" | \
     gcloud secrets versions add p0_install_gitguardian_<workspace-id>_admin-token \
     --project=<project-id> --data-file=-
   ```

   P0 never sees the token: only your connector reads it. Then click **Next**.

   P0 checks that the connector is deployed. A new connector can take a minute to start. If the check fails, wait a minute and click **Next** again.
6. Review the summary and click **Finish**. P0 has the connector check the admin token: GitGuardian accepts it in the workspace's region, it is active, it belongs to this workspace, and it holds `api_tokens:read` and `api_tokens:write`. If a check fails, the message says what to fix. The workspace then appears with the state **Installed**.

To rotate the admin token, create a new one as the connector member, store it with the same command, and then revoke the old one in GitGuardian.

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

## Add the GitGuardian MCP server

You can add the GitGuardian MCP server once at least one workspace is installed. P0 offers one server per region, **GitGuardian (US)** and **GitGuardian (EU)**, and lists each one only when a workspace 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 the server for your workspace's region.
2. The server now appears with the state **Installed**.

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

## How agents request access

An agent requests access with the server's `access` tool. It names the workspace by its ID, and one or more of these scopes:

| Scope             | What the agent can do                                                                                                                                                      |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scan`            | Scan content for secrets, and list GitGuardian's detectors.                                                                                                                |
| `incidents:read`  | Read secret incidents, their occurrences, comments, and activity, and the remediation steps for an incident.                                                               |
| `incidents:write` | Update, assign, resolve, and comment on incidents, and open pull requests in your repositories that fix a leaked secret. GitGuardian also grants `incidents:read` with it. |
| `sources:read`    | Read the repositories and other sources that GitGuardian monitors.                                                                                                         |
| `members:read`    | Read the workspace's members.                                                                                                                                              |

The agent's `list` tool shows the installed workspaces and these scopes. A person can request the same access with the P0 CLI:

```bash
p0 request gitguardian-ai permission <workspace-id> <scope>... --reason "<reason>"
```

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

Each agent has one token per workspace. A new grant in the same workspace adds its scopes, and when a grant ends, P0 removes its scopes. Each change replaces the token with a new one. In GitGuardian, the agents' tokens appear among the connector member's personal access tokens, named `P0` followed by a hash and a timestamp. A token expires when the longest grant it serves ends, rounded up to a whole day, or after 365 days for a grant with no end.

### Token limit

GitGuardian allows each member 5 active personal access tokens, and the admin token is one of them. So up to 4 agents can hold access in a workspace at once. When all 5 are in use, a new request fails with this message:

```
GitGuardian workspace <workspace-id> has no free API token slots. Its connector member already holds the most tokens GitGuardian allows. Try again when another grant ends, or ask a GitGuardian admin to revoke unused tokens of that member.
```

### Ending access

When an agent's last grant in a workspace ends, P0 revokes its token in GitGuardian and deletes its secret. The token stops working at once. An agent can also end its own access early with the MCP server's `revoke_current_token` tool. It then needs a new request to regain access.

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 GitGuardian

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

* `workspace`: the workspace, keyed on `id`, the workspace ID.
* `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 (`^scan$`), or every read scope (`^.*:read$`).

For example, auto-approve reading incidents and sources for one agent, but only in workspace `123456`. A request for `incidents:write` doesn't match, so it goes to a person for approval under your other rules:

```yaml
- requestor:
    type: agentic
    actor:
      type: agent-client
      clientId: triage-agent
    subject:
      type: any
  resource:
    type: integration
    service: gitguardian-ai
    accessType: permission
    filters:
      workspace:
        effect: keep
        key: id
        pattern: ^123456$
      policy:
        effect: keep
        key: name
        pattern: ^(incidents:read|sources: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 GitGuardian access.
