PostgreSQL MCP server
Connect Claude, ChatGPT or Claude Code to a PostgreSQL database over MCP (Model Context Protocol), without putting a connection string on anyone's laptop. The assistant reads the schema, writes SQL and runs it, and Thunderduck checks every query before it reaches Postgres.
The problem: an assistant with a connection string
The usual way to give an assistant a Postgres database is a local MCP server started with a connection string. It works on day one, and it leaves you with three problems once the database is a real one:
- The credential lives in a config file on every machine that uses it, usually a role with more rights than the assistant needs.
- Nothing checks the cost of a query. An assistant exploring a table it
does not know will happily run a
SELECT *or an unfiltered join against production. - The assistant only sees names and types.
amtcould be dollars or cents, andstatus = 3means nothing without the application code, so plausible SQL returns wrong numbers.
How Thunderduck solves it
Thunderduck runs a hosted MCP server in front of the database, at
https://mcp.thunderduck.ai/mcp.
- No connection string on any laptop. The Postgres password goes to a secrets manager when you add the database. People sign in to the assistant with their own Thunderduck account (OAuth), and the assistant never sees the password.
- Read-only in three places. The Postgres role, the catalog's read-only flag and the user's token scope each block writes on their own, so a persuasive prompt cannot talk its way past them.
- Every query is priced before it runs. Thunderduck plans the SQL first and refuses it above the per-query or daily limit, or when it would scan a large table with no selective filter. See Scopes & costs.
- Filters run in Postgres. Filters on constant values are pushed down, and
so are
GROUP BY,ORDER BYandLIMITwhen the query reads one table, so only matching rows leave the database. Each statement carries a comment naming the Thunderduck user, so you can find it in your Postgres logs. - Columns come with meanings. Thunderduck infers a description and a unit for each column and lets your team correct them. The assistant reads them before it writes SQL. See Column meanings.
- One server for every database. The same connection reaches your MySQL, BigQuery and S3 data, and one query can join them.
Set it up
1. Create a read-only role
Run this in Postgres. Change the schema and the password:
CREATE ROLE thunderduck_ro LOGIN PASSWORD '…';
GRANT USAGE ON SCHEMA public TO thunderduck_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO thunderduck_ro;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO thunderduck_ro;Tables outside the granted schemas stay invisible to the assistant, because Thunderduck only catalogs what the role can read.
2. Add the database as a catalog
In the console, Catalogs → Create catalog → PostgreSQL. Give it a short
lowercase name such as shop, enter the host, port, database and the role from
step 1, and turn on Read-only. SSL defaults to require.
The database must be reachable from the internet or through your own tunnel.
If you connect through a pooler (Supabase, PgBouncer), use its session
mode, not transaction mode. On Supabase that is port 5432.
All fields are on the PostgreSQL & MySQL page.
3. Connect your assistant
Claude (claude.ai and Claude Desktop): Settings → Connectors → Add custom connector, paste the URL below, and sign in.
https://mcp.thunderduck.ai/mcpClaude Code:
claude mcp add --transport http thunderduck https://mcp.thunderduck.ai/mcp \
--client-id thunderduck-mcp-cli --callback-port 33418ChatGPT: add a connector with the same URL.
More on each client in Connecting Claude & ChatGPT.
4. Ask a question
Which ten products had the most revenue in October, and how does that compare with September?
The assistant calls get_catalog_context('shop') to read the tables, keys and
column meanings, checks the price with estimate_query_cost, then runs
something like:
SELECT p.name,
sum(oi.amount) FILTER (WHERE o.created_at >= DATE '2026-10-01') AS october,
sum(oi.amount) FILTER (WHERE o.created_at < DATE '2026-10-01') AS september
FROM shop.public.orders o
JOIN shop.public.order_items oi ON oi.order_id = o.id
JOIN shop.public.products p ON p.id = oi.product_id
WHERE o.created_at >= DATE '2026-09-01'
AND o.created_at < DATE '2026-11-01'
GROUP BY p.name
ORDER BY october DESC
LIMIT 10;Tables are addressed as catalog.schema.table. The date filter runs inside
Postgres, so it only reads two months of orders.
What the assistant can do
| With a read-only setup | |
|---|---|
| List schemas, tables and columns | Yes |
| Read column meanings, keys and joins | Yes |
Run SELECT | Yes, within the cost limits |
| Export a large result to Parquet or CSV | Only with the export scope |
INSERT, UPDATE, DELETE, DDL | No: refused by the role, the catalog and the token |
| Schedule a query | Only with the query:write scope |
The full list is on the Tools page.
Compared with a local open-source server
Open-source Postgres MCP servers run on your own machine with a connection string. For a database on your laptop, or a quick look at a dev database, that is the simpler choice: no account, nothing hosted, and nothing between you and the database.
Thunderduck fits when the database is shared or in production: when more than one person will connect, when the password should not sit in config files, when queries need a cost check, or when the questions span more than one database.
Related
- PostgreSQL & MySQL catalogs: every connection field
- Scopes & costs: limits, row caps and refusals
- Column meanings: how the assistant learns what columns mean
- MySQL MCP server · BigQuery MCP server · ClickHouse MCP server · SQL Server MCP server