Skip to content
MCP server

Mcpg

PostgreSQL MCP server with 279 tools for queries, tuning and ops, read-only by default

Runs locallyStatus and history
Install
Pricing
Open source
Platforms
CLI, self-hosted
Runs
Locally
Version
0.8.4
Listing updated
3 days ago

About Mcpg

Mcpg is an open-source MCP server for databases. It runs locally on your machine and is started by your AI client.

Safety is built into the parsing. Every SQL statement an agent supplies is checked against an AST allowlist before it runs, DDL, shell and LISTEN/NOTIFY stay off until opted in, and each tool publishes read-only and open-world annotations so clients can auto-approve reads and ask before writes.

The tool surface is unusually wide: catalog introspection, EXPLAIN analysis, index tuning, locks, vacuum, dumps, replicas, migrations, natural-language SQL, hybrid search and graph queries. It talks to Postgres through psycopg3 and uses TimescaleDB, pgvector, PostGIS, Apache AGE and pg_stat_statements when present.

For production use it offers connection pooling, per-request SET ROLE multi-tenancy, read-replica routing, rate limiting, redacted audit events, TLS enforcement, OIDC JWT auth and a Prometheus metrics endpoint on the HTTP transport. A read-only demo is hosted on Hugging Face Spaces.

Install

Run in a terminal

claude mcp add mcpg -- uvx mcpg

Add to claude_desktop_config.json

{
  "mcpServers": {
    "mcpg": {
      "command": "uvx",
      "args": [
        "mcpg"
      ]
    }
  }
}
Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "mcpg": {
      "command": "uvx",
      "args": [
        "mcpg"
      ]
    }
  }
}
Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to .vscode/mcp.json

{
  "servers": {
    "mcpg": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "mcpg"
      ]
    }
  }
}

Add to ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "mcpg": {
      "command": "uvx",
      "args": [
        "mcpg"
      ]
    }
  }
}

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "mcpg": {
      "command": "uvx",
      "args": [
        "mcpg"
      ]
    }
  }
}

What it does

AST-validated SQL
Statements pass an allowlist before running.
Read-only default
Writes, DDL and shell are opt-in.
DBA operations
Health checks, index tuning, locks, vacuum and replicas.
Multi-tenancy
Per-request SET ROLE and OIDC bearer auth.
Observability
Prometheus metrics and redacted audit trail.
Extension support
Works with pgvector, PostGIS, TimescaleDB and Apache AGE.

Good for

  • Let an agent inspect a schema safely
  • Analyze a slow query with EXPLAIN
  • Tune indexes with pg_stat_statements data
  • Run read-only reporting against a replica

Pricing

Open source

Free, self-hosted

Prices change. Check devopam.github.io before you buy.

Mcpg FAQ

How do I install it?

pip install mcpg, or use the Docker image from ghcr.io.

Which Postgres versions are covered?

14 to 19, with 19 tested as beta.

Is it read-only?

Yes by default; write capabilities must be enabled.

Can I try it first?

Yes, a hosted read-only demo runs against throwaway data.

Is Mcpg free?

Yes. Mcpg is open source, so you can use and self-host it for free.

How do I add Mcpg to Claude Code?

Run this command in your terminal: claude mcp add mcpg -- uvx mcpg

What are the best alternatives to Mcpg?

The closest alternatives to Mcpg are REA, Codebase Memory, GitHub, Serena MCP: the IDE for your agent and XERJ.

Alternatives to Mcpg

  1. REA

    MCP server

    CLI and MCP server that lets coding agents reverse engineer apps and binaries

    Runs locally
    • Open source
    • 464K GitHub stars
    • Developer tools
  2. Codebase Memory

    MCP server

    Local MCP server that builds a code knowledge graph for AI coding agents

    Runs locally
    • Open source
    • 48.7K GitHub stars
    • Knowledge and memory
  3. GitHub

    MCP server

    Official MCP server connecting AI assistants to GitHub repos, issues and workflows

    Not checked yet
    • Remote
    • Open source
    • 34.5K GitHub stars
    • Developer tools
  4. MCP toolkit giving coding agents symbol-level code retrieval and editing

    Runs locally
    • Open source
    • 31.5K GitHub stars
    • Developer tools
  5. XERJ

    MCP server

    Local search engine for AI agents with cited answers over your code and docs

    Runs locally
    • Open source
    • 19.2K GitHub stars
    • Knowledge and memory
  6. Ouroboros

    MCP server

    Spec-first layer that pins requirements and verifies results of AI coding agent work

    Runs locally
    • Open source
    • 6.4K GitHub stars
    • Developer tools