P

Postgres MCP Hardened

by Eszetael · io.github.Eszetael/postgres-mcp-hardened

A drop-in Model Context Protocol (MCP) server that lets an AI agent query PostgreSQL — read-only, enforced at the database level, with real SQL validation, timeouts, cost limits, OAuth 2.1, and an audit trail.

npm Local · stdio GlamaOfficial MCP Registry High confidence

Install

Add to ~/Library/Application Support/Claude/claude_desktop_config.json

Windows / Linux path
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "io-github-eszetael-postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_VALUE>",
        "MCP_STATEMENT_TIMEOUT": "<VALUE>",
        "MCP_ALLOW_TABLES": "<VALUE>",
        "MCP_AUDIT_LOG": "<VALUE>",
        "MCP_DATABASE_URLS": "<VALUE>"
      }
    }
  }
}

Restart Claude Desktop to activate the new server.

Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)

Windows / Linux path
Windows: .cursor\mcp.json (project) or %USERPROFILE%\.cursor\mcp.json (global)
Linux: .cursor/mcp.json (project) or ~/.cursor/mcp.json (global)
{
  "mcpServers": {
    "io-github-eszetael-postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_VALUE>",
        "MCP_STATEMENT_TIMEOUT": "<VALUE>",
        "MCP_ALLOW_TABLES": "<VALUE>",
        "MCP_AUDIT_LOG": "<VALUE>",
        "MCP_DATABASE_URLS": "<VALUE>"
      }
    }
  }
}

Cursor usually picks up config changes automatically; if the server does not appear, reload the window.

Add to .mcp.json (project) or ~/.claude.json (global)

Windows / Linux path
Windows: .mcp.json (project) or %USERPROFILE%\.claude.json (global)
Linux: .mcp.json (project) or ~/.claude.json (global)
{
  "mcpServers": {
    "io-github-eszetael-postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_VALUE>",
        "MCP_STATEMENT_TIMEOUT": "<VALUE>",
        "MCP_ALLOW_TABLES": "<VALUE>",
        "MCP_AUDIT_LOG": "<VALUE>",
        "MCP_DATABASE_URLS": "<VALUE>"
      }
    }
  }
}

The server will be available in the next Claude Code session.

Add to .vscode/mcp.json

Windows / Linux path
Windows: .vscode\mcp.json
Linux: .vscode/mcp.json
{
  "servers": {
    "io-github-eszetael-postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_VALUE>",
        "MCP_STATEMENT_TIMEOUT": "<VALUE>",
        "MCP_ALLOW_TABLES": "<VALUE>",
        "MCP_AUDIT_LOG": "<VALUE>",
        "MCP_DATABASE_URLS": "<VALUE>"
      }
    }
  }
}

Reload the VS Code window to activate.

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

Windows / Linux path
Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json
Linux: ~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "io-github-eszetael-postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_VALUE>",
        "MCP_STATEMENT_TIMEOUT": "<VALUE>",
        "MCP_ALLOW_TABLES": "<VALUE>",
        "MCP_AUDIT_LOG": "<VALUE>",
        "MCP_DATABASE_URLS": "<VALUE>"
      }
    }
  }
}

Restart Windsurf (or refresh its MCP servers panel) to activate the new server.

Windsurf Next uses ~/.codeium/windsurf-next/mcp_config.json. Devin Desktop (the Windsurf rebrand) uses ~/.config/devin/mcp_config.json and imports the Windsurf file.

Add to ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

Windows / Linux path
Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
{
  "mcpServers": {
    "io-github-eszetael-postgres-mcp-hardened": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-hardened"
      ],
      "env": {
        "DATABASE_URL": "<YOUR_VALUE>",
        "MCP_STATEMENT_TIMEOUT": "<VALUE>",
        "MCP_ALLOW_TABLES": "<VALUE>",
        "MCP_AUDIT_LOG": "<VALUE>",
        "MCP_DATABASE_URLS": "<VALUE>"
      }
    }
  }
}

Cline reloads cline_mcp_settings.json automatically; if the server does not appear, reload the VS Code window.

Open it from Cline's MCP Servers panel → Configure. Roo Code uses a different file and format.

Configuration

Environment variables this server reads. Secrets stay on your machine.

NameRequiredDescription
DATABASE_URL secret Yes PostgreSQL connection string (use a read-only role)
MCP_STATEMENT_TIMEOUT No Server-side statement timeout, e.g. `5s`. A question that would pin the database is cancelled by PostgreSQL, not by hope.
MCP_ALLOW_TABLES No Comma-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_LOG No Path 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.
MCP_DATABASE_URLS No Several databases from one server: prod=postgres://…;dev=postgres://…

Similar servers