PostgreSQL Operations
Enables comprehensive PostgreSQL database monitoring, analysis, and management through natural language queries. Provides performance insights, bloat analysis, vacuum monitoring, and intelligent maintenance recommendations across PostgreSQL versions
What is PostgreSQL Operations?
PostgreSQL Operations is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to enables comprehensive postgresql database monitoring, analysis, and management through natural language queries. provides performance insights, bloat analysis, vacuum monitoring, and intelligent maint...
Enables comprehensive PostgreSQL database monitoring, analysis, and management through natural language queries. Provides performance insights, bloat analysis, vacuum monitoring, and intelligent maintenance recommendations across PostgreSQL versions
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Enables comprehensive PostgreSQL database monitoring, analys
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx mcp-postgresql-operationsConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use PostgreSQL Operations
MCP PostgreSQL Operations is a Python-based MCP server that gives AI assistants comprehensive read-only DBA superpowers over PostgreSQL databases spanning versions 12 through 18. It provides over 30 tools covering schema discovery, performance monitoring, bloat analysis, vacuum tracking, lock monitoring, replication status, and intelligent maintenance recommendations — all accessible through natural language queries. Built on FastMCP with automatic version detection, it adapts its capabilities to the connected PostgreSQL version without requiring any database extensions, making it safe and useful against production, RDS, and Aurora databases alike.
Prerequisites
- Python 3.12+ installed
- uv package manager recommended (pip also works)
- PostgreSQL 12–18 database accessible from the server host
- Database credentials with at least SELECT privileges on pg_stat_* views
- An MCP client such as Claude Desktop or Claude Code
Install the package
Install mcp-postgresql-ops from PyPI using uv (faster) or pip.
pip install mcp-postgresql-ops
# or with uv (recommended)
uv add mcp-postgresql-opsConfigure database connection environment variables
Set environment variables for your PostgreSQL connection. All variables have sensible defaults so only POSTGRES_PASSWORD and possibly POSTGRES_HOST need to be overridden for most setups.
export POSTGRES_HOST=127.0.0.1
export POSTGRES_PORT=5432
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=your_password
export POSTGRES_DB=mydbOptional: enable pg_stat_statements for slow query analysis
For enhanced slow query tracking, add the following lines to your postgresql.conf and reload PostgreSQL. This is optional — the server works without it but some query analysis tools will be limited.
# In postgresql.conf:
shared_preload_libraries = 'pg_stat_statements'
track_functions = pl
track_io_timing = onAdd to Claude Desktop configuration
Edit your claude_desktop_config.json to register the MCP server using the uvx runner so credentials stay in the env block.
{
"mcpServers": {
"postgresql-ops": {
"command": "uvx",
"args": ["mcp-postgresql-ops"],
"env": {
"POSTGRES_HOST": "127.0.0.1",
"POSTGRES_PORT": "5432",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "your_password",
"POSTGRES_DB": "mydb"
}
}
}
}Verify the connection
Ask Claude to call get_server_info to confirm the server can connect and to see the detected PostgreSQL version and installed extensions.
PostgreSQL Operations Examples
Client configuration (Claude Desktop)
Complete Claude Desktop config block using uvx with all connection environment variables.
{
"mcpServers": {
"postgresql-ops": {
"command": "uvx",
"args": ["mcp-postgresql-ops"],
"env": {
"POSTGRES_HOST": "db.example.com",
"POSTGRES_PORT": "5432",
"POSTGRES_USER": "readonly_user",
"POSTGRES_PASSWORD": "secret",
"POSTGRES_DB": "production"
}
}
}
}Prompts to try
Natural language queries that map to the server's 30+ tools.
- "What are the top 10 slowest queries in the database?"
- "Show me all tables with significant bloat and estimate how much disk would be reclaimed after VACUUM"
- "Are there any blocked sessions or lock conflicts right now?"
- "Which indexes are unused and safe to drop?"
- "Show me autovacuum activity and whether any tables are falling behind on maintenance"
- "What is the current replication lag on my standby?"Troubleshooting PostgreSQL Operations
Connection refused or authentication failed
Verify POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, and POSTGRES_PASSWORD are set correctly. For remote hosts, confirm the PostgreSQL server's pg_hba.conf allows connections from the MCP server's IP address.
Slow query tools return no data
The get_pg_stat_statements_top_queries tool requires the pg_stat_statements extension. Add `shared_preload_libraries = 'pg_stat_statements'` to postgresql.conf, restart PostgreSQL, then run `CREATE EXTENSION pg_stat_statements;` in the target database.
Some tools are missing or unavailable
Several tools are version-specific (e.g., get_wal_summarizer_status requires PG17+, get_async_io_status requires PG18+). The server auto-detects the PostgreSQL version and only exposes tools that are supported. Check get_server_info to confirm which version was detected.
Frequently Asked Questions about PostgreSQL Operations
What is PostgreSQL Operations?
PostgreSQL Operations is a Model Context Protocol (MCP) server that enables comprehensive postgresql database monitoring, analysis, and management through natural language queries. provides performance insights, bloat analysis, vacuum monitoring, and intelligent maintenance recommendations across postgresql versions It connects AI assistants to external tools and data sources through a standardized interface.
How do I install PostgreSQL Operations?
Follow the installation instructions on the PostgreSQL Operations GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with PostgreSQL Operations?
PostgreSQL Operations works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is PostgreSQL Operations free to use?
Yes, PostgreSQL Operations is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
PostgreSQL Operations Alternatives — Similar Databases Servers
Looking for alternatives to PostgreSQL Operations? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
★ 20.6kGo language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
★ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
★ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
★ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
★ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
★ 1.7k🏎️ 🏠 ☁️ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up PostgreSQL Operations in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use PostgreSQL Operations?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.