MCP-PostgreSQL-Ops
š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-17.
claude mcp add --transport stdio call518-mcp-postgresql-ops python -m mcp_postgresql_ops \ --env POSTGRES_DB="Default database to connect to (can be any DB, read access required)" \ --env POSTGRES_HOST="Hostname or IP of the PostgreSQL server (e.g., localhost or container host)" \ --env POSTGRES_PORT="Port for PostgreSQL (default 5432, can be overridden if using a test container)" \ --env POSTGRES_USER="PostgreSQL user with read-only monitoring privileges" \ --env POSTGRES_PASSWORD="Password for the PostgreSQL user"
How to use
MCP-PostgreSQL-Ops is an MCP server that provides PostgreSQL database operations, monitoring, and maintenance recommendations via natural language queries. It supports PostgreSQL versions 12 through 17 and can leverage optional extensions like pg_stat_statements and pg_stat_monitor for deeper query analytics. Once the MCP server is running, you can connect it through the OpenWebUI and use the built-in tools to perform read-only analysis, performance monitoring, bloat detection, and maintenance recommendations across one or more PostgreSQL databases. The server exposes its capabilities via the MCPO API (documented in the OpenWebUI docs), allowing you to ask questions like: Which queries are slow? What is the current VACUUM effectiveness? How bloated are our tables across databases? The toolset is designed to be safe for production environments, operating in read-only mode unless you explicitly enable non-destructive maintenance aids through controlled queries. To use the tools, ensure your OpenWebUI is connected to the MCP server address (e.g., http://localhost:8003/postgresql-ops) and then navigate to available endpoints or the swagger docs to issue natural-language queries and view structured results.
How to install
Prerequisites:
- Python 3.8+ (preferably 3.10+)
- pip (Python package manager)
- Network access to the target PostgreSQL instance (and necessary credentials)
Step 1: Install the MCP PostgreSQL Ops package
- Option A: Install from PyPI
pip install MCP-PostgreSQL-Ops - Option B: Install from source (clone repository and install)
git clone https://github.com/call518/MCP-PostgreSQL-Ops.git cd MCP-PostgreSQL-Ops pip install -e .
Step 2: Configure environment (example values shown; replace with your own)
- Create a run configuration file or export environment variables as needed. Example:
export POSTGRES_HOST=host.docker.internal export POSTGRES_PORT=15432 export POSTGRES_USER=postgres export POSTGRES_PASSWORD=changeme!@34 export POSTGRES_DB=ecommerce
Step 3: Run the MCP server
- If using the recommended Python module entrypoint:
python -m mcp_postgresql_ops - Or run via your preferred invocation method if using a packaged entrypoint.
Step 4: Verify the server is up
- Check logs for readiness and access the OpenWebUI at the configured URL (e.g., http://localhost:3003/ or as documented by your deployment).
Additional notes
Tips and notes:
- The MCP server operates in a read-only mode for safety in production environments. Ensure your PostgreSQL permissions align with read-only monitoring tasks unless you explicitly enable maintenance-facing features.
- If you use your own PostgreSQL instance, set POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB accordingly. The READMEās quickstart shows a built-in testing container; adjust docker-compose or environment variables if you point to an external database.
- Extensions like pg_stat_statements and pg_stat_monitor enhance query analytics. Install them in your PostgreSQL server if you want richer insights.
- When deploying with OpenWebUI, ensure the MCP server address is correctly configured in the UI to enable tool registration and usage.
- For multi-database analysis, the MCP server will aggregate data across accessible databases, provided the connected user has privileges as needed.
Related MCP Servers
PPTAgent
An Agentic Framework for Reflective PowerPoint Generation
pgmcp
An MCP server to query any Postgres database in natural language.
mem0
⨠mem0 MCP Server: A memory system using mem0 for AI applications with model context protocl (MCP) integration. Enables long-term memory for AI agents as a drop-in MCP server.
zerodha
Zerodha MCP Server & Client - AI Agent (w/Agno & w/Google ADK)
Common_Chronicle
Common Chronicle turns messy context into structured, sourced timelines.
fast -telegram
Telegram MCP Server and HTTP-MTProto bridge | Multi-user auth, intelligent search, file sending, web setup | Docker & PyPI ready