PostgreSQL

Analyze performance, optimize queries, and tune PostgreSQL databases with health checks

Containerized Updated 3 hours ago
Databases

About

License: MIT PyPI - Version Contributors

Analyze and optimize PostgreSQL performance with index tuning, workload-aware query insights, safe execution controls, schema-aware SQL generation, health diagnostics, and EXPLAIN plan simulation.

Features

  • Database Health Analysis: Comprehensive health checks including index health, connection utilization, buffer cache analysis, vacuum health, and replication lag monitoring
  • Advanced Index Tuning: Industrial-strength algorithms that explore thousands of possible indexes using proven optimization techniques
  • Query Performance Optimization: EXPLAIN plan analysis and hypothetical index simulation for performance validation
  • Schema Intelligence: Context-aware SQL generation based on detailed database schema understanding
  • Safe SQL Execution: Configurable access control with read-only mode and SQL parsing for both development and production environments
  • Workload Analysis: Identify resource-intensive queries and get targeted optimization recommendations

What you’ll need to connect

Required:

  • Database URI: PostgreSQL connection string (e.g., postgresql://username:password@localhost:5432/dbname)

Example Usage

  • “Check the health of my database and identify any issues”
  • “What are the slowest queries in my database? And how can I speed them up?”
  • “Analyze my database workload and suggest indexes to improve performance”
  • “Help me optimize this query: SELECT * FROM orders JOIN customers ON orders.customer_id = customers.id WHERE orders.created_at > ‘2023-01-01′”

Known Issues

Some tools require extensions to be installed in the target postgres instance:

  • get_top_queries requires the pg_stat_statements extension
  • analyze_workload_indexes and analyze_query_indexes require the hypopg extension

Configuration

Environment variables

VariableDescriptionRequired
DATABASE_URIThe connection string for your Postgres database; e.g. "postgresql://username:password@localhost:5432/dbname"Yes

Container runtime

Image
ghcr.io/obot-platform/mcp-images/postgresql:0.3.0-obot2
Port
8099
Path
/
Args
postgres-mcp, --access-mode=unrestricted