PostgreSQL Ops

Databases

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.

Your AI app calls the PostgreSQL Ops MCP server, which does the work through tools like get_server_info, get_active_connections, get_postgresql_config and get_database_list and sends the result back to the chat.

About PostgreSQL Ops

PostgreSQL Ops is a community MCP server from call518, filed in our directory under databases. 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.

The README for PostgreSQL Ops lists tools such as get_server_info, get_active_connections, get_postgresql_config and get_database_list, which your AI app can call once the server is connected.

At a glance

Publisher
call518 (community)
Runs
See the README for setup
Written in
Python
License
MIT
GitHub stars
164

Tools PostgreSQL Ops gives your AI app

  • get_server_info
  • get_active_connections
  • get_postgresql_config
  • get_database_list
  • get_table_list
  • get_table_schema_info
  • get_database_schema_info
  • get_table_relationships
  • get_user_list
  • get_index_usage_stats
  • get_database_size_info
  • get_table_size_info
  • get_vacuum_analyze_stats
  • get_current_database_info
  • get_table_bloat_analysis
  • get_database_bloat_overview
  • get_autovacuum_status
  • get_autovacuum_activity
  • get_running_vacuum_operations
  • get_vacuum_effectiveness_analysis
  • get_lock_monitoring
  • get_wal_status
  • get_replication_status
  • get_database_stats

Tool names as the PostgreSQL Ops README lists them. Your AI app shows the live list once PostgreSQL Ops is connected.

How to set up PostgreSQL Ops

  1. Follow the install steps in the PostgreSQL Ops README; it is written in Python, so have that toolchain ready.
  2. Check the PostgreSQL Ops README for keys or settings; the registry lists none that PostgreSQL Ops requires.
  3. Add PostgreSQL Ops to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the PostgreSQL Ops tools to confirm the connection.
  5. Run one read-only task with PostgreSQL Ops first, such as a call to get_server_info, before you allow anything that writes or sends.

PostgreSQL Ops compared with similar servers

  • Eion by eiondb has fewer GitHub stars than PostgreSQL Ops (160 against 164); both are community servers, and both run locally. The Eion README lists 11 tools to PostgreSQL Ops's 30.
  • Werbot by werbot has more GitHub stars than PostgreSQL Ops (171 against 164); both are community servers, and both run locally.
  • Mssql (Aaronontheweb) by Aaronontheweb has fewer GitHub stars than PostgreSQL Ops (159 against 164); both are community servers, and both run locally.

Before you connect PostgreSQL Ops

  • Give PostgreSQL Ops its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each PostgreSQL Ops tool call until you trust what it does with them.
  • Treat text that PostgreSQL Ops fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for PostgreSQL Ops on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for PostgreSQL Ops

How marketing and sales teams put PostgreSQL Ops to work, by company size. Pick the size closest to yours and start PostgreSQL Ops on one use case.

Small business

  • A small business with its own app can ask PostgreSQL Ops plain questions about customers and orders, without writing SQL.
  • Owners can use PostgreSQL Ops to pull a list of customers who haven't bought in 90 days and plan a win-back email.
  • PostgreSQL Ops runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing analysts can connect PostgreSQL Ops to answer campaign questions from the warehouse directly, instead of waiting on the data team's queue.
  • Lifecycle teams can use PostgreSQL Ops to build audience lists from product data and check counts before a send.
  • Start with get_server_info and get_active_connections, the tools PostgreSQL Ops lists first, and add more once the team trusts the results.

Enterprise

  • Enterprises should point PostgreSQL Ops at a read replica with a read-only role, so agents query freely without risk to production data.
  • Data teams can expose curated views through PostgreSQL Ops, so marketing gets self-serve answers without access to raw customer tables.
  • PostgreSQL Ops is a community server, so have security review the code and pin a version before PostgreSQL Ops touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

PostgreSQL Ops README

From call518/MCP-PostgreSQL-Ops on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

MCP-PostgreSQL-Ops

