Skip to content

MCP PostgreSQL Ops

Give AI assistants full PostgreSQL DBA superpowers — 30+ tools for performance analysis, bloat detection, lock/deadlock monitoring, autovacuum & schema inspection. No…

Install

$pip install mcp-postgresql-ops

Install command taken from the project's README or registry entry. Always review code before running it.

MCP Server for PostgreSQL Operations and Monitoring


Architecture & Internal (DeepWiki)


Overview

MCP-PostgreSQL-Ops is a professional MCP server for PostgreSQL database operations, monitoring, and management. Supports PostgreSQL 12-18 with comprehensive database analysis, performance monitoring, and intelligent maintenance recommendations through natural language queries. Most features work independently, but advanced query analysis capabilities are enhanced when pg_stat_statements and (optionally) pg_stat_monitor extensions are installed.


Features

  • ✅ Zero Configuration: Works with PostgreSQL 12-18 out-of-the-box with automatic version detection.
  • ✅ Natural Language: Ask questions like "Show me slow queries" or "Analyze table bloat."
  • ✅ Production Safe: Read-only operations, RDS/Aurora compatible with regular user permissions.
  • ✅ Extension Enhanced: Optional pg_stat_statements and pg_stat_monitor for advanced query analytics.
  • ✅ Comprehensive Database Monitoring: Performance analysis, bloat detection, and maintenance recommendations.
  • ✅ Smart Query Analysis: Slow query identification with pg_stat_statements and pg_stat_monitor integration.
  • ✅ Schema & Relationship Discovery: Database structure exploration with detailed relationship mapping.
  • ✅ VACUUM & Autovacuum Intelligence: Real-time maintenance monitoring and effectiveness analysis.
  • ✅ Multi-Database Operations: Seamless cross-database analysis and monitoring.
  • ✅ Enterprise-Ready: Safe read-only operations with RDS/Aurora compatibility.
  • ✅ Developer-Friendly: Simple codebase for easy customization and tool extension.

🔧 Advanced Capabilities

  • Version-aware I/O statistics (enhanced on PostgreSQL 16+, byte columns on PG 18+).
  • Real-time connection and lock monitoring.
  • Background process and checkpoint analysis.
  • Replication status and WAL monitoring.
  • Database capacity and bloat analysis.
  • Wait event catalog with descriptions (PG 17+).
  • WAL summarizer monitoring for incremental backups (PG 17+).
  • Async I/O subsystem monitoring (PG 18+).
  • Per-backend I/O and WAL statistics (PG 18+).

Tool Usage Examples

📸 More Examples with Screenshots →




⭐ Quickstart (5 minutes)

Note: The postgresql container included in docker-compose.yml is intended for quickstart testing purposes only. You can connect to your own PostgreSQL instance by adjusting the environment variables as needed.

If you want to use your own PostgreSQL instance instead of the built-in test container:

  • Update the target PostgreSQL connection information in your .env file (see POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB).
  • In docker-compose.yml, comment out (disable) the postgres and postgres-init-extensions containers to avoid starting the built-in test database.

Flow Diagram of Quickstart/Tutorial

1. Environment Setup

Note: While superuser privileges provide access to all databases and system information, the MCP server also works with regular user permissions for basic monitoring tasks.

git clone https://github.com/call518/MCP-PostgreSQL-Ops.git
cd MCP-PostgreSQL-Ops

### Check and modify .env file
cp .env.example .env
vim .env

Similar plugs

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype…