pgmcp
by subnetmarco·★ 529·Score 49
PGMCP is a production-ready MCP server that enables natural language queries to any PostgreSQL database with proper security controls.
Overview
PGMCP is a robust MCP server that connects AI assistants to PostgreSQL databases through natural language queries. It provides safe read-only access with automatic streaming, error handling, and support for multiple output formats. The server works with any PostgreSQL schema without requiring modifications, making it highly versatile for various database structures. It includes features like intelligent query understanding, case sensitivity support for PostgreSQL, and integration with popular AI clients like Claude Desktop and Cursor.
Try asking AI
After installing, here are 6 things you can ask your AI assistant:
When to choose this
Choose PGMCP when you need to provide AI assistants with read-only access to existing PostgreSQL databases without modifying your schema or writing SQL.
When NOT to choose this
Don't choose PGMCP if you need write access to your database or require AI-generated modifications to your schema.
Tools this server exposes
3 tools extracted from the READMEaskNatural language questions → SQL queries with automatic streaming
searchFree-text search across all database text columns
streamAdvanced streaming for very large result sets with pagination
Comparable tools
Installation
Installation
Download Pre-compiled Binaries
- Go to [GitHub Releases](https://github.com/subnetmarco/pgmcp/releases)
- Download the binary for your platform (Linux, macOS, Windows)
- Extract and run:
# Example for macOS/Linux
tar xzf pgmcp_*.tar.gz
cd pgmcp_*
./pgmcp-serverHomebrew (macOS/Linux)
brew tap subnetmarco/homebrew-tap
brew install pgmcpEnvironment Variables
export DATABASE_URL="postgres://user:password@localhost:5432/your-existing-db"
export OPENAI_API_KEY="your-api-key"
./pgmcp-serverClaude Desktop Integration
Edit ~/.config/claude-desktop/claude_desktop_config.json:
{
"mcpServers": {
"pgmcp": {
"transport": {
"type": "http",
"url": "http://localhost:8080/mcp"
}
}
}
}FAQ
- Does PGMCP modify my database?
- No, PGMCP provides read-only access by blocking write operations (INSERT, UPDATE, DELETE, etc.)
- Can I use PGMCP without OpenAI API?
- Yes, the server works without OpenAI API, though you'll need to provide your own SQL generation method
- What databases are supported?
- Any PostgreSQL database - no schema modifications required
On Hacker News
Recent discussion from the developer community.
- Story by fosk · 2025-09-17
Compare pgmcp with
Last updated · Auto-generated from public README + GitHub signals.