Give Claude and other AI assistants read-only PostgreSQL observability for slow queries, locks, bloat, VACUUM, indexes, replication, WAL, and capacity.

What is MCP-PostgreSQL-Ops?

MCP-PostgreSQL-Ops lets Claude, OpenWebUI, and other MCP clients inspect a PostgreSQL server through natural-language questions. It turns requests such as “Which tables need VACUUM now?” into predefined, read-only SQL queries and returns the evidence needed to diagnose the database.

  • Read-only tools: no arbitrary SQL execution or data-changing operations.
  • PostgreSQL 12–18: version-specific views and columns are detected automatically.
  • Useful without extensions: core monitoring works immediately; pg_stat_statements and pg_stat_monitor add query analytics.
  • Deployment choice: install a Claude Desktop extension, run with uvx, or connect OpenWebUI directly to the HTTP MCP server.

For an AI-generated code walkthrough, use .

What can you ask?

Show the current active connections and blocked sessions
Which queries consume the most execution time?
Find bloated tables and explain what needs attention first
Which tables need VACUUM or autovacuum tuning?
Show unused or inefficient indexes
Check replication, WAL, checkpoints, and background processes
Summarize database size, growth, and I/O activity
Draw the relationships for the ecommerce schema

More requests to try: see Example Queries for requests by area (performance, health checks, capacity and VACUUM, structure, troubleshooting, multi-step workflows) and per-tool examples.

Core tools work with normal catalog access. Broader cross-database visibility depends on the PostgreSQL role; use a least-privilege monitoring account in production.

Example: slow-query evidence and recommendations

More examples are available in the screenshots and usage wiki.

Quick Start

Choose one path. If you already have PostgreSQL and Claude Desktop, Option A is the shortest. Option B provides a complete local demonstration with sample databases and OpenWebUI.

Option A: Claude Desktop extension (fastest)

Requirements: Claude Desktop with extension support and a PostgreSQL server reachable from the computer running Claude Desktop.

  1. Open the latest GitHub Release and download mcp-postgresql-ops-<version>.mcpb.
  2. In Claude Desktop, open Settings → Extensions → Advanced settings → Install Extension… and select the downloaded file.
  3. Enter the PostgreSQL host, port, user, password, and default database.
  4. Ask Claude: Show the current active PostgreSQL connections.

The password field is marked sensitive and is stored by Claude Desktop. The extension runs the server locally over stdio; it does not expose an HTTP port.

Option B: OpenWebUI 0.13 with the included demo database

Requirements: Git, Docker with the Compose plugin, and an OpenWebUI model provider whose model supports tool calling.

1. Configure

git clone https://github.com/call518/MCP-PostgreSQL-Ops.git
cd MCP-PostgreSQL-Ops
cp .env.example .env
cp mcp-config.json.http mcp-config.json.http.local
chmod 600 mcp-config.json.http.local
openssl rand -hex 32   # use the output as WEBUI_SECRET_KEY
vi .env                # set WEBUI_SECRET_KEY; adjust ports if needed

mcp-config.json.http.local is ignored by Git and is mounted only into MCPO. If REMOTE_AUTH_ENABLE=true, replace <REMOTE_SECRET_KEY> in that local file with the same secret configured in .env. Leave the tracked mcp-config.json.http file as a credential-free template.

The default .env.example credentials are only for the included disposable PostgreSQL demo. Do not reuse them for an existing or externally reachable database.

2. Start

docker compose up -d
docker compose ps --all  # wait for mcp-server to be healthy and init to exit 0

This starts OpenWebUI at http://localhost:3003, the MCP server at http://localhost:18003/mcp, optional MCPO/OpenAPI compatibility at http://localhost:8003, and a disposable PostgreSQL demo environment. The demo includes ecommerce, analytics, inventory, and HR data plus intentional bloat and index patterns for realistic monitoring questions.

