Skip to main content

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.

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.

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

CREATE ROLE querybear LOGIN PASSWORD 'choose-a-strong-one';
GRANT CONNECT ON DATABASE your_db TO querybear;
GRANT USAGE ON SCHEMA public TO querybear;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO querybear;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT ON TABLES TO querybear;

Step 2: Add the connection to QueryBear

In the QueryBear dashboardConnectionsNew connectionPostgreSQL, with the credentials from Step 1. For ChatGPT specifically, set the column block list aggressively — anything ChatGPT reads goes through OpenAI’s API. Block email, phone, address, password_hash, and any other PII at the QueryBear level so it never leaves your perimeter.

Step 3: Add QueryBear to ChatGPT

1

Enable developer mode

SettingsConnectorsAdvanced → enable Developer mode.
2

Add custom connector

Click Add connectorCustom connector.
3

Fill in the form

FieldValue
Namequerybear
URLhttps://mcp.querybear.com/mcp
4

Authorize

OAuth opens in browser. Approve.

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:
  1. Create a Custom GPT in ChatGPT’s GPT builder.
  2. Add the QueryBear connector.
  3. 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.”
  4. Share the GPT link with your team.
The audit log in the QueryBear dashboard shows every query, so you can see exactly what your team is asking.

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.