# pgman

> pgman is an open-source MCP server for databases. PostgreSQL schema, read-only queries, EXPLAIN and masked dumps for coding agents. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** macOS, Linux, CLI
- **Website:** https://www.poly.io/products/pgman/
- **Repository:** https://github.com/tombaldwin/pgman
- **MCP Registry name:** io.github.tombaldwin/pgman
- **Categories:** databases, developer tools
- **Listing updated:** 2026-11-14

## About

Built as part of pgman, a k9s-style terminal UI for PostgreSQL, the MCP mode (pgman mcp serve) gives an agent a guarded view of your databases. Reads cover queries, lock pre-flights, pending patches, schema lint and environments, while apply_patches, dump and restore each need your confirmation.

Every statement is classified before it runs, a write waits inside a transaction until committed or rolled back, and a project's config can only tighten rules. Migrations can be dry-run with real locks, rehearsed on a throwaway copy and applied one transaction at a time, never on a replica. pgman dump masks names, emails, phones and free text as rows are read while keeping foreign keys joined.

It works with PostgreSQL 10 or newer on laptops, docker, RDS, Aurora and managed hosts with direct connections, and installs through Homebrew, cargo or binaries.

## Features

- **Read-only by default:** Statements are classified before running; writes wait for commit.
- **Safe migrations:** Dry-run with real locks, then apply one transaction at a time.
- **Masked production copies:** Dumps mask personal data and keep foreign keys joining.
- **Environment overview:** See dev, staging and production side by side.
- **Log to SQL:** Turn application logs back into runnable SQL.

## Good for

- Let an agent inspect a schema without write access
- Preview locks before a migration
- Create a masked copy of production for debugging
- Run EXPLAIN on a slow query through an assistant

## Install

### Claude Code (Terminal)

```sh
claude mcp add pgman -- npx -y pgman
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "pgman": {
      "command": "npx",
      "args": [
        "-y",
        "pgman"
      ]
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "pgman": {
      "command": "npx",
      "args": [
        "-y",
        "pgman"
      ]
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "pgman": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "pgman"
      ]
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "pgman": {
      "command": "npx",
      "args": [
        "-y",
        "pgman"
      ]
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "pgman": {
      "command": "npx",
      "args": [
        "-y",
        "pgman"
      ]
    }
  }
}
```

## FAQ

### Is it free?

Yes, it is open source under MIT or Apache-2.0; paid support plans start at £1,500 a year.

### Can the agent write to my database?

Writes wait in a transaction until you commit or roll back, and patches, dumps and restores need confirmation.

### Which Postgres versions work?

PostgreSQL 10 or newer.

### Is pgman free?

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

### How do I add pgman to Claude Code?

Run this command in your terminal: claude mcp add pgman -- npx -y pgman

### What are the best alternatives to pgman?

The closest alternatives to pgman are REA, Codebase Memory, GitHub, Serena MCP: the IDE for your agent and XERJ.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [Ouroboros](https://ai-powered.com/mcp/ouroboros): Ouroboros is an open-source MCP server for developer tools.
- [Claude Code Ultimate Guide](https://ai-powered.com/mcp/claude-code-ultimate-guide): Claude Code Ultimate Guide is an open-source MCP server for ai models and llm tooling.
- [Concord MCP](https://ai-powered.com/mcp/concord-mcp): Concord MCP is a freemium MCP server for developer tools.

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