3. Connect OpenWebUI to the MCP server

  1. Open http://localhost:3003, create the administrator account, and add a model provider under Settings → Admin → Connections:

    • OpenAI: add an OpenAI API connection with URL https://api.openai.com/v1, enter your OpenAI API key (Auth Bearer), set API Type to Chat Completions, and save it.
    • Ollama on the Docker host: the Compose file already points OpenWebUI to http://host.docker.internal:11434; ensure Ollama is reachable from Docker and pull a tool-capable model.

    Confirm that the model appears in a new chat before continuing.

  2. The Quick Start calls tools through Chat Completions with model reasoning turned off, using this default already present in .env.example:

    DEFAULT_MODEL_PARAMS={"reasoning_effort":"none"}
    

    This value requires API Type: Chat Completions. With Responses, OpenWebUI 0.13.0 still sends reasoning_effort, and every request fails with Unsupported parameter: 'reasoning_effort'. If the open-webui-data volume already exists, set the same value under Settings → Admin → Models → Model Defaults → Model Parameters because its saved database value takes precedence. To keep model reasoning through Responses instead, see OpenAI reasoning models.

  3. Under Settings → Admin → Tools → Integrations → External Tool Servers, add a connection of type MCP (Streamable HTTP) with URL http://mcp-server:8000/mcp and authentication None. This matches the Quick Start default REMOTE_AUTH_ENABLE=false; enable and configure Bearer authentication before exposing the server outside the local Docker host.

  4. Under Settings → Admin → System → Interface → Chat, enable Tool Search and Defer Built-in Tools, then set Deferral Threshold to 0. This keeps the full PostgreSQL tool list within the model's tool limits.

  5. In a new chat, enable the connection under Integrations → Tools and ask: Use mcp-postgresql-ops to show tables that need VACUUM.

If setup or tool calls fail, see OpenWebUI Issues for existing-volume precedence, per-model and per-chat overrides, and provider compatibility notes.

MCPO is optional. OpenWebUI 0.13 connects to the MCP server directly and does not require the MCPO proxy. To expose the tools as an OpenAPI/Swagger service for a legacy client, use MCPO at http://localhost:8003. The Compose file starts it so every project keeps the same deployment layout. To run without it, use docker compose up -d mcp-server open-webui.

To connect the Docker stack to an existing PostgreSQL server instead, update the POSTGRES_* values in .env and run:

docker compose -f docker-compose.custom-db.yml up -d

Why this project?

  • Operational evidence, not arbitrary SQL: every tool uses a predefined monitoring query and returns inspectable PostgreSQL statistics.
  • Automatic version adaptation: one server supports PostgreSQL 12 through 18, including newer I/O, wait-event, checkpointer, and WAL views.
  • Maintenance intelligence: bloat, VACUUM, autovacuum, indexes, locks, capacity, replication, and query performance are covered together.
  • Managed-service friendly: core tools work on RDS/Aurora and with regular monitoring roles; advanced visibility still follows provider permissions.
  • Multiple clients: Claude Desktop, OpenWebUI, any Streamable HTTP MCP client, and optional OpenAPI clients through MCPO.

How it works

Claude Desktop ── stdio ───────────────┐
                                       │
OpenWebUI 0.13 ─ Streamable HTTP ──────┼─> MCP-PostgreSQL-Ops
                                       │      │
OpenAPI client ─ optional MCPO proxy ──┘      └─> read-only SQL ─> PostgreSQL

The MCP server is the required component. OpenWebUI can call it directly; MCPO is only an optional protocol adapter. The DeepWiki architecture provides a code-level walkthrough.

Installation options

Setup Best for Requirements
MCPB extension Fastest Claude Desktop setup Claude Desktop
uvx --python 3.12 mcp-postgresql-ops Explicit local configuration uv
Docker Compose OpenWebUI and HTTP MCP clients Docker Compose
Source checkout Development and customization Git, uv

All methods run the same server. Choose one; they are not cumulative.

Features and compatibility

Tool Compatibility Matrix

Automatic Adaptation: All tools work transparently across supported versions - no configuration needed!

🟢 Extension-Independent Tools (No Extensions Required)
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 ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ information_schema.tables
get_table_schema_info ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ information_schema.*, pg_indexes, pg_constraint
get_database_schema_info ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_namespace, pg_class, pg_proc
get_table_relationships ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_constraint, information_schema.*
get_user_list ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_user, pg_roles
get_index_usage_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_user_indexes
get_database_size_info ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_database_size()
get_table_size_info ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_total_relation_size()
get_vacuum_analyze_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ Enhanced pg_stat_user_tables
get_current_database_info ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_database, current_database()
get_table_bloat_analysis ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_user_tables
get_database_bloat_overview ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_user_tables
get_autovacuum_status ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_user_tables
get_autovacuum_activity ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_user_tables
get_running_vacuum_operations ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_activity
get_vacuum_effectiveness_analysis ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_user_tables
get_lock_monitoring ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_locks, pg_stat_activity
get_wal_status ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_current_wal_lsn()
get_database_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ Enhanced pg_stat_database
get_table_io_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_statio_user_tables
get_index_io_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_statio_user_indexes
get_database_conflicts_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ ✅ pg_stat_database_conflicts
🚀 Version-Aware Tools (Auto-Adapting)
Tool Name Extensions Required PG 12 PG 13 PG 14 PG 15 PG 16 PG 17 PG 18 Special Features
get_io_stats ❌ None ✅ Basic ✅ Basic ✅ Basic ✅ Basic ✅ Enhanced ✅ Enhanced ✅ Enhanced PG16+: pg_stat_io support; PG18+: byte columns
get_bgwriter_stats ❌ None ✅ ✅ ✅ ✅ ✅ ✅ Special ✅ Enhanced PG17: Separate checkpointer stats; PG18+: num_done, slru_written
get_replication_status ❌ None ✅ Compatible ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced PG13+: wal_status, safe_wal_size; PG16+: enhanced WAL receiver; PG17+: invalidation_reason, inactive_since
get_all_tables_stats ❌ None ✅ Compatible ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced PG13+: n_ins_since_vacuum tracking for vacuum maintenance optimization
get_user_functions_stats ⚙️ Config Required ✅ ✅ ✅ ✅ ✅ ✅ ✅ Requires track_functions=pl
get_wait_events ❌ None ✅ Fallback ✅ Fallback ✅ Fallback ✅ Fallback ✅ Fallback ✅ Native ✅ Native PG17+: pg_wait_events catalog; PG12-16: fallback to pg_stat_activity current waits
get_wal_summarizer_status ❌ None ❌ ❌ ❌ ❌ ❌ ✅ ✅ PG17+: WAL summarizer monitoring for incremental backups
get_async_io_status ❌ None ❌ ❌ ❌ ❌ ❌ ❌ ✅ PG18+: pg_aios async I/O subsystem monitoring
get_per_backend_io_stats ❌ None ❌ ❌ ❌ ❌ ❌ ❌ ✅ PG18+: Per-backend I/O and WAL statistics
🟡 Extension-Dependent Tools (Extensions Required)
Tool Name Required Extension PG 12 PG 13 PG 14 PG 15 PG 16 PG 17 PG 18 Notes
get_pg_stat_statements_top_queries pg_stat_statements ✅ Compatible ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced PG12: total_time → total_exec_time; PG13+: native total_exec_time; PG17+: stats_since
get_pg_stat_monitor_recent_queries pg_stat_monitor ✅ Compatible ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced ✅ Enhanced PG12: total_time → total_exec_time; PG13+: native total_exec_time
🆕 Version-Specific Features
PostgreSQL 17
  • pg_wait_events view: Native wait event catalog with descriptions (used by get_wait_events)
  • WAL summarizer: Monitoring for incremental backup support (used by get_wal_summarizer_status)
  • Replication slot enhancements: invalidation_reason and inactive_since columns (used by get_replication_status)
  • pg_stat_statements stats_since: Track when statistics were last reset (used by get_pg_stat_statements_top_queries)
  • VACUUM progress: Index vacuum tracking in progress views (future enhancement for get_running_vacuum_operations)
