deploy_monitoring
Put a PostgreSQL database under PostgresAI Cloud monitoring: provisions the monitoring box, prepares the role, handles IP/PrivateLink access, and returns status, links, and the next action.
Instructions
Put a Postgres database under PostgresAI Cloud monitoring (same as pgai mon deploy): prepares the monitoring role (an admin URL creates it; otherwise returns the SQL), provisions the monitoring box, and returns JSON with status (ready | in_progress | deleting | deleted | inactive | action_required | failed: the same words as pgai dblab deploy), health_url (the project's Health Matrix in the console), dashboard_url (Grafana, signing in with PostgresAI) and next (the exact next action). A billed box is provisioned only with yes: true: without it the result is action_required with the price (and requires_payment_method), so show the price to the user first. It does not wait for the box: call it again to see the status. Safe to call again. When PostgresAI can't reach the database the way an IP allowlist refuses (or with ip_first), the box's IP is reserved first and the result is action_required with step allow_ip (ip, cidr, host, port, reserved_until): give the user the cidr and port to allow on the database, then call again with ip_allowed: true. ClickHouse Managed Postgres, RDS and Supabase are detected from the host. An RDS instance that is not publicly accessible is monitored over AWS PrivateLink (no public IP, nothing opened): the user creates a CloudFormation stack in their AWS account from a link. Until the stack exists the result is action_required with step privatelink_stack and cfn_url: give the user the link to open in the RDS's AWS account (the stack keeps its name); once they say it is created, call again. When this machine's aws CLI can read the RDS (read-only; aws_profile picks the profile, no_aws: true skips it), the link is filled in and the stack is found by itself; otherwise pass vpce_service, the stack's VpceServiceName output. When the URL's user can't create the monitoring role, or this machine can't reach the database (a private RDS seen from outside its VPC), the result is action_required with step prepare_db, sql, nonce and monitoring_password: the user runs the SQL as the master user in that database, then call again with monitoring_password and nonce. host_stats: true adds host CPU, memory, disk and IOPS through a read-only role the stack creates (host_stats_role: its HostStatsRoleArn output, when not read from AWS). Aurora and RDS Proxy endpoints are not supported over PrivateLink. Supabase needs no password (PostgresAI prepares the database through the Supabase Management API): the first time, the result is action_required with a consent link in next; give it to the user to open and approve, then call again. Elsewhere the URL must carry its password, and only these query parameters: sslmode, channel_binding, application_name. PGAI_MON_PASSWORD, PGPASSWORD and CLICKHOUSE_KEY_ID + CLICKHOUSE_KEY_SECRET of the server process are not used (pass clickhouse_key), and a TLS failure is not retried in plaintext (say sslmode=disable for a server without TLS). For another database on a server PostgresAI already monitors for the org, an admin URL with sslmode=require (or verify-*), each query parameter once, is enough: PostgresAI fills in the password of postgres_ai_mon it keeps, over TLS only (on a server without TLS, pass the postgres_ai_mon URL; if nobody has its password, the user runs in a terminal: pgai mon instances delete the server's other databases, then pgai mon deploy --reset-password with PGAI_MON_PASSWORD set to a new one, then deploys them again with it).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database_url": "<database_url>"
},
"name": "deploy_monitoring"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| yes | No | Deploy: accept where the box runs and its price. Without it no box is provisioned, free or billed (on a platform without cloud choice, only a billed one waits for it): the result has status action_required with cloud, location, location_reason_text, price and choices (each cloud's locations); show them to the user, then call again with yes: true (and cloud/location if they chose another place) | |
| cloud | No | Where the monitoring box runs: aws or hetzner (default: the database's cloud, else the platform's default). One of the result's choices | |
| debug | No | Enable verbose debug logs | |
| nonce | No | RDS over PrivateLink: the nonce of that prepare_db result | |
| vcpus | No | vCPUs of the database server. Without it there is no AAS (database load) data for this database: ask the user for it | |
| coupon | No | Stripe promotion code for the organization's monitoring subscription (applies when it is first created) | |
| no_aws | No | RDS: do not use the aws CLI on this machine | |
| org_id | No | Organization ID. Optional with a per-organization token (uses the stored org); REQUIRED with a global token, which can reach every organization the user belongs to and will not assume one. Use orgs_list / `pgai orgs` to discover valid values. | |
| ip_first | No | Reserve the monitoring box's IP and stop before the box (even when PostgresAI can reach the database), so the user can allow it on the database first. The result is action_required with step allow_ip: ip, cidr, host, port, reserved_until | |
| location | No | A location of that cloud, from the result's choices (default: the database's region, else the cloud's default) | |
| provider | No | generic (direct PostgreSQL URL; alias: self-managed) | clickhouse | rds | supabase (default: detected from the host) | |
| terraform | No | RDS over PrivateLink: write the stack as a Terraform module (in the current directory) instead of the CloudFormation link | |
| host_stats | No | RDS over PrivateLink: also host CPU, memory, disk and IOPS, through a read-only role the stack creates in the user's account | |
| ip_allowed | No | The database now allows the reserved IP (a previous result's step allow_ip): create the box with it. Give the user the cidr and port to allow first, and call with ip_allowed: true only once they confirm | |
| aws_profile | No | RDS: the aws CLI profile that reads the RDS and its stack (read-only); default: the aws CLI's own (AWS_PROFILE, default, the instance role) | |
| privatelink | No | RDS: true monitors it over AWS PrivateLink (it is not publicly accessible), false directly (it is). Default: decided from AWS or public DNS; asked (action_required) when neither tells | |
| database_url | Yes | postgresql:// URL with the password in it (admin, or the postgres_ai_mon role) | |
| vpce_service | No | RDS over PrivateLink: the stack's VpceServiceName output (com.amazonaws.vpce.<region>.vpce-svc-<id>), from the user, after step privatelink_stack | |
| clickhouse_key | No | ClickHouse Cloud API key as <key-id>:<key-secret> (Basic Service API Reader), for CPU, memory and disk | |
| host_stats_role | No | RDS over PrivateLink with host_stats: the stack's HostStatsRoleArn output, when it is not read from AWS | |
| monitoring_user | No | Monitoring role to create or use (default postgres_ai_mon). A custom role always carries its own password: PostgresAI keeps only postgres_ai_mon's, so pass the role's own URL as database_url (an admin URL creates only postgres_ai_mon). Not for Supabase, where PostgresAI creates postgres_ai_mon, nor for a private RDS over AWS PrivateLink | |
| monitoring_password | No | RDS over PrivateLink: the monitoring_password of a prepare_db result whose SQL the user ran (with nonce) |