Skip to content
MCP server

PostgreSQL (hardened, read-only)

Read-only PostgreSQL over MCP. Writes refused at the parsed SQL, plus a READ ONLY…

Install
Pricing
Open source
Runs
Locally or Remotely
Version
0.1.10
Listing updated
4 days ago

About PostgreSQL (hardened, read-only)

PostgreSQL (hardened, read-only) is an open-source MCP server for databases. It can run locally on your machine or as a hosted remote server.

Read-only PostgreSQL over MCP. Writes refused at the parsed SQL, plus a READ ONLY transaction.

Install

Run in a terminal

claude mcp add postgres-mcp-hardened --env DATABASE_URL='<DATABASE_URL>' -- npx -y postgres-mcp-hardened

Add to claude_desktop_config.json

{
  "mcpServers": {
    "postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}

Add to .vscode/mcp.json

{
  "servers": {
    "postgres-mcp-hardened": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}

Add to ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}

Configuration

  • DATABASE_URLConnection string for the role the server connects as. Use a role that cannot write — the server refuses writes twice, but a read-only role is the layer that does not depend on us being correct. `--print-setup-sql` prints the SQL that creates one.Required
  • MCP_STATEMENT_TIMEOUTServer-side statement timeout, e.g. `5s`. A question that would pin the database is cancelled by PostgreSQL, not by hope.
  • MCP_ALLOW_TABLESComma-separated allowlist. A table off the list is refused by name, and hiding it inside a CTE, a view or a join does not help.
  • MCP_AUDIT_LOGPath to the tamper-evident audit log. Entries are chained by hash and survive a restart; `--verify-audit` checks the chain against an off-host anchor.
  • DATABASE_URLConnection string for a role that cannot write.Required
  • MCP_ADDRAddress to bind, default 127.0.0.1:8080.

Pricing

Open source

PostgreSQL (hardened, read-only) FAQ

Is PostgreSQL (hardened, read-only) free?

Yes. PostgreSQL (hardened, read-only) is open source, so you can use and self-host it for free.

How do I add PostgreSQL (hardened, read-only) to Claude Code?

Run this command in your terminal: claude mcp add postgres-mcp-hardened --env DATABASE_URL='<DATABASE_URL>' -- npx -y postgres-mcp-hardened

What are the best alternatives to PostgreSQL (hardened, read-only)?

The closest alternatives to PostgreSQL (hardened, read-only) are Midplane, PlatypusDB, Lorebase, Sovaria and model2data studio.

Alternatives to PostgreSQL (hardened, read-only)

  1. Midplane

    MCP server

    Postgres gateway for AI agents with table grants, column masking and approval for writes

    Runs locally
    • Open source
    • 5 GitHub stars
    • Databases
  2. PlatypusDB

    MCP server

    Gives MCP clients access to your PlatypusDB database connections, scoped per agent

    Runs locally
    • Open source
    • Databases
  3. Lorebase

    MCP server

    Lets agents read and change a governed, versioned Postgres knowledge graph

    Runs locally
    • Open source
    • Knowledge and memory
  4. Sovaria

    MCP server

    Manage a Sovaria backend (Postgres, auth, storage, functions) from an AI assistant

    Not checked yet
    • 4 tools
    • Remote
    • Freemium
    • Databases
  5. Generate realistic connected test data, dbt projects and dashboards from a schema

    • Remote
    • Freemium
    • Databases
  6. semlayer

    MCP server

    Infers a semantic layer from your data warehouse and serves it to agents

    Runs locally
    • Free
    • Databases