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
- Installed CLI
- npx
- bunx
postgresai [global options] <command> [command options] [arguments...]
npx postgresai [global options] <command> [command options] [arguments...]
bunx 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
- Installed CLI
- npx
- bunx
postgresai auth
npx postgresai auth
bunx 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
- Installed CLI
- npx
- bunx
postgresai init <conn>
npx postgresai init <conn>
bunx postgresai init <conn>
Examples
- Installed CLI
- npx
- bunx
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
npx postgresai init postgresql://admin@host:5432/dbname
npx postgresai init "dbname=dbname host=host user=admin"
npx postgresai init -h host -p 5432 -U admin -d dbname
bunx postgresai init postgresql://admin@host:5432/dbname
bunx postgresai init "dbname=dbname host=host user=admin"
bunx 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
- Installed CLI
- npx
- bunx
postgresai mon <subcommand> [options]
npx postgresai mon <subcommand> [options]
bunx 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
- Installed CLI
- npx
- bunx
postgresai mon quickstart [--demo] [--api-key <key>] [--db-url <url>] [-y]
npx postgresai mon quickstart [--demo] [--api-key <key>] [--db-url <url>] [-y]
bunx postgresai mon quickstart [--demo] [--api-key <key>] [--db-url <url>] [-y]
Subcommand group: targets
Manage databases to monitor.
Usage
- Installed CLI
- npx
- bunx
postgresai mon targets <subcommand> [args]
npx postgresai mon targets <subcommand> [args]
bunx 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
- Installed CLI
- npx
- bunx
postgresai issues <subcommand> [options]
npx postgresai issues <subcommand> [options]
bunx 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
- Installed CLI
- npx
- bunx
postgresai issues list
postgresai issues view <issue_id>
postgresai issues post_comment <issue_id> "comment"
npx postgresai issues list
npx postgresai issues view <issue_id>
npx postgresai issues post_comment <issue_id> "comment"
bunx postgresai issues list
bunx postgresai issues view <issue_id>
bunx postgresai issues post_comment <issue_id> "comment"
Command: mcp
MCP server integration for AI coding tools.
Usage
- Installed CLI
- npx
- bunx
postgresai mcp <subcommand> [options]
npx postgresai mcp <subcommand> [options]
bunx 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
- Installed CLI
- npx
- bunx
postgresai add-key <key>
npx postgresai add-key <key>
bunx postgresai add-key <key>
Command: show-key
Show the currently configured API key (masked).
Usage
- Installed CLI
- npx
- bunx
postgresai show-key
npx postgresai show-key
bunx postgresai show-key
Command: remove-key
Remove the stored API key.
Usage
- Installed CLI
- npx
- bunx
postgresai remove-key
npx postgresai remove-key
bunx postgresai remove-key