Database · MCP Server

Postgres MCP

MCP server for any Postgres database. Claude can inspect schema, run queries, and explain plans.

MCP · Postgres

What it does

The Postgres MCP server works against any Postgres database — not just Supabase. Use it for self-hosted Postgres, RDS, or Neon. Claude can list tables, describe columns, run SELECTs, and ANALYZE query plans to help you find missing indexes.

How to install

Which tool are you using?

Not sure? Claude.ai is the website. Claude Code is the command-line tool you install separately. Cursor is a code editor that reads .cursorrules.

  1. 01

    Open your MCP config

    Claude Desktop reads MCP config from ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, or %APPDATA%/Claude/claude_desktop_config.json on Windows.

    terminal
    open ~/Library/Application\ Support/Claude/claude_desktop_config.json
  2. 02

    Add the Postgres server block

    Merge the JSON below into the "mcpServers" object. If the file is empty, paste the full block.

  3. 03

    Replace placeholder credentials

    Swap the placeholder values with your real tokens / URLs. Never commit this file.

  4. 04

    Restart Claude Desktop

    Fully quit Claude and reopen. The MCP server will be available as tools in every new chat.

  5. 05

    Verify

    Start a new chat and ask Claude to list available tools. You should see Postgres tools in the list.

The mcp server file

Copy the full contents below, or download the file directly.

claude_desktop_config.json
claude_desktop_config.json
{  "mcpServers": {    "postgres": {      "command": "npx",      "args": [        "-y",        "@modelcontextprotocol/server-postgres",        "postgresql://USER:PASSWORD@HOST:5432/DBNAME"      ]    }  }}

Example output

What Claude does before and after you install this mcp server.

Without this mcp server

You switch to psql, run \d, copy the schema back to Claude, paste the slow query plan separately.

With this mcp server

Claude queries the schema and EXPLAIN plan directly, spots the missing index on user_id, and proposes the CREATE INDEX. 30 seconds.

Customization tips

Use a read-only role for production. Create a separate role per developer with minimum grants. Never use the postgres superuser role.

Related resources

Frequently asked questions

Supports any Postgres version?

Yes — 12+ recommended. Older versions work with limited features.

Works with Neon?

Yes — use the Neon connection string.

Does it write?

Only if the connection string has write permission. Prefer read-only.

Can I connect to SSH-tunneled DBs?

Open the tunnel first; point the connection string at localhost.

Does it handle row-level security?

Yes — RLS applies per the connection role.

Want more like this?

Browse the full RohanKit library — free resources for Claude and Cursor.

Back to RohanKit