# Postgres MCP Pro

> The maintained Postgres MCP server — safe SQL execution, EXPLAIN with hypothetical indexes, workload-driven index tuning, and database health checks.

Postgres MCP Pro (MIT) is the maintained successor to the archived reference Postgres server — and goes further: alongside schema browsing and execute_sql with a restricted read-only mode, it pairs the LLM with classical optimization algorithms: explain_query with hypothetical-index simulation, workload index analysis via pg_stat_statements, and a multi-dimension analyze_db_health check.

Website: https://github.com/crystaldba/postgres-mcp

Postgres MCP Pro answers "let the agent talk to the database" without making the DBA wince. It pairs the model with **deterministic, classical optimization tooling** — real EXPLAIN plans, hypothetical-index simulation, workload-driven index analysis — so recommendations come from algorithms, with the LLM doing the orchestration and explanation.

## Highlights

- **Two access modes** — `--access-mode=restricted` (read-only, SQL safety-parsed, for shared/prod-adjacent databases) and `unrestricted` for dev.
- **`explain_query` with what-ifs** — EXPLAIN any statement, optionally simulating hypothetical indexes via `hypopg` before committing to a build.
- **Workload-aware tuning** — `analyze_workload_indexes` reads `pg_stat_statements` and recommends indexes for the queries you actually run; `analyze_query_indexes` does the same for up to 10 specific queries.
- **`analyze_db_health`** — buffer cache hit rates, connection pressure, index and vacuum health, sequences, replication — the morning-checklist sweep in one tool.
- **Schema navigation** — list schemas/objects, get object details, and `get_top_queries` for slow-query triage.

## In an AI-assisted workflow

```bash
claude mcp add postgres \
  -e DATABASE_URI="postgresql://user:pass@localhost:5432/db" \
  -- uvx postgres-mcp --access-mode=restricted
# then:
# > Why is the orders dashboard slow? Check top queries and propose indexes —
# > simulate them before recommending.
```

This is the natural data layer under the site's Postgres workflow trio — [profile queries](/commands/perf/profile-postgres-queries), [pick the index](/skills/database/postgres-index-strategist), [optimize the SQL](/skills/data/sql-optimizer) — with the agent now able to measure instead of guess.

> [!TIP]
> The advanced tools lean on extensions: enable `pg_stat_statements` (workload analysis) and `hypopg` (hypothetical indexes) to unlock the headline features. Without them you still get schema browsing, EXPLAIN, and health checks.

## Good to know

MIT-licensed, Python 3.12+ via `uvx`/`pipx` or Docker (`crystaldba/postgres-mcp`); SSE transport available for shared deployments. Credentials ride in `DATABASE_URI` — keep them in env vars, not committed config, per the [MCP setup guide](/guides/mcp/claude-code-mcp-setup). Development pace has slowed in 2026 (the multi-database `bytebase/dbhub` is the very active alternative if you need MySQL/SQL Server too); for Supabase-managed Postgres specifically, the [official Supabase server](/tools/supabase-mcp) is the better fit.

---

_Source: https://agentscamp.com/tools/postgres-mcp — Tool on AgentsCamp._
