MCPg is a production-grade MCP server (created in Python) for PostgreSQL. It gives AI agents (Claude Desktop, Cursor, etc.) over 100 carefully guarded tools for schema introspection, natural-language-to-SQL, query optimization, index tuning, performance analysis, multi-tenancy operations, and DBA tasks — all while prioritizing safety.
Key Features:
Safety-first design: Read-only by default, AST validation for all SQL, strict identifier sanitization (no string concatenation), opt-in gates for DDL/shell/LISTEN. Broad Postgres support: native psycopg3, works with pgvector, TimescaleDB, PostGIS, Apache AGE, and pg_stat_statements.
Production ready: connection pooling, SET ROLE multi-tenancy, read-replica routing, Prometheus metrics, structured audit logging (with redaction), OIDC + static auth, rate limiting. Transports: stdio (Claude Desktop) + HTTP/SSE/Streamable HTTP. Easy install: pip install mcpg or Docker.
Categories / Tags: Database, Postgres, SQL, AI Agents, DBA, Observability, Developer Tools
GitHub URL: https://github.com/devopam/MCPg Documentation / Website: https://devopam.github.io/MCPg/
Why it's useful:
Designed for real production use cases where agents need safe, powerful access to Postgres without risking destructive actions. License: MIT
Server Config
{
"mcpServers": {
"mcpg": {
"command": "uvx",
"args": [
"mcpg"
],
"env": {
"MCPG_DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}