PostgreSQL 18
  • pg_aios view: Async I/O subsystem monitoring (used by get_async_io_status)
  • Per-backend I/O stats: Individual backend I/O and WAL statistics (used by get_per_backend_io_stats)
  • VACUUM/ANALYZE time columns: total_vacuum_time, total_autovacuum_time, total_analyze_time, total_autoanalyze_time cumulative timing (used by get_vacuum_analyze_stats)
  • pg_stat_io byte columns: read_bytes, write_bytes, extend_bytes (used by get_io_stats)
  • Parallel worker stats: parallel_workers_launched, parallel_workers_to_launch (used by get_database_stats)
  • Checkpointer enhancements: num_done, slru_written columns (used by get_bgwriter_stats)

Other local setups

Run from PyPI with uvx
# Local stdio transport
uvx --python 3.12 mcp-postgresql-ops --type stdio

# Streamable HTTP transport
uvx --python 3.12 mcp-postgresql-ops \
  --type streamable-http \
  --host 127.0.0.1 \
  --port 8000
Run from source
git clone https://github.com/call518/MCP-PostgreSQL-Ops.git
cd MCP-PostgreSQL-Ops
uv sync
uv run mcp-postgresql-ops --help

The package is also available through pip install mcp-postgresql-ops.

Advanced configuration

Claude Desktop Configuration

(Optional) Run with Local Source:

{
  "mcpServers": {
    "mcp-postgresql-ops": {
      "command": "uv",
      "args": ["run", "python", "-m", "mcp_postgresql_ops"],
      "env": {
        "POSTGRES_HOST": "127.0.0.1",
        "POSTGRES_PORT": "15432",
        "POSTGRES_USER": "postgres",
        "POSTGRES_PASSWORD": "changeme",
        "POSTGRES_DB": "ecommerce"
      }
    }
  }
}
Run the MCP server standalone
With PyPI and uvx
# Stdio mode
uvx --python 3.12 mcp-postgresql-ops \
  --type stdio

# HTTP mode
uvx --python 3.12 mcp-postgresql-ops \
  --type streamable-http \
  --host 127.0.0.1 \
  --port 8000 \
  --log-level DEBUG
(Option) Configure Multiple PostgreSQL Instances
{
  "mcpServers": {
    "Postgresql-A": {
      "command": "uvx",
      "args": ["--python", "3.12", "mcp-postgresql-ops"],
      "env": {
        "POSTGRES_HOST": "a.foo.com",
        "POSTGRES_PORT": "5432",
        "POSTGRES_USER": "postgres",
        "POSTGRES_PASSWORD": "postgres",
        "POSTGRES_DB": "postgres"
      }
    },
    "Postgresql-B": {
      "command": "uvx",
      "args": ["--python", "3.12", "mcp-postgresql-ops"],
      "env": {
        "POSTGRES_HOST": "b.bar.com",
        "POSTGRES_PORT": "5432",
        "POSTGRES_USER": "postgres",
        "POSTGRES_PASSWORD": "postgres",
        "POSTGRES_DB": "postgres"
      }
    }
  }
}
/w Local Source
# Method 1: Module execution (for development, requires PYTHONPATH)
PYTHONPATH=/path/to/MCP-PostgreSQL-Ops/src
python -m mcp_postgresql_ops \
  --type stdio

# Method 2: Direct script (after uv installation in project directory)
uv run mcp-postgresql-ops \
  --type stdio

# Method 3: Installed package script (after pip/uv install)
mcp-postgresql-ops \
  --type stdio

# HTTP mode examples:
# Development mode
PYTHONPATH=/path/to/MCP-PostgreSQL-Ops/src
python -m mcp_postgresql_ops \
  --type streamable-http \
  --host 127.0.0.1 \
  --port 8000 \
  --log-level DEBUG

