by call518
πProfessional MCP server for PostgreSQL operations & monitoring: 30+ extension-independent tools for performance analysis, table bloat detection, autovacuum monitoring, schema introspection, and database management. Supports PostgreSQL 12+.
# Add to your Claude Code skills
git clone https://github.com/call518/MCP-PostgreSQL-OpsMCP-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 and (optionally) extensions are installed.
No comments yet. Be the first to share your thoughts!
pg_stat_statementspg_stat_monitorpg_stat_statements and pg_stat_monitor for advanced query analytics.pg_stat_statements and pg_stat_monitor integration.

Note: The
postgresqlcontainer included indocker-compose.ymlis 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
.envfile (see POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB).- In
docker-compose.yml, comment out (disable) thepostgresandpostgres-init-extensionscontainers to avoid starting the built-in test database.

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
### No need to modify defaults, but if using your own PostgreSQL server, edit below:
POSTGRES_HOST=host.docker.internal
POSTGRES_PORT=15432 # External port for host access (mapped to internal 5432)
POSTGRES_USER=postgres
POSTGRES_PASSWORD=changeme!@34
POSTGRES_DB=ecommerce # Default connection DB. Superusers can access all DBs.
Note:
PGDATA=/data/dbis preconfigured for the Percona PostgreSQL Docker image, which requires this specific path for proper write permissions.
# Start all containers including built-in PostgreSQL for testing
docker-compose up -d
# Alternative: If using your own PostgreSQL instance
# Comment out postgres and postgres-init-extensions services in docker-compose.yml
# Then use the custom configuration:
# docker-compose -f docker-compose.custom-db.yml up -d
β° Wait for Environment Setup: The initial environment setup takes a few minutes as containers are started in sequence:
- PostgreSQL container starts first with database initialization
- PostgreSQL Extensions container installs extensions and creates comprehensive test data (~83K records)
- MCP Server and MCPO Proxy containers start after PostgreSQL is ready
- OpenWebUI container starts last and may take additional time to load the web interface
π‘ Tip: Wait 2-3 minutes after running
docker-compose up -dbefore accessing OpenWebUI to ensure all services are fully initialized.
π Check Container Status (Optional):
# Monitor container startup progress
docker-compose logs -f
# Check if all containers are running
docker-compose ps
# Verify PostgreSQL is ready
docker-compose logs postgres | grep "ready to accept connections"
http://localhost:3003/
swagger can be found in the MCPO API Docs URL.
http://localhost:8003/docsπ Note: Web-UI configuration instructions are based on OpenWebUI v0.6.22. Menu locations and settings may differ in newer versions.
postgresql-ops Tool address (e.g., http://localhost:8003/postgresql-ops) to connect MCP Tools.Congratulations! Your MCP PostgreSQL Operations server is now ready for use. You can start exploring your databases with natural language queries.
The create-test-data.sql script is executed by the postgres-init-extensions container (defined in docker-compose.yml) on first startup, automatically generating comprehensive test databases for MCP tool testing:
| Database | Purpose | Schema & Tables | Scale | |----------|---------|-----------------|-------| | ecommerce | E-commerce system | public: categories, products, customers, orders, order_items | 10 categories, 500 products, 100 customers, 200 orders, 400 order items | | analytics | Analytics & reporting | public: page_views, sales_summary | 1,000 page views, 30 sales summaries | | inventory | Warehouse management | public: suppliers, inventory_items, purchase_orders | 10 suppliers, 100 items, 50 purchase orders | | hr_system | HR management | public: departments, employees, payroll | 5 departments, 50 employees, 150 payroll records |
Test users created: app_readonly, app_readwrite, analytics_user, backup_user
Optimized for testing: Intentional table bloat, various indexes (used/unused), time-series data, complex relationships
Automatic Adaptation: All tools work transparently across supported versions - no configuration needed!
| Tool Name | Extensions Required | PG 12 | PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 | System Views/Tables Used |
|-----------|-------------------|-------|-------|-------|-------|-------|-------|-------|--------------------------|
| get_server_info | β None | β
| β
| β
| β
| β
| β
| β
| version(), pg_extension |
| get_active_connections | β None | β
| β
| β
| β
| β
| β
| β
| pg_stat_activity |
| get_postgresql_config | β None | β
| β
| β
| β
| β
| β
| β
| pg_settings |
| get_database_list | β None | β
| β
| β
| β
| β
| β
| β
| pg_database |
| get_table_list | β No