MCP PostgreSQL Ops Server

🔍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.
  • python

137

GitHub Stars

python

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "call518-mcp-postgresql-ops": {
      "command": "uvx",
      "args": [
        "--python",
        "3.12",
        "mcp-postgresql-ops"
      ],
      "env": {
        "POSTGRES_DB": "ecommerce",
        "POSTGRES_HOST": "127.0.0.1",
        "POSTGRES_PORT": "15432",
        "POSTGRES_USER": "postgres",
        "POSTGRES_PASSWORD": "changeme!@34"
      }
    }
  }
}

You use MCP-PostgreSQL-Ops to run a read-only, production-safe MCP server that connects to PostgreSQL databases for monitoring, analysis, and maintenance recommendations. It supports PostgreSQL 12–17, with optional extensions for enhanced query analytics, and provides natural language queries to explore your databases without running SQL manually.

How to use

To use this MCP server, run it with your MCP client in either standard input/output (stdio) mode or HTTP transport mode. In stdio mode, you interact via the local command line interface and feed prompts directly from your MCP client. In HTTP mode, you expose a REST-like endpoint that clients can call remotely, enabling authentication if you enable bearer tokens.

How to install

Prerequisites: Python 3.12, a supported PostgreSQL server (12–17), and network access to PostgreSQL. You may also prefer to run an MCP server container or install via Python packaging tools.

# 1) Install via PyPI (recommended)
pip install mcp-postgresql-ops

# 2) Or install with uv (faster)
uv add mcp-postgresql-ops

# 3) Verify installation
mcp-postgresql-ops --help
# 4) If building from source
git clone https://github.com/call518/MCP-PostgreSQL-Ops.git
cd MCP-PostgreSQL-Ops
uv sync
uv run mcp-postgresql-ops --help

You can also run the MCP server in standalone HTTP mode or stdio mode using the commands shown in the next steps.

## Configuration and usage notes

You control access and connections through environment variables and MCP client configuration. The following key settings are used to connect to PostgreSQL and to configure how the MCP server exposes its interface.

## Security and authentication

For remote HTTP access, you can enable Bearer token authentication. This protects the MCP server when it is exposed to untrusted networks.

## Example queries you can run

Examples you can try with natural language prompts include: Show me the current active connections, What are the slowest queries, Analyze table bloat across all databases, Show database sizes, What tables need VACUUM maintenance.

## Available tools

### get\_server\_info

Show PostgreSQL server version and extension status; check available MCP tools for this version.

### get\_active\_connections

Show all active connections and sessions with database and user.

### get\_postgresql\_config

Show all PostgreSQL configuration parameters.

### get\_database\_list

List all databases and their sizes.

### get\_table\_list

List all tables in a database and their sizes.

### get\_table\_schema\_info

Show detailed schema information for a specific table, including columns, constraints, and indexes.

### get\_database\_schema\_info

Show schema details for a database, including schemas, objects, and permissions.

### get\_table\_relationships

Show foreign key relationships for a given table or across the database.

### get\_user\_list

List database users and their roles.

### get\_index\_usage\_stats

Analyze index usage and identify unused indexes.

### get\_database\_size\_info

Provide overall database size information and growth trends.

### get\_table\_size\_info

Provide size details for tables and indexes.

### get\_vacuum\_analyze\_stats

Show VACUUM and ANALYZE activity statistics.

### get\_current\_database\_info

Show current database information including encoding, collation, and size.

### get\_table\_bloat\_analysis

Analyze table bloat and provide VACUUM recommendations.

### get\_database\_bloat\_overview

Provide a high-level view of bloat by schema.

### get\_autovacuum\_status

Monitor autovacuum status, thresholds, and activity.

### get\_autovacuum\_activity

Show autovacuum activity patterns over time.

### get\_running\_vacuum\_operations

Show currently running VACUUM/ANALYZE operations.

### get\_vacuum\_effectiveness\_analysis

Analyze VACUUM effectiveness and maintenance patterns.

### get\_lock\_monitoring

Show current locks and blocked sessions.

### get\_wal\_status

Show WAL status and archiving information.

### get\_replication\_status

Check replication connections and lag.

### get\_database\_stats

Provide comprehensive performance metrics for databases.

### get\_bgwriter\_stats

Analyze background writer and checkpoint performance.

### get\_user\_functions\_stats

Analyze user-defined function performance (requires track\_functions).

### get\_table\_io\_stats

Analyze table I/O performance and timing (requires track\_io\_timing).

### get\_index\_io\_stats

Analyze index I/O performance (requires track\_io\_timing).

### get\_database\_conflicts\_stats

Check replication conflicts and related statistics.

### get\_pg\_stat\_statements\_top\_queries

Show top slow queries using pg\_stat\_statements (extension required).
Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational