Last tested 2026-11-23 against PostgreSQL 18.3
Connect PostgreSQL to Claude, read-only, without pasting a password
Add Portward to Claude, connect with a login that can only read, and tick the columns your AI never gets. Your AI writes the SQL; Portward runs it read-only and shows you a receipt of what it got.
01The login
Create a read-only role first
Portward refuses a superuser or administrator login. A login that can write is accepted with a warning, but this one is better.
-- Run as an administrator. Replace the names in angle brackets. CREATE ROLE claude_ro WITH LOGIN PASSWORD '<a new password>'; GRANT CONNECT ON DATABASE <your_db> TO claude_ro; GRANT USAGE ON SCHEMA <your_schema> TO claude_ro; GRANT SELECT ON ALL TABLES IN SCHEMA <your_schema> TO claude_ro; -- Portward reads the tables in the login's current schema: ALTER ROLE claude_ro SET search_path = <your_schema>; -- Tables the owner creates later: ALTER DEFAULT PRIVILEGES FOR ROLE <table_owner> IN SCHEMA <your_schema> GRANT SELECT ON TABLES TO claude_ro;
- To keep a column out at the database too, grant columns instead of tables:
GRANT SELECT (id, region, total) ON orders TO claude_ro; - Refused as administrators: a superuser, and a login in
rds_superuser,azure_pg_admin,cloudsqlsuperuser,alloydbsuperuser,pg_write_all_dataorpg_database_owner. On a managed service, that is the admin user the service gave you.
02Add the connector
Add the connector and connect
Add Portward
In Claude, open Customize, then Connectors, select + Add, then Add custom connector, and paste:
https://mcp.portward.ai/mcpConnect Postgres
You connect it once, in Portward, and its secret never goes through the chat. The setup page asks for this: Give the host, port, database, claude_ro and its password. The database must be reachable from the internet and present a TLS certificate that Portward checks in full (verify-full): one from a public certificate authority, or Amazon RDS's or Supabase's own authority on their hosts.
Choose what your AI never gets
Tick the columns to keep from your AI. Ones whose names look personal, such as email, phone and address, are ticked for you to check. Portward reads names to suggest them, never rows, and nothing is kept back until you confirm.
03What your AI sees
What happens when you ask
The question
Exactly one SELECT over the tables in the role's schema, in a read-only transaction, stopped after 30 seconds.
What Portward reads
The tables and views the login can SELECT in its current schema, with the columns it can SELECT. Nothing in another schema.
The rows
Each result minus the columns you keep, up to 200 rows on Free. Or switch the connection to I send rows myself, and your AI gets only the shape until you pick rows. A column set to Anonymised reaches your AI as stand-ins: the same value always gets the same stand-in, so counting, grouping and joining still work.
The record
Portward keeps a history of each query (question, SQL, row count, a hash of the result) with no time limit, and keeps what your AI was sent, sealed, for 30 days. You see a receipt under each answer.
04Limits
What it doesn't do
- One schema per connection: the login's current schema.
- A database on a private network can't be reached. Portward connects only to addresses on the public internet.
- Portward never writes to PostgreSQL.
- Free allows 1 connection and 200 questions in any 7 days.
- Portward runs the engine that reads your data, so it can technically see what it reads, and what your AI receives goes to the AI company like the rest of the chat. Portward holds your account email, your database login (sealed to your engine's key), your rules and notes, the questions and SQL your AI ran, receipts and usage counts, and the AI log of what the AI was sent. Rows pass through your engine to the AI and are not stored by Portward, except in that AI log, which deletes them after 30 days, and in the results panel, which deletes them after 24 hours. Your engine is separate from every other account's. Details on the security page.
Every source Portward connects. Is it safe to connect an AI to your database? Other ways to give Claude database access, compared.