Skip to main content
MCP server CX Codex

mcpg — Claude Code MCP server: PostgreSQL tools and install

MCP server with 254 PostgreSQL tools for queries, performance tuning, and ops. Read-only by default.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add mcpg -- uvx mcpg
Open on GitHub

What mcpg does

The server connects an agent to a PostgreSQL database through 254 tools. Built on psycopg3, it supports TimescaleDB, pgvector, PostGIS, Apache AGE, and pg_stat_statements when present in your database. Tools cover catalog introspection, natural-language SQL, hybrid search, graph queries, performance analysis, and migrations. Read-only mode is on by default; every SQL statement passes AST validation.

Install via pip install mcpg or uvx mcpg. For Docker, pull ghcr.io/devopam/mcpg:latest. The server runs over stdio and HTTP/SSE; HTTP mode exposes /metrics for Prometheus. Supports PostgreSQL 14–19 (beta), connection pooling, read-replica routing, multi-tenant mode via SET ROLE, and audit logs with credential redaction.

You need a PostgreSQL database and the MCPG_DATABASE_URL environment variable with the connection string. Without psycopg3 in the Python environment, pip won't start the server.

What it helps with

  • write a SQL query from a natural-language description
  • check index load and find bottlenecks via EXPLAIN
  • get the schema of a table or the entire database catalog
  • run hybrid search or graph queries on your data
  • track locks, active queries, and replica health

Example prompts for the agent

  • Connect the mcpg server and show the schema for the orders table
  • Use mcpg to build a SQL query: last 50 orders this month
  • Run EXPLAIN ANALYZE on the query in slow_query.sql via mcpg

How to install mcpg

Platform CLI

claude mcp add mcpg -- uvx mcpg

uvx runs the command named after the package; if the README names another one, use uvx --from mcpg <command>

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about mcpg

How to install mcpg in Claude Code?

Run claude mcp add mcpg -- uvx mcpg in your terminal. Claude Code will add the server to config and start it via uvx.

What does mcpg do?

Connects an agent to PostgreSQL through 254 tools for queries, introspection, performance tuning, and operations. Read-only by default, every SQL statement is validated through AST.

Which PostgreSQL versions does mcpg support?

PostgreSQL 14, 15, 16, 17, 18 are tested in CI. Version 19 (beta) works experimentally.

Similar MCP servers

All MCP servers for Data and databases →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor