QueryBear is a managed Postgres MCP server. Drop the QueryBear MCP endpoint into your AI client and it can query your PostgreSQL database through a hardened read-only gateway. No local install, no credentials in client config files, and no risk of the agent running a destructive query. Works with PostgreSQL 12 and newer, including managed Postgres on AWS RDS, Google Cloud SQL, Azure Database for PostgreSQL, Supabase, Neon, Render, Railway, Fly.io, and Heroku.Documentation Index
Fetch the complete documentation index at: https://docs.querybear.com/llms.txt
Use this file to discover all available pages before exploring further.
Why a Postgres MCP server (vs. raw psql)
Without a gateway, hooking an AI to Postgres means one of two things:
- Give the agent direct DB credentials — convenient and catastrophic. The agent can
DROP TABLE, read every column of every table, and accidentally run scans that DoS your replica. - Use a read-only role — solves writes but nothing else. The agent still sees every table, every column (including
password_hash,email,api_key), and can still run unbounded scans.
- A SQL parser that rejects writes at the gateway layer, including writes hidden inside CTEs.
- Per-table allow-listing — new tables stay invisible until you opt them in.
- Per-column block lists — sensitive columns are stripped from the schema the agent sees.
- Row limits and query timeouts.
- Full audit log.
Create a read-only Postgres role
QueryBear’s gateway is read-only by design, but a least-privilege DB role is belt-and-suspenders. Run this as a Postgres superuser:public, repeat the GRANT USAGE and ALTER DEFAULT PRIVILEGES for each.
Connection settings
In the QueryBear dashboard, add a new PostgreSQL connection:- Host — e.g.
db.example.com, your RDS endpoint, or Supabase pooler URL - Port —
5432by default - Database
- User —
querybear(the role above) - Password
- SSL mode —
requirefor any non-localhost connection
Postgres-specific notes
- CTEs with writes are rejected.
WITH x AS (DELETE FROM ...) SELECT * FROM xis a real Postgres feature. The QueryBear parser catches it. pg_*system tables are visible by default for schema introspection but are not query-allow-listed unless you opt in.- Read replicas work. Point QueryBear at your replica — the gateway doesn’t care.
- Materialized views and views are first-class. They appear in
get_schemaand are queryable like tables. - PgVector and other extensions work transparently — the parser permits
<->,<=>, and other operator syntax.
Connect Postgres to your AI client
Pick your client for a step-by-step guide:Claude Code
One-line CLI setup. Read your DB from
claude in the terminal.Claude Desktop
Custom connector in Claude’s desktop app.
Cursor
Drop into
.cursor/mcp.json. Query your DB while pairing with Cursor.Codex
Add to
~/.codex/config.toml. Database access in Codex CLI.Windsurf
Add as a custom MCP server in Windsurf settings.
ChatGPT
Custom connector in ChatGPT (developer mode).