# Pg Checkup

> Pg Checkup is an open-source MCP server for databases. Read-only PostgreSQL health checks for AI assistants, with prioritized fixes and SQL. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, API, Self-hosted
- **Repository:** https://github.com/pgcheckup/pg-checkup/tree/HEAD/mcp
- **MCP Registry name:** io.github.pgcheckup/pg-checkup
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-11-28

## About

Connects to a PostgreSQL database using a statistics-only login and returns a prioritized list of problems, grouped into fix now, fix next and watch. Findings cover bloat, missing or unused indexes, slow queries, blocked transactions, sequences nearing their limit and several row-level security issues. When one problem causes another, the root cause is listed first.

The server runs its queries in a read-only session with a 15-second timeout per query and reads only statistics views and the catalog, never table rows. The connection string is read from the environment rather than passed through the chat, and every query it runs can be printed for review.

It suits developers and database administrators who want an AI assistant to triage a database before or after a migration, or to compare checkups over time. It can also be run from the command line or on a schedule in GitHub Actions.

## Features

- **Prioritized findings:** Problems are sorted into fix now, fix next and watch groups, with causes listed before their effects.
- **Read-only sessions:** Queries run in a read-only session with a per-query timeout and never read table rows.
- **Index analysis:** Flags missing, invalid, unused and duplicate indexes along with slow and sequential scans.
- **Row-level security review:** Finds tables without row-level security, overlapping policies and SECURITY DEFINER functions missing a search_path.
- **Migration baseline and verify:** Saves schema, grants and policies before a migration and reports what changed afterward.
- **Visible query log:** Prints every SQL statement the tool executes so the activity can be reviewed.

## Good for

- Triage a production PostgreSQL database for bloat, slow queries and blocked transactions
- Ask an AI assistant which database fixes to apply first and get the SQL for each
- Compare checkups over time to confirm fixes and catch new regressions
- Check schema, grants and policies before and after a database migration
- Run scheduled database health checks in GitHub Actions with failure thresholds

## Install

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

```sh
claude mcp add pg-checkup --env DATABASE_URL='<DATABASE_URL>' -- npx -y pg-checkup-mcp
```

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": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "pg-checkup": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<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 pg-checkup --env DATABASE_URL='<DATABASE_URL>' -- npx -y pg-checkup-mcp
```

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

```toml
[mcp_servers.pg-checkup]
command = "npx"
args = ["-y", "pg-checkup-mcp"]
env = { DATABASE_URL = "<DATABASE_URL>" }
```

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

```json
{
  "mcpServers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e DATABASE_URL='<DATABASE_URL>' pg-checkup npx -- -y pg-checkup-mcp

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

```json
{
  "mcpServers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<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": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

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

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<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": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<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": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

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

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

```json
{
  "mcpServers": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<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": {
    "pg-checkup": {
      "command": "npx",
      "args": [
        "-y",
        "pg-checkup-mcp"
      ],
      "env": {
        "DATABASE_URL": "<DATABASE_URL>"
      }
    }
  }
}
```

## FAQ

### What access does Pg Checkup need on the database?

It works with a login that holds the pg_monitor role, which only allows reading statistics. The server prints the SQL needed to create such a login.

### Can Pg Checkup modify my database?

No. The session is read-only, and the tool does not read table rows or make network calls other than to the database.

### Which PostgreSQL versions are supported?

The CLI requires Node 18 or newer and PostgreSQL 12 or newer.

### How is the database connection string provided?

It is read from the DATABASE_URL environment variable and is not sent through the chat.

### Is Pg Checkup free?

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

### How do I add Pg Checkup to Claude Code?

Run this command in your terminal: claude mcp add pg-checkup --env DATABASE_URL='<DATABASE_URL>' -- npx -y pg-checkup-mcp

### What are the best alternatives to Pg Checkup?

The closest alternatives to Pg Checkup are PostgreSQL Performance (read-only), PostgreSQL (hardened, read-only), Postgres Scout MCP, PostgreSQL performance Tuner MCP Server and MCP Database Doctor.

## Where this comes from

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

## Alternatives

- [PostgreSQL Performance (read-only)](https://ai-powered.com/mcp/postgresql-performance-read-only): PostgreSQL Performance (read-only) is an open-source MCP server for databases.
- [PostgreSQL (hardened, read-only)](https://ai-powered.com/mcp/postgresql-hardened-read-only): PostgreSQL (hardened, read-only) is an open-source MCP server for databases.
- [Postgres Scout MCP](https://ai-powered.com/mcp/postgres-scout-mcp): Postgres Scout MCP is an open-source MCP server for databases.
- [PostgreSQL performance Tuner MCP Server](https://ai-powered.com/mcp/postgresql-performance-tuner-mcp-server): PostgreSQL performance Tuner MCP Server is an open-source MCP server for databases.
- [MCP Database Doctor](https://ai-powered.com/mcp/mcp-database-doctor): MCP Database Doctor is an open-source MCP server for databases.
- [SQL Server DBA (read-only)](https://ai-powered.com/mcp/sql-server-dba-read-only): SQL Server DBA (read-only) is an open-source MCP server for databases.
- [Postgres AIops](https://ai-powered.com/mcp/postgres-aiops): Postgres AIops is an open-source MCP server for databases.
- [PostgreSQL MCP by InsightfulPipe](https://ai-powered.com/mcp/postgresql-mcp-by-insightfulpipe): PostgreSQL MCP by InsightfulPipe is an MCP server for databases.

---
Source: https://ai-powered.com/mcp/pg-checkup
