Show HN: Pgmcp, an MCP server to query any Postgres database in natural language (github.com)

🤖 AI Summary
PGMCP is an open-source Model Context Protocol (MCP) server that lets AI assistants query any PostgreSQL database in plain English while enforcing read-only, production-ready safety and performance controls. It implements the MCP spec over HTTP Server-Sent Events, works with MCP-compatible clients (Cursor, Claude Desktop, VS Code, custom integrations) and LLM backends (OpenAI, Anthropic, or local models), translating natural-language questions into PostgreSQL queries via the OpenAI API by default. Key runtime features include schema introspection and caching, pgx/v5 connection pooling, automatic streaming and pagination for large result sets, multiple output formats (table/JSON/CSV), optional bearer auth, and a CLI client for local usage. Technical safeguards and usability features make it noteworthy for the AI/ML community: built-in SQL guards ensure 100% read-only access, input sanitization, comprehensive audit logging, error detection and graceful recovery when models generate invalid SQL, and performance protection that detects and simplifies expensive queries. No schema changes are required, so PGMCP can plug into analytics, e‑commerce, CRM, or IoT Postgres instances immediately. For teams building retrieval-augmented systems or tool-enabled agents, PGMCP reduces data-leakage risk and operational friction while exposing structured DB results to models and apps in a controlled, observable way.
Loading comments...
loading comments...