Postgres MCP Pro

A PostgreSQL MCP server with index tuning, EXPLAIN plans, database health checks and a read-only mode

MCP serverHigh risk

crystaldba/postgres-mcp

Install

{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": ["postgres-mcp", "--access-mode=unrestricted"],
      "env": {
        "DATABASE_URI": "postgresql://username:password@localhost:5432/dbname"
      }
    }
  }
}

For production use --access-mode=restricted

This is third-party code. Review the repository files before installing.

What it does

The server gives the agent DBA tools rather than bare SQL execution. It checks index health, connection usage, buffer cache, vacuum, sequence limits and replication lag. Index tuning searches candidate indexes for your workload, and EXPLAIN plans can be compared with hypothetical indexes. Unrestricted mode suits development, while restricted mode limits work to read-only transactions with an execution time cap.

Who it is for. For backend developers and PostgreSQL admins hunting slow queries and database problems.

Good fit when

  • The app is slow and you need to find slow queries and missing indexes
  • You need to check a production database without risk of changes
  • You want the agent to write SQL that matches the real schema

Not a fit when

  • Your database is not PostgreSQL
  • The agent must not see database data

Example request

Check database health and suggest indexes for the slowest queries

Limitations

Requires Docker or Python 3.12 and a database connection string. Some analysis needs the pg_stat_statements and hypopg extensions. In unrestricted mode the agent can change data and schema; use restricted for production.

How to disable. Remove the postgres block from the MCP client config.

MCP

Transport
stdio, sse
Authentication
API key
Environment variables
Environment variables
DATABASE_URI
required, secret
PostgreSQL connection URI

Security check

  • Works with a database and can change data in unrestricted mode
  • Keeps database credentials in the config

README in short

The README covers five areas: database health, index tuning, query plans, schema understanding and safe SQL execution. A demo walkthrough shows the server speeding up a slow SQLAlchemy app. Installation uses the Docker image or pipx and uv, with Claude Desktop configs and pointers for Cursor and Windsurf. Stdio and SSE transports are supported. MIT licensed.

FAQ

Is it safe for a production database?

Use restricted mode: it allows only read-only transactions and caps execution time.

Docker or Python?

The authors recommend Docker because Python installs hit more environment issues.

Editors’ pick

The official FastAPI skill, bundled with the package, teaching agents to write code for the installed version

SkillLow risk102.3K
Editors’ pick

Official skills and agents from the .NET team: performance, MSBuild, NuGet, upgrades, testing, ASP.NET Core, Blazor and MAUI

PluginMedium risk5.4K

Firebase MCP Server

Firebase CLI and MCP Server

Editors’ pick

Official Firebase MCP server from the Firebase CLI: projects, Firestore, Auth, Crashlytics, Remote Config and function logs

MCP serverHigh risk4.5K
Editors’ pick

Laravel's official MCP server, guidelines and skills: the agent sees the DB schema, logs and package versions and searches ecosystem docs

MCP serverMedium risk3.6K