# Production mode (after installation)
mcp-postgresql-ops \
  --type streamable-http \
  --host 127.0.0.1 \
  --port 8000 \
  --log-level DEBUG

CLI Arguments

  • --type: Transport type (stdio or streamable-http) - Default: stdio
  • --host: Host address for HTTP transport - Default: 127.0.0.1
  • --port: Port number for HTTP transport - Default: 8000
  • --auth-enable: Enable Bearer token authentication for streamable-http mode - Default: false
  • --secret-key: Secret key for Bearer token authentication (required when auth enabled)
  • --log-level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - Default: INFO

Environment Variables

Variable Description Default Project Default
PYTHONPATH Python module search path (only needed for development mode) - /app/src
MCPO_CONFIG_FILE Ignored local MCPO configuration mounted by Docker Compose mcp-config.json.http.local mcp-config.json.http.local
MCP_LOG_LEVEL Server logging verbosity (DEBUG, INFO, WARNING, ERROR) INFO INFO
FASTMCP_TYPE MCP transport protocol (stdio for CLI, streamable-http for web) stdio streamable-http
FASTMCP_HOST HTTP server bind address (0.0.0.0 for all interfaces) 127.0.0.1 0.0.0.0
FASTMCP_PORT HTTP server port for MCP communication 8000 8000
REMOTE_AUTH_ENABLE Enable Bearer token authentication for streamable-http mode (Default: false if undefined/null/empty) false false
REMOTE_SECRET_KEY Secret key for Bearer token authentication (required when auth enabled) - empty
PGSQL_VERSION PostgreSQL major version for Docker image selection 16 16
PGDATA PostgreSQL data directory inside Docker container (Do not modify) /var/lib/postgresql/data /data/db
POSTGRES_HOST PostgreSQL server hostname or IP address 127.0.0.1 host.docker.internal
POSTGRES_PORT PostgreSQL server port number 5432 15432
POSTGRES_USER PostgreSQL connection username (needs read permissions) postgres postgres
POSTGRES_PASSWORD PostgreSQL user password (supports special characters) changeme changeme
POSTGRES_DB Default database name for connections testdb ecommerce
POSTGRES_MAX_CONNECTIONS PostgreSQL max_connections configuration parameter 200 200
DOCKER_BIND_ADDRESS Host address for published Docker ports 127.0.0.1 127.0.0.1
DOCKER_EXTERNAL_PORT_OPENWEBUI Host port mapping for Open WebUI container 8080 3003
DOCKER_EXTERNAL_PORT_MCP_SERVER Host port mapping for MCP server container 8080 18003
DOCKER_EXTERNAL_PORT_MCPO_PROXY Host port mapping for MCPO proxy container 8000 8003
DOCKER_INTERNAL_PORT_POSTGRESQL PostgreSQL container internal port 5432 5432

Note: POSTGRES_DB serves as the default target database for operations when no specific database is specified. In Docker environments, if set to a non-default name, this database will be automatically created during initial PostgreSQL startup.

Port Configuration: The built-in PostgreSQL container uses port mapping 15432:5432 where:

  • POSTGRES_PORT=15432: External port for host access and MCP server connections
  • DOCKER_INTERNAL_PORT_POSTGRESQL=5432: Internal container port (PostgreSQL default)
  • When using external PostgreSQL servers, set POSTGRES_PORT to match your server's actual port

Prerequisites

Required PostgreSQL Extensions

For more details, see the ## Tool Compatibility Matrix

Note: Most MCP tools work without any PostgreSQL extensions. section below. Some advanced performance analysis tools require the following extensions:

-- Query performance statistics (required only for get_pg_stat_statements_top_queries)
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

-- Advanced monitoring (optional, used by get_pg_stat_monitor_recent_queries)
CREATE EXTENSION IF NOT EXISTS pg_stat_monitor;

Quick Setup: For new PostgreSQL installations, add to postgresql.conf:

shared_preload_libraries = 'pg_stat_statements'

