Skip to main content

PostgresAI CLI reference

Description

PostgresAI Command Line Interface (postgresai) is a tool for working with postgres_ai monitoring, including authentication, MCP integration, and issue management.

Getting started

To install and authenticate, see PostgresAI CLI.

Synopsis

postgresai [global options] <command> [command options] [arguments...]

Run postgresai --help to list available commands and global options. For command-specific help, run postgresai <command> --help.

Command overview

COMMANDS:
auth authenticate via browser and store API key locally
init create a monitoring role, required view(s), and grant permissions
mon manage monitoring services
issues manage issue reports in PostgresAI Console
mcp MCP server integration for AI coding tools
add-key store API key locally
show-key show the current API key (masked)
remove-key remove the stored API key

Command: auth

Authenticate via browser and store the API key locally.

Usage

postgresai auth

Notes

  • Configuration is stored in ~/.config/postgresai/config.json.

Command: init

Create or update the monitoring role, required view(s), and grant required permissions (idempotent).

Usage

postgresai init <conn>

Examples

postgresai init postgresql://admin@host:5432/dbname
postgresai init "dbname=dbname host=host user=admin"
postgresai init -h host -p 5432 -U admin -d dbname

Common options

  • --verify: verify that monitoring role/permissions are in place (no changes).
  • --reset-password: reset monitoring role password only.
  • --print-sql: print SQL plan and exit (no changes applied).
  • --skip-optional-permissions: skip optional permissions (managed and self-managed extras).

Command: mon

Manage monitoring services.

Usage

postgresai mon <subcommand> [options]

Subcommands

  • quickstart: complete setup (generate config and start services).
  • start: start monitoring services.
  • stop: stop monitoring services.
  • restart [service]: restart all services or a specific service.
  • status: show services status.
  • health: check that services are up and healthy.
  • targets: manage databases to monitor.
  • logs [service]: show logs for all or a specific service.
  • config: show monitoring configuration.
  • update-config: apply configuration changes (generate sources).
  • update: update monitoring stack.
  • reset [service]: reset all or a specific service data.
  • clean: cleanup artifacts.
  • check: system readiness check.
  • shell <service>: open a shell in a monitoring service container.
  • generate-grafana-password: generate a new Grafana password.
  • show-grafana-credentials: show Grafana credentials.

Subcommand: quickstart

Complete setup (generate config and start monitoring services).

Usage

postgresai mon quickstart [--demo] [--api-key <key>] [--db-url <url>] [-y]

Subcommand group: targets

Manage databases to monitor.

Usage

postgresai mon targets <subcommand> [args]

Subcommands

  • list: list configured monitoring targets.
  • add <conn-string> [name]: add a Postgres instance to monitor.
  • remove <name>: remove a monitoring target.
  • test <name>: test connectivity to a configured target.

Command: issues

Manage issue reports in PostgresAI Console.

Usage

postgresai issues <subcommand> [options]

Subcommands

  • list: list issues.
  • view <issue_id>: view issue details (and comments).
  • post_comment <issue_id> <content>: post a comment to an issue.

Examples

postgresai issues list
postgresai issues view <issue_id>
postgresai issues post_comment <issue_id> "comment"

Command: mcp

MCP server integration for AI coding tools.

Usage

postgresai mcp <subcommand> [options]

Subcommands

  • start: start the MCP server in stdio mode.
  • install [client]: install MCP client configuration for a supported tool.

Command: add-key

Store an API key locally.

Usage

postgresai add-key <key>

Command: show-key

Show the currently configured API key (masked).

Usage

postgresai show-key

Command: remove-key

Remove the stored API key.

Usage

postgresai remove-key