# PostgreSQL MCP Server

Connects PostgreSQL to an AI agent through MCP, with tools for queries, schema inspection, migrations, and database operations.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 12
- Author: neverinfamous
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/neverinfamous/postgres-mcp
- Updated: 2026-09-28
- HTML: https://affpapa.org/en/nevibecode/mcp/neverinfamous-postgresql-mcp-server

## What it does

PostgreSQL MCP Server connects a PostgreSQL database to an AI agent through the Model Context Protocol. It includes 63 tools, 10 resources, and 10 prompts for data operations, schema inspection, migration tracking, and diagnostics. Code Mode runs complex sequences inside an isolated V8 environment, while tool filtering can narrow the server to selected groups.

The server supports connection pooling, HTTP/SSE transport, OAuth 2.1, and PostgreSQL extensions such as `pgvector`, `PostGIS`, `pg_cron`, and `pgcrypto`. The setup below requires Docker and PostgreSQL 12-18. Without Docker, the `claude mcp add` command cannot start this server.

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

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add neverinfamous-postgresql-mcp-server -- docker run -i --rm docker.io/writenotenow/postgres-mcp-enhanced:v1.2.0
```

### Codex

**Platform CLI**
```bash
codex mcp add neverinfamous-postgresql-mcp-server -- docker run -i --rm docker.io/writenotenow/postgres-mcp-enhanced:v1.2.0
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "neverinfamous-postgresql-mcp-server": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "docker.io/writenotenow/postgres-mcp-enhanced:v1.2.0"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "neverinfamous-postgresql-mcp-server": {
            "type": "stdio",
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "docker.io/writenotenow/postgres-mcp-enhanced:v1.2.0"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add neverinfamous-postgresql-mcp-server docker run -i --rm docker.io/writenotenow/postgres-mcp-enhanced:v1.2.0
```

## When to use it
- inspect a PostgreSQL database schema
- run database queries through an AI agent
- track migration history
- restrict access by tool groups
- work with PostgreSQL extensions

## Example prompts
- Inspect the PostgreSQL schema and find tables that lack foreign keys.
- Run a query that returns the latest rows from `orders`.
- Assess the impact of a migration that changes the type of `user_id`.

## Similar
- [postgresql-database-engineering](https://affpapa.org/en/nevibecode/skills/postgresql-database-engineering.md) — skill · 1800 installs
- [postgresql-best-practices](https://affpapa.org/en/nevibecode/skills/postgresql-best-practices.md) — skill · 1500 installs
- [PostgreSQL Database Administration](https://affpapa.org/en/nevibecode/skills/postgresql-database-administration.md) — skill · 452 installs
- [postgresql-expert](https://affpapa.org/en/nevibecode/skills/postgresql-expert.md) — skill · 424 installs
- [postgresql](https://affpapa.org/en/nevibecode/skills/devops-skills-postgresql.md) — skill · 419 installs
- [postgresql-expert-best-practices-code-review](https://affpapa.org/en/nevibecode/skills/postgresql-expert-best-practices-code-review.md) — skill · 387 installs

## Other versions with the same name
- [PostgreSQL MCP Server · yawlabs](https://affpapa.org/en/nevibecode/mcp/yawlabs-postgresql-mcp-server.md) — ★ 10

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