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.
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) andunrestrictedfor dev. explain_querywith what-ifs — EXPLAIN any statement, optionally simulating hypothetical indexes viahypopgbefore committing to a build.- Workload-aware tuning —
analyze_workload_indexesreadspg_stat_statementsand recommends indexes for the queries you actually run;analyze_query_indexesdoes 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_queriesfor slow-query triage.
In an AI-assisted workflow
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, pick the index, optimize the SQL — 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. 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 is the better fit.
Frequently asked questions
- What happened to the official Postgres MCP server?
- The reference @modelcontextprotocol/server-postgres was archived in 2025 along with most reference servers (it lives read-only in modelcontextprotocol/servers-archived). Postgres MCP Pro is the most-adopted Postgres-specific successor, adding index tuning and health checks the reference server never had.
- How do I add Postgres MCP Pro to Claude Code?
- claude mcp add postgres -e DATABASE_URI="postgresql://user:pass@localhost:5432/db" -- uvx postgres-mcp --access-mode=restricted. It's a Python server (uv/pipx/Docker); restricted mode gives read-only, safety-parsed SQL — the right default for anything shared.
- What makes it 'Pro' versus a basic SQL bridge?
- Deterministic database smarts alongside the LLM: explain_query can simulate hypothetical indexes (via hypopg) before you create them, analyze_workload_indexes mines pg_stat_statements for what your real workload needs, and analyze_db_health checks buffer cache, connections, vacuum, indexes, sequences, and replication in one call.
Related
- The Best MCP Servers in 2026The MCP servers actually worth connecting in 2026 — Context7, GitHub, Chrome DevTools, Playwright, Serena, Exa, Firecrawl, and the best official vendor servers, by use case.
- Adding MCP Servers to Claude Code: Local, Remote, and Project-ScopedThe complete claude mcp add reference — stdio vs HTTP transports, local/project/user scopes, .mcp.json with env expansion, OAuth via /mcp, and the gotchas.
- Postgres Index StrategistRecommend the right Postgres index for a query or workload — choosing B-Tree vs. GIN vs. BRIN vs. partial/covering/expression, checking for redundant or unused indexes, and verifying the choice against the query plan. Use when a query needs an index, when deciding an index type for jsonb/array/full-text/time-series data, or when auditing an over-indexed table.
- SQL OptimizerDiagnose a slow SQL query from its execution plan and propose a verified optimization — finding the real bottleneck (sequential scan, missing or unused index, bad join order, app-side N+1) and measuring the fix before and after. Use when a query is slow and you need a fix backed by EXPLAIN ANALYZE, not a guess.
- Profile Postgres QueriesProfile a Postgres workload to find the queries actually costing you — rank by total time with pg_stat_statements, EXPLAIN the worst offenders, and recommend the highest-leverage fix.
- Supabase MCPSupabase's official MCP server — run SQL and migrations, read logs and advisors, generate types, and deploy Edge Functions, with read-only and project scoping.
- Indexing Postgres at Scale: B-Tree vs GIN vs BRIN and the Hidden Cost of Over-IndexingA practical guide to choosing Postgres index types — B-Tree, GIN, BRIN, partial, and covering — and why every index you add taxes every write.