Basic information
About Postgres MCP Pro Server
Boost Postgres performance with Postgres MCP Pro—AI-driven index tuning, health checks, and safe, intelligent SQL optimization.
Postgres MCP Pro is a MCP server in the Databases category listed in the AddMCP.net directory, published by crystaldba. It exposes 1 tool, including Health:. Supported transport: stdio. Runtime: Python. License: MIT. The repository has 3,016 GitHub stars. Source code is hosted on github.com. Related topics: community, databases.
Setup
{
"mcpServers": {
"postgres": {
"command": "uv",
"args": [
"run",
"postgres-mcp",
"--access-mode=unrestricted"
],
"env": {
"DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
}
}
}
}
{
"mcpServers": {
"postgres": {
"command": "uv",
"args": [
"run",
"postgres-mcp",
"--access-mode=unrestricted"
],
"env": {
"DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
}
}
}
}
{
"servers": {
"postgres": {
"command": "uv",
"args": [
"run",
"postgres-mcp",
"--access-mode=unrestricted"
],
"env": {
"DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
}
}
}
}
Postgres MCP Pro config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"postgres": {
"command": "uv",
"args": [
"run",
"postgres-mcp",
"--access-mode=unrestricted"
],
"env": {
"DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
}
}
}
}
Postgres MCP Pro tools
- Health: — `analyze_db_health` runs the full set of health checks.
Overview
What is Postgres MCP Pro?
Postgres MCP Pro is an open-source postgres mcp server from Crystal DBA that gives AI agents safe SQL execution, schema intelligence, EXPLAIN plans, database health checks and index tuning for PostgreSQL.
It does more than wrap a database connection. Alongside running queries, it adds deterministic tools for performance work: it finds slow queries with pg_stat_statements, simulates hypothetical indexes with hypopg, and searches for an index configuration that suits your workload. A restricted, read-only access mode makes it usable against production databases. It is MIT-licensed, published on PyPI as postgres-mcp and on Docker Hub as crystaldba/postgres-mcp, and supports both stdio and SSE transports.
How to use Postgres MCP Pro?
Prerequisites: a PostgreSQL connection URI (check it first with psql or pgAdmin) and either Docker or Python 3.12+. The maintainers generally recommend Docker, because Python installs can hit more environment-specific issues.
Install one way:
docker pull crystaldba/postgres-mcp
# or
pipx install postgres-mcp
# or
uv pip install postgres-mcp
Choose an access mode: --access-mode=unrestricted allows full read/write access to data and schema (for development); --access-mode=restricted limits the agent to read-only transactions and caps execution time (for production).
Claude Desktop
Edit claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json, Windows: %APPDATA%/Claude/claude_desktop_config.json). With 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 Docker image remaps localhost automatically (host.docker.internal on macOS/Windows, 172.17.0.1 or the right host address on Linux). With uvx instead:
{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": ["postgres-mcp", "--access-mode=restricted"],
"env": {
"DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
}
}
}
}
If you installed with pipx, use "command": "postgres-mcp"; with uv, use "command": "uv" and "args": ["run", "postgres-mcp", "--access-mode=unrestricted"].
Claude Code
Add the same stdio command with the Claude Code CLI:
claude mcp add postgres \
-e DATABASE_URI=postgresql://username:password@localhost:5432/dbname \
-- uvx postgres-mcp --access-mode=restricted
Cursor
Open Cursor Settings from the Command Palette, go to the MCP tab and paste one of the mcpServers blocks above. Windsurf (Open Windsurf Settings Page), Goose (goose configure → Add Extension) and Qodo Gen use the same configuration.
SSE transport (shared or remote server)
Start the server with --transport=sse:
docker run -p 8000:8000 \
-e DATABASE_URI=postgresql://username:password@localhost:5432/dbname \
crystaldba/postgres-mcp --access-mode=unrestricted --transport=sse
Then point Cursor (mcp.json) or Cline at it with {"type": "sse", "url": "http://localhost:8000/sse"}. Windsurf uses serverUrl instead of url.
Optional extensions
For index tuning and workload analysis, enable pg_stat_statements and hypopg. On managed services such as AWS RDS, Azure or Google Cloud SQL they are usually available already:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
CREATE EXTENSION IF NOT EXISTS hypopg;Key features of Postgres MCP Pro
- Database health checks: index health (duplicate, unused, invalid), connection utilization, buffer cache hit rates, vacuum health, sequence limits, constraint validation and replication lag.
- Index tuning based on a version of Microsoft's Anytime algorithm, exploring many candidate indexes and weighing performance gains against storage cost.
- EXPLAIN plans, including simulations of hypothetical indexes before you create them.
- Schema intelligence for context-aware SQL generation.
- Safe SQL execution with restricted (read-only) and unrestricted access modes and safe SQL parsing.
- Everything exposed as MCP tools rather than resources, for broad client support.
- stdio and SSE transports; Docker and Python installs.
Postgres MCP Pro tools
- Schema exploration:
list_schemas,list_objects(tables, views, sequences, extensions) andget_object_details(columns, constraints, indexes). - Query execution:
execute_sql, read-only when the server runs in restricted mode. - Query planning:
explain_queryreturns the execution plan and can include hypothetical indexes. - Performance analysis:
get_top_queriesreports the slowest queries frompg_stat_statements;analyze_workload_indexesrecommends indexes for the whole workload;analyze_query_indexesdoes the same for up to 10 specific queries. - Health:
analyze_db_healthruns the full set of health checks.
Use cases of Postgres MCP Pro
- Health check: "Check the health of my database and identify any issues."
- Slow query hunt: "What are the slowest queries in my database? And how can I speed them up?"
- Index recommendations: "Analyze my database workload and suggest indexes to improve performance."
- Query optimization: "Help me optimize this query: SELECT * FROM orders JOIN customers ON ..."
- ORM performance fixes in the editor: the project's demo uses Cursor to fix slow SQLAlchemy queries in a generated app.
- Schema-aware development: explore an unfamiliar schema and generate SQL that matches it.
Frequently asked questions
1 Who makes Postgres MCP Pro? Is it official?
It is created and maintained by Crystal DBA. It is not an official PostgreSQL project, and it is a different project from the archived reference Postgres MCP server.
2 Is this postgres mcp server free?
Yes. It is open source under the MIT license and runs on your own machine or infrastructure.
3 Is it safe to use on a production database?
Use --access-mode=restricted. It limits the agent to read-only transactions and caps execution time. Unrestricted mode allows changes to data and schema and is meant for development.
4 Which PostgreSQL versions are supported?
Testing currently focuses on Postgres 15, 16 and 17; the maintainers plan to support 13 through 17.
5 Does it work with RDS, Cloud SQL or Azure?
Yes. It connects with a standard connection URI, and the README covers enabling the extensions on AWS RDS, Azure SQL and Google Cloud SQL with CREATE EXTENSION.
6 Does it work with Claude Code, Cursor and VS Code?
The README gives full steps for Claude Desktop, plus Cursor, Windsurf, Goose, Qodo Gen and Cline. Other clients that run stdio or SSE MCP servers, including Claude Code, can use the same command.
7 Is it local or remote?
By default it runs locally over stdio. With --transport=sse it can run as a shared server that several clients connect to over HTTP.
8 Do I need API keys?
No. It only needs a DATABASE_URI for your PostgreSQL database.
Videos
Tutorials, guides, and showcases related to Postgres MCP Pro. The player loads when you press play.
Videos belong to their creators. Relevance is approximate; check the channel and description before following setup steps.
Comments
No comments yet
Be the first to share feedback about this listing. Sign in to leave a comment.
Sign In