# MCP-PostgreSQL-Ops [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/call518/MCP-PostgreSQL-Ops  
**GitHub Stars:** 165  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/mcp-postgresql-ops

## Description
Give AI assistants full PostgreSQL DBA superpowers — 30+ tools for performance analysis, bloat detection, lock/deadlock monitoring, autovacuum & schema inspection. No extensions required. PG 12-18.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "mcp-postgresql-ops": {
    "command": "uvx",
    "args": ["--python","3.12","mcp-postgresql-ops"],
    "env": {
      "POSTGRES_HOST": "",
      "POSTGRES_PORT": "",
      "POSTGRES_USER": "",
      "POSTGRES_PASSWORD": "",
      "POSTGRES_DB": ""
    }
  }
}
```

**Requires environment variables:** `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What MCP-PostgreSQL-Ops does

MCP-PostgreSQL-Ops exposes PostgreSQL operations and monitoring through MCP tools that can be invoked with natural-language requests. It is designed for PostgreSQL versions 12 through 18 and focuses on read-only inspection, making it suitable for database visibility tasks where the agent should not modify production data or configuration.

The server covers database performance, capacity, table bloat, active connections, locks, deadlocks, background processes, checkpoints, replication, WAL, schemas, and table relationships. It can also assess VACUUM and autovacuum activity and produce maintenance-oriented findings. Multi-database analysis is supported, allowing monitoring across databases accessible through the configured PostgreSQL connection.

## How it works

The server connects to PostgreSQL using connection settings supplied through environment variables. It detects the PostgreSQL version and adjusts supported statistics and fields accordingly. PostgreSQL 16 and later provide enhanced I/O statistics, PostgreSQL 17 adds wait-event and WAL-summarizer monitoring, and PostgreSQL 18 adds byte-level or per-backend I/O and WAL details described by the project.

Core monitoring works with ordinary database permissions, while superuser access can expose more databases and system information. Query analysis benefits from the optional `pg_stat_statements` extension and can use `pg_stat_monitor` when that extension is installed. These extensions are enhancements rather than prerequisites for the main monitoring features.

## Setup and configuration

A Docker Compose quickstart is provided for local testing. Clone the repository, copy `.env.example` to `.env`, set the PostgreSQL connection values, and start the Compose services. The bundled PostgreSQL container is intended for demonstration; to use an existing database, configure the connection variables and disable the built-in `postgres` and `postgres-init-extensions` services.

The connection settings are `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, and `POSTGRES_DB`. The default database identifies the initial connection, while superusers may be able to access additional databases. The quickstart also starts an MCPO proxy and OpenWebUI environment; the example interface is available on port 3003, and the proxy's API documentation is exposed on port 8003.

## Tools and capabilities

Available operations cover:

- Finding slow queries and analyzing query statistics.
- Inspecting active connections, locks, deadlocks, wait events, and background processes.
- Reviewing database size, capacity, table bloat, and maintenance needs.
- Examining schemas and relationships between database objects.
- Checking VACUUM and autovacuum effectiveness.
- Monitoring replication state, WAL activity, checkpoints, and I/O statistics.
- Comparing or inspecting multiple accessible databases.

## Limitations and notes

Operations are read-only, so the server is intended for observation and recommendations rather than executing maintenance changes. The depth of results depends on PostgreSQL version, available permissions, and installed statistics extensions. Features tied to newer PostgreSQL releases are not available on older versions. The Docker Compose database and generated test data are for quickstart testing, not a substitute for connecting the server to an intended production instance.

_Full upstream README: https://allmcps.com/mcp/mcp-postgresql-ops/readme_

