# read-only-local-postgres-mcp-server

Connect PostgreSQL to an agent over MCP and run queries that cannot write to the database. Useful for asking questions about tables and records in plain language.

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

## What it does

This MCP server lets Claude Code query PostgreSQL and returns results as JSON. You can switch database connections at runtime. Set `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, and `DB_PASSWORD` as environment variables for the connection.

Before a query runs, the server validates its SQL and uses a transaction marked `READ ONLY`. Writes through this connection are blocked. You need Node.js version 16 or later and a PostgreSQL server; with `mise`, configure the full path to the Node.js executable.

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

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add read-only-local-postgres-mcp-server -- npx -y @hovecapital/read-only-postgres-mcp-server
```

### Codex

**Platform CLI**
```bash
codex mcp add read-only-local-postgres-mcp-server -- npx -y @hovecapital/read-only-postgres-mcp-server
```

### Cursor

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

### GitHub Copilot

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

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add read-only-local-postgres-mcp-server npx -y @hovecapital/read-only-postgres-mcp-server
```

## When to use it
- inspect the tables in a PostgreSQL database
- retrieve database records through natural-language requests
- run SQL that cannot modify data
- switch to another database connection at runtime

## Example prompts
- List the tables in my PostgreSQL database.
- Show rows from `customers` without changing anything.
- Connect to another PostgreSQL database and find its order tables.

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