---
title: "Postgres MCP Pro: Query and Tune Postgres from Claude"
url: "https://mcpshelf.co/servers/postgres-mcp-pro"
description: "Postgres MCP Pro by Crystal DBA runs SQL, explains plans, checks database health and suggests indexes. A Docker config that starts today, run read-only."
updated: "2026-10-27"
site: "MCP Shelf"
---

# Postgres MCP Pro

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

Source: https://mcpshelf.co/servers/postgres-mcp-pro  
Markdown: https://mcpshelf.co/servers/postgres-mcp-pro.md  
Generated: 2026-11-24T14:09:07.558Z

## Facts

- **Name:** Postgres MCP Pro
- **Tagline:** SQL, query plans, health checks and index advice for Postgres.
- **Description:** Postgres MCP Pro is an open-source MCP server from Crystal DBA that lets AI assistants query PostgreSQL and tune it, with index advice, query plans and health checks, in a read-only restricted mode when needed.
- **Repository:** https://github.com/crystaldba/postgres-mcp
- **Install:** `claude mcp add postgres-mcp-pro -e DATABASE_URI=postgresql://user:password@localhost:5432/dbname -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted`
- **Transport:** stdio (local)
- **Auth:** Needs `DATABASE_URI`, `--access-mode`
- **Tools exposed:** 9: `list_schemas`, `list_objects`, `get_object_details`, `explain_query`, `analyze_workload_indexes`, `analyze_query_indexes`, `analyze_db_health`, `get_top_queries`, `execute_sql`
- **Category:** Databases and data (https://mcpshelf.co/categories/databases)
- **Stats:** 3.4K GitHub stars, 147K downloads a week, last commit 17 Aug 2026, 0 upvotes on MCP Shelf
- **Install check:** Started in our test
- **Listed:** 2026-10-26
- **Page updated:** 2026-10-27

## Full description

### What is Postgres MCP Pro?

**Postgres MCP Pro is an open-source MCP server from Crystal DBA that lets AI assistants query PostgreSQL and tune it, with index advice, query plans and health checks, in a read-only restricted mode when needed.**

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 |
| GitHub | https://github.com/crystaldba/postgres-mcp |
| Licence | MIT |
| GitHub stars | 3.4K |
| Downloads | 147K a week |
| Last commit | 17 Aug 2026 |
| Tools | 9 |
| Runs on | Your computer |
| Install check | Started in our test |
| Category | [Databases and data](https://mcpshelf.co/categories/databases) |
| Works with | Claude Code, Cursor, Claude Desktop, VS Code, Codex, Windsurf |
| Setup checked | 27 Oct 2026 |
| Page updated | 27 Oct 2026 |

**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.

#### Try asking Postgres MCP Pro

- "Run a health check on my database and tell me what needs attention first."
- "Explain why this query is slow and suggest indexes: SELECT * FROM orders WHERE customer_id = 42"
- "Which queries use the most time in this database, and how could I speed them up?"

#### MCP Shelf take

> We started Postgres MCP Pro on our own test machine on 26 Oct 2026 and it answered with 9 tools. 4 of the 9 only read; the other 5 can change things. Every tool comes with a useful description, none says whether they change things, and the tool list costs about 500 tokens of context before you ask a thing. Other directories point at a package with the same name that belongs to someone else; the config on this page installs the real one. It sits 4th of 10 in its category on our shelf by GitHub stars (3.4K, with 147K downloads a week).

— MCP Shelf tests (numbers from our own runs), tested on 26 Oct 2026

### What tools does Postgres MCP Pro have?

We listed 9 tools on 26 Oct 2026. 4 only read; the rest can change things or run commands.

| Tool | Kind | What it is for |
| --- | --- | --- |
| `list_schemas` | reads | Lists the schemas in the database. |
| `list_objects` | reads | Lists the tables, views, sequences and extensions in a schema. |
| `get_object_details` | reads | Describes a table or view: columns, constraints and indexes. |
| `explain_query` | changes | Shows how Postgres plans to run a query, and can test the plan with pretend indexes that do not exist yet. |
| `analyze_workload_indexes` | changes | Finds the heaviest queries in your workload and works out which indexes would speed them up most. |
| `analyze_query_indexes` | changes | Suggests the best indexes for up to ten queries you hand it. |
| `analyze_db_health` | changes | Runs a set of fixed checks: cache hit rate, connections, bloated or unused indexes, vacuum and sequence limits. |
| `get_top_queries` | reads | Lists the slowest queries by total time, from pg_stat_statements. |
| `execute_sql` | runs | Runs SQL, limited to read-only transactions in restricted mode. |

#### How clearly it describes its tools

9 of 9 tools have a description and 0 of 9 say whether they change things. The tool list takes at least ~500 tokens of context. No tool says whether it only reads or can change things, so your client treats them all alike: keep approvals on.

### How do I install Postgres MCP Pro?

#### Install steps from the Postgres MCP Pro README

Copied from the project's [README on GitHub](https://github.com/crystaldba/postgres-mcp#readme) on 10 Nov 2026 under its MIT licence.

##### Quick Start

###### Prerequisites

Before getting started, ensure you have:

1. Access credentials for your database.
2. Docker *or* Python 3.12 or higher.

###### Access Credentials

You can confirm your access credentials are valid by using `psql` or a GUI tool such as [pgAdmin](https://www.pgadmin.org/).

###### Docker or Python

The choice to use Docker or Python is yours.
We generally recommend Docker because Python users can encounter more environment-specific issues.
However, it often makes sense to use whichever method you are most familiar with.

###### Installation

Choose one of the following methods to install Postgres MCP Pro:

###### Option 1: Using Docker

Pull the Postgres MCP Pro MCP server Docker image.
This image contains all necessary dependencies, providing a reliable way to run Postgres MCP Pro in a variety of environments.

```
docker pull crystaldba/postgres-mcp
```

###### Option 2: Using Python

If you have `pipx` installed you can install Postgres MCP Pro with:

```
pipx install postgres-mcp
```

Otherwise, install Postgres MCP Pro with `uv`:

```
uv pip install postgres-mcp
```

If you need to install `uv`, see the [uv installation instructions](https://docs.astral.sh/uv/getting-started/installation/).

###### Configure Your AI Assistant

We provide full instructions for configuring Postgres MCP Pro with Claude Desktop.
Many MCP clients have similar configuration files, you can adapt these steps to work with the client of your choice.

###### Claude Desktop Configuration

You will need to edit the Claude Desktop configuration file to add Postgres MCP Pro.
The location of this file depends on your operating system:

- MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%/Claude/claude_desktop_config.json`

You can also use `Settings` menu item in Claude Desktop to locate the configuration file.

You will now edit the `mcpServers` section of the configuration file.

###### If you are using Docker

```
{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_URI",
        "crystaldba/postgres-mcp",
        "--access-mode=unrestricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}
```

The Postgres MCP Pro Docker image will automatically remap the hostname `localhost` to work from inside of the container.

- MacOS/Windows: Uses `host.docker.internal` automatically
- Linux: Uses `172.17.0.1` or the appropriate host address automatically

###### If you are using `uvx`

```
{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=unrestricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}
```

###### If you are using `pipx`

```
{
  "mcpServers": {
    "postgres": {
      "command": "postgres-mcp",
      "args": [
        "--access-mode=unrestricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}
```

###### If you are using `uv`

```
{
  "mcpServers": {
    "postgres": {
      "command": "uv",
      "args": [
        "run",
        "postgres-mcp",
        "--access-mode=unrestricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}
```

###### Connection URI

Replace `postgresql://...` with your [Postgres database connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS).

###### Access Mode

Postgres MCP Pro supports multiple *access modes* to give you control over the operations that the AI agent can perform on the database:

- **Unrestricted Mode**: Allows full read/write access to modify data and schema. It is suitable for development environments.
- **Restricted Mode**: Limits operations to read-only transactions and imposes constraints on resource utilization (presently only execution time). It is suitable for production environments.

To use restricted mode, replace `--access-mode=unrestricted` with `--access-mode=restricted` in the configuration examples above.

###### Other MCP Clients

Many MCP clients have similar configuration files to Claude Desktop, and you can adapt the examples above to work with the client of your choice.

- If you are using Cursor, you can use navigate from the `Command Palette` to `Cursor Settings`, then open the `MCP` tab to access the configuration file.
- If you are using Windsurf, you can navigate to from the `Command Palette` to `Open Windsurf Settings Page` to access the configuration file.
- If you are using Goose run `goose configure`, then select `Add Extension`.
- If you are using Qodo Gen, open the Chat panel, click `Connect more tools`, click `+ Add new MCP`, then add the new configuration.

#### What you need first

- Docker
- A Postgres connection string

#### Claude Code

Where: Your terminal, in the project folder

```bash
claude mcp add postgres-mcp-pro -e DATABASE_URI=postgresql://user:password@localhost:5432/dbname -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted
```

#### Cursor

Where: ~/.cursor/mcp.json, or .cursor/mcp.json in a project

```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"
      }
    }
  }
}
```

#### Claude Desktop

Where: claude_desktop_config.json (Settings → Developer → Edit 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"
      }
    }
  }
}
```

No Docker? With Python 3.12 or later, use uvx postgres-mcp --access-mode=restricted as the command and keep DATABASE_URI in env.

#### VS Code

Where: .vscode/mcp.json in your project

```json
{
  "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"
      }
    }
  }
}
```

#### Codex

Where: ~/.codex/config.toml, shared by the Codex CLI, IDE extension and ChatGPT desktop app

```
[mcp_servers.postgres-mcp-pro]
command = "docker"
args = ["run", "-i", "--rm", "-e", "DATABASE_URI", "crystaldba/postgres-mcp", "--access-mode=restricted"]

[mcp_servers.postgres-mcp-pro.env]
DATABASE_URI = "postgresql://user:password@localhost:5432/dbname"
```

Or run: `codex mcp add postgres-mcp-pro --env DATABASE_URI=postgresql://user:password@localhost:5432/dbname -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted`

#### Windsurf

Where: ~/.codeium/windsurf/mcp_config.json

```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"
      }
    }
  }
}
```

#### ChatGPT

Where: Not supported

ChatGPT on the web only connects to servers by URL. This one runs on your computer: the ChatGPT desktop app can start it from its MCP servers settings, with the same config as the Codex tab.

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.

Checked against the project's own install docs on 27 Oct 2026: https://github.com/crystaldba/postgres-mcp#readme

### How do I configure Postgres MCP Pro?

| Setting | Kind | Required | What it does |
| --- | --- | --- | --- |
| `DATABASE_URI` | env | yes | The Postgres connection string to use. Example: `postgresql://username:password@localhost:5432/dbname` |
| `--access-mode` | flag | yes | unrestricted lets the agent change data and schema, for development. restricted allows read-only queries with a time limit, for production. Example: `--access-mode=restricted` |
| `--transport` | flag | no | stdio by default, or sse to share one server between clients. Example: `--transport=sse` |
| `pg_stat_statements` | config | no | Postgres extension it needs for slow query reports and workload index tuning. |
| `hypopg` | config | no | Postgres extension that lets it test indexes without building them. |

### What can Postgres MCP Pro read and change?

**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.

### Good for

- Finding why a query is slow
- Index suggestions backed by real workload stats
- Safe, read-only exploration of production data

### Postgres MCP Pro not working? Common fixes

**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.

### What are the alternatives to Postgres MCP Pro?

| Server | What it does | Tools | Runs on | Licence | Stars |
| --- | --- | --- | --- | --- | --- |
| [Postgres MCP Pro](https://mcpshelf.co/servers/postgres-mcp-pro) | SQL, query plans, health checks and index advice for Postgres. | 9 | Your computer | MIT | 3.4K |
| [Supabase](https://mcpshelf.co/servers/supabase) | Manage Supabase projects, tables, migrations, logs and Edge Functions. | 29 | Hosted | Apache-2.0 | 3K |
| [MCP Toolbox for Databases](https://mcpshelf.co/servers/mcp-toolbox-for-databases) | Google's toolbox for Postgres, MySQL, BigQuery, Spanner and other databases. | 29 | Your computer | Apache-2.0 | 16.7K |
| [Qdrant](https://mcpshelf.co/servers/qdrant) | Store notes and find them by meaning in a Qdrant vector collection. | 2 | Your computer | Apache-2.0 | 1.6K |
| [Excel MCP Server](https://mcpshelf.co/servers/excel) | Create, edit, format and chart .xlsx files, no Excel needed. | 46 | Your computer | MIT | 4.3K |
| [DBHub](https://mcpshelf.co/servers/dbhub) | One small server for Postgres, MySQL, MariaDB, SQL Server, Oracle and SQLite. | 2 | Your computer | MIT | 3.7K |

### Postgres MCP Pro FAQ

#### How do I add Postgres MCP Pro to Claude Code?

With Docker running, run claude mcp add postgres-mcp-pro -e DATABASE_URI=postgresql://user:password@localhost:5432/dbname -- docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted, using your own connection string. The image rewrites localhost so it reaches a database on your machine.

#### Can I run Postgres MCP Pro without Docker?

Yes, with Python 3.12 or later: run it through uvx postgres-mcp, pipx or uv and pass DATABASE_URI in the env block. The project recommends Docker because the Python route hits more environment problems.

#### Is Postgres MCP Pro safe for production databases?

Use --access-mode=restricted there: it runs read-only transactions with a time limit on each query. Unrestricted mode can change data and schema, so keep it for development databases, and connect with a read-only role as a second guard.

#### Is Postgres MCP Pro free?

Yes. It is open source under the MIT licence and talks to your own database, so there is no service to pay for.

#### Why are index advice and top queries empty?

Those tools need two Postgres extensions: pg_stat_statements for query statistics and hypopg for testing hypothetical indexes. Install them with CREATE EXTENSION, which most managed services such as RDS and Cloud SQL allow.

#### Does Postgres MCP Pro work with Supabase, RDS or Cloud SQL?

Yes, with any Postgres it can reach by connection string. For managed databases, check the network allows your machine and enable the two extensions to get the tuning tools.

#### How is Postgres MCP Pro different from other Postgres servers?

Most just run SQL. This one adds tuning built on classic algorithms: it can test indexes without creating them, explain query plans and run fixed health checks, so its advice is repeatable rather than the model's guess.

#### Postgres MCP Pro or the Supabase MCP server?

Use Supabase's server when your database lives in Supabase and you also want its project, branch, edge function and docs tools. Use Postgres MCP Pro for any Postgres when the goal is query performance and health.

#### How do I add Postgres MCP Pro to Cursor?

In ~/.cursor/mcp.json, or .cursor/mcp.json for one project, add an entry named postgres-mcp-pro that runs docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted, with DATABASE_URI set under env. Save, and the tools show up in Agent chat.

#### Can I use Postgres MCP Pro in VS Code?

Yes, through GitHub Copilot. In .vscode/mcp.json, add a server named postgres-mcp-pro with type stdio that runs docker run -i --rm -e DATABASE_URI crystaldba/postgres-mcp --access-mode=restricted, with DATABASE_URI set under env. Then switch Copilot Chat to Agent mode to use its tools.

#### Does Postgres MCP Pro work with Codex?

Yes. Add an [mcp_servers.postgres-mcp-pro] table to ~/.codex/config.toml with the command and args from the Codex tab, and DATABASE_URI in its env table. The Codex CLI and IDE extension share that file.

Full docs on GitHub: https://github.com/crystaldba/postgres-mcp

## Notes for agents

Fetch these instead of parsing the HTML page:

- llms.txt: https://mcpshelf.co/llms.txt
- llms-full.txt: https://mcpshelf.co/llms-full.txt
- ai.txt: https://mcpshelf.co/ai.txt
- Full catalog (.md): https://mcpshelf.co/catalog.md
- API spec: https://mcpshelf.co/openapi.json
- MCP server: https://mcpshelf.co/mcp
- MCP manifest: https://mcpshelf.co/.well-known/mcp.json
- Developer docs: https://mcpshelf.co/developers

MCP endpoint (Streamable HTTP, no key): https://mcpshelf.co/mcp. REST API: https://mcpshelf.co/api/v1.