Then restart PostgreSQL and run the CREATE EXTENSION commands above.

  • pg_stat_statements is required only for slow query analysis tools.
  • pg_stat_monitor is optional and used for real-time query monitoring.
  • All other tools work without these extensions.
Minimum Requirements
  • PostgreSQL 12+ (tested with PostgreSQL 17 and 18)
  • Python 3.12
  • Network access to PostgreSQL server
  • Read permissions on system catalogs
Required PostgreSQL Configuration

⚠️ Statistics Collection Settings: Some MCP tools require specific PostgreSQL configuration parameters to collect statistics. Choose one of the following configuration methods:

Tools affected by these settings:

  • get_user_functions_stats: Requires track_functions = pl or track_functions = all
  • get_table_io_stats & get_index_io_stats: More accurate timing with track_io_timing = on
  • get_database_stats: Enhanced I/O timing with track_io_timing = on

Verification: After applying any method, verify the settings:

SELECT name, setting, context FROM pg_settings WHERE name IN ('track_activities', 'track_counts', 'track_io_timing', 'track_functions') ORDER BY name;

       name       | setting |  context  
------------------+---------+-----------
 track_activities | on      | superuser
 track_counts     | on      | superuser
 track_functions  | pl      | superuser
 track_io_timing  | on      | superuser
(4 rows)
Method 1: postgresql.conf (Recommended for Self-Managed PostgreSQL)

Add the following to your postgresql.conf:

# Basic statistics collection (usually enabled by default)
track_activities = on
track_counts = on

# Required for function statistics tools
track_functions = pl    # Enables PL/pgSQL function statistics collection

# Optional but recommended for accurate I/O timing
track_io_timing = on    # Enables I/O timing statistics collection

Then restart PostgreSQL server.

Method 2: PostgreSQL Startup Parameters

For Docker or command-line PostgreSQL startup:

# Docker example
docker run -d \
  -e POSTGRES_PASSWORD=mypassword \
  postgres:17 \
  -c track_activities=on \
  -c track_counts=on \
  -c track_functions=pl \
  -c track_io_timing=on

# Direct postgres command
postgres -D /data \
  -c track_activities=on \
  -c track_counts=on \
  -c track_functions=pl \
  -c track_io_timing=on
Method 3: Dynamic Configuration (AWS RDS, Azure, GCP, Managed Services)

For managed PostgreSQL services where you cannot modify postgresql.conf, use SQL commands to change settings dynamically:

-- Enable basic statistics collection (usually enabled by default)
ALTER SYSTEM SET track_activities = 'on';
ALTER SYSTEM SET track_counts = 'on';

-- Enable function statistics collection (requires superuser privileges)
ALTER SYSTEM SET track_functions = 'pl';

-- Enable I/O timing statistics (optional but recommended)
ALTER SYSTEM SET track_io_timing = 'on';

-- Reload configuration without restart (run separately)
SELECT pg_reload_conf();

Alternative for session-level testing:

-- Set for current session only (temporary)
SET track_activities = 'on';
SET track_counts = 'on';
SET track_functions = 'pl';
SET track_io_timing = 'on';

Note: When using command-line tools, run each SQL statement separately to avoid transaction block errors.

RDS/Aurora Compatibility

  • This server is read-only and works with regular roles on RDS/Aurora. For advanced analysis enable pg_stat_statements; pg_stat_monitor is not available on managed engines.
  • On RDS/Aurora, prefer DB Parameter Group over ALTER SYSTEM for persistent settings.
    -- Verify preload setting
    SHOW shared_preload_libraries;
    
    -- Enable extension in target DB
    CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
    
    -- Recommended visibility for monitoring
    GRANT pg_read_all_stats TO <app_user>;
    

Example Queries

Requests are grouped first by task area, then by tool. Each tool runs read-only queries; results depend on the PostgreSQL version, installed extensions, and the connected role's privileges.

🧭 Requests by Area

📈 Database Performance Analysis

  • "Show database-wide performance statistics"
  • "Analyze transaction commit ratios and I/O patterns"
  • "Check buffer cache hit ratios for all databases"
  • "Monitor temporary file usage and deadlock counts"

