> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL as an MCP

> Let your AI agents use PostgreSQL in real time through the Nekt MCP Gateway.

PostgreSQL is a powerful, open-source object-relational database system. By connecting it to Nekt, your AI agent can query your live database, analyze results, and safely execute schema or data changes directly from chat.

| | Available |
| :- | :- |
| **Nekt Express** | Yes |
| **GCP** | Yes |
| **AWS** | Yes |

## Adding PostgreSQL as an MCP

Before you start, make sure the [MCP Server](/mcp-server/setup) is set up. See [MCPs](/mcps/overview) for how MCPs work.

1. Go to **Activate → [MCPs](https://app.nekt.ai/mcps)**, click **New MCP** and choose **PostgreSQL**.
2. **Name your MCP** and describe what it is used for. The agent reads the description to choose between MCPs of the same provider.
3. **Setup access**. Provide your connection credentials to allow the agent to connect to your database.
   * **Host** (Required): The host address of your Postgres database.
   * **Port** (Required): The port used for connecting to your Postgres database. The default port for Postgres is 5432, but your port might be different.
   * **Database** (Required): The name of a database in your Postgres account.
   * **User** (Required): The user name for accessing your Postgres database. Read-only tools are always run inside a READ ONLY transaction, so a user with write access is only able to write through the write tool.
   * **Password** (Required): The password used for accessing your Postgres database.
   * **Enable SSL**: Whether or not to use SSL to verify the server's identity.
   * **SSL Mode**: SSL protection method.
   * **SSH Tunnel**: SSH Tunnel to be used in your database connection
4. **Select tools**. Pick the tools your agents can use. See [Available tools](#available-tools) below.
5. Click **Save**. On Growth and Custom plans, choose who can use it; see [Access levels](/mcps/overview#access-levels).

## Example prompts

* "Count the number of new user signups we had in our database over the last 30 days."
* "Update the status of order #84920 to 'shipped' in the orders table."
* "Create a new table called 'marketing\_campaigns' with columns for id, name, budget, and start date."
* "Show me the top 5 most expensive products currently in our inventory."

## Available tools

Choose which of these tools your agents can use in **Select tools**.

### Read tools

| Tool | Description | Parameters |
| :- | :- | :- |
| `execute_read_only_sql` | Run one read-only SQL statement against the PostgreSQL database and return the rows. Accepts a single SELECT, WITH, EXPLAIN, SHOW, TABLE or VALUES statement — it runs inside a READ ONLY transaction, so it can never change data or schema even if the connection user has write acce… | `sql` (string, required), `row_limit` (integer), `parameters` (array), `statement_timeout_seconds` (integer) |

### Write tools

| Tool | Description | Parameters |
| :- | :- | :- |
| `execute_write_sql` | Run a SQL statement that changes the PostgreSQL database (INSERT, UPDATE, DELETE, DDL, ...). The statement runs in a transaction that is committed on success and rolled back on error. Rows are returned when the statement produces a result set (for example INSERT ... RETURNING),… | `sql` (string, required), `row_limit` (integer), `parameters` (array), `statement_timeout_seconds` (integer) |

## Troubleshooting

If your database password changes or your user access is revoked, the MCP will show that it needs to reconnect. You can update your credentials and reconnect directly from the MCP's page.

If the agent fails to read or write data, verify that the configured PostgreSQL **User** has the necessary permissions (such as `SELECT`, `INSERT`, `UPDATE`, or `DELETE`) for the specific tables the agent is trying to access.

## Need help?

Contact our support team if you have trouble connecting PostgreSQL.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.