Skip to content

Summary

An open-source Postgres MCP server that goes beyond running SQL: index tuning, EXPLAIN plans with hypothetical indexes, database health checks and a read-only restricted mode.

Features

  • list_schemas, list_objects and get_object_details for schema-aware SQL
  • execute_sql, read-only when the server runs in restricted mode
  • explain_query with hypothetical indexes to preview a plan before creating an index
  • get_top_queries from pg_stat_statements
  • analyze_workload_indexes and analyze_query_indexes recommend indexes for a workload or up to 10 queries
  • analyze_db_health: index, buffer cache, connection, vacuum, sequence, constraint and replication checks
  • Unrestricted (dev) and restricted read-only (production) access modes
  • Docker image or Python 3.12+; stdio, SSE and Streamable HTTP transports

Installation

Set up this MCP server in your favorite AI agent — copy a ready-made configuration below.

Any MCP-compatible agent

Most agents (Claude, Cursor, Windsurf, VS Code, and more) read a standard mcpServers configuration.

  1. Open your agent's MCP configuration file.
  2. Merge the snippet below into it, filling in the environment variables with your own values.
  3. Restart the agent — the "Postgres MCP Pro" tools will be available.
{
  "mcpServers": {
    "postgres-mcp-pro": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}

Description

Postgres MCP Pro, from Crystal DBA, is an MIT-licensed MCP server for PostgreSQL. It is meant to help an agent through the whole life of a database, from writing schema-aware SQL during development to tuning a production workload, rather than only wrapping a connection.

It works through nine tools. Schema tools (list_schemas, list_objects, get_object_details) give the agent the context to write correct SQL. execute_sql runs statements. explain_query returns the execution plan and can simulate hypothetical indexes to show what an index would change before you create it. get_top_queries reads pg_stat_statements to find the slowest queries, and analyze_workload_indexes / analyze_query_indexes search candidate indexes for a workload or for up to ten queries, using an approach modelled on Microsoft's Anytime index-selection algorithm. analyze_db_health checks index health (duplicate, unused, invalid), buffer cache hit rates, connections, vacuum health, sequence limits, constraints and replication lag.

Access is set per deployment: unrestricted mode allows full read/write and DDL for development, while restricted mode limits the agent to read-only transactions with an execution-time cap, for production. The server runs from Docker (crystaldba/postgres-mcp) or Python 3.12+ (uvx, pipx), takes the connection as DATABASE_URI, and speaks stdio, SSE or Streamable HTTP; the HTTP transports have no authentication of their own, so keep them on a trusted network.

MCP: MySQL MCP Server

by Design Computer

New

Open-source Python MCP server for MySQL: lets an AI assistant list tables, read schemas, sample rows and run SQL against your database, with multi-database mode, SSH tunnelling and stdio or SSE transport.

MCP: DBHub

by Bytebase

Featured

A universal database MCP server — one integration for PostgreSQL, MySQL, SQL Server, SQLite, and MariaDB.

MCP: PlanetScale

by PlanetScale

PlanetScale's official hosted MCP server — browse organizations, databases and branches, read schema, run guarded SQL, and pull Insights and schema recommendations.

Browse all MCP servers →