PostgreSQL MCP Server

PostgreSQL database health, index tuning, and schema analysis for AI agents.

Data last scanned last week · Reviewed last month

Overview

Postgres MCP Pro facilitates database management by providing AI agents with deep insights into PostgreSQL internals. The server assists with performance optimization by offering index tuning recommendations, analyzing EXPLAIN plans, and simulating the impact of hypothetical schema changes on query performance. Beyond performance tuning, the tool provides health monitoring for production environments, including metrics for replication lag, vacuum health, and sequence limits. It supports both stdio and SSE transport protocols, allowing for flexible integration across various development and deployment workflows.

Our verdict

With a security score of 44/100, this server is classified as high risk. The rating reflects that it is community-maintained rather than vendor-official and its authentication, read-only mode, and OAuth implementations remain unreviewed. Users should exercise caution and ensure they have validated the tool's access controls before deploying it in sensitive database environments.

  • Analyzes index health and database replication lag
  • Provides context-aware SQL generation based on schema
  • Zero direct dependencies minimize supply chain surface area
  • Supports both stdio and SSE transport protocols
  • Community-maintained status lacks formal vendor verification
  • Authentication and read-only modes are currently unreviewed
  • Repository has not received commits in over 180 days

Tools

ToolDescriptionRisk
list_schemasLists all database schemas available in the PostgreSQL instance.low
list_objectsLists database objects (tables, views, sequences, extensions) within a specified schema.low
get_object_detailsProvides information about a specific database object, for example, a table's columns, constraints, and indexes.low
execute_sqlExecutes SQL statements on the database, with read-only limitations when connected in restricted mode.high
explain_queryGets 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.low
get_top_queriesReports the slowest SQL queries based on total execution time using pg_stat_statements data.low
analyze_workload_indexesAnalyzes the database workload to identify resource-intensive queries, then recommends optimal indexes for them.low
analyze_query_indexesAnalyzes a list of specific SQL queries (up to 10) and recommends optimal indexes for them.low
analyze_db_healthPerforms comprehensive health checks including: buffer cache hit rates, connection health, constraint validation, index health (duplicate/unused/invalid), sequence limits, and vacuum health.low
analyze_query_workloadAnalyzes slow queries in the workload based on execution count and mean execution time to identify index tuning targets.low

Compatibility

ClientLocalDockerRemoteRead-only
ChatGPT
Claude Desktop
Cursor
VS Code
Windsurf

Frequently asked questions

What are the environment prerequisites for running the Postgres MCP server?

You need valid database access credentials and either Docker or Python 3.12 or higher installed on your system.

Does the server support different transport methods?

Yes, it supports both Standard Input/Output (stdio) and Server-Sent Events (SSE) transports for flexible deployment.

How can I restrict SQL execution capabilities?

The server includes configurable access control, which allows you to enable read-only mode and use safe SQL parsing for production environments.

Are there specific requirements for using the Docker installation method?

The server automatically handles hostname remapping for 'localhost' to work from inside the container, supporting host.docker.internal on MacOS and Windows, or the appropriate host address on Linux.

Alternatives

Changelog

Badge

PostgreSQL MCP Server security score, rated on RepoAI

Maintain this server? Add the live badge to your README.