MCP Server Studio

PostgreSQL (hardened, read-only) MCP server

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

Registry name: io.github.Eszetael/postgres-mcp-hardened

Publisher
Eszetael
Runs
Runs locally
Package
npm
Version
0.1.12
Category
Databases
Updated
2026-11-24

Source code on GitHub

Set up PostgreSQL (hardened, read-only) (run locally)

Claude Desktop

Add to claude_desktop_config.json:

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

Claude Code

Run in your terminal:

claude mcp add postgres-mcp-hardened -e DATABASE_URL='<DATABASE_URL>' -e MCP_STATEMENT_TIMEOUT='<MCP_STATEMENT_TIMEOUT>' -e MCP_ALLOW_TABLES='<MCP_ALLOW_TABLES>' -e MCP_AUDIT_LOG='<MCP_AUDIT_LOG>' -- npx -y [email protected]

Cursor

Add to .cursor/mcp.json:

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

VS Code

Add to .vscode/mcp.json:

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

Windsurf

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

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

Settings

NameRequiredWhat it is
DATABASE_URLYesConnection 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…
MCP_STATEMENT_TIMEOUTNoServer-side statement timeout, e.g. `5s`. A question that would pin the database is cancelled by PostgreSQL, not by hope.
MCP_ALLOW_TABLESNoComma-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_LOGNoPath 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.

More databases MCP servers