Skip to content
MCP server

Pgmoat

Read-only Postgres access for agents: SQL parsing, hidden columns, row limits, audit log

Runs locally

Pgmoat is an open-source MCP server for databases. It runs locally on your machine and is started by your AI client.

Pricing
Open source
Platforms
CLI, Self-hosted, Linux
Runs
Locally
Access
Needs a secret key or token
Version
0.1.2
Listing updated

Similar MCP servers

Install

Add with the CLI

Run in a terminal

claude mcp add pgmoat --env PGMOAT_DATABASE_URL='<PGMOAT_DATABASE_URL>' -- npx -y pgmoat

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": {
    "pgmoat": {
      "command": "npx",
      "args": [
        "-y",
        "pgmoat"
      ],
      "env": {
        "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
      }
    }
  }
}

Claude Code setup guide

Add to claude_desktop_config.json

{
  "mcpServers": {
    "pgmoat": {
      "command": "npx",
      "args": [
        "-y",
        "pgmoat"
      ],
      "env": {
        "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
      }
    }
  }
}

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

Claude Desktop setup guide

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "pgmoat": {
      "command": "npx",
      "args": [
        "-y",
        "pgmoat"
      ],
      "env": {
        "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
      }
    }
  }
}

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

Cursor setup guide

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

{
  "mcpServers": {
    "pgmoat": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "pgmoat"
      ],
      "env": {
        "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
      }
    }
  }
}

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 pgmoat --env PGMOAT_DATABASE_URL='<PGMOAT_DATABASE_URL>' -- npx -y pgmoat

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.pgmoat]
command = "npx"
args = ["-y", "pgmoat"]
env = { PGMOAT_DATABASE_URL = "<PGMOAT_DATABASE_URL>" }

Codex setup guide

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

{
  "mcpServers": {
    "pgmoat": {
      "command": "npx",
      "args": [
        "-y",
        "pgmoat"
      ],
      "env": {
        "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
      }
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.json

    {
      "mcpServers": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    Or run: gemini mcp add -s user -e PGMOAT_DATABASE_URL='<PGMOAT_DATABASE_URL>' pgmoat npx -- -y pgmoat

    Antigravity

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

    {
      "mcpServers": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    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": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    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": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

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

    Cline setup guide

  • Zed

    Add to Zed settings.json

    {
      "context_servers": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    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": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    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": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    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": {
        "pgmoat": {
          "command": "npx",
          "args": [
            "-y",
            "pgmoat"
          ],
          "env": {
            "PGMOAT_DATABASE_URL": "<PGMOAT_DATABASE_URL>"
          }
        }
      }
    }

    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

  • PGMOAT_DATABASE_URLPostgres connection URL (use a read-only role)Required

About Pgmoat

Every query is checked with the real Postgres parser before it runs, and the server removes the write path altogether. Tables and columns you mark hidden never reach the agent, row limits and timeouts apply, and Row-Level Security is bound to the caller's identity. Each action goes into a tamper-evident audit log whose hash chain can be verified with a command.

Setup can be zero-config with a read-only connection URL, or a pgmoat.yaml generated by pgmoat init, which auto-hides columns such as password_hash and lets you add table descriptions and sensitivity levels. A doctor command checks the role: with a config file it refuses to start for a superuser, a role with BYPASSRLS while RLS is configured, or a table owner without FORCE ROW LEVEL SECURITY, unless an unsafe override is passed and recorded.

The README is explicit about limits: it does not stop prompt injection, does not replace Postgres permissions and does not fix flawed RLS policies. It needs Node.js 22.12 or newer and Postgres 15 to 18, is MIT licensed, and also ships as a Docker image.

What it does

Parser-based query checks
Uses the real Postgres parser to validate every query.
Hidden columns and tables
Withholds anything marked hidden from the agent.
Budgets
Applies row limits and query timeouts, defaulting to 200 rows and 5 seconds in the sample config.
RLS binding
Sets session variables so Row-Level Security follows the caller.
Tamper-evident audit
Writes a hash-chained log you can verify.
Role safety checks
Refuses unsafe database roles at startup in config mode.

Good for

  • Let a coding agent explore a production-like database without write risk
  • Hide password hashes and tokens from assistant queries
  • Keep an auditable record of what an agent read
  • Export the visible schema as Markdown for documentation

Pricing

Open source

MIT licensed

Pgmoat FAQ

Which versions does Pgmoat need?

Node.js 22.12 or newer and Postgres 15 to 18.

Does Pgmoat stop prompt injection?

No. The README says an agent with other tools can still be tricked into sending readable data elsewhere.

How do I keep the password out of process listings?

Pass the URL with --url-env instead of on the command line.

What licence is Pgmoat?

MIT.

Is Pgmoat free?

Yes. Pgmoat is open source, so you can use and self-host it for free.

How do I add Pgmoat to Claude Code?

Run this command in your terminal: claude mcp add pgmoat --env PGMOAT_DATABASE_URL='<PGMOAT_DATABASE_URL>' -- npx -y pgmoat

What are the best alternatives to Pgmoat?

The closest alternatives to Pgmoat are REA, AiSOC, x64dbg-mcp-server, redamon and Treasure Map.

Where this comes from

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

How AIPoweredBot checks servers