Skip to content
Aurabase Logo
aurabase

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).

How-to guide7 min readLevel beginner

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-mcp

Verify that Claude Code discovers and starts the server cleanly:

claude mcp list
claude mcp get aurabase
Project scope vs user scope

Use --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
ModeTools exposedDestructive DDL/DMLIdeal environment
Default (elicit)82 / 86Interactive confirmation requiredLocal dev / disposable branch
--destructive-policy deny82 / 86Hard-blocked by serverShared staging
--read-only37 / 86Impossible (Postgres READ ONLY tx)Production debugging & audits

High-leverage Claude Code prompts#

  • Full-stack feature + RLS in one pass: "Inspect the existing projects schema (describe_table), create a migration for api_tokens (apply_migration), add tenant-scoped RLS (create_rls_policy), and regenerate src/types/database.ts (generate_types)."
  • Production incident triage (read-only): "Check active and slow queries (list_active_queries, list_slow_queries), run explain_query on the top bottleneck, and check get_performance_advisors."
  • Security review before launch: "Run get_security_advisors and list_rls_policies across every table and produce a remediation migration for any unprotected table."

Troubleshooting#

  • npx fails to resolve binary: make sure -p @aurabase/mcp-server aurabase-mcp appears after -- in claude mcp add.
  • Missing tools (list_all_projects, create_api_key): those 4 tools require management-plane credentials; a project service_role key intentionally exposes 82 tools.
  • Unresolved ${AURABASE_URL} in .mcp.json: ensure the environment variables are exported in the shell that starts claude.

To go further#

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Report a problem