# postgres-mcp

Connects PostgreSQL databases to AI coding assistants for natural language queries, schema inspection, and hybrid search.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed · ★ 241
- Author: pgEdge
- License: PostgreSQL · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pgEdge/pgedge-postgres-mcp
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/mcp/postgres-mcp

## What it 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.

## Requirements
- Needs: Docker
- Works with: PostgreSQL

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add postgres-mcp -- docker run -i --rm ghcr.io/pgedge/postgres-mcp:latest
```

### Codex

**Platform CLI**
```bash
codex mcp add postgres-mcp -- docker run -i --rm ghcr.io/pgedge/postgres-mcp:latest
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "postgres-mcp": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "ghcr.io/pgedge/postgres-mcp:latest"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "postgres-mcp": {
            "type": "stdio",
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "ghcr.io/pgedge/postgres-mcp:latest"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add postgres-mcp docker run -i --rm ghcr.io/pgedge/postgres-mcp:latest
```

## When to use it
- 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
- 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

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89408
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89433
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27669
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49845

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
