
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
postgresai
Advanced tools
Command-line interface for PostgresAI monitoring and database management.
npm install -g postgresai
Or install the latest beta release explicitly:
npm install -g postgresai@beta
Note: in this repository, cli/package.json uses a placeholder version (0.0.0-dev.0). The real published version is set by the git tag in CI when publishing to npm.
# Add the PostgresAI tap
brew tap postgres-ai/tap https://gitlab.com/postgres-ai/homebrew-tap.git
# Install postgresai
brew install postgresai
The postgresai package provides two command aliases:
postgresai --help # Canonical, discoverable
pgai --help # Short and convenient
You can also run it without installing via npx:
npx postgresai --help
pgaiIf you want npx pgai ... as a shorthand for npx postgresai ..., install the separate pgai wrapper package:
npx pgai --help
This command creates (or updates) the postgres_ai_mon user, creates the required view(s), and grants the permissions described in the root README.md (it is idempotent). Where supported, it also enables observability extensions described there.
Run without installing (positional connection string):
npx postgresai prepare-db postgresql://admin@host:5432/dbname
It also accepts libpq "conninfo" syntax:
npx postgresai prepare-db "dbname=dbname host=host user=admin"
And psql-like options:
npx postgresai prepare-db -h host -p 5432 -U admin -d dbname
Password input options (in priority order):
--password <password>PGAI_MON_PASSWORD environment variableBy default, the generated password is printed only in interactive (TTY) mode. In non-interactive mode, you must either provide the password explicitly, or opt-in to printing it:
--print-password (dangerous in CI logs)Optional permissions (RDS/self-managed extras from the root README.md) are enabled by default. To skip them:
npx postgresai prepare-db postgresql://admin@host:5432/dbname --skip-optional-permissions
To see what SQL would be executed (passwords redacted by default):
npx postgresai prepare-db postgresql://admin@host:5432/dbname --print-sql
For Supabase projects, you can use the Management API instead of direct PostgreSQL connections. This is useful when direct database access is restricted.
# Using environment variables
export SUPABASE_ACCESS_TOKEN='your_management_api_token'
export SUPABASE_PROJECT_REF='your_project_ref'
npx postgresai prepare-db --supabase
# Using command-line options
npx postgresai prepare-db --supabase \
--supabase-access-token 'your_token' \
--supabase-project-ref 'your_project_ref'
# Auto-detect project ref from a Supabase database URL
npx postgresai prepare-db postgresql://postgres:password@db.abc123.supabase.co:5432/postgres \
--supabase --supabase-access-token 'your_token'
The Supabase access token can be created at https://supabase.com/dashboard/account/tokens.
Options:
--supabase - Enable Supabase Management API mode--supabase-access-token <token> - Supabase Management API access token (or use SUPABASE_ACCESS_TOKEN env var)--supabase-project-ref <ref> - Supabase project reference (or use SUPABASE_PROJECT_REF env var)Notes:
--verify, --print-sql, --skip-optional-permissions, etc.)--verify, the tool checks if all required setup is in placeVerify that everything is configured as expected (no changes):
npx postgresai prepare-db postgresql://admin@host:5432/dbname --verify
Reset monitoring user password only (no other changes):
npx postgresai prepare-db postgresql://admin@host:5432/dbname --reset-password --password 'new_password'
Authenticate via browser to obtain API key:
postgresai auth
This will:
~/.config/postgresai/config.jsonStart monitoring with demo database:
postgresai mon local-install --demo
Start monitoring with your own database:
postgresai mon local-install --db-url postgresql://user:pass@host:5432/db
Complete automated setup with API key and database:
postgresai mon local-install --api-key your_key --db-url postgresql://user:pass@host:5432/db -y
This will:
mon group)# Complete setup with various options
postgresai mon local-install # Interactive setup for production
postgresai mon local-install --demo # Demo mode with sample database
postgresai mon local-install --api-key <key> # Setup with API key
postgresai mon local-install --db-url <url> # Setup with database URL
postgresai mon local-install --api-key <key> --db-url <url> # Complete automated setup
postgresai mon local-install -y # Auto-accept all defaults
# Service management
postgresai mon start # Start monitoring services
postgresai mon stop # Stop monitoring services
postgresai mon restart [service] # Restart all or specific monitoring service
postgresai mon status # Show monitoring services status
postgresai mon health [--wait <sec>] # Check monitoring services health
--demo - Demo mode with sample database (testing only, cannot use with --api-key)--api-key <key> - Postgres AI API key for automated report uploads--db-url <url> - PostgreSQL connection URL to monitor (format: postgresql://user:pass@host:port/db)-y, --yes - Accept all defaults and skip interactive promptsmon targets subgroup)postgresai mon targets list # List databases to monitor
postgresai mon targets add <conn-string> <name> # Add database to monitor
postgresai mon targets remove <name> # Remove monitoring target
postgresai mon targets test <name> # Test target connectivity
postgresai mon config # Show monitoring configuration
postgresai mon update-config # Apply configuration changes
postgresai mon update # Update monitoring stack
postgresai mon reset [service] # Reset service data
postgresai mon clean # Cleanup artifacts
postgresai mon check # System readiness check
postgresai mon shell <service> # Open shell to monitoring service
mcp group)postgresai mcp start # Start MCP stdio server exposing tools
Cursor configuration example (Settings → MCP):
{
"mcpServers": {
"PostgresAI": {
"command": "postgresai",
"args": ["mcp", "start"],
"env": {
"PGAI_API_BASE_URL": "https://postgres.ai/api/general/"
}
}
}
}
Tools exposed:
postgresai issues list.issues group)postgresai issues list # List issues (shows: id, title, status, created_at)
postgresai issues view <issueId> # View issue details and comments
postgresai issues post_comment <issueId> <content> # Post a comment to an issue
# Options:
# --parent <uuid> Parent comment ID (for replies)
# --debug Enable debug output
# --json Output raw JSON (overrides default YAML)
By default, issues commands print human-friendly YAML when writing to a terminal. For scripting, you can:
--json to force JSON output:postgresai issues list --json | jq '.[] | {id, title}'
postgresai issues view <issueId> > issue.json
postgresai mon generate-grafana-password # Generate new Grafana password
postgresai mon show-grafana-credentials # Show Grafana credentials
postgresai auth # Authenticate via browser (OAuth)
postgresai auth --set-key <key> # Store API key directly
postgresai show-key # Show stored key (masked)
postgresai remove-key # Remove stored key
The CLI stores configuration in ~/.config/postgresai/config.json including:
API key resolution order:
--api-key)PGAI_API_KEY)~/.config/postgresai/config.json).pgwatch-config)Base URL resolution order:
apiBaseUrl):
--api-base-url)PGAI_API_BASE_URL)baseUrl (~/.config/postgresai/config.json)https://postgres.ai/api/general/uiBaseUrl):
--ui-base-url)PGAI_UI_BASE_URL)https://console.postgres.aiNormalization:
/ is removed to ensure consistent path joining.PGAI_API_KEY - API key for PostgresAI servicesPGAI_API_BASE_URL - API endpoint for backend RPC (default: https://postgres.ai/api/general/)PGAI_UI_BASE_URL - UI endpoint for browser routes (default: https://console.postgres.ai)--api-base-url <url> - overrides PGAI_API_BASE_URL--ui-base-url <url> - overrides PGAI_UI_BASE_URLFor production (uses default URLs):
# Production auth - uses console.postgres.ai by default
postgresai auth --debug
For staging/development environments:
# Linux/macOS (bash/zsh)
export PGAI_API_BASE_URL=https://v2.postgres.ai/api/general/
export PGAI_UI_BASE_URL=https://console-dev.postgres.ai
postgresai auth --debug
# Windows PowerShell
$env:PGAI_API_BASE_URL = "https://v2.postgres.ai/api/general/"
$env:PGAI_UI_BASE_URL = "https://console-dev.postgres.ai"
postgresai auth --debug
Via CLI options (overrides env):
postgresai auth --debug \
--api-base-url https://v2.postgres.ai/api/general/ \
--ui-base-url https://console-dev.postgres.ai
Notes:
PGAI_UI_BASE_URL is not set, the default is https://console.postgres.ai.The CLI uses Bun as the test runner with built-in coverage reporting.
# Run tests with coverage (default)
bun run test
# Run tests without coverage (faster iteration during development)
bun run test:fast
# Run tests with coverage and show report location
bun run test:coverage
Coverage configuration is in bunfig.toml. Reports are generated in coverage/ directory:
coverage/lcov-report/index.html - HTML coverage reportcoverage/lcov.info - LCOV format for CI integrationFAQs
postgres_ai CLI
The npm package postgresai receives a total of 36 weekly downloads. As such, postgresai popularity was classified as not popular.
We found that postgresai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.