Skip to content
MCP Shelf

Postgres MCP Pro

View on GitHub

SQL, query plans, health checks and index advice for Postgres.

  • Started in our test
  • ★ 3.4K GitHub stars
  • 147K downloads a week
  • Last commit 17 Aug 2026

At a glance

Most database servers stop at running SQL. Postgres MCP Pro adds the things a DBA would check: explain plans, slow queries from pg_stat_statements, index recommendations, and health checks for vacuum, bloat and connections.

It has an access-mode switch. Restricted mode keeps it to read-only transactions with time limits, which is where to start on any database that matters.

Made by
Crystal DBA
Licence
MIT
Latest version
0.3.0 (16 May 2025)
PyPI package
postgres-mcp
GitHub stars
3.4K
Downloads
147K a week
Last commit
17 Aug 2026
Tools
9
Runs on
Your computer

Our check: We ran this exact config on 26 Oct 2026: it started and answered with 9 tools. The npm package called "postgres-mcp" is a different project (llm-graph/postgres-mcp). Crystal DBA publishes this server to PyPI and Docker Hub. In October 2026 "uvx postgres-mcp" falls back to an old 0.1.0 release that crashes, because 0.3.0 pins a pglast version PyPI no longer has, so we publish the Docker image instead.

What's in the pod: its tools

We found 9 tools when we started it on 26 Oct 2026. 4 only read. The rest can change things, so keep your app's "ask before each tool call" setting on for them.

How we tested it: Started with the published Docker config against a local Postgres 16 database. The older "uvx postgres-mcp" config crashed on start (it resolves to release 0.1.0).

Runs commands1 tool · Can start programs or run code.

ToolWhat it is for
execute_sqlRuns SQL, limited to read-only transactions in restricted mode.

Changes things4 tools · Can create, edit, send or delete.

ToolWhat it is for
analyze_db_healthRuns a set of fixed checks: cache hit rate, connections, bloated or unused indexes, vacuum and sequence limits.
analyze_query_indexesSuggests the best indexes for up to ten queries you hand it.
analyze_workload_indexesFinds the heaviest queries in your workload and works out which indexes would speed them up most.
explain_queryShows how Postgres plans to run a query, and can test the plan with pretend indexes that do not exist yet.

Only reads4 tools · Looks things up and changes nothing.

ToolWhat it is for
get_object_detailsDescribes a table or view: columns, constraints and indexes.
get_top_queriesLists the slowest queries by total time, from pg_stat_statements.
list_objectsLists the tables, views, sequences and extensions in a schema.
list_schemasLists the schemas in the database.

Grouped and described by us. The README on GitHub lists the inputs each tool takes.

Set it up

Pick your app for the exact snippet and where it goes.

Where it goes: claude_desktop_config.json (Settings → Developer → Edit Config)

Claude Desktop
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_URI",
        "crystaldba/postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://user:password@localhost:5432/dbname"
      }
    }
  }
}

The image rewrites localhost in the connection string so it reaches a database on your own machine. Swap restricted for unrestricted only on a database you can afford to change.

New to this? See the setup guides for Claude Code, Cursor, Claude Desktop and ChatGPT.

Settings

Names are exactly as the project spells them. Required ones are marked.

SettingWhat it does
DATABASE_URIEnvironment variable · requiredThe Postgres connection string to use.postgresql://username:password@localhost:5432/dbname
--access-modeCommand line flag · requiredunrestricted lets the agent change data and schema, for development. restricted allows read-only queries with a time limit, for production.--access-mode=restricted
--transportCommand line flagstdio by default, or sse to share one server between clients.--transport=sse
pg_stat_statementsConfigPostgres extension it needs for slow query reports and workload index tuning.
hypopgConfigPostgres extension that lets it test indexes without building them.

What it can touch

It can read

  • Schemas, query statistics, plans and health data from the database you connect

It can change

  • Any data or schema, in unrestricted mode
  • Nothing in restricted mode, where every query runs read-only

Safer setup: Use --access-mode=restricted for anything that matters, and connect with a database role that has read-only rights as a second guard.

Before you start

  • Docker
  • A Postgres connection string

If it does not work

Index advice or top queries are empty
Install pg_stat_statements and hypopg. Self-managed Postgres also needs pg_stat_statements added to shared_preload_libraries and a restart.
Docker cannot reach the database
The image already maps localhost to your machine. For a database elsewhere, check the host in DATABASE_URI is reachable from inside Docker.
Python install has dependency errors
It needs Python 3.12 or newer. The project recommends Docker to avoid these issues.

Peas in a pod: similar servers

How Postgres MCP Pro lines up against other databases and data servers on the shelf.

ServerToolsRuns onLicenceStars
Postgres MCP Pro9Your computerMIT3.4K
Supabase29Hosted–3K
MCP Toolbox for Databases29Your computerApache-2.016.7K
Qdrant2Your computerApache-2.01.6K
Excel MCP Server46Your computerMIT4.3K

Questions

How is it different from other Postgres servers?

Besides running SQL, it uses classic tuning algorithms and fixed health checks, so index advice and diagnoses are repeatable rather than the model's guess.

Is it safe for production?

Restricted mode is meant for production: read-only transactions with an execution time limit.

Which Postgres versions work?

It is tested on Postgres 15, 16 and 17.

Does it work with RDS, Cloud SQL or Supabase?

Yes, with any reachable Postgres. Managed services usually let you add the two extensions with CREATE EXTENSION.

Full docs on GitHubcrystaldba/postgres-mcp

Something wrong on this page? Tell us.

More in Databases and data