🔧 Background Writer & Checkpoints

  • "Analyze checkpoint performance and timing"
  • "Show background writer efficiency statistics"
  • "Check buffer allocation and writing patterns"
  • "Monitor checkpoint scheduling vs requested ratios"

🔍 Server Health Check

  • "Check PostgreSQL server status."
  • "What database am I connected to?"
  • "Show current database connection details."
  • "Verify if extensions are installed."
  • "Show current active connection count."
  • "Display PostgreSQL version and configuration."

📊 Performance Analysis

  • "Show top 20 slowest queries."
  • "Find unused indexes."
  • "Analyze recent query activity."
  • "Identify performance bottlenecks."
  • "Show cache hit ratios for queries."

💾 Capacity Management

  • "Check database sizes."
  • "Find largest tables."
  • "Show tables that need VACUUM."
  • "Analyze disk usage by database."
  • "Display table and index sizes."
  • "Analyze table bloat and dead tuples."
  • "Show database-wide bloat summary."
  • "Check autovacuum status and trigger conditions."
  • "Monitor recent autovacuum activity patterns."
  • "Show currently running VACUUM operations."
  • "Analyze VACUUM effectiveness and maintenance patterns."

🗄️ Structure Analysis

  • "List all databases with owners."
  • "Show tables in public schema."
  • "Display user accounts and permissions."
  • "Explore database structure."

📈 Advanced Monitoring

  • "Monitor active sessions and queries."
  • "Analyze index usage efficiency."
  • "Check VACUUM and ANALYZE history."
  • "Review PostgreSQL configuration settings."
  • "Find memory-related configuration parameters."
  • "Show all logging configuration options."
  • "Search for connection-related settings."
  • "Identify connection patterns."
🩺 Troubleshooting Requests

Connection Issues

  • "Check PostgreSQL server connectivity."
  • "Verify connection parameters."
  • "Test database access permissions."

Extension Problems

  • "Check if pg_stat_statements is installed."
  • "Verify pg_stat_monitor availability."
  • "Show installed extensions status."

Performance Issues

  • "Analyze slow query performance."
  • "Check database load and connections."
  • "Review index usage efficiency."
  • "Monitor recent query patterns."
🔁 Multi-Step Workflows

Send these requests in order to run a routine review.

Regular Health Checks

  1. "Check server status and active connections."
  2. "Show top 10 slowest queries from last hour."
  3. "Verify all databases are accessible."
  4. "Check if any tables need maintenance."

Capacity Planning

  1. "Analyze database sizes and growth trends."
  2. "Identify largest tables and indexes."
  3. "Review disk usage by schema."
  4. "Plan storage capacity requirements."

Performance Optimization

  1. "Find queries consuming most resources."
  2. "Identify unused or inefficient indexes."
  3. "Analyze cache hit ratios."
  4. "Monitor query execution patterns."

Read the rest of the PostgreSQL Ops README on GitHub

Questions about PostgreSQL Ops

What is the PostgreSQL Ops MCP server?

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. PostgreSQL Ops is maintained by call518 on GitHub at call518/MCP-PostgreSQL-Ops, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the PostgreSQL Ops MCP server?

PostgreSQL Ops doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (call518/MCP-PostgreSQL-Ops). Like most servers, PostgreSQL Ops ends with a command or URL you paste into your AI app's MCP config.

Does PostgreSQL Ops need an API key?

The registry lists no required keys for PostgreSQL Ops. Check the PostgreSQL Ops README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is PostgreSQL Ops an official MCP server?

No. PostgreSQL Ops is a community server maintained by call518. Community servers can be excellent; read the code and the open issues before you give PostgreSQL Ops access to company data.

What license is PostgreSQL Ops under?

PostgreSQL Ops is released under the MIT license, according to its GitHub repository. The license covers the code of PostgreSQL Ops; the service it connects to has its own terms.