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

# PostgreSQL on AWS RDS

Install the predefined PostgreSQL on AWS RDS MCP server behind the P0 AI Gateway, so agents can query RDS PostgreSQL databases with a just-in-time database role.

The **PostgreSQL on AWS RDS** MCP server lets agents inspect and query PostgreSQL databases hosted on Amazon RDS. It runs [Postgres MCP](https://github.com/crystaldba/postgres-mcp) by Crystal DBA inside the AI Gateway, part of [P0 Runtime Access for AI](https://docs.p0.dev/readme/agentic-control-plane.md). To see the tools it offers, follow that link.

An agent never holds a database password. It requests a PostgreSQL role on one database in an installed instance, the same way a person does in [Requesting PostgreSQL access](https://docs.p0.dev/integrations/resource-integrations/postgresql/requesting-postgresql-access.md). Once the request is approved, the gateway signs in to the database with a short-lived RDS IAM token for that role. The role's own grants decide what the agent can read or change.

## Prerequisites

* A registered [Gateway](https://docs.p0.dev/agentic-access/agentic-gateway/gateway.md) component, with the gateway deployed in your environment.
* The [AWS OIDC](https://docs.p0.dev/agentic-access/credential-sources/aws-oidc.md) component installed on the AWS account that hosts the instances.
* Each RDS instance installed in the P0 PostgreSQL integration, as in [Installing an RDS instance](https://docs.p0.dev/integrations/resource-integrations/postgresql/installing-an-rds-database.md), with IAM authentication turned on.
* Network access from the gateway to each instance's hostname and port.

## Configure the PostgreSQL on AWS RDS MCP server

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.
2. On the configuration screen, set these fields:
   * **Credential source**: choose **AWS IAM federation**, then select the **Federation provider**. This is the [AWS OIDC](https://docs.p0.dev/agentic-access/credential-sources/aws-oidc.md) identity for the account that hosts your instances.
   * **Definition**: choose **P0**, then select **PostgreSQL on AWS RDS**.
3. Click **Finish**. The server now appears with the state **Installed**.

One server covers every installed PostgreSQL instance in that AWS account. The agent names the instance on each call. To reach instances in another AWS account, add a second server with that account's AWS OIDC identity.

## Next steps

* Define the [Agentic access policies](https://docs.p0.dev/agentic-access/agentic-access-policies.md) that decide which agents and users may request PostgreSQL roles through this server.
