MetorialDocs

Set up PostgreSQL in Metorial for Claude, ChatGPT and Cursor

Share PostgreSQL with your team in Claude, ChatGPT and Cursor through Metorial: connection parameters or connection string sign-in, 13 tools (4 read-only).

To give your team PostgreSQL in Claude, ChatGPT, Cursor and other AI clients, an admin shares the PostgreSQL integration in a Metorial portal, and each person connects with connection parameters. Agents can query, insert, update, and delete data in PostgreSQL relational databases. The integration has 13 tools, 4 read-only, 2 write and 7 destructive, plus 2 triggers.

What you'll learn

  • How an admin shares PostgreSQL in a portal and how each person connects
  • What PostgreSQL asks for when you connect, and where to find it
  • How to keep the 4 read-only tools and reject the other 9

Before you start

Sign-in methods

MethodTypeWhat a person provides
Connection Parameters (default)Custom credentialshost, port, database, username, password and sslMode
Connection StringCustom credentialsconnectionString

The portal and metorial setup use Connection Parameters unless someone picks another method.

Connection Parameters

To connect, a person enters these values:

  • host: PostgreSQL server hostname or IP address
  • port (optional): PostgreSQL server port (default: 5432)
  • database: Target database name
  • username: Database username
  • password: Database password
  • sslMode (optional): SSL connection mode One of "disable", "require", "verify-ca", "verify-full".

Connection String

To connect, a person enters:

  • connectionString: PostgreSQL connection URI (e.g., postgresql://user:password@host:5432/dbname?sslmode=require)

Setup settings

Whichever method you pick, setup also asks for:

  • defaultSchema (optional): Default schema to use for queries when not explicitly specified
  • queryTimeout (optional): Query timeout in milliseconds
  • maxRows (optional): Maximum number of rows to return from queries by default

Admin: share PostgreSQL in a portal

In the dashboard

Open Shared Resources

Open Workforce, choose the portal, and select Shared Resources under Access.

Share a new integration

Select Share a Resource, then New Integration, and choose PostgreSQL. Under Auth Method, keep Connection Parameters or pick another. For how members connect, choose Each person connects so everyone enters their own connection parameters, or Shared connection to enter the connection parameters once for everyone.

Limit the tools

Under Tool Filters, set the write and destructive groups to Reject if agents should only read from PostgreSQL.

Choose who gets it

Add the access groups that should see PostgreSQL. When a person asks for access from the portal, the request appears under Access Requests.

With the CLI

The CLI cannot create the per-user PostgreSQL integration. Once it exists, check which groups have it:

metorial-admin portals access list <portal-id> --type provider_template --search postgresql

Employee: connect PostgreSQL

In the portal

Open PostgreSQL in the catalog

Sign in to your portal and open PostgreSQL. The status reads Available.

Authenticate

Under Quick setup, select Authenticate. In the setup window, enter your connection parameters (host, database, username and password).

Confirm

The status changes to Configured. If it later reads Needs reconnect, select Reconnect and sign in again.

With the CLI

metorial catalog search postgresql
metorial setup <catalog-item-id>

catalog search prints the catalog item ID. metorial setup uses Connection Parameters. To connect with Connection String instead, find its ID with metorial catalog get <catalog-item-id> and add --auth-method <auth-method-id>.

Add it to your AI client

metorial install adds your PostgreSQL connection to a local MCP client such as Claude Code, Cursor or Codex. metorial list prints the integration ID and metorial client list the client identifiers.

metorial list postgresql
metorial client list
metorial install <client-identifier> <integration-id>

For a client that takes a server URL, such as ChatGPT, metorial install custom <integration-id> creates an installation token and shows the endpoint details.

Make it read-only

Open the integration's Tool Filters and set the write and destructive groups to Reject. Agents keep the 4 read-only tools, such as list_tables and list_schemas, and lose the 2 write tools, such as insert_rows or execute_query, and the 7 destructive tools, such as delete_rows or update_rows.

Employees see the result on the integration's page in the portal under Tool access. For the full walkthrough, see Tool permissions.

Check it worked

metorial list postgresql
metorial tools <integration-id>
metorial call <integration-id> list_tables -d '{}'

metorial tools lists the 13 tools, minus any you rejected. list_tables takes no input. It lists all tables in the PostgreSQL database, optionally filtered by schema.

To see every input a tool takes, run metorial schema <integration-id> <tool-key>.

Tools

Read-only tools (4)

  • list_tables: List all tables in the PostgreSQL database, optionally filtered by schema.
  • list_schemas: List all schemas in the PostgreSQL database with their table counts and sizes.
  • describe_table: Get detailed schema information for a specific table, including columns, data types, constraints, indexes, and foreign keys. Needs tableName.
  • select_query: Run a read-only SELECT query against the PostgreSQL database. Needs sql.

Write tools (2)

  • insert_rows: Insert one or more rows into a PostgreSQL table. Needs tableName and rows.
  • execute_query: Execute an arbitrary SQL query against the PostgreSQL database. Needs sql.

Destructive tools (7)

  • delete_rows: Delete rows from a PostgreSQL table based on a WHERE condition. Needs tableName.
  • manage_table: Create, alter, or drop a PostgreSQL table. Needs action and tableName.
  • manage_roles: Manage PostgreSQL roles and their privileges. Needs action.
  • manage_indexes: Create or drop indexes on PostgreSQL tables. Needs action and indexName.
  • update_rows: Update rows in a PostgreSQL table based on a WHERE condition. Needs tableName and set.
  • manage_schemas: Create, rename, or drop PostgreSQL schemas. Needs action and schemaName.
  • manage_views: Create and drop PostgreSQL views or materialized views, and refresh materialized views. Needs action and viewName.

Triggers

PostgreSQL has 2 triggers, which fire on events in PostgreSQL:

  • table_row_changes: Polls a PostgreSQL table for new or updated rows based on a timestamp or auto-incrementing column.
  • inbound_webhook

Next steps