postgres-mcp — Claude Code MCP server: features and setup
Connects PostgreSQL databases to AI coding assistants for natural language queries, schema inspection, and hybrid search.
claude mcp add postgres-mcp -- docker run -i --rm ghcr.io/pgedge/postgres-mcp:latestWhat postgres-mcp does
This server bridges PostgreSQL instances with AI assistants via Stdio or HTTP transports. It inspects schemas, reads database statistics, and translates conversational prompts into working SQL. Built-in tools also handle hybrid search using BM25 and MMR.
Queries execute inside read-only transactions by default. The repository also includes a standalone Go chat client with Anthropic prompt caching, cutting token expenses by up to 90%.
It requires PostgreSQL 14 or newer. Because the server exposes full schema and data access to the model, avoid running it in public environments.
What it helps with
- query PostgreSQL databases using plain English prompts
- inspect database schema details and engine statistics
- run hybrid search with BM25 and MMR scoring
- diagnose database queries directly inside an AI workflow
Example prompts for the agent
- Inspect the customers table and retrieve the top five balances
- Check database statistics and locate the slowest queries
- Run a hybrid search across the catalog items
How to install postgres-mcp
Platform CLI
claude mcp add postgres-mcp -- docker run -i --rm ghcr.io/pgedge/postgres-mcp:latestPlatform CLI
codex mcp add postgres-mcp -- docker run -i --rm ghcr.io/pgedge/postgres-mcp:latestConfig file
{
"mcpServers": {
"postgres-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/pgedge/postgres-mcp:latest"
]
}
}
}Config file
{
"servers": {
"postgres-mcp": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/pgedge/postgres-mcp:latest"
]
}
}
}Platform CLI
gemini mcp add postgres-mcp docker run -i --rm ghcr.io/pgedge/postgres-mcp:latestStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about postgres-mcp
How to install postgres-mcp in Claude Code?
Run this command in your terminal: claude mcp add postgres-mcp -- docker run -i --rm ghcr.io/pgedge/postgres-mcp:latest. Make sure Docker is running on your machine.
What does postgres-mcp do?
It connects AI tools to PostgreSQL, turning text requests into SQL, reading schema metadata, and executing hybrid searches.
Can postgres-mcp be used in public web applications?
No. The server gives models read access to the entire schema, making it suitable only for internal developer workflows or trusted setups.