PostgresAI CLI
Reference
Install (optional)
You can run postgresai commands without installing, using npx or bunx. If you prefer to install it globally:
- npm
- Homebrew (macOS)
npm install -g postgresai
brew tap postgres-ai/tap https://gitlab.com/postgres-ai/homebrew-tap.git
brew install postgresai
Authenticate
Authenticate via browser and store the API key locally:
- Installed CLI
- npx
- bunx
postgresai auth login
npx postgresai@latest auth login
bunx postgresai@latest auth login
postgresai login is a short alias for postgresai auth login, with the same options.
In the browser, pick one organization, or All my organizations to get a
global token that works across all of them. With a global token, add
--org <alias> or --org-id <id> (or set PGAI_ORG) to organization-specific
commands, and run postgresai orgs to list the organizations it can reach. See
organization selection.
Install MCP (Cursor, Claude Code, Windsurf, Codex)
Install MCP integration for your AI coding tool:
- Installed CLI
- npx
- bunx
postgresai mcp install
npx postgresai@latest mcp install
bunx postgresai@latest mcp install
Query metrics with PromQL
Run a PromQL query on a monitoring instance's metric store:
npx postgresai@latest promql 'up' --project <project>
The platform queues the query and the instance answers on its next poll, so the first answer can
take up to about 10 minutes; follow-ups within a minute are fast. Options, prerequisites and
output: promql in the CLI reference.
Work with issues
List open issues (pass --status closed or --status all for the rest):
- Installed CLI
- npx
- bunx
postgresai issues list
npx postgresai@latest issues list
bunx postgresai@latest issues list
View a specific issue:
- Installed CLI
- npx
- bunx
postgresai issues view <issue_id>
npx postgresai@latest issues view <issue_id>
bunx postgresai@latest issues view <issue_id>
Post a comment:
- Installed CLI
- npx
- bunx
postgresai issues post-comment <issue_id> "<comment>"
npx postgresai@latest issues post-comment <issue_id> "<comment>"
bunx postgresai@latest issues post-comment <issue_id> "<comment>"