# Pgmoat

> Pgmoat is an open-source MCP server for databases. Read-only Postgres access for agents: SQL parsing, hidden columns, row limits, audit log. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, Self-hosted, Linux, macOS, Windows
- **Repository:** https://github.com/kitalon-labs-llc/pgmoat
- **MCP Registry name:** io.github.Kitalon-Labs-LLC/pgmoat
- **Categories:** [databases](https://ai-powered.com/categories/databases), [security](https://ai-powered.com/categories/security)
- **Listing updated:** 2026-11-23

## About

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.

## Features

- **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

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
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.

### Claude Code: Or share it with your project (.mcp.json)

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

### Claude Desktop (claude_desktop_config.json)

```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.

### Cursor (~/.cursor/mcp.json)

```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.

### VS Code (~/.copilot/mcp-config.json)

```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.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add pgmoat --env PGMOAT_DATABASE_URL='<PGMOAT_DATABASE_URL>' -- npx -y pgmoat
```

### Codex: Or add to config.toml (~/.codex/config.toml)

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

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```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

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```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.

### Devin Desktop (~/.config/devin/mcp_config.json)

```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.

### Cline (cline_mcp_settings.json)

```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.

### Zed (Zed settings.json)

```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.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "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.

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```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.

### Kiro (~/.kiro/settings/mcp.json)

```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.

### Other clients (your client's MCP settings (most use this shape))

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

## 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.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [AiSOC](https://ai-powered.com/mcp/aisoc): AiSOC is an open-source MCP server for ai models and llm tooling.
- [x64dbg-mcp-server](https://ai-powered.com/mcp/x64dbg-mcp-server): x64dbg-mcp-server is an open-source MCP server for ai models and llm tooling.
- [redamon](https://ai-powered.com/mcp/redamon): redamon is an open-source MCP server for ai models and llm tooling.
- [Treasure Map](https://ai-powered.com/mcp/treasure-map): Treasure Map is an open-source MCP server for security.
- [Agent Roast](https://ai-powered.com/mcp/agent-roast): Agent Roast is an open-source MCP server for developer tools.
- [NostrPulse](https://ai-powered.com/mcp/nostrpulse): NostrPulse is an open-source MCP server for finance and payments.
- [Runeward](https://ai-powered.com/mcp/runeward): Runeward is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/pgmoat
