This guide walks through connecting PostgreSQL to Cursor using QueryBear’s managed MCP server. End result: Cursor’s chat, composer, and inline modes can all query your Postgres database — perfect for migrations, schema-aware refactors, and debugging.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+)
- Cursor 0.42+ (any version with MCP support)
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.Step 3: Add QueryBear to Cursor
Create.cursor/mcp.json in your project root (or ~/.cursor/mcp.json for global):
.cursor/mcp.json. If not, add it to .gitignore.
Step 4: Authorize and verify
Open Cursor. The first time it uses QueryBear, an OAuth browser tab opens — approve. In Cursor chat:“What QueryBear tools do you have? List my connections.”You should see
list_connections, get_schema, run_query, and your Postgres connection.
Try it
“I’m about to addCursor callsNOT NULLtousers.email_verified_at. Pull the schema forusers, then count how many rows currently have NULL there.”
get_schema, writes the SELECT COUNT(*) ... WHERE email_verified_at IS NULL, runs it through QueryBear, and reports back.
Or, mid-refactor:
“This function joinsorderstouserstosubscriptions. Verify against production that noorders.user_idis orphaned.”
Postgres + Cursor gotchas
.cursor/mcp.jsonis project-scoped. If you have multiple projects targeting different DBs, you can configure each independently.- Cursor caches MCP server status. If you change the config, restart Cursor.
- Composer mode chains tool calls — Cursor may call
get_schemaandrun_querymultiple times in one composer task. This is normal. - For read replicas, point QueryBear at the replica. Cursor’s queries will land there, sparing your primary.
- Cursor’s Postgres-native integration (
@dbsyntax) is separate from MCP — you don’t need to choose one. They can coexist.
Related
- PostgreSQL MCP server — Postgres-specific deep dive
- Cursor client — Cursor overview
- Security model — what the gateway protects against