Postgres MCP Pro

by @crystaldba

Postgres Pro MCP Server

Give assistants PostgreSQL schema access, SQL execution, health checks, and performance analysis. Postgres MCP Pro adds query plans and hypothetical index evaluation with configurable read-only operation.

Databases3,403pythonMIT

Server facts

Postgres MCP Pro

GitHub stars

3,403

Last commit

Aug 17, 2026

Runtime

python

License

MIT

Project

License
MIT
Category
Databases

Tech

Runtime
pythonPython
Transports
stdio
Remote access
No

Activity

GitHub stars
3,403
Last commit
Data as of

Tags

  • Database Health
  • Index Tuning
  • Postgresql
  • Query Optimization

Overview

Postgres MCP Pro is a PostgreSQL integration aimed at both application development and database performance work. It exposes schema and object details so an assistant can understand the database before generating queries. Beyond SQL execution, its tools inspect query plans, identify slow statements, check database health, and recommend indexes. Health analysis covers areas such as cache behavior, connections, vacuum activity, sequence limits, and problematic indexes. Query planning can incorporate hypothetical indexes to assess a possible change before actually creating it.

Access controls distinguish development from more constrained use. Unrestricted mode permits data and schema writes, while restricted mode uses read-only transactions and execution-time limits. The README documents local stdio clients and an SSE service that multiple clients can share. Installation can use Docker or Python, with database credentials required either way; Python users need version 3.12 or newer. Docker is the recommended route in the README because it avoids some environment-specific issues. Fuller workload and index analysis depends on the optional pg_stat_statements and hypopg database extensions, which may need server configuration or additional installation on self-managed Postgres. These prerequisites make the project more than a connection wrapper: its distinguishing features depend on both the MCP process and capabilities available inside the target database.

Install & configure

Requirements

  • Python 3.12+ for this launch path
  • uv with uvx
  • PostgreSQL database access credentials
  • An MCP-compatible client
Documented launch / install command
uvx postgres-mcp --access-mode=restricted

The README supports this restricted replacement for its unrestricted example. pg_stat_statements and hypopg are optional database extensions needed for fuller performance and index analysis. Docker is also documented.

Config file · macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Use Settings → Developer → Edit Config when available. Do not assume a Linux configuration path; check the client documentation for your platform. Remote servers use the app’s connector flow when supported, not the local stdio file shown here. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Desktop configuration
{
  "mcpServers": {
    "postgres-mcp": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "<PostgreSQL connection URI with your database credentials>"
      }
    }
  }
}

Read the Claude Desktop setup guide

Config file · Project: .cursor/mcp.json

User: ~/.cursor/mcp.json

The project path is relative to the workspace root. The tilde denotes your user home directory. Use Cursor’s MCP settings to confirm which configuration and scope your installed version is reading. Merge this example with existing settings; do not overwrite unrelated servers.

Cursor configuration
{
  "mcpServers": {
    "postgres-mcp": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "<PostgreSQL connection URI with your database credentials>"
      }
    }
  }
}

Read the Cursor setup guide

Config file · Workspace: .vscode/mcp.json

For user scope, use the “MCP: Open User Configuration” command if available. Do not guess a user configuration path across operating systems, profiles, containers, or remote workspaces; check the client documentation. Merge this example with existing settings; do not overwrite unrelated servers.

VS Code configuration
{
  "servers": {
    "postgres-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "<PostgreSQL connection URI with your database credentials>"
      }
    }
  }
}

Read the VS Code setup guide

Config file · macOS/Linux: ~/.codeium/windsurf/mcp_config.json

Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json

Open the MCP configuration through Windsurf’s settings when possible to confirm the active file. Paths can differ in managed or future releases; check the client documentation if this location is not present. Merge this example with existing settings; do not overwrite unrelated servers.

Windsurf configuration
{
  "mcpServers": {
    "postgres-mcp": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "<PostgreSQL connection URI with your database credentials>"
      }
    }
  }
}

Read the Windsurf setup guide

Config file · Project scope: .mcp.json at the repository root

The project file uses mcpServers. For user scope, use claude mcp add --scope user rather than assuming .mcp.json in your home directory is the user configuration. Check the client documentation for managed settings and storage details. Merge this example with existing settings; do not overwrite unrelated servers.

Claude Code configuration
{
  "mcpServers": {
    "postgres-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ],
      "env": {
        "DATABASE_URI": "<PostgreSQL connection URI with your database credentials>"
      }
    }
  }
}

Read the Claude Code setup guide

Examples are translated from the published configuration. Supply your own credentials and verify requirements in the upstream README. Remote connectors are shown only where a supported configuration format is known.

Tools

Source: repository README. Tool descriptions are a documented snapshot, not a live capability check.

ToolWhat it does
list_schemasDiscover schemas available in the PostgreSQL instance.
list_objectsInspect tables, views, sequences, and extensions within a schema.
get_object_detailsRead an object's columns, indexes, constraints, and related structural details.
execute_sqlRun SQL statements subject to the configured access restrictions.
explain_queryInspect a query plan and optionally evaluate hypothetical indexes.
get_top_queriesIdentify slow statements using pg_stat_statements execution statistics.
analyze_workload_indexesRecommend indexes for resource-intensive statements across a workload.
analyze_query_indexesRecommend indexes for a supplied set of up to ten SQL queries.
analyze_db_healthCheck cache, connections, indexes, constraints, sequences, and vacuum health.

Use cases

  • Inspect tables, views, constraints, and indexes before writing SQL.
  • Investigate slow queries with execution plans and statistics.
  • Evaluate index recommendations against a workload or selected queries.
  • Review database health using a restricted read-only connection.

Strengths

  • Combines schema exploration with health and performance tooling.
  • Supports hypothetical index evaluation.
  • Documents restricted access, stdio, and shared SSE operation.

Limitations

  • Advanced workload and index analysis needs optional Postgres extensions.
  • Unrestricted mode allows data and schema modification.
  • Native Python execution requires Python 3.12 or newer.

Postgres MCP Pro setup notes

  • Check DATABASE_URI in the Postgres MCP Pro configuration if startup or authentication fails.
  • Postgres MCP Pro's stdio example needs a client that launches local processes.

Frequently asked questions

It limits SQL to read-only transactions and constrains execution time, unlike unrestricted mode which permits data and schema writes.

Related MCP servers