r/Python • u/AutoModerator • Jun 04 '26
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
27
Upvotes
r/Python • u/AutoModerator • Jun 04 '26
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/Professional-Clerk30 Jun 08 '26
MCPg: A production-grade PostgreSQL Model Context Protocol server (Python)
Hi r/Python,
I've been working on a side project called MCPg — a Python-based MCP (Model Context Protocol) server for PostgreSQL.
It gives AI agents (Claude Desktop, Cursor, etc.) a broad but carefully guarded set of tools to inspect schemas, run queries, analyze performance, suggest indexes, do natural-language-to-SQL, and handle some DBA tasks — all while staying safe by default.
Key bits I focused on:
Safety-first design: Read-only mode by default, AST validation for any user SQL, strict identifier sanitization (no string concatenation into queries), and opt-in gates for DDL/shell/LISTEN.
Pure psycopg3 under the hood — no ORM layer. Works with core Postgres + extensions like pgvector, TimescaleDB, PostGIS, Apache AGE where available.
Production touches: connection pooling, multi-tenancy via SET ROLE, read-replica routing, Prometheus metrics, structured audit logging, OIDC support, rate limiting, etc.
1000+ tests, runs against Postgres 14–18 in CI.
Installs cleanly with pip install mcpg or uv tool install mcpg.
Quick start example for Claude Desktop is in the README (stdio transport). There's also an HTTP/SSE mode for other integrations.
Repo: https://github.com/devopam/MCPg
Docs site: https://devopam.github.io/MCPg/
Would love feedback from the Python/Postgres crowd — especially on the safety model, ergonomics for agent use, or anything that feels off. Contributions welcome too.
Thanks!