# PostgreSQL — Pipedream Connect

> PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.

- API slug: `postgresql` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Databases
- Website: https://www.postgresql.org/
- This page (HTML): https://pipedream.com/apps/postgresql
- Tools: 9 actions · 5 triggers

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: postgresql`

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "postgresql",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// e.g. run Execute SQL Query:
const result = await mcp.callTool({
  name: "postgresql-execute-custom-query",
  arguments: {
    sql: "PostgreSQL Query",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## SDK

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "postgresql-execute-custom-query",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    postgresql: { authProvisionId: "apn_xxxxxxx" },
    sql: "PostgreSQL Query",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (9)

### `postgresql-execute-custom-query` — Execute SQL Query (Write)

Execute a custom PostgreSQL query. See our docs to learn more about working with SQL in Pipedream.

Full schema: https://pipedream.com/apps/postgresql/actions/execute-custom-query.md

### `postgresql-delete-rows` — Delete Row(s) (Write)

Deletes a row or rows from a table. See the documentation

Full schema: https://pipedream.com/apps/postgresql/actions/delete-rows.md

### `postgresql-find-row` — Find Row (Read-only)

Finds a row in a table via a lookup column. See the documentation

Full schema: https://pipedream.com/apps/postgresql/actions/find-row.md

### `postgresql-find-row-custom-query` — Find Row With Custom Query (Read-only)

Finds a row in a table via a custom query. See the documentation

Full schema: https://pipedream.com/apps/postgresql/actions/find-row-custom-query.md

### `postgresql-insert-row` — Insert Row (Write)

Adds a new row. See the documentation

Full schema: https://pipedream.com/apps/postgresql/actions/insert-row.md

### `postgresql-list-schema-options` — List Schema Options (Read-only)

Retrieves available options for the Schema field.

Full schema: https://pipedream.com/apps/postgresql/actions/list-schema-options.md

### `database-query-sql-database` — Query SQL Database (Write)

Execute a SQL Query. See our docs to learn more about working with SQL in Pipedream.

Full schema: https://pipedream.com/apps/postgresql/actions/database-query-sql-database.md

### `postgresql-update-row` — Update Row (Write)

Updates an existing row. See the documentation

Full schema: https://pipedream.com/apps/postgresql/actions/update-row.md

### `postgresql-upsert-row` — Upsert Row (Write)

Adds a new row or updates an existing row. See the documentation

Full schema: https://pipedream.com/apps/postgresql/actions/upsert-row.md

## Triggers (5)

### `postgresql-new-column` — New Column (Polling)

Emit new event when a new column is added to a table. See the documentation

Full schema: https://pipedream.com/apps/postgresql/triggers/new-column.md

### `postgresql-new-or-updated-row` — New or Updated Row (Polling)

Emit new event when a row is added or modified. See the documentation

Full schema: https://pipedream.com/apps/postgresql/triggers/new-or-updated-row.md

### `postgresql-new-row` — New Row (Polling)

Emit new event when a new row is added to a table. See the documentation

Full schema: https://pipedream.com/apps/postgresql/triggers/new-row.md

### `postgresql-new-row-custom-query` — New Row Custom Query (Polling)

Emit new event when new rows are returned from a custom query that you provide. See the documentation

Full schema: https://pipedream.com/apps/postgresql/triggers/new-row-custom-query.md

### `postgresql-new-table` — New Table (Polling)

Emit new event when a new table is added to the database. See the documentation

Full schema: https://pipedream.com/apps/postgresql/triggers/new-table.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
