MCPg logo

MCPg

by devopam

PostgreSQL MCP server with safe query execution, catalog inspection, tuning, search, operations, and stdio or HTTP transports.

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",
        "MCPG_ACCESS_MODE": "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 4d ago.

Overview

The devopam/MCPg MCP server exposes PostgreSQL operations to AI agents through 254 MCP tools. It uses psycopg3, AST validation, read-only defaults, connection pooling, audit logging, and optional HTTP/SSE or stdio transports. Tools cover catalog inspection, query analysis, natural-language SQL, indexing, data movement, hybrid search, graph queries, and live database operations. Reach for it when an agent needs controlled access to a PostgreSQL database rather than a separate tool for each DBA or application-data task.

Use cases

  • Inspect PostgreSQL schemas and catalog metadata
  • Analyze query plans and identify index opportunities
  • Generate SQL from natural-language database questions
  • Monitor locks, replicas, vacuum activity, and database health
  • Run controlled hybrid, vector, time-series, or graph queries

Key features

  • 254 PostgreSQL-focused MCP tools
  • AST-validated SQL with read-only defaults
  • Catalog introspection and structural diffs
  • Index tuning and query plan analysis
  • pgvector, TimescaleDB, PostGIS, and AGE support
  • stdio and HTTP/SSE transports

Security & health

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

ActiveLast checked 1d ago

Recent health check succeeded.

96/96 checks healthy over the last 42d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 11d 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 commit2d agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Directory activity21 viewsConfig copies, upvotes, and views on AllMCPs.

How MCPg works

What devopam/MCPg MCP server does

The devopam/MCPg MCP server gives MCP-compatible clients access to PostgreSQL databases through a broad toolset. It supports catalog introspection, SQL execution, query intelligence, natural-language-to-SQL workflows, structural comparisons, search, graph queries, data movement, and operational tasks such as health checks, lock inspection, vacuum work, replica checks, dumps, migrations, and index tuning.

The implementation is PostgreSQL-specific rather than ORM-based. It uses psycopg3 and can work with PostgreSQL versions 14 through 19 according to the project’s compatibility table. Optional integrations include pgvector, TimescaleDB, PostGIS, Apache AGE, and pg_stat_statements when those capabilities are available in the database.

How it works

MCPg supports both stdio and HTTP/SSE transports. For local clients, the mcpg console script can run through uvx; HTTP deployments can expose the server and its Prometheus metrics endpoint. The HTTP transport reports tool-call totals and durations, while tool calls also produce structured audit events with credential-sensitive argument redaction.

Read-only access is the default. User-supplied SQL passes through AST parsing and an allowlist before execution, and identifier interpolation is restricted by a naming pattern. DDL, shell operations, and LISTEN/NOTIFY are disabled unless explicitly enabled. Tool annotations reflect the configured read and write gates so clients can distinguish read-only operations from tools that may change data.

Production-oriented controls include connection pooling, per-request SET ROLE handling, read-replica routing, server-side cursors, rate limiting, PostgreSQL TLS enforcement, OIDC JWT bearer authentication, and per-session statement and lock timeouts. These options make the devopam/MCPg MCP server suitable for deployments where database access needs operational controls as well as query tools.

Setup and configuration

Install the Python package from PyPI with pip install mcpg, or install it as an isolated tool with uv tool install mcpg. The executable is named mcpg. The manual stdio configuration shown for MCP clients runs uvx mcpg and supplies a PostgreSQL connection URL through MCPG_DATABASE_URL.

A Docker image is published at ghcr.io/devopam/mcpg. The documented container example maps port 8000, sets MCPG_DATABASE_URL, and sets MCPG_ACCESS_MODE=read-only. The image can also be built from the GitHub repository. Source-based development uses uv sync after cloning the project.

Claude Desktop users can install a versioned .mcpb bundle from the latest GitHub release. The bundle asks for the database URL and access mode, storing the URL in the operating system keychain. The repository also documents setup for Cursor, Windsurf, Cline, and other MCP clients.

Tools and capabilities

The documented tool surface includes:

  • Inspecting schemas, tables, columns, indexes, roles, extensions, and other PostgreSQL catalog information.
  • Running validated queries and examining plans, statistics, locks, health, replicas, and vacuum state.
  • Generating SQL from natural-language requests and working with cursors for larger result sets.
  • Comparing database structures and moving data through supported operations.
  • Using hybrid search, pgvector-backed features, TimescaleDB features, and Apache AGE graph queries when available.
  • Monitoring activity through audit records and Prometheus metrics.

Limitations and notes

The hosted demonstration endpoint is read-only and uses throwaway demo data; it is not a connection to a user’s database. For real workloads, the project instructs users to run MCPg alongside their own PostgreSQL instance.

Read-only mode does not mean every possible PostgreSQL operation is available: write-oriented capabilities must be enabled through configuration gates. Extension-specific tools depend on the corresponding database features being installed, and the server degrades when optional extensions are unavailable. Database credentials and access permissions remain the responsibility of the deployment.

The project is released under the MIT license. The devopam/MCPg MCP server is open source, but using it with a PostgreSQL deployment still requires an accessible database and suitable database credentials.

Reviews

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

Frequently Asked Questions about MCPg

Install the `mcpg` package from PyPI with `pip install mcpg`, or use `uv tool install mcpg`. The project also publishes a Docker image and a Claude Desktop `.mcpb` bundle.

Yes. The repository documents a Claude Desktop `.mcpb` installation and a manual stdio configuration using `uvx mcpg`.

The documented configuration uses `MCPG_DATABASE_URL` for the PostgreSQL connection URL. Docker examples also set `MCPG_ACCESS_MODE` to `read-only`.

Yes. Read-only access is the default, and write-oriented capabilities such as DDL are disabled until explicitly enabled.

Yes.

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>