Skip to content
MCP server

pgwarden

Postgres gateway where each person queries as their own database role

pgwarden is an MCP server for databases. It runs as a hosted remote server, so there is nothing to install locally.

Platforms
Self-hosted, API
Runs
Remotely
Access
Needs a secret key or token
Version
0.1.1
Listing updated

Similar MCP servers

Install

You install MCP servers on a computer. Send yourself the link.

Add with the CLI

Run in a terminal

claude mcp add pgwarden --env PGWARDEN_CONFIG='<PGWARDEN_CONFIG>' --env PGWARDEN_TARGET_DSN='<PGWARDEN_TARGET_DSN>' --env PGWARDEN_STATE_DSN='<PGWARDEN_STATE_DSN>' --env PGWARDEN_ROLE_SECRET_FILE='<PGWARDEN_ROLE_SECRET_FILE>' --env PGWARDEN_SIGNING_KEY_FILE='<PGWARDEN_SIGNING_KEY_FILE>' --env PGWARDEN_SESSION_SECRET_FILE='<PGWARDEN_SESSION_SECRET_FILE>' --env PGWARDEN_OIDC_CLIENT_SECRET_FILE='<PGWARDEN_OIDC_CLIENT_SECRET_FILE>' -- docker run -i --rm -e PGWARDEN_CONFIG -e PGWARDEN_TARGET_DSN -e PGWARDEN_STATE_DSN -e PGWARDEN_ROLE_SECRET_FILE -e PGWARDEN_SIGNING_KEY_FILE -e PGWARDEN_SESSION_SECRET_FILE -e PGWARDEN_OIDC_CLIENT_SECRET_FILE ghcr.io/b0yko/pgwarden:0.1.1

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

Or share it with your project

Add to .mcp.json

{
  "mcpServers": {
    "pgwarden": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PGWARDEN_CONFIG",
        "-e",
        "PGWARDEN_TARGET_DSN",
        "-e",
        "PGWARDEN_STATE_DSN",
        "-e",
        "PGWARDEN_ROLE_SECRET_FILE",
        "-e",
        "PGWARDEN_SIGNING_KEY_FILE",
        "-e",
        "PGWARDEN_SESSION_SECRET_FILE",
        "-e",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
        "ghcr.io/b0yko/pgwarden:0.1.1"
      ],
      "env": {
        "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
        "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
        "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
        "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
        "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
        "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
      }
    }
  }
}

Claude Code setup guide

Add to claude_desktop_config.json

{
  "mcpServers": {
    "pgwarden": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PGWARDEN_CONFIG",
        "-e",
        "PGWARDEN_TARGET_DSN",
        "-e",
        "PGWARDEN_STATE_DSN",
        "-e",
        "PGWARDEN_ROLE_SECRET_FILE",
        "-e",
        "PGWARDEN_SIGNING_KEY_FILE",
        "-e",
        "PGWARDEN_SESSION_SECRET_FILE",
        "-e",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
        "ghcr.io/b0yko/pgwarden:0.1.1"
      ],
      "env": {
        "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
        "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
        "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
        "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
        "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
        "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
      }
    }
  }
}

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

Claude Desktop setup guide

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "pgwarden": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PGWARDEN_CONFIG",
        "-e",
        "PGWARDEN_TARGET_DSN",
        "-e",
        "PGWARDEN_STATE_DSN",
        "-e",
        "PGWARDEN_ROLE_SECRET_FILE",
        "-e",
        "PGWARDEN_SIGNING_KEY_FILE",
        "-e",
        "PGWARDEN_SESSION_SECRET_FILE",
        "-e",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
        "ghcr.io/b0yko/pgwarden:0.1.1"
      ],
      "env": {
        "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
        "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
        "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
        "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
        "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
        "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
      }
    }
  }
}

Use .cursor/mcp.json in a project to share it with the project.

Cursor setup guide

Add to ~/.copilot/mcp-config.json

