MCP Catalogs
Home

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.

databasedeveloper-toolsai-llm
61
Forks
3
Open issues
8 mo ago
Last commit
2d ago
Indexed

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:

you:Business analysts can query e-commerce databases using natural language instead of writing complex SQL
you:Developers can quickly explore unfamiliar database schemas during development and debugging
you:Teams can share database access with non-technical stakeholders through AI assistants
you:Does PGMCP modify my database?
you:Can I use PGMCP without OpenAI API?
you:What databases are supported?

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 README
  • ask

    Natural language questions → SQL queries with automatic streaming

  • search

    Free-text search across all database text columns

  • stream

    Advanced streaming for very large result sets with pagination

Comparable tools

mysql-mcpsupabase-mcpsql-mcpshell-mcp

Installation

Installation

Download Pre-compiled Binaries

  1. Go to [GitHub Releases](https://github.com/subnetmarco/pgmcp/releases)
  2. Download the binary for your platform (Linux, macOS, Windows)
  3. Extract and run:
# Example for macOS/Linux
tar xzf pgmcp_*.tar.gz
cd pgmcp_*
./pgmcp-server

Homebrew (macOS/Linux)

brew tap subnetmarco/homebrew-tap
brew install pgmcp

Environment Variables

export DATABASE_URL="postgres://user:password@localhost:5432/your-existing-db"
export OPENAI_API_KEY="your-api-key"
./pgmcp-server

Claude 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.

Compare pgmcp with

GitHub →

Last updated · Auto-generated from public README + GitHub signals.