# Postgres MCP Pro

> Production-grade Postgres MCP with index advice, EXPLAIN, and health checks.

[Canonical HTML page](https://top-mcps.com/mcp/postgres-mcp-pro) · [server.json](https://top-mcps.com/mcp/postgres-mcp-pro.json) · [methodology](https://top-mcps.com/about/methodology)

## Install

### Claude Desktop — `claude_desktop_config.json`

Paste under mcpServers. Fully quit and reopen Claude after editing.

```json
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp"
      ],
      "env": {
        "DATABASE_URI": "${DATABASE_URI}"
      }
    }
  }
}
```

### Claude Code — `CLI or .mcp.json`

Run from your repo. Commit .mcp.json to share with your team.

```shell
# export DATABASE_URI=postgresql://user:pass@localhost/db
claude mcp add postgres-mcp-pro -- uvx postgres-mcp
```

### Cursor — `.cursor/mcp.json`

Global path: ~/.cursor/mcp.json. Reload window after editing.

```json
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp"
      ],
      "env": {
        "DATABASE_URI": "${DATABASE_URI}"
      }
    }
  }
}
```

### VS Code — `.vscode/mcp.json`

VS Code uses the "servers" key (not "mcpServers").

```jsonc
{
  "servers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp"
      ],
      "env": {
        "DATABASE_URI": "${DATABASE_URI}"
      }
    }
  }
}
```

### Windsurf — `~/.codeium/windsurf/mcp_config.json`

Open via Cascade → hammer icon → Configure.

```json
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp"
      ],
      "env": {
        "DATABASE_URI": "${DATABASE_URI}"
      }
    }
  }
}
```

### Cline — `cline_mcp_settings.json`

Open via the Cline sidebar → MCP Servers → Edit.

```json
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp"
      ],
      "env": {
        "DATABASE_URI": "${DATABASE_URI}"
      }
    }
  }
}
```

### Continue — `~/.continue/config.json`

Continue uses modelContextProtocolServers with a transport block.

```json
{
  "experimental": {
    "modelContextProtocolServers": [
      {
        "transport": {
          "type": "stdio",
          "command": "uvx",
          "args": [
            "postgres-mcp"
          ],
          "env": {
            "DATABASE_URI": "${DATABASE_URI}"
          }
        }
      }
    ]
  }
}
```

### Codex CLI — `~/.codex/config.toml`

Codex uses TOML. Each server is a [mcp_servers.<name>] subtable.

```shell
# ~/.codex/config.toml
[mcp_servers.postgres-mcp-pro]
command = "uvx"
args = [
  "postgres-mcp",
]
env = { DATABASE_URI = "${DATABASE_URI}" }
```

### Zed — `~/.config/zed/settings.json`

Zed calls them "context_servers". Settings live-reload on save.

```jsonc
{
  "context_servers": {
    "postgres-mcp-pro": {
      "command": {
        "path": "uvx",
        "args": [
          "postgres-mcp"
        ]
      },
      "env": {
        "DATABASE_URI": "${DATABASE_URI}"
      }
    }
  }
}
```

### ChatGPT — `ChatGPT → Apps directory`

Postgres MCP Pro doesn't ship a hosted HTTPS endpoint today. ChatGPT supports remote MCP servers only — to use this server in ChatGPT you'll need to deploy it to a public HTTPS URL first (e.g. via Cloudflare Workers or Vercel) or wait for an official remote build.

```none

```

## At a glance

- **Maintainer:** Crystal DBA
- **Transport:** stdio
- **Auth model:** API key
- **Required secrets:** DATABASE_URI
- **Supported clients:** Claude, Cursor, VS Code, Windsurf, Any MCP-compatible client, PostgreSQL 12+
- **License:** MIT
- **Language:** Python
- **Latest version:** latest
- **Last verified:** 2026-05-06
- **GitHub stars:** 2,722 (fetched 2026-05-11T09:29:10.737Z)
- **Score:** 74/100 (rubric 2026-04 — see https://top-mcps.com/about/methodology)
- **Source:** https://github.com/crystaldba/postgres-mcp

## Tools & permissions

| Tool | Description | Args | Side effects |
|------|-------------|------|--------------|
| `execute_sql` | Run a SQL statement; behaviour depends on safe-mode and role privileges. | `sql: string` | read |
| `explain_query` | Return the query plan with cost estimates. | `sql: string` | read |
| `analyze_workload` | Surface slow queries and index opportunities from pg_stat_statements. | `—` | read |
| `recommend_indexes` | Suggest indexes for a given query or table workload, with estimated cost and benefit. | `sql?: string` | read |
| `check_health` | Run a schema-wide health check (bloat, missing PKs, duplicate indexes, replication lag). | `—` | read |

## Security & scope

- **Access scope:** read-write
- **Sandbox:** Connects to a Postgres database via the connection string in DATABASE_URI. Write tools are guarded by a safe-mode flag — when disabled, the server only exposes read-and-EXPLAIN capabilities. Database-level role permissions are the final guard regardless of MCP-side toggles.
- **Gotchas:**
  - Safe-mode is a server-side flag, not a database-level constraint — pair it with a read-only DB role for defence-in-depth.
  - EXPLAIN ANALYZE actually executes queries to gather timing data; on production, prefer plain EXPLAIN or run against a snapshot.

## Quick answer

**What it does.** Connects to a PostgreSQL database and exposes query execution, EXPLAIN plan analysis, index advice, schema health checks, and optional write tools behind an explicit safe-mode flag.

**Best for:**
- Query performance tuning
- Index recommendations
- Schema health audits
- Guarded write workflows
- Explainable query optimization

**Not for:**
- Pure read-only schema exploration (use the official Postgres MCP)
- Non-Postgres databases

## Recipes

### Diagnose a slow report query and suggest indexes

```
Using Postgres MCP Pro, take this query and explain why it is slow: SELECT ... FROM ... Then run analyze_workload on the related tables and recommend the top 3 indexes that would help, with estimated cost and benefit. Do not apply any index — just propose.
```

_Tested with: Claude Desktop, Claude Code, Cursor_

## Description

Postgres MCP Pro is a community-maintained Postgres MCP that goes beyond read-only query execution. It adds EXPLAIN-plan analysis, index recommendations, schema-wide health checks, and write-mode toggles guarded by an explicit safe-mode setting. Designed for engineers who want a Postgres assistant that understands query performance, not just syntax.

## Why it matters

The official Postgres MCP is read-only and intentionally minimal. Postgres MCP Pro fills the gap when you want index advice, performance analysis, or write capability under controlled circumstances.

## Key features

- EXPLAIN plan analysis
- Index advisor with cost estimates
- Schema-wide health checks
- Safe-mode toggle for writes
- Slow-query introspection

## FAQ

### How is Postgres MCP Pro different from the official Postgres MCP?

The official server is read-only and exposes a small set of query/schema tools. Postgres MCP Pro adds EXPLAIN-plan analysis, an index advisor, schema-wide health checks, and a guarded write mode. Same protocol, deeper toolset.

### Is the write mode safe?

Writes are gated behind an explicit safe-mode flag and require the connecting role to actually have write privileges. Pair it with a read-only Postgres role for review workflows; switch to a write role only when you genuinely want the agent to issue mutations.

### Does it require Python or Docker?

Python via `uvx postgres-mcp` is the simplest path — no separate install needed if you have `uv`. A Docker image is also published if you prefer containerised deployment.

### Will the index advisor change my schema automatically?

No. The advisor returns recommended indexes with cost-and-benefit estimates; applying them is left to a human-reviewed migration. Auto-applying index changes is intentionally not exposed as a tool.

### Can I run it against managed Postgres (RDS, Neon, Supabase)?

Yes. The connection string format is standard `postgresql://...` so any managed provider works. For Supabase, prefer the dedicated Supabase MCP if you need RLS-aware features; use Postgres MCP Pro when raw performance work matters more than auth integration.

## Changelog

- **2026-05-06** — Refreshed install snippets and fact sheet; verified for 2026.
- **2025-04-10** — Initial directory listing.
