This guide walks through connecting PostgreSQL to ChatGPT using QueryBear’s managed MCP server. End result: ChatGPT can answer real questions about your Postgres data — useful for sales, support, exec prep, and anyone who wants to ask a database question in natural language.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.
What you’ll need
- A QueryBear account (sign up free)
- A PostgreSQL database (any version 12+)
- A ChatGPT account (Plus, Team, or Enterprise — developer mode required)
Step 1: Create a read-only PostgreSQL role
Step 2: Add the connection to QueryBear
In the QueryBear dashboard → Connections → New connection → PostgreSQL, with the credentials from Step 1. For ChatGPT specifically, set the column block list aggressively — anything ChatGPT reads goes through OpenAI’s API. Blockemail, phone, address, password_hash, and any other PII at the QueryBear level so it never leaves your perimeter.
Step 3: Add QueryBear to ChatGPT
Step 4: Verify
In a new ChatGPT conversation:“What QueryBear tools do you have? List my connections.”You should see
list_connections, get_schema, run_query, and your Postgres connection.
Try it
“In our production Postgres, how many users signed up in each of the last 12 months, broken down by signup source? Format as a markdown table.”ChatGPT calls
get_schema to find the right tables, writes the SQL, calls run_query, and formats the result.
Productionize for team use
For non-technical teammates, build a Custom GPT with QueryBear as a connector:- Create a Custom GPT in ChatGPT’s GPT builder.
- Add the QueryBear connector.
- System prompt: “You are a data assistant for {company}. Always use the production connection. Always call get_schema before writing SQL. Format results as markdown tables.”
- Share the GPT link with your team.
Postgres + ChatGPT gotchas
- Custom Connectors require ChatGPT Plus/Team/Enterprise and developer mode. The free tier doesn’t support them.
- Column blocks are non-negotiable for PII. Once ChatGPT sees a value, you can’t un-see it. Block PII at QueryBear, not in your prompt.
- The row limit (default 1000) prevents accidental large reads. Raise it per-connection if you have legitimate “give me everything” use cases.
- OAuth tokens are scoped per ChatGPT account. Revoke in QueryBear dashboard if needed.
Related
- PostgreSQL MCP server — Postgres-specific deep dive
- ChatGPT client — ChatGPT overview
- Security model — what the gateway protects against