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.
| Tool | What it is for |
|---|---|
execute_sql | Runs SQL, limited to read-only transactions in restricted mode. |
Changes things4 tools · Can create, edit, send or delete.
| Tool | What it is for |
|---|---|
analyze_db_health | Runs a set of fixed checks: cache hit rate, connections, bloated or unused indexes, vacuum and sequence limits. |
analyze_query_indexes | Suggests the best indexes for up to ten queries you hand it. |
analyze_workload_indexes | Finds the heaviest queries in your workload and works out which indexes would speed them up most. |
explain_query | Shows 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.
| Tool | What it is for |
|---|---|
get_object_details | Describes a table or view: columns, constraints and indexes. |
get_top_queries | Lists the slowest queries by total time, from pg_stat_statements. |
list_objects | Lists the tables, views, sequences and extensions in a schema. |
list_schemas | Lists 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)
{
"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"
}
}
}
}Where it goes: Your terminal, in the project folder
claude mcp add-json 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"}}'Where it goes: ~/.cursor/mcp.json, or .cursor/mcp.json in a project
{
"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"
}
}
}
}Where it goes: .vscode/mcp.json in your project
{
"servers": {
"postgres-mcp-pro": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"DATABASE_URI",
"crystaldba/postgres-mcp",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "postgresql://user:password@localhost:5432/dbname"
}
}
}
}Where it goes: ~/.codeium/windsurf/mcp_config.json
{
"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"
}
}
}
}Where it goes: Not supported
ChatGPT only connects to remote servers by URL. This one runs on your computer, so use Claude, Cursor or VS Code.
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.
| Setting | What it does |
|---|---|
DATABASE_URIEnvironment variable · required | The Postgres connection string to use.postgresql://username:password@localhost:5432/dbname |
--access-modeCommand line flag · required | unrestricted 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 flag | stdio by default, or sse to share one server between clients.--transport=sse |
pg_stat_statementsConfig | Postgres extension it needs for slow query reports and workload index tuning. |
hypopgConfig | Postgres 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.
| Server | Tools | Runs on | Licence | Stars |
|---|---|---|---|---|
| Postgres MCP Pro | 9 | Your computer | MIT | 3.4K |
| Supabase | 29 | Hosted | – | 3K |
| MCP Toolbox for Databases | 29 | Your computer | Apache-2.0 | 16.7K |
| Qdrant | 2 | Your computer | Apache-2.0 | 1.6K |
| Excel MCP Server | 46 | Your computer | MIT | 4.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.
Something wrong on this page? Tell us.