PGMCP is an MCP server that enables querying any PostgreSQL database through natural language. It connects AI assistants to PostgreSQL databases, allowing users to ask questions in plain English and receive structured SQL results with automatic streaming and robust error handling.
One-Minute Overview#
PGMCP is a tool that connects AI assistants to any PostgreSQL database through natural language queries. It doesn't require schema modifications and provides read-only access to ensure data security. Whether your database is for e-commerce, analytics, or CRM, PGMCP makes it accessible to AI assistants.
Core Value: Enables any PostgreSQL database to interact with AI assistants through natural language while maintaining secure read-only access.
Quick Start#
Installation Difficulty: Low - Pre-compiled binaries available, just download and run
# Set up environment variables
export DATABASE_URL="postgres://user:password@localhost:5432/your-existing-db"
export OPENAI_API_KEY="your-api-key" # Optional
# Run server (using pre-compiled binary)
./pgmcp-server
# Test with client in another terminal
./pgmcp-client -ask "What tables do I have?" -format table
./pgmcp-client -ask "Who is the customer that has placed the most orders?" -format table
Is this suitable for me?
- ✅ Database Querying: Need to query PostgreSQL databases through natural language with AI assistants
- ✅ Data Analysis: Want AI assistants to analyze your business data and provide insights
- ✅ E-commerce: Perform intelligent queries on product catalogs, orders, and customer data
- ❌ Write Operations: PGMCP only supports read-only queries, cannot modify data
- ❌ Non-PostgreSQL Databases: Only supports PostgreSQL databases, not other database types
Core Capabilities#
1. Natural Language to SQL - Eliminate Technical Barriers#
- Transforms natural language questions into accurate SQL queries without writing SQL User Value: Enables non-technical users to query databases through AI assistants, improving data accessibility
2. Automatic Streaming - Handle Large Datasets#
- Automatically processes large result sets with pagination and memory management User Value: Efficiently handles large query results without failures due to oversized datasets
3. Read-Only Secure Access - Data Safety Guarantee#
- Strictly enforces read-only policy, blocking all write operations User Value: 100% secure database protection against accidental data modification or deletion
4. Intelligent Text Search - Full-Text Retrieval#
- Performs free-text search across all text columns User Value: Easily find specific information like customer names, product descriptions, etc.
5. Multiple Output Formats - Flexible Data Presentation#
- Supports table, JSON, and CSV output formats User Value: Choose the most suitable data presentation for different needs, facilitating further processing or display
Technical Stack & Integration#
Development Language: Go Main Dependencies: PostgreSQL database, OpenAI API (optional for AI-powered SQL generation) Integration Method: API / MCP Protocol
Maintenance Status#
- Development Activity: Actively developed with CI/CD pipeline and Go code quality checks
- Recent Updates: Recent updates with comprehensive features and documentation
- Community Response: Clear examples and integration guides indicating an active development community
Commercial & Licensing#
License: Apache 2.0
- ✅ Commercial Use: Allowed
- ✅ Modification: Allowed
- ⚠️ Restrictions: Must include license and copyright notices
Documentation & Learning Resources#
- Documentation Quality: Comprehensive
- Official Documentation: README contains detailed usage guides and examples
- Example Code: Includes sample database schemas and basic usage examples