Skip to content

Menu

Postgres MCP Pro

Published

At a glance

Category
Databases
GitHub repository
crystaldba/postgres-mcp
Watch out for
Unrestricted mode gives the agent full read and write access to data and schema, so it is only meant for development databases.

Postgres MCP Pro is an open source MCP server for PostgreSQL, built and maintained by Crystal DBA and released under the MIT licence. Like most database servers it lets an agent list schemas, inspect tables and run SQL, but its main focus is performance work: health checks, EXPLAIN plans, slow query reports and index recommendations.

It is a good replacement for the original reference Postgres server from the MCP project, which has been moved to the servers-archived repository and no longer gets updates. The reference server exposed schema information as MCP resources and ran read-only queries. Postgres MCP Pro uses tools only, which more clients support, and adds an access mode switch so you can choose between full read and write access for development and read-only transactions with a time limit for production.

The index tuning is the part that sets it apart. Rather than asking the model to guess at indexes, analyze_workload_indexes and analyze_query_indexes run a search based on Microsoft's Anytime Algorithm for database tuning, and explain_query can simulate hypothetical indexes through the hypopg extension, so you see the planner's estimate before creating anything.

The repository was still getting commits in late November 2026, though the latest tagged release on GitHub and PyPI is still 0.3.0 from May 2025.

How it connects

Your AI app

An assistant or agent that supports MCP

Postgres MCP Pro

Runs as

  • Python (uv / pip)
  • Docker

Gives the agent

  • Schema browsing
  • SQL execution
  • Query plans
  • Slow queries
  • Index recommendations
  • Health checks

Postgres MCP Pro

Signs in with

  • Username and password
Your AI app talks to Postgres MCP Pro over the Model Context Protocol, and the server carries out the work. Built from the setup and capability sections on this page.

What it can do

Schema browsing
list_schemas, list_objects and get_object_details list schemas, tables, views, sequences and extensions, and show a table's columns, constraints and indexes.
SQL execution
execute_sql runs statements against the database, limited to read-only transactions when the server runs in restricted mode.
Query plans
explain_query returns the execution plan for a query and can include hypothetical indexes to show how the plan would change.
Slow queries
get_top_queries reports the slowest queries by total execution time, using pg_stat_statements data.
Index recommendations
analyze_workload_indexes looks at the heaviest queries in the workload and recommends indexes; analyze_query_indexes does the same for up to 10 queries you supply.
Health checks
analyze_db_health checks buffer cache hit rates, connections, constraints, duplicate, unused or invalid indexes, sequence limits and vacuum health.

Setting it up

You need database credentials and either Docker or Python 3.12 or later; the README recommends Docker because Python setups hit more environment problems. Pull crystaldba/postgres-mcp, or install with pipx install postgres-mcp or uv pip install postgres-mcp. For Claude Desktop, add a postgres entry under mcpServers in claude_desktop_config.json with command uvx and args ["postgres-mcp", "--access-mode=unrestricted"], and set DATABASE_URI to a connection string such as postgresql://username:password@localhost:5432/dbname in env. The Docker form uses command docker with args run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=unrestricted, and the image remaps localhost to the host machine. Use --access-mode=restricted for read-only access. Cursor, Windsurf, Goose and Qodo Gen take similar settings. To share one server between clients, start it with --transport=sse and point clients at http://localhost:8000/sse. For index tuning and slow query reports, run CREATE EXTENSION for pg_stat_statements and hypopg; on self-managed Postgres, pg_stat_statements must also be in shared_preload_libraries.

Where each client keeps its MCP config file, and the JSON it expects (cheat sheet)

Where it helps

  • Ask which queries are slowest in a database and get index suggestions backed by the tuning search rather than guesswork.
  • Check whether a proposed index would change a query plan before creating it, using hypothetical indexes.
  • Run a health check on a production database in restricted mode and review vacuum, cache and sequence issues.
  • Let a coding agent read an unfamiliar schema and write queries that match the real tables and constraints.
  • Replace the archived reference Postgres server in an existing Claude Desktop setup.

Limitations and things to watch

  • Unrestricted mode gives the agent full read and write access to data and schema, so it is only meant for development databases.
  • Index tuning and slow query reports need the pg_stat_statements and hypopg extensions, which self-managed servers may have to install and preload first.
  • The README says testing focuses on Postgres 15, 16 and 17, with support for 13 through 17 planned.
  • The only network transport is SSE, and the README does not describe any authentication for it, so keep that port off public networks.
  • The connection string, including the password, sits in your client's config file.

Sources

Written from the project's own documentation, checked November 2026.

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…