Connect a Postgres MCP server to Claude Code
Give Claude Code direct, audited access to your dedicated European PostgreSQL 18 database, RLS policies, Auth, S3 Storage, Edge Functions, and ClickHouse slow-query logs using @aurabase/mcp-server (82 of 86 tools with a project key).
Quick answer#
To connect a PostgreSQL MCP server to Claude Code, register @aurabase/mcp-server (aurabase-mcp) with claude mcp add. With a project key, Claude Code receives 82 of 86 tools across Database, RLS, Auth, Storage, Edge Functions, Backups, Realtime, AI, and Observability — hosted in the EU. For production projects, pass --read-only (37 tools backed by PostgreSQL READ ONLY transactions) and --destructive-policy deny.
Option 1: Add via claude mcp add#
Register the server for the current repository (--scope local) or across all projects (--scope user):
claude mcp add --scope local aurabase \
-e AURABASE_URL="https://<slug>.aurabase.cloud" \
-e AURABASE_PROJECT_ID="<project-uuid>" \
-e AURABASE_SERVICE_ROLE_KEY="aura_sk_..." \
-- npx -y -p @aurabase/mcp-server aurabase-mcpVerify that Claude Code discovers and starts the server cleanly:
claude mcp list
claude mcp get aurabaseUse --scope local when each Git repository maps to a different Aurabase project. Use --scope user only if you intentionally connect a single shared sandbox across repositories.
Option 2: Team .mcp.json (zero secrets in Git)#
Commit a .mcp.json file at the root of your repository referencing environment variables so every teammate gets identical MCP tooling without checking in credentials:
{
"mcpServers": {
"aurabase": {
"command": "npx",
"args": ["-y", "-p", "@aurabase/mcp-server", "aurabase-mcp"],
"env": {
"AURABASE_URL": "${AURABASE_URL}",
"AURABASE_PROJECT_ID": "${AURABASE_PROJECT_ID}",
"AURABASE_SERVICE_ROLE_KEY": "${AURABASE_SERVICE_ROLE_KEY}"
}
}
}
}Each developer exports those three variables in their shell (or .envrc via direnv) before launching claude.
Option 3: Claude Desktop configuration#
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"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_..."
}
}
}
}Restart Claude Desktop and open the tools menu (hammer icon) to verify the 82 project tools appear.
Read-only mode & destructive SQL policy#
When connecting Claude Code to a staging or production project, combine --read-only (which hides write tools and executes SQL inside PostgreSQL READ ONLY transactions, leaving 37 of 86 tools) or scope write access with --destructive-policy and --allowed-tools:
# Production inspection only (37 read-only tools, engine-enforced)
claude mcp add --scope local aurabase-prod-ro \
-e AURABASE_URL="https://<slug>.aurabase.cloud" \
-e AURABASE_PROJECT_ID="<project-uuid>" \
-e AURABASE_SERVICE_ROLE_KEY="aura_sk_..." \
-- npx -y -p @aurabase/mcp-server aurabase-mcp --read-only
# Staging with destructive SQL hard-blocked
claude mcp add --scope local aurabase-staging \
-e AURABASE_URL="https://<slug>.aurabase.cloud" \
-e AURABASE_PROJECT_ID="<project-uuid>" \
-e AURABASE_SERVICE_ROLE_KEY="aura_sk_..." \
-- npx -y -p @aurabase/mcp-server aurabase-mcp --destructive-policy deny| Mode | Tools exposed | Destructive DDL/DML | Ideal environment |
|---|---|---|---|
Default (elicit) | 82 / 86 | Interactive confirmation required | Local dev / disposable branch |
--destructive-policy deny | 82 / 86 | Hard-blocked by server | Shared staging |
--read-only | 37 / 86 | Impossible (Postgres READ ONLY tx) | Production debugging & audits |
High-leverage Claude Code prompts#
- Full-stack feature + RLS in one pass: "Inspect the existing
projectsschema (describe_table), create a migration forapi_tokens(apply_migration), add tenant-scoped RLS (create_rls_policy), and regeneratesrc/types/database.ts(generate_types)." - Production incident triage (read-only): "Check active and slow queries (
list_active_queries,list_slow_queries), runexplain_queryon the top bottleneck, and checkget_performance_advisors." - Security review before launch: "Run
get_security_advisorsandlist_rls_policiesacross every table and produce a remediation migration for any unprotected table."
Troubleshooting#
npxfails to resolve binary: make sure-p @aurabase/mcp-server aurabase-mcpappears after--inclaude mcp add.- Missing tools (
list_all_projects,create_api_key): those 4 tools require management-plane credentials; a projectservice_rolekey intentionally exposes 82 tools. - Unresolved
${AURABASE_URL}in.mcp.json: ensure the environment variables are exported in the shell that startsclaude.