Connect a Postgres MCP server to Cursor
Connect Cursor Agent directly to your European PostgreSQL 18 backend with @aurabase/mcp-server: 82 of 86 tools with a project key, engine-enforced read-only mode (37 tools), signed destructive confirmations, and zero manufactured output.
Quick answer#
To connect a PostgreSQL MCP server in Cursor, add @aurabase/mcp-server (aurabase-mcp) to .cursor/mcp.json. With a project key, Cursor immediately gets 82 of 86 tools across 13 domains (Database, RLS, Auth, Storage, Edge Functions, Realtime, Backups, Notifications, AI, Observability) on your dedicated European PostgreSQL 18 instance. For production projects, add --read-only to enforce a 37-tool read-only catalog backed by PostgreSQL read-only transactions.
Prerequisites#
- Node.js 20+ installed locally (
npxstarts@aurabase/mcp-serveron demand) - An Aurabase project on
aurabase.cloud(or a local Docker/k3d stack athttp://localhost:8080) - Three values from Studio › Settings › API Keys:
AURABASE_URL(https://<slug>.aurabase.cloud)AURABASE_PROJECT_ID(<uuid>— required byaurabase-mcp)AURABASE_SERVICE_ROLE_KEY(aura_sk_...)
@aurabase/mcp-server ships two binaries (aurabase-mcp and aurabase-mcp-hosted). Omitting -p and the binary name fails with could not determine executable to run; always invoke npx -y -p @aurabase/mcp-server aurabase-mcp.
Option 1: Local stdio (recommended)#
Create .cursor/mcp.json at the root of your repository (project-scoped) or ~/.cursor/mcp.json (global). Passing credentials via env keeps the command block clean and portable:
{
"mcpServers": {
"aurabase": {
"command": "npx",
"args": ["-y", "-p", "@aurabase/mcp-server", "aurabase-mcp"],
"env": {
"AURABASE_URL": "https://<slug>.aurabase.cloud",
"AURABASE_PROJECT_ID": "<project-uuid>",
"AURABASE_SERVICE_ROLE_KEY": "aura_sk_..."
}
}
}
}Open Cursor Settings › Tools & MCP and click Refresh. The aurabase indicator turns green and lists 82 tools (the 4 management-plane tools — list_all_projects, create_api_key, list_api_keys, revoke_api_key — stay hidden when only a project key is supplied so Cursor never hits broken tools).
Option 2: Local Streamable HTTP (shared across IDEs)#
If you run Cursor alongside Claude Code or Windsurf and want a single persistent server process (MCP 2025-11-25 / 2026-07-28 Streamable HTTP with Origin anti-CSRF checks), start aurabase-mcp once in a terminal:
npx -y -p @aurabase/mcp-server aurabase-mcp \
--transport http \
--host 127.0.0.1 \
--port 3001 \
--auth-token "replace_with_32_char_secret" \
--url "https://<slug>.aurabase.cloud" \
--project-id "<project-uuid>" \
--service-role-key "aura_sk_..."Then point .cursor/mcp.json at the local endpoint:
{
"mcpServers": {
"aurabase": {
"url": "http://127.0.0.1:3001/mcp",
"headers": {
"Authorization": "Bearer replace_with_32_char_secret"
}
}
}
}Production guardrails: read-only, destructive policy & whitelist#
Unlike generic Postgres MCP wrappers that rely purely on prompt instructions, aurabase-mcp enforces three server-level safety controls:
| Control | Flag / Env var | What it actually enforces |
|---|---|---|
| Engine read-only | --read-only (AURABASE_READ_ONLY=true) | Removes all mutating tools (leaves 37 of 86 tools) and forces PostgreSQL to run every query inside a READ ONLY transaction. |
| Destructive SQL gate | --destructive-policy (elicit | token | deny) | Requires interactive confirmation (elicit, default), a signed confirmation token (token with --state-key), or hard-blocks (deny) destructive SQL (DROP, TRUNCATE, unbounded DELETE). |
| Tool whitelist | --allowed-tools (AURABASE_ALLOWED_TOOLS) | Comma-separated allowlist (e.g. list_tables,describe_table,explain_query,get_security_advisors). |
Recommended production profile in .cursor/mcp.json:
{
"mcpServers": {
"aurabase-prod-ro": {
"command": "npx",
"args": ["-y", "-p", "@aurabase/mcp-server", "aurabase-mcp", "--read-only"],
"env": {
"AURABASE_URL": "https://<slug>.aurabase.cloud",
"AURABASE_PROJECT_ID": "<project-uuid>",
"AURABASE_SERVICE_ROLE_KEY": "aura_sk_..."
}
}
}
}Add .cursor/mcp.json to .gitignore whenever it contains an aura_sk_... service-role key, or run against a disposable database branch during feature work.
Real Cursor workflows (with actual MCP tool names)#
| Developer goal | Prompt in Cursor Agent | Tools Cursor invokes |
|---|---|---|
| Security & RLS audit | "Audit every table in this project and flag missing RLS policies or overly broad anon rules." | list_tables, list_rls_policies, get_security_advisors |
| Schema + migration | "Add an invoices table linked to organizations, enable RLS scoped to auth.uid(), and regenerate TypeScript types." | describe_table, apply_migration, create_rls_policy, generate_types |
| Slow query tuning | "Check the slowest queries from the last hour, run EXPLAIN on the worst one, and suggest an index." | list_slow_queries, explain_query, get_performance_advisors |
| Edge Functions & Storage | "List deployed Edge Functions and check if our avatars bucket has public read enabled." | list_functions, get_bucket |
Troubleshooting#
could not determine executable to run: you omitted-p @aurabase/mcp-server aurabase-mcp. Use the exactargsarray shown above.- Server exits immediately on start:
--project-id(AURABASE_PROJECT_ID) is mandatory; verify the UUID matches your project in Studio › Settings › General. - HTTP mode refuses to start:
--auth-tokenis mandatory in--transport httpmode (fail-closed by design). - Empty or error responses: every Aurabase MCP tool returns the real backend response or an explicit error — never a fabricated placeholder. Check
AURABASE_URLreachability and key validity.
To go further#
- Full MCP Server Reference
All 86 tools by domain, flags, and Streamable HTTP security model.
- Postgres MCP in Claude Code
One-line CLI setup with claude mcp add and team .mcp.json.
- Postgres MCP in VS Code
Copilot Agent Mode setup with encrypted input prompts.
- Row-Level Security
Design tenant-isolated Postgres policies enforced across REST and MCP.