{
  "mcpServers": {
    "pgwarden": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PGWARDEN_CONFIG",
        "-e",
        "PGWARDEN_TARGET_DSN",
        "-e",
        "PGWARDEN_STATE_DSN",
        "-e",
        "PGWARDEN_ROLE_SECRET_FILE",
        "-e",
        "PGWARDEN_SIGNING_KEY_FILE",
        "-e",
        "PGWARDEN_SESSION_SECRET_FILE",
        "-e",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
        "ghcr.io/b0yko/pgwarden:0.1.1"
      ],
      "env": {
        "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
        "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
        "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
        "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
        "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
        "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
      }
    }
  }
}

Or put the same entry in .mcp.json at your workspace root to share it.

VS Code setup guide

Add with the CLI

Run in a terminal

codex mcp add pgwarden --env PGWARDEN_CONFIG='<PGWARDEN_CONFIG>' --env PGWARDEN_TARGET_DSN='<PGWARDEN_TARGET_DSN>' --env PGWARDEN_STATE_DSN='<PGWARDEN_STATE_DSN>' --env PGWARDEN_ROLE_SECRET_FILE='<PGWARDEN_ROLE_SECRET_FILE>' --env PGWARDEN_SIGNING_KEY_FILE='<PGWARDEN_SIGNING_KEY_FILE>' --env PGWARDEN_SESSION_SECRET_FILE='<PGWARDEN_SESSION_SECRET_FILE>' --env PGWARDEN_OIDC_CLIENT_SECRET_FILE='<PGWARDEN_OIDC_CLIENT_SECRET_FILE>' -- docker run -i --rm -e PGWARDEN_CONFIG -e PGWARDEN_TARGET_DSN -e PGWARDEN_STATE_DSN -e PGWARDEN_ROLE_SECRET_FILE -e PGWARDEN_SIGNING_KEY_FILE -e PGWARDEN_SESSION_SECRET_FILE -e PGWARDEN_OIDC_CLIENT_SECRET_FILE ghcr.io/b0yko/pgwarden:0.1.1

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.pgwarden]
command = "docker"
args = ["run", "-i", "--rm", "-e", "PGWARDEN_CONFIG", "-e", "PGWARDEN_TARGET_DSN", "-e", "PGWARDEN_STATE_DSN", "-e", "PGWARDEN_ROLE_SECRET_FILE", "-e", "PGWARDEN_SIGNING_KEY_FILE", "-e", "PGWARDEN_SESSION_SECRET_FILE", "-e", "PGWARDEN_OIDC_CLIENT_SECRET_FILE", "ghcr.io/b0yko/pgwarden:0.1.1"]
env = { PGWARDEN_CONFIG = "<PGWARDEN_CONFIG>", PGWARDEN_TARGET_DSN = "<PGWARDEN_TARGET_DSN>", PGWARDEN_STATE_DSN = "<PGWARDEN_STATE_DSN>", PGWARDEN_ROLE_SECRET_FILE = "<PGWARDEN_ROLE_SECRET_FILE>", PGWARDEN_SIGNING_KEY_FILE = "<PGWARDEN_SIGNING_KEY_FILE>", PGWARDEN_SESSION_SECRET_FILE = "<PGWARDEN_SESSION_SECRET_FILE>", PGWARDEN_OIDC_CLIENT_SECRET_FILE = "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>" }

Codex setup guide

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

{
  "mcpServers": {
    "pgwarden": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "PGWARDEN_CONFIG",
        "-e",
        "PGWARDEN_TARGET_DSN",
        "-e",
        "PGWARDEN_STATE_DSN",
        "-e",
        "PGWARDEN_ROLE_SECRET_FILE",
        "-e",
        "PGWARDEN_SIGNING_KEY_FILE",
        "-e",
        "PGWARDEN_SESSION_SECRET_FILE",
        "-e",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
        "ghcr.io/b0yko/pgwarden:0.1.1"
      ],
      "env": {
        "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
        "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
        "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
        "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
        "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
        "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
        "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
      }
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.json

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    Or run: gemini mcp add -s user -e PGWARDEN_CONFIG='<PGWARDEN_CONFIG>' -e PGWARDEN_TARGET_DSN='<PGWARDEN_TARGET_DSN>' -e PGWARDEN_STATE_DSN='<PGWARDEN_STATE_DSN>' -e PGWARDEN_ROLE_SECRET_FILE='<PGWARDEN_ROLE_SECRET_FILE>' -e PGWARDEN_SIGNING_KEY_FILE='<PGWARDEN_SIGNING_KEY_FILE>' -e PGWARDEN_SESSION_SECRET_FILE='<PGWARDEN_SESSION_SECRET_FILE>' -e PGWARDEN_OIDC_CLIENT_SECRET_FILE='<PGWARDEN_OIDC_CLIENT_SECRET_FILE>' pgwarden docker -- run -i --rm -e PGWARDEN_CONFIG -e PGWARDEN_TARGET_DSN -e PGWARDEN_STATE_DSN -e PGWARDEN_ROLE_SECRET_FILE -e PGWARDEN_SIGNING_KEY_FILE -e PGWARDEN_SESSION_SECRET_FILE -e PGWARDEN_OIDC_CLIENT_SECRET_FILE ghcr.io/b0yko/pgwarden:0.1.1

    Antigravity

    Add to ~/.gemini/config/mcp_config.json

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    Use .agents/mcp_config.json to add it to one workspace only.

    Gemini CLI and Antigravity setup guide

  • Devin Desktop (formerly Windsurf)

    Add to ~/.config/devin/mcp_config.json

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

    Devin Desktop setup guide

  • Cline

    Add to cline_mcp_settings.json

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    Open it from the MCP Servers icon → Configure → Configure MCP Servers.

    Cline setup guide

  • Zed

    Add to Zed settings.json

    {
      "context_servers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    Open it with zed: open settings file. Merge context_servers into the settings you already have.

    Zed setup guide

  • JetBrains AI Assistant and Junie

    AI Assistant

    Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

    Junie

    Add to ~/.junie/mcp/mcp.json

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    Use .junie/mcp/mcp.json to share it with a project.

    JetBrains AI Assistant and Junie setup guide

  • Kiro

    Add to ~/.kiro/settings/mcp.json

    {
      "mcpServers": {
        "pgwarden": {
          "command": "docker",
          "args": [
            "run",
            "-i",
            "--rm",
            "-e",
            "PGWARDEN_CONFIG",
            "-e",
            "PGWARDEN_TARGET_DSN",
            "-e",
            "PGWARDEN_STATE_DSN",
            "-e",
            "PGWARDEN_ROLE_SECRET_FILE",
            "-e",
            "PGWARDEN_SIGNING_KEY_FILE",
            "-e",
            "PGWARDEN_SESSION_SECRET_FILE",
            "-e",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE",
            "ghcr.io/b0yko/pgwarden:0.1.1"
          ],
          "env": {
            "PGWARDEN_CONFIG": "<PGWARDEN_CONFIG>",
            "PGWARDEN_TARGET_DSN": "<PGWARDEN_TARGET_DSN>",
            "PGWARDEN_STATE_DSN": "<PGWARDEN_STATE_DSN>",
            "PGWARDEN_ROLE_SECRET_FILE": "<PGWARDEN_ROLE_SECRET_FILE>",
            "PGWARDEN_SIGNING_KEY_FILE": "<PGWARDEN_SIGNING_KEY_FILE>",
            "PGWARDEN_SESSION_SECRET_FILE": "<PGWARDEN_SESSION_SECRET_FILE>",
            "PGWARDEN_OIDC_CLIENT_SECRET_FILE": "<PGWARDEN_OIDC_CLIENT_SECRET_FILE>"
          }
        }
      }
    }

    Use .kiro/settings/mcp.json to add it to one workspace only.

    Kiro setup guide

Using several servers? Build one config file with the MCP config generator.

Configuration

  • PGWARDEN_CONFIGPath to pgwarden.yaml inside the container.Required
  • PGWARDEN_TARGET_DSNTarget Postgres 16+ DSN: host, port and database, no user or password.Required
  • PGWARDEN_STATE_DSNState database DSN, connecting as the pgwarden_app role that `pgwarden db init` creates.Required
  • PGWARDEN_ROLE_SECRET_FILEFile with the secret that derives each login role's SCRAM password.Required
  • PGWARDEN_SIGNING_KEY_FILEFile with the Ed25519 key that signs access tokens.Required
  • PGWARDEN_SESSION_SECRET_FILEFile with the browser session secret.Required
  • PGWARDEN_OIDC_CLIENT_SECRET_FILEFile with the client secret your identity provider issued for pgwarden.Required

About pgwarden

pgwarden is an MCP gateway that lets Claude, ChatGPT, Cursor or any MCP client query Postgres as the person asking. Users sign in through your OIDC provider, and the gateway connects with their own Postgres role, so grants, row-level security and masking views decide what they can see.

Reads run in a read-only transaction with one statement per call, without any SQL parsing. Writes are proposed, checked with EXPLAIN, approved by a named person and run once. Every tool call, sign-in, approval and admin change is recorded in an append-only, hash-chained audit log.

It ships as a container image and needs Postgres 16+, a separate state database and an OIDC provider. A Docker Compose demo includes a mock identity provider and sample users with different access.

Tools this server provides (4)

Taken from the project documentation; the running server may differ.

From the tool list in its README, going by the names, 3 of 4 tools read data; 1 name doesn't say.

From the server's own tool labels and tool names; not verified by us.

whoami
Show the identity and Postgres role in use
list_tablesName suggests: reads
List tables available to the signed-in role
describe_tableName suggests: reads
Describe a table
queryName suggests: reads
Run a read-only query as the person's own role

What it does

Per-person database roles
Each user is mapped from your identity provider to their own Postgres login role.
Read-only by construction
Queries run in a read-only transaction with a single statement per call.
Approved writes
Writes wait for a named approver after an EXPLAIN check, and run once.
Masking and row-level security
Postgres grants, RLS and masking views control what each person sees.
Hash-chained audit log
Tool calls, sign-ins, approvals and admin changes are logged append-only.
OAuth 2.1 sign-in
Clients connect with consent, PKCE and OIDC sign-in.

Good for

  • Give analysts AI access to Postgres without a shared credential
  • Mask personal data for some users and not others
  • Require approval before an AI-proposed write
  • Keep an auditable record of AI database access
  • Try the setup locally with the demo stack

pgwarden FAQ

What does pgwarden need?

Postgres 16+, a state database and an OIDC provider; it runs from a container image.

How does pgwarden keep reads safe?

Each query runs in a read-only transaction with one statement per call, and access is enforced by the database itself.

How do writes work?

A write is proposed, checked with EXPLAIN, approved by a named person and then run once.

Can I try pgwarden first?

Yes. A Docker Compose demo starts Postgres, a mock identity provider and the gateway locally.

How do I add pgwarden to Claude Code?

Run this command in your terminal: claude mcp add pgwarden --env PGWARDEN_CONFIG='<PGWARDEN_CONFIG>' --env PGWARDEN_TARGET_DSN='<PGWARDEN_TARGET_DSN>' --env PGWARDEN_STATE_DSN='<PGWARDEN_STATE_DSN>' --env PGWARDEN_ROLE_SECRET_FILE='<PGWARDEN_ROLE_SECRET_FILE>' --env PGWARDEN_SIGNING_KEY_FILE='<PGWARDEN_SIGNING_KEY_FILE>' --env PGWARDEN_SESSION_SECRET_FILE='<PGWARDEN_SESSION_SECRET_FILE>' --env PGWARDEN_OIDC_CLIENT_SECRET_FILE='<PGWARDEN_OIDC_CLIENT_SECRET_FILE>' -- docker run -i --rm -e PGWARDEN_CONFIG -e PGWARDEN_TARGET_DSN -e PGWARDEN_STATE_DSN -e PGWARDEN_ROLE_SECRET_FILE -e PGWARDEN_SIGNING_KEY_FILE -e PGWARDEN_SESSION_SECRET_FILE -e PGWARDEN_OIDC_CLIENT_SECRET_FILE ghcr.io/b0yko/pgwarden:0.1.1

What are the best alternatives to pgwarden?

The closest alternatives to pgwarden are Pgmoat, Db Gateway, Postgres Secured (Aegis Zero-Trust), Midplane and Warehouse MCP.

Where this comes from

  • Description: written from the project's README and its MCP Registry entry.
  • Install steps: from the official MCP Registry entry.

How AIPoweredBot checks servers