pgEdge Postgres MCP
pgEdge Postgres MCP Server
Postgres MCP in Go with read-mode queries, EXPLAIN plans, semantic search, several databases and a ready chat client and web interface
- 239 ★ on the repository
- Last commit
- PostgreSQL
Extended access
Why this level
- The model reads the whole schema and data of the database, personal data included, and table descriptions and query results reach its provider
- Writes are switched on with the allow_writes flag, after which the agent changes data with the rights of the database user
Install
- Works in
Manual install
sudo apt-get install -y pgedge-postgres-mcpAdd the pgEdge package repository first. The binary installs to /usr/bin/pgedge-postgres-mcp and the config is at /etc/pgedge/postgres-mcp.yaml. On RHEL, Rocky and Alma use dnf install -y pgedge-postgres-mcp.
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- The model reads the whole schema and data of the database, personal data included, and table descriptions and query results reach its provider
- Writes are switched on with the allow_writes flag, after which the agent changes data with the rights of the database user
This is third-party code. Review the repository files before installing.
What it does
pgEdge's Postgres MCP is a Go server that gives an agent SQL queries against PostgreSQL 14 and newer databases. Connection settings live in a YAML file or in the `PGHOST`, `PGPORT`, `PGDATABASE`, `PGUSER` and `PGPASSWORD` variables. The file can describe several databases, and writes are switched on for each one separately with the `allow_writes` flag. By default every query runs in a read-only transaction. Built-in tools: `query_database` runs SQL, `get_schema_info` shows the schema, `count_rows` counts table rows with a filter, `execute_explain` builds a query plan with real timing, `similarity_search` searches by meaning and by words (BM25 and MMR), `generate_embedding` gets a text vector from OpenAI, Voyage AI, Google Gemini or Ollama, and `search_knowledgebase` searches a connected knowledge base. Each tool can be turned off in the config, and a disabled one does not reach the model's list. There is a `system_info` resource and four ready workflows: exploring a database, setting up semantic search, diagnosing a slow query and designing a schema. The server runs over stdio for a local client or over HTTP with users, expiring tokens and OAuth sign-in. The repository also ships a Go chat client that starts the server as a child process and a React web interface for asking the database questions in plain language.
Who it is for. For developers, analysts and database administrators who work with PostgreSQL from Claude Code, Cursor, Windsurf or VS Code with Copilot and want schema, queries and EXPLAIN plans without hand-written SQL. It suits internal teams with trusted users.
Good fit when
- An agent has to show the database schema and answer a data question without being given write rights
- A slow query has to be analyzed through an EXPLAIN ANALYZE plan to see where an index is missing
- The database stores texts with vectors, and questions to them are needed by meaning, not only by keywords
- One server must serve several databases and several users with tokens and expiry dates
- You need a ready web interface or a terminal chat so colleagues without an agent can ask the database questions in plain language
Not a fit when
- The database sits behind a public-facing application: the author classes the server as an internal tool and points to its own RAG server for open services
- The PostgreSQL version is below 14: only 14 and newer are supported
- You need a server with index tuning and database health checks: the postgres-mcp-pro entry covers that
- You cannot set up a YAML config and, for HTTP mode, users: authentication is on by default in that mode
Example request
Show the schema of the orders database, count orders with the pending status and analyze with an EXPLAIN plan the query that looks them up by customer emailMCP
- Transport
- stdio, http
- Authentication
- not required
Environment variables
PGHOST- PostgreSQL host, when the database is set by variables rather than a YAML file
PGDATABASE- Database name
PGUSER- PostgreSQL user, preferably with read-only rights
PGPASSWORDsecret- PostgreSQL user password
Limitations
- The author warns that the server gives the model read access to the whole schema and data of the database and does not recommend it for public-facing applications.
- The built-in chat client and web interface need an Anthropic or OpenAI key or a local Ollama. For the web interface the `llm` section is enabled in the config.
- Embeddings and knowledge base search are off by default. They need a provider: an OpenAI, Voyage AI or Gemini key, or a running Ollama with an embedding model.
- In HTTP mode sign-in is required: a user is created with the `-add-user` flag before the server starts. Installation through Docker Compose works only in HTTP mode and needs `PGEDGE_HTTP_ENABLED=true` in the `.env` file.
- Stdio clients need a binary on disk or the `docker run -i --rm` command.
- Packages in the apt and dnf repositories are built for Debian, Ubuntu, RHEL, Rocky and Alma; on other systems the server is built from source with Go 1.21 or newer.
- The license is the PostgreSQL License.
How to disable. Remove the pgedge entry from the project's `.mcp.json` or from the client settings and restart the agent. For an HTTP server revoke tokens and users: the server rereads their files without a restart.
FAQ
How do I connect pgEdge's Postgres MCP to Claude Code?
Install the `pgedge-postgres-mcp` package or download the binary from the releases, create a YAML config with a `databases` section and add a `.mcp.json` to the project with the server command and the `-config` argument pointing to the config. Database settings can also be passed through the `PGHOST`, `PGPORT`, `PGDATABASE`, `PGUSER` and `PGPASSWORD` variables.
Can Postgres MCP change data in the database?
Not by default: queries run in a read-only transaction. Writes are switched on with the `allow_writes` flag for a specific database in the config, so they stay off for the others.
Which PostgreSQL versions does the server support?
PostgreSQL 14 and newer. Building from source needs Go 1.21 or newer.
Do I need an Anthropic or OpenAI key to use the server?
The server itself hands tools to any MCP client, such as Claude Code or Cursor, and uses that client's model. A key is needed by the built-in chat client and web interface: Anthropic, OpenAI or a local Ollama. Embedding generation connects a separate provider.
How do I turn on semantic search in Postgres MCP?
In the `embedding` section of the config enable embedding generation and pick a provider: OpenAI, Voyage AI, Gemini or Ollama. Then `generate_embedding` works and `similarity_search` combines vector search with BM25 and MMR. For searching your own documentation the `knowledgebase` section is enabled.
Can I connect several databases and different users?
Yes. The `databases` section lists several databases, and the `available_to_users` parameter on a database limits who sees it. In HTTP mode users and expiring tokens are created with server commands.
What else is in the repository besides the MCP server?
The `pgedge-nla-cli` chat client in Go, a React web interface, Dockerfiles for the server, client and web, and documentation on authentication, row-level security and distributed deployment.
Discussion
No questions or reviews yet.
Related
MCP serversAn MCP server for PostgreSQL with several databases at once, table descriptions from the catalog, PostGIS and pgvector hints and query plans
An MCP server and skills from TigerData that help agents write PostgreSQL schemas and queries from current docs and practices
Postgres MCP (Microsoft)
Postgres MCP Server (Microsoft)
Postgres MCP from Microsoft: connection profiles with passwords in the OS keyring, Entra ID sign-in for Azure, queries, schema, CSV and server metrics
A Go MCP server and REST API for databases: PostgreSQL, MySQL, ClickHouse, Snowflake, BigQuery and more, with personal data masking and a cache
Google's open-source MCP server for databases: ready tools for Postgres, MySQL, BigQuery, Spanner and more, plus custom tools in tools.yaml
A SQLite-based SQL engine with plugins for apps, databases and files: the anyquery mcp command exposes that data to Claude, Cursor and other MCP clients
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Authentication | Repository stars | Main difference |
|---|---|---|---|---|
| pgEdge Postgres MCP (this entry) | no | not required | 239 | |
| Postgres MCP Pro | no | API key | 3,420 | a server aimed at administration: index tuning, database health checks and plans with hypothetical indexes, over stdio and SSE |
| PG-MCP Server | no | not required | 541 | a Python server over SSE with several databases, schema through resources and reference sheets for PostGIS and pgvector |
| Postgres MCP (Microsoft) | no | key is optional | 61 | Microsoft's npx server with saved connection profiles, passwords in the OS keyring and Entra ID sign-in |
README in short
The documentation in the docs folder is split into sections: a quick start for the CLI, web interface, Claude Code, Claude Desktop, Cursor, Windsurf and VS Code, deployment in Docker and from source, and a reference for tools, resources and workflows. It separately covers authentication (users, tokens, OAuth), a security checklist, row-level and column-level security, distributed deployment and custom tool definitions. The repository has server, client and web tests, an OpenAPI schema, a changelog and data for a Cursor plugin.