← Back to directory
P

Postgres MCP Pro

Community
Configurable read/write access and performance analysis for PostgreSQL MCP
GitHub source repository ↗
★ 3.2k Stars Category · Database Popular Source revision 15c8e3335354
48FMRS · D
Reliability
9/20
Security and permissions
7/20
Maintenance
10/20
Documentation
11/20
Setup experience
11/20

Postgres MCP Pro is a feature-rich PostgreSQL MCP server offering health checks, index tuning, and safe SQL execution. Its use of classic optimization algorithms rather than relying solely on LLMs enhances reliability. Suitable for teams aiming to boost database performance and AI-assisted development.

Read the FMRS scoring method →

Postgres MCP Pro is an open-source Model Context Protocol (MCP) server that supports developers and AI agents across the entire development lifecycle, from initial coding to production tuning and maintenance. It offers database health checks, index tuning, query plan analysis, safe SQL execution, and more, with configurable access modes for development and production environments.

Tools

list_schemas
List all database schemas available in the PostgreSQL instance.
list_objects
List database objects (tables, views, sequences, extensions) within a specified schema.
get_object_details
Provide information about a specific database object, such as columns, constraints, and indexes.
execute_sql
Execute SQL statements on the database, with read-only limitations when connected in restricted mode.
explain_query
Get the execution plan for a SQL query, showing how Postgres will process it. Can be used with hypothetical indexes to simulate behavior after adding indexes.
get_top_queries
Report the slowest SQL queries based on total execution time using pg_stat_statements data.
analyze_workload_indexes
Analyze the database workload to identify resource-intensive queries, then recommend optimal indexes.
analyze_query_indexes
Analyze a list of specific SQL queries (up to 10) and recommend optimal indexes.
analyze_db_health
Perform comprehensive health checks including buffer cache hit rates, connection health, constraint validation, index health, sequence limits, and vacuum health.

Setup

  1. Ensure you have database access credentials and verify them (e.g., using psql).
  2. Choose an installation method: Docker (docker pull crystaldba/postgres-mcp) or Python (via pipx or uv install postgres-mcp).
  3. Configure your MCP client (e.g., Claude Desktop) by editing its configuration file, adding an mcpServers entry with the DATABASE_URI environment variable and access mode (--access-mode=unrestricted or --access-mode=restricted).
  4. Optionally, enable required extensions (pg_stat_statements and hypopg) for index tuning and performance analysis.
claude_desktop_config.json
{
  "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"
      }
    }
  }
}

Fit and risk

Best for

  • PostgreSQL developers needing deep performance analysis and index tuning
  • DBAs who need read-only access and health checks in production
  • Teams that want AI assistants to help with database optimization and monitoring

Not for

  • Users needing full write access but wanting safety controls (restricted mode is read-only)
  • Users of non-PostgreSQL databases
  • Users needing real-time monitoring or alerting (this tool is analytical)

Required permissions

  • Database connection credentials (connection URI)
  • Read-write or read-only database access (depending on access mode)
  • Optional: permission to load extensions (pg_stat_statements, hypopg)
  • Optional: OpenAI API key for experimental LLM index tuning

Risks and side effects

  • Unrestricted mode can allow SQL that might damage or delete data
  • SQL parsing may not prevent all bypasses of read-only restrictions if unsafe procedural languages are enabled
  • Connection credentials may be stored in plaintext in MCP client configuration
  • Index tuning search may consume significant database resources

Troubleshooting

  1. Ensure DATABASE_URI is correct and the database is reachable
  2. Check that required extensions (pg_stat_statements, hypopg) are installed
  3. If using Docker, verify port and network configuration
  4. Inspect server logs for error messages
  5. Try different access modes (unrestricted or restricted)

Use cases

Check database health and identify issues
Analyze slow queries and get optimization suggestions
Get index recommendations for your workload
Optimize a specific query
Simulate the impact of adding indexes
Execute SQL safely in development environments

Supported clients

Claude DesktopFull support
CursorFull support
WindsurfFull support
GooseFull support
Qodo GenFull support