PostgreSQL Read-Only MCP

Inspect relational schemas and run safe EXPLAIN plans without mutation risk

Provides read-only SQL execution, foreign-key topology lookup, and query plan diagnostics for PostgreSQL databases in local and staging environments.

Install & Client JSON Configurations

All client configuration manifests are exposed directly below without hidden tabs for zero-click copying.

CLI Install Command
npx -y @modelcontextprotocol/server-postgres postgresql://readonly@localhost:5432/app
Claude Desktop · claude_desktop_config.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly:password@localhost:5432/app"
      ]
    }
  }
}
Cursor · .cursor/mcp.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly:password@localhost:5432/app"
      ]
    }
  }
}
VS Code · .vscode/mcp.json
{
  "servers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly:password@localhost:5432/app"
      ]
    }
  }
}

Operational Architecture

PostgreSQL Read-Only MCP isolates agent queries inside a strict read-only transaction wrapper so schema discovery never triggers unintended writes or locks. By exposing only five targeted tools, initial prompt schema injection stays near 1,120 tokens.

Core Capabilities

  • Enumerates schemas, tables, column nullability, and composite indexes from information_schema.
  • Wraps every submitted SELECT statement in READ ONLY transaction mode with configurable statement timeouts.
  • Surfaces sequential scan bottlenecks via structured EXPLAIN JSON summaries.

Recommended Security Baseline

Create a dedicated PostgreSQL role limited to SELECT on target tables rather than reusing superuser credentials. Bind connection strings through runtime environment variables rather than committing plain credentials inside workspace JSON files.

Alternative Servers in This Category

Database MCP
Rising Stack

SQLite Local Inspector MCP

Inspect embedded SQLite schemas and run local read-only queries fast

stdiononeopen-source
Tool Surface6 tools
Reliability Score95 / 100
980 tok · 12,100 starsInspect config
Database MCP
Core Ecosystem

Supabase Schema & Migration MCP

Inspect Postgres tables, RLS policies, and Edge Functions with zero drift

httpstdiooauth-2.1freemium
Tool Surface14 tools
Reliability Score95 / 100
2540 tok · 5,800 starsInspect config
Database MCP
Long-Tail Niche

ClickHouse Analytics MCP

Columnar OLAP schema explorer and safe partition-aware analytical queries

stdiohttpapi-keyopen-source
Tool Surface8 tools
Reliability Score91 / 100
1580 tok · 1,680 starsInspect config