Official Data & Analytics

PostgreSQL

Anthropic's official Postgres server with read-only schema and queries.

Works with: Claude DesktopClaude CodeCursorWindsurfClineVS Code (Continue)
Quick install
npx -y @modelcontextprotocol/server-postgres postgresql://localhost/db

How to install the PostgreSQL MCP server

Add this to your Claude Desktop MCP configuration:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/db"
      ]
    }
  }
}

Add this to your Claude Code MCP configuration:

npx -y @modelcontextprotocol/server-postgres postgresql://localhost/db

Add this to your Cursor MCP configuration:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/db"
      ]
    }
  }
}

Add this to your Windsurf MCP configuration:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/db"
      ]
    }
  }
}

Add this to your Cline MCP configuration:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/db"
      ]
    }
  }
}

Add this to your VS Code (Continue) MCP configuration:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/db"
      ]
    }
  }
}

The Postgres MCP server is Anthropic’s official integration with PostgreSQL. It gives Claude read-only access to your database: schema introspection, query execution, and table inspection. Critical for any AI workflow that touches structured data.

The read-only design is deliberate. It means you can install this server against production databases without worrying about Claude accidentally dropping a table. Writes go through your existing tooling.

Why use it

Most operational questions live in databases. “How many users signed up last week?” “What’s our MRR by plan tier?” “Which features are stickiest?” The Postgres MCP server lets Claude answer these directly without you copy-pasting query results.

For solo founders running their own analytics, this is the cheapest analytics-as-code setup that exists. Claude writes the SQL, runs it, interprets the results. No dashboard required.

What it actually does

Two primitives: list tables (with full schema), and execute a SQL query (read-only). Claude composes them into analysis workflows automatically.

Practical patterns:

  • “How many active users did we have last month?”
  • “Compare conversion rates between the free and paid tiers, broken down by signup month.”
  • “Find the top 10 customers by lifetime value and show their last login date.”

Gotchas

Read-only doesn’t mean “safe forever”. Claude can still write expensive queries that lock tables or cause replicas to fall behind. For production databases, consider connecting Claude to a read replica rather than the primary.

Connection strings often contain passwords. Don’t paste them into MCP configs that get checked into git. Use environment variables or your client’s secrets feature.

If you want write access, run a separate MCP server (the SQLite server allows writes for local databases) or use Claude Code with raw psql via the Filesystem server. Mixing read-only and write access in one MCP isn’t supported by the Anthropic Postgres server, by design.

PostgreSQL MCP server: FAQs

Is it really read-only?

Yes. The official Anthropic implementation is read-only by design. It executes queries against a transaction that's rolled back at the end. This is a safety feature, not a limitation. Use other tooling for writes.

How does it discover the schema?

It introspects information_schema on connection and exposes table and column metadata to Claude. Claude can then write SQL queries with full awareness of the schema without you having to paste it in.

Does it support SSL connections?

Yes. Pass a postgresql:// or postgres:// URL with sslmode=require in the query string.

Can I use it with Supabase or Neon?

Yes. Both Supabase and Neon expose standard Postgres connection strings, which the server accepts as-is. If you want richer features (branching for Neon, RLS for Supabase), use their dedicated MCP servers instead.

What about row-level security?

The server connects with whatever role's credentials you pass in. Use a read-only role with appropriate RLS policies to avoid exposing data Claude shouldn't see.