# Kaiva Postgres MCP

Connects assistants to PostgreSQL with guaranteed read-only execution. Replaces the archived official Postgres MCP package without breaking existing workflows.

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

## What it does

Serves as a direct drop-in alternative to the unsupported `@modelcontextprotocol/server-postgres`. It restricts incoming SQL to single read-safe statements like `SELECT`, `SHOW`, `TABLE`, `VALUES` or `EXPLAIN`. Calls to dangerous database internals such as server file readers, `dblink`, advisory locks or `COPY ... TO PROGRAM` are rejected upfront.

Queries run inside isolated read-only transactions using the extended query protocol. Every statement auto-terminates with a rollback and `DISCARD ALL` to purge temporary session state. Standard execution caps returned data at 1,000 rows with a 15-second timeout. Without `--allow-superuser`, connecting as a superuser to remote hosts will fail immediately.

## Requirements
- Needs: Node.js (commands run via npx)
- Works with: PostgreSQL

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add kaiva-postgres-mcp -- npx -y @kaiva/postgres-mcp
```

### Codex

**Platform CLI**
```bash
codex mcp add kaiva-postgres-mcp -- npx -y @kaiva/postgres-mcp
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "kaiva-postgres-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "@kaiva/postgres-mcp"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "kaiva-postgres-mcp": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@kaiva/postgres-mcp"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add kaiva-postgres-mcp npx -y @kaiva/postgres-mcp
```

## When to use it
- inspect database schema, column types, and foreign key relations
- run analytical SQL queries without risking table updates or drops
- evaluate query performance via `EXPLAIN`
- cap large result sets automatically to prevent context overflow

## Example prompts
- Inspect the columns, keys, and indexes of the `users` table
- Run an `EXPLAIN` query on the recent subscriptions report
- List all available database schemas and tables with row estimates

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89609
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89899
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16730
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40459
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27844
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49863

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