MCPg logo

MCPg

by devopam

PostgreSQL MCP server with 279 tools for safe queries, database operations, tuning, search, and specialized extensions.

Install MCPg

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "devopam-mcpg": {
      "command": "uvx",
      "args": [
        "mcpg"
      ],
      "env": {
        "MCPG_DATABASE_URL": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

uvx mcpg

No response to initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

devopam/MCPg connects AI agents to PostgreSQL through 279 MCP tools for catalog inspection, querying, administration, tuning, search, and data movement. It uses psycopg3 directly, validates user SQL through an AST allowlist, and defaults to read-only access. stdio and HTTP/SSE transports are available, with support for PostgreSQL 14–19 and integrations including pgvector, TimescaleDB, PostGIS, and Apache AGE. Reach for it when an agent needs both application-level database access and operational PostgreSQL workflows with controls such as role switching, timeouts, audit events, and replica routing.

Use cases

  • Inspect PostgreSQL schemas and system catalogs
  • Generate and validate SQL from natural-language requests
  • Tune indexes and analyze query plans
  • Monitor locks, replicas, vacuum activity, and database health
  • Query vector, time-series, spatial, or graph data

Key features

  • 279 PostgreSQL-focused MCP tools
  • AST-validated SQL with read-only defaults
  • stdio and HTTP/SSE transports
  • pgvector, TimescaleDB, PostGIS, and Apache AGE support
  • Connection pooling, replica routing, and multi-tenancy controls
  • Prometheus metrics and redacted audit events

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

96/96 checks healthy over the last 65d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 2d ago via OSV.dev · mcpg (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars14Stargazers on the source repository.
Last commit4d agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Directory activity24 viewsConfig copies, upvotes, and views on AllMCPs.

How MCPg works

What devopam/MCPg MCP server does

devopam/MCPg exposes PostgreSQL through the Model Context Protocol. Its 279 tools cover catalog introspection, SQL execution, natural-language-to-SQL workflows, structural comparisons, hybrid search, graph queries, data movement, health checks, index analysis, EXPLAIN inspection, locks, vacuum operations, dumps, replicas, and migrations.

The server is designed for both database consumers and operators. It uses psycopg3 rather than an ORM and can work with PostgreSQL-native system views. Where available, it can use pgvector, TimescaleDB, PostGIS, Apache AGE, and pg_stat_statements; unsupported extensions are handled through graceful degradation.

How it works

MCPg can communicate over stdio or HTTP/SSE. The hosted demo endpoint at https://devopam-mcpg-demo.hf.space/mcp exposes read tools against throwaway data; production deployments should run the server alongside the target database.

Read-only access is the default. User-provided SQL is parsed and checked against an AST allowlist before execution, while capabilities such as DDL, shell access, and LISTEN/NOTIFY require explicit enablement. MCP tool annotations expose read-only and open-world hints based on these gates, allowing clients to distinguish operations that can be approved automatically from those requiring review.

Production-oriented controls include connection pooling, per-request SET ROLE handling, read-replica routing with degraded-host detection, dedicated connections for server-side cursors, rate limiting, statement and lock timeouts, audit records with credential redaction, and PostgreSQL TLS enforcement at startup. HTTP deployments also expose Prometheus metrics for tool-call counts and durations.

Setup and configuration

Install the Python package from PyPI with pip install mcpg, or use uv tool install mcpg. Source development uses uv sync. A container image is available at ghcr.io/devopam/mcpg:latest, and the image accepts the database connection through MCPG_DATABASE_URL.

A stdio client configuration runs uvx mcpg and passes MCPG_DATABASE_URL, for example:

config.json
{
  "mcpServers": {
    "mcpg": {
      "command": "uvx",
      "args": ["mcpg"],
      "env": {
        "MCPG_DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
      }
    }
  }
}

Claude Desktop users can install the .mcpb bundle from the latest GitHub release. The bundle prompts for the PostgreSQL URL and access mode, storing the URL in the operating system keychain. The default access mode remains read-only.

Tools and capabilities

  • Inspect PostgreSQL catalogs and system views.
  • Execute AST-validated SQL and generate SQL from natural-language requests.
  • Analyze queries, indexes, locks, vacuum activity, health, and replicas.
  • Work with vector, time-series, spatial, and graph data when the relevant extensions are available.
  • Compare database structures and support dumps, migrations, cursors, and data movement.
  • Expose tool-call metrics and structured audit events over production deployments.

Limitations and notes

Write-oriented features are gated rather than enabled by default. Extension-specific operations depend on the corresponding PostgreSQL extension being available. The live demo is read-only and uses disposable data, so it is suitable for trying the MCP interface rather than accessing an application database. PostgreSQL compatibility is listed for versions 14 through 19, with PostgreSQL 19 identified as experimental in the project’s test matrix.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about MCPg

devopam/MCPg is an MCP server that connects AI agents to PostgreSQL through 279 tools for catalog introspection, safe SQL execution, natural-language SQL, query and index analysis, operations, search, and data movement. It supports stdio and HTTP/SSE transports and defaults to read-only access with AST validation.

Install it with `pip install mcpg`, use `uv tool install mcpg`, run the published container image, or build from source with `uv sync`. Claude Desktop also supports the downloadable `.mcpb` bundle, and stdio clients can launch it with `uvx mcpg`.

Set `MCPG_DATABASE_URL` to a PostgreSQL connection URL such as `postgresql://user:pass@localhost:5432/mydb`. Pass that variable in the MCP client environment or to the Docker container, then start MCPg over stdio or HTTP/SSE.

Yes, devopam/MCPg provides a Cursor installation configuration and can run through its stdio transport. Configure Cursor to launch `uvx mcpg` and provide `MCPG_DATABASE_URL` for the target PostgreSQL database.

Yes, read-only access is the default. User SQL is checked against an AST allowlist, while capabilities such as DDL, shell operations, and `LISTEN/NOTIFY` require explicit opt-in.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewMCPg AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/devopam-mcpg?style=directory)](https://allmcps.com/mcp/devopam-mcpg)
HTML Embed
<a href="https://allmcps.com/mcp/devopam-mcpg"><img src="https://allmcps.com/api/badge/devopam-mcpg?style=directory" alt="MCPg on AllMCPs" /></a>