---
title: "Postgres MCP Pro: PostgreSQL queries and index tuning for AI agents"
canonical_url: https://cookiesforai.app/mcp/postgres-mcp-pro
last_updated: 2026-10-03T10:04:47+02:00
type: mcp
summary: "Postgres MCP Pro is an open-source MCP server that gives AI agents access to a PostgreSQL database, with schema browsing, safe SQL execution, EXPLAIN plans, index recommendations and database health checks."
install: "{\"mcpServers\": {\"postgres\": {\"command\": \"docker\", \"args\": [\"run\", \"-i\", \"--rm\", \"-e\", \"DATABASE_URI\", \"crystaldba/postgres-mcp\", \"--access-mode=unrestricted\"], \"env\": {\"DATABASE_URI\": \"postgresql://localhost:5432/dbname\"}}}}"
related:
  - "https://cookiesforai.app/mcp/dbhub"
  - "https://cookiesforai.app/mcp/mongodb"
  - "https://cookiesforai.app/mcp/neon"
  - "https://cookiesforai.app/mcp/redis"
---

# Postgres MCP Pro MCP server

Postgres MCP Pro is an open-source MCP server that gives AI agents access to a PostgreSQL database, with schema browsing, safe SQL execution, EXPLAIN plans, index recommendations and database health checks.

| Fact | Value |
|---|---|
| Publisher | Crystal DBA |
| Source | https://github.com/crystaldba/postgres-mcp |
| License | MIT |
| GitHub stars | 3,361 on 2026-10-02 |
| Last code push | 2026-08-17 |
| Page updated | 2026-10-03 |
| Official MCP Registry | not listed |
| Documented clients | Claude Desktop, Cursor, Windsurf, Cline, Goose, Qodo Gen |
| Category | Databases |
| Free tier | Free |
| Cost | Free and open source under MIT, with no paid tier; it runs on your machine against your own PostgreSQL database. |
| Current prices | https://github.com/crystaldba/postgres-mcp |
| Facts checked | 2026-10-02 |

## Connect

Claude Desktop or any client with a JSON config, using Docker:

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

The same with uvx, in read-only restricted mode:

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

Shared server over SSE with Docker:

```
docker run -p 8000:8000 -e DATABASE_URI=postgresql://localhost:5432/dbname crystaldba/postgres-mcp --access-mode=unrestricted --transport=sse
```

Put your database user and password into the URI in the usual user:password@host form. The Docker image remaps localhost to the host machine automatically. On AWS RDS, Azure or Google Cloud SQL, enable pg_stat_statements and hypopg through the provider before using the tuning tools.

## Ask your coding agent

```text
Connect the Postgres MCP Pro MCP server to my coding agent using its documented setup: https://github.com/crystaldba/postgres-mcp.
```

## What it does

Postgres MCP Pro is an MCP server from Crystal DBA, a company that builds tools for PostgreSQL. It connects an AI agent to any Postgres database by connection URI. The agent can list schemas and objects, read a table's columns, constraints and indexes, run SQL, and get the execution plan for a query, which gives it enough context to write SQL that fits the real schema.

Postgres MCP Pro's main difference from a plain database connector is tuning. It reports the slowest queries from pg_stat_statements, recommends indexes for the whole workload or for up to 10 given queries by searching many index combinations, and uses the hypopg extension to test hypothetical indexes in EXPLAIN without creating them. A health check covers buffer cache hit rates, connections, vacuum, sequence limits, replication lag and duplicate or unused indexes.

The server runs locally through Docker, uvx, pipx or uv and needs Python 3.12 or newer outside Docker. It has two access modes: unrestricted for development, and restricted, which allows only read-only transactions with an execution time limit, for production. The repo had 3,359 GitHub stars on 2026-10-01; its last push was 2026-08-17.

Tools it gives your agent: `list_schemas`, `list_objects`, `get_object_details`, `execute_sql`, `explain_query`, `get_top_queries`, `analyze_workload_indexes`, `analyze_query_indexes`, `analyze_db_health`

## When to use it

- Your app's queries are slow and you want index suggestions backed by the real workload.
- You want the agent to read your schema before it writes SQL or ORM code.
- You want a health report on a production database with no write access for the agent.
- You want to check whether a planned index would change a query plan before adding it.

## When to pick something else

- Databases other than PostgreSQL; DBHub covers MySQL, SQL Server, SQLite and others.
- Unattended use in unrestricted mode: the agent can then change data and schema, so use --access-mode=restricted on anything that matters.

## What it needs

- A PostgreSQL connection URI
- Docker, or Python 3.12 or newer
- The pg_stat_statements and hypopg extensions for index tuning and workload analysis

## Questions people ask

### Is Postgres MCP Pro free?

Yes. It is open source under MIT with no paid version; you run it yourself against your own database.

### Can Postgres MCP Pro write to my database, or only read?

That depends on the mode. Unrestricted mode allows full reads and writes, including schema changes; restricted mode limits the agent to read-only transactions with a time limit.

## Related

### Other MCP servers for databases

- [DBHub](https://cookiesforai.app/mcp/dbhub): DBHub is an open-source MCP server by Bytebase that gives AI agents SQL access to PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite through one server with two default tools.
- [MongoDB](https://cookiesforai.app/mcp/mongodb): The MongoDB MCP server gives AI agents access to MongoDB databases and MongoDB Atlas: run find and aggregate queries, inspect schemas and indexes, and create or manage Atlas clusters and users.
- [Neon](https://cookiesforai.app/mcp/neon): The Neon MCP server gives AI agents control of Neon serverless Postgres: create projects and branches, run SQL, inspect schemas, find slow queries and run migrations on a branch before applying them.
- [Redis](https://cookiesforai.app/mcp/redis): The Redis MCP server gives AI agents natural-language access to a Redis database: strings, hashes, lists, sets, sorted sets, streams, JSON documents, pub/sub and vector search indexes.

