Postgres MCP Pro

An MCP server that analyzes database health, tunes indexes, explains queries, and safely executes SQL against PostgreSQL.
  • python

0

GitHub Stars

python

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs

Postgres MCP Pro is an MCP server that lets you safely interact with PostgreSQL while gaining health checks, index tuning, and explain plan insights. It provides structured tools for querying, analyzing workloads, and driving performance improvements with deterministic checks and safe execution modes designed for both development and production contexts.

How to use

You connect your MCP client to Postgres MCP Pro to perform health checks, tune indexes, review query plans, and execute SQL in a controlled environment. Use the available tools to inspect schemas, list objects, analyze top queries, and generate index recommendations. You can run in either a local stdio configuration or connect via the SSE transport for multi-client setups.

How to install

Prerequisites: you need access credentials for your PostgreSQL database and a runtime environment (Docker or Python 3.12+). Use the Docker-based setup for the most predictable experience, or pick Python tooling if you prefer local development.

HTTP MCP server via SSE transport

{
  "type": "http",
  "name": "postgres_sse",
  "url": "http://localhost:8000/sse",
  "args": []
}
```} ,{

StdIO MCP server configurations

{
  "type": "stdio",
  "name": "postgres_docker",
  "command": "docker",
  "args": [
    "run",
    "-i",
    "--rm",
    "-e",
    "DATABASE_URI",
    "crystaldba/postgres-mcp",
    "--access-mode=unrestricted"
  ],
  "env": {
    "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
  }
}
{
  "type": "stdio",
  "name": "postgres_pipx",
  "command": "postgres-mcp",
  "args": [
    "--access-mode=unrestricted"
  ],
  "env": {
    "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
  }
}
{
  "type": "stdio",
  "name": "postgres_uvx",
  "command": "uv",
  "args": [
    "run",
    "postgres-mcp",
    "--access-mode=unrestricted"
  ],
  "env": {
    "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
  }
}

Notes on usage and features

Postgres MCP Pro supports two access modes to balance convenience and safety. Unrestricted mode allows full read/write operations, ideal for development. Restricted mode limits to read-only transactions and caps execution time to protect production environments.

Postgres MCP Pro Development

If you are developing locally, you can set up the server with the following commands to run against your PostgreSQL instance.

Additional configuration and tools

For extended capabilities, enable the optional extensions and use the included tools to inspect health, analyze workloads, and generate index recommendations. The server provides a suite of tools for schema inspection, query analysis, and health checks.

Troubleshooting and notes

If you encounter connection issues, verify your DATABASE_URI, ensure the Postgres instance is reachable, and confirm that the MCP server process is running with the correct environment variables. For safety, consider using restricted mode in production to limit potential damage from unexpected queries.

Available tools

list_schemas

Lists all database schemas available in the PostgreSQL instance.

list_objects

Lists database objects (tables, views, sequences, extensions) within a specified schema.

get_object_details

Provides information about a specific database object, for example, a table's columns, constraints, and indexes.

execute_sql

Executes SQL statements on the database, with read-only limitations when connected in restricted mode.

explain_query

Gets the execution plan for a SQL query describing how PostgreSQL will process it and exposing the query planner's cost model. Can be invoked with hypothetical indexes to simulate the behavior after adding indexes.

get_top_queries

Reports the slowest SQL queries based on total execution time using pg_stat_statements data.

analyze_workload_indexes

Analyzes the database workload to identify resource-intensive queries, then recommends optimal indexes for them.

analyze_query_indexes

Analyzes a list of specific SQL queries (up to 10) and recommends optimal indexes for them.

analyze_db_health

Performs comprehensive health checks including: buffer cache hit rates, connection health, constraint validation, index health, sequence limits, and vacuum health.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational