A Postgres Model Context Protocol (MCP) server that offers safe SQL execution plus advanced DBA tooling such as index tuning, query-plan inspection, workload analysis and health checks. Supports stdio and SSE transports and can run from Docker or a Python 3.12+ environment.
https://github.com/crystaldba/postgres-mcpStop letting your AI assistants guess at database performance issues. Postgres MCP Pro transforms any MCP-compatible AI into a skilled database administrator with professional-grade PostgreSQL optimization tools.
You know the drill: your app slows down, queries take forever, and you're stuck manually analyzing EXPLAIN plans or guessing which indexes might help. Meanwhile, your AI assistant can write SQL but has no clue about the performance implications or database health.
Postgres MCP Pro bridges that gap. Instead of having your AI generate generic "try adding an index" suggestions, it gets access to the same algorithmic approaches used by enterprise database tuning advisors.
Real DBA Tools, Not Just Query Execution
Most PostgreSQL MCP servers just wrap database connections. This one includes:
Safety Without Sacrificing Capability
Two access modes give you flexibility:
The restricted mode uses SQL parsing to prevent transaction control statements, making it safe to connect to production databases without risking data integrity.
Development Workflow: Your AI can now diagnose why that ORM-generated query is taking 3 seconds, suggest specific indexes, and show you the projected performance improvement—all in one conversation.
Production Troubleshooting: Connect safely to production databases and get health reports, slow query analysis, and index recommendations without manual EXPLAIN plan interpretation.
Code Reviews: Have your AI analyze database schemas and query patterns to catch performance issues before they hit production.
Install with Docker (recommended) or Python 3.12+:
# Docker approach
docker pull crystaldba/postgres-mcp
# Python approach
pipx install postgres-mcp
Configure with Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"postgres": {
"command": "docker",
"args": [
"run", "-i", "--rm", "-e", "DATABASE_URI",
"crystaldba/postgres-mcp",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "postgresql://user:pass@localhost:5432/db"
}
}
}
}
The index tuning implementation deserves special attention. Rather than having your AI guess at indexing strategies, it:
This isn't theoretical—it's the same algorithmic approach used by enterprise database tuning tools.
Unlike stdio-only servers, this supports Server-Sent Events transport, letting multiple developers share one server instance:
docker run -p 8000:8000 \
-e DATABASE_URI=postgresql://... \
crystaldba/postgres-mcp --transport=sse
Point multiple MCP clients at http://localhost:8000/sse and you're set.
Your AI assistant is already capable of understanding complex database concepts. Give it the tools to act on that understanding with professional-grade PostgreSQL optimization capabilities.
The combination of AI reasoning with proven algorithmic approaches beats both pure AI guessing and manual database administration. Install Postgres MCP Pro and see the difference in your next database performance conversation.