
pgmcp
MCP server letting AI assistants query your PostgreSQL database in plain English
pgmcp is an open-source MCP server for databases. It is available on CLI, API, Linux, macOS, Windows and Self-hosted.
- Pricing
- Open source
- Platforms
- CLI, API, Linux
- GitHub stars
- 544
- Last commit
- Language
- Go
- Listing updated
Similar MCP servers
About pgmcp
Point it at an existing PostgreSQL database and AI clients can ask questions in everyday language, getting back SQL results as tables, JSON or CSV. Queries are generated with an optional OpenAI model, while the server enforces read-only access inside read-only transactions with timeouts and input checks.
Beyond natural-language questions, it offers a free-text search across all text columns and a streaming tool for very large result sets with pagination. A companion command-line client lets you run the same questions from a terminal.
It suits developers and analysts who want to explore production-style data from Cursor, Claude Desktop or similar MCP clients without granting write access to the database.
Tools this server provides (3)
Taken from the project documentation; the running server may differ.
From the tool list in its README, going by the names, 1 of 3 tools reads data; 2 names don't say.
From the server's own tool labels and tool names; not verified by us.
- ask
- Natural language questions converted to SQL queries with automatic streaming.
- searchName suggests: reads
- Free-text search across all database text columns.
- stream
- Streaming for very large result sets with pagination.
What it does
- Natural language querying
- Turns plain-English questions into SQL run against your own schema.
- Read-only enforcement
- Blocks write statements and runs queries inside read-only transactions.
- Free-text search
- Searches across every text column in the database for a given term.
- Streaming large results
- Paginates very large result sets instead of loading them all at once.
- Multiple output formats
- Returns results as tables, JSON or CSV.
- Optional bearer authentication
- Protects the HTTP endpoint with a configurable bearer token.
Good for
- Exploring an unfamiliar production database by asking questions in chat
- Letting analysts pull reports from PostgreSQL without writing SQL
- Exporting filtered query results to CSV from a terminal
- Searching for a customer or record across all text fields
Pricing
Open source
Free and open source under Apache 2.0 licence.
pgmcp FAQ
Can pgmcp modify my data?
No. Write operations such as INSERT, UPDATE and DELETE are blocked, and all queries run in read-only transactions.
Does pgmcp need an OpenAI key?
The OpenAI API key is optional and is used for AI-powered SQL generation; the server reads its model from OPENAI_MODEL, defaulting to gpt-4o-mini.
Which clients can connect?
Any MCP-compatible client that supports the HTTP transport, including Cursor and Claude Desktop, can connect to the /mcp endpoint.
How is pgmcp installed?
Install from pre-compiled binaries on GitHub Releases, via Homebrew, from source with Go, or by running the Docker image.
Is pgmcp free?
Yes. pgmcp is open source, so you can use and self-host it for free.
What are the best alternatives to pgmcp?
The closest alternatives to pgmcp are postgres_mcp, Postgres MCP, PostgreSQL MCP Server, sql-query-mcp and MCP Postgres.
Where this comes from
- Description: written from the project's README.

