| list_activityA | [READ] Current sessions (pg_stat_activity) with per-state counts. Flags idle-in-transaction backends (open transactions holding resources).
Args:
state: Optional exact state filter (active, idle, 'idle in transaction').
include_idle: Include plain idle backends (default True).
target: Target name from config; omit for the default.
|
| long_running_queriesB | [READ] Active queries running at least min_seconds, oldest first. Args:
min_seconds: Minimum age in seconds (default 60).
target: Target name from config; omit for the default.
|
| list_locksA | [READ] Held/awaited locks joined to their owning backend and object. Args:
target: Target name from config; omit for the default.
|
| slow_query_rcaA | [READ] RCA for the worst pg_stat_statements entry, with cause + action. Picks the statement with the greatest total execution time and maps its
numbers (mean time, cache-hit ratio, temp spill, calls) — plus an optional
EXPLAIN plan — to cited causes and concrete actions. Pass 'statements' for
pure/offline analysis, or omit to pull the top statements live.
Args:
statements: Injected pg_stat_statements rows (as from top_queries); if
omitted, the worst statements are pulled live.
explain_sql: Optional SQL to EXPLAIN so plan node types feed the RCA.
limit: How many statements to pull when not injected (default 20).
target: Target name from config; omit for the default.
|
| bloat_and_vacuum_analysisA | [READ] Rank tables needing vacuum from dead-tuple ratio + autovacuum recency. Pass 'tables' (as from table_bloat) for pure/offline analysis, or omit to
pull the worst dead-tuple tables live. Each recommendation cites its numbers.
Args:
tables: Injected table-bloat rows; if omitted, pulled live.
limit: How many tables to pull when not injected (default 50).
target: Target name from config; omit for the default.
|
| blocking_lock_chain_rcaA | [READ] Build the wait-for tree from blocking pairs and name the root blocker. Pass 'pairs' (as from the live blocking-pairs read) for pure/offline analysis,
or omit to pull the current blocking graph live.
Args:
pairs: Injected blocking pairs {blockedPid, blockingPid, ...}; if omitted,
pulled live from pg_blocking_pids.
target: Target name from config; omit for the default.
|
| unused_indexesA | [READ] Non-unique, non-primary indexes with zero scans (drop candidates). Args:
min_size_bytes: Only report indexes at least this large (default 0).
target: Target name from config; omit for the default.
|
| missing_index_hintsA | [READ] Tables with heavy sequential scans and few index scans (index hints). Args:
min_seq_scan: Minimum cumulative sequential scans to flag (default 1000).
min_live_tup: Minimum live tuples for a table to qualify (default 10000).
target: Target name from config; omit for the default.
|
| index_bloatA | [READ] Coarse index-bloat estimate (all inputs returned for transparency). Args:
limit: Number of indexes to inspect, largest first (default 50).
target: Target name from config; omit for the default.
|
| invalid_indexesA | [READ] Invalid indexes (failed CONCURRENTLY builds) and duplicate indexes. Args:
target: Target name from config; omit for the default.
|
| top_queriesA | [READ] Top statements from pg_stat_statements by a whitelisted metric. Args:
order_by: One of total_time, mean_time, calls, rows, io.
limit: Number of statements to return (1..200, default 20).
target: Target name from config; omit for the default.
|
| explain_queryA | [READ] Return the JSON execution plan for sql (EXPLAIN). analyze=False (default) plans without executing; analyze=True runs the
statement to collect real timing — only use it for read-only SQL.
Args:
sql: A single SQL statement to EXPLAIN.
analyze: If True, execute the statement to gather real row counts/timing.
target: Target name from config; omit for the default.
|
| reset_query_statsA | [WRITE][risk=medium] Reset pg_stat_statements accumulators (irreversible). The counters cannot be restored, so no undo is recorded. Pass dry_run=True
to preview.
Args:
dry_run: If True, preview without resetting.
target: Target name from config; omit for the default.
|
| terminate_backendA | [WRITE][risk=high] Terminate a backend (pg_terminate_backend). No safe inverse. Captures the backend's pid + query for the audit trail; a terminate cannot be
undone, so no undo is offered. Pass dry_run=True to preview.
Refuses this tool's own backend pid — including under dry_run, which must
report a refusal rather than preview a call that will be refused.
Args:
pid: Backend process id (from list_activity).
dry_run: If True, preview without terminating.
target: Target name from config; omit for the default.
|
| cancel_queryA | [WRITE][risk=high] Cancel a backend's running query (pg_cancel_backend). No inverse. Captures the backend's pid + query for audit; a cancel has no undo. Pass
dry_run=True to preview.
Refuses this tool's own backend pid — the query it would cancel is this very
call. Enforced under dry_run too.
Args:
pid: Backend process id (from list_activity).
dry_run: If True, preview without cancelling.
target: Target name from config; omit for the default.
|
| run_vacuumA | [WRITE][risk=medium] VACUUM a table (optionally FULL/ANALYZE). Records prior stats. No undo (a vacuum has no inverse); the prior dead-tuple/last-vacuum stats are
captured for the audit trail. VACUUM FULL takes an exclusive lock. Pass
dry_run=True to preview.
Args:
table: Table name (optionally schema-qualified, e.g. public.orders).
full: Run VACUUM FULL (rewrites the table, exclusive lock).
analyze: Also refresh planner statistics (VACUUM ANALYZE).
dry_run: If True, preview without running.
target: Target name from config; omit for the default.
|
| run_analyzeA | [WRITE][risk=medium] ANALYZE a table to refresh planner statistics. No undo; captures prior stats for audit. Pass dry_run=True to preview.
Args:
table: Table name (optionally schema-qualified).
dry_run: If True, preview without running.
target: Target name from config; omit for the default.
|
| create_indexA | [WRITE][risk=medium] Create an index. Reversible: undo drops the created name. Supports CONCURRENTLY (non-blocking build). The created name is returned so
the harness records an undo that drops exactly this index. Pass dry_run=True
to preview. Alternatively pass ``definition`` (a captured pg_get_indexdef
statement — this is how drop_index's undo descriptor replays) INSTEAD of
table/columns.
Args:
table: Table to index (optionally schema-qualified). Required unless
``definition`` is given.
columns: Column names to index. Required unless ``definition`` is given.
name: Index name (auto-generated from table+columns when omitted).
unique: Create a UNIQUE index.
concurrently: Build with CONCURRENTLY (no table lock).
method: Index method — btree/hash/gist/gin/brin/spgist (default btree).
definition: A full CREATE [UNIQUE] INDEX statement to execute verbatim
(shape-validated). Mutually exclusive with table/columns.
dry_run: If True, preview without creating.
target: Target name from config; omit for the default.
|
| drop_indexA | [WRITE][risk=high] Drop an index. Reversible: captures pg_get_indexdef first. Before dropping, the exact index definition is captured so the harness records
an undo that recreates it. Pass dry_run=True to preview.
Args:
name: Index name (optionally schema-qualified).
concurrently: Drop with CONCURRENTLY (no table lock).
dry_run: If True, preview without dropping.
target: Target name from config; omit for the default.
|
| reindexA | [WRITE][risk=medium] REINDEX an index/table/schema (rebuild in place, no undo). Rebuilds physical index storage; there is no inverse. Pass dry_run=True to
preview.
Args:
target_name: The index/table/schema name to reindex.
kind: INDEX, TABLE, or SCHEMA (default INDEX).
concurrently: Rebuild with CONCURRENTLY.
dry_run: If True, preview without rebuilding.
target: Target name from config; omit for the default.
|
| update_settingA | [WRITE][risk=medium] ALTER SYSTEM SET (or RESET) a parameter. Reversible. Writes postgresql.auto.conf; most parameters need SELECT pg_reload_conf() (or
a restart for postmaster-context settings) to take effect — reported but NOT
performed automatically. The prior state is captured so the harness records
an undo. Pass dry_run=True to preview.
reset=True issues ALTER SYSTEM RESET, dropping the parameter's auto.conf
entry so postgresql.conf or the built-in default applies again. That is the
recorded inverse when the parameter had no auto.conf entry to begin with:
writing the prior value back would leave a pin that shadows postgresql.conf.
Refuses the connection-affecting postmaster settings (listen_addresses,
port, max_connections, superuser_reserved_connections, ssl, hba_file):
nothing breaks now, but the operator's next restart applies them and strands
the undo. Enforced under dry_run too.
Args:
name: The configuration parameter name (e.g. work_mem).
value: The new value (as a string). Omit when reset=True.
reset: If True, ALTER SYSTEM RESET the parameter instead of setting it.
dry_run: If True, preview without changing.
target: Target name from config; omit for the default.
|
| replication_statusA | [READ] Connected standbys and their replay lag (pg_stat_replication). Args:
target: Target name from config; omit for the default.
|
| replication_slotsB | [READ] Replication slots, flagging inactive slots that retain WAL. Args:
target: Target name from config; omit for the default.
|
| wal_statusA | [READ] WAL position, level, size settings and archiver health. Args:
target: Target name from config; omit for the default.
|
| overviewA | [READ] One-shot cluster health snapshot. Version + uptime, connections by state, idle-in-transaction count, the
longest-running query, the worst dead-tuple table, and standby replay lag —
each section captured defensively so one failing probe does not sink the rest.
Args:
target: Target name from config; omit for the default.
|
| server_versionA | [READ] Server version, uptime, recovery state, and data directory. Args:
target: Target name from config; omit for the default.
|
| show_settingsA | [READ] Configuration parameters from pg_settings. Args:
pattern: Optional case-insensitive substring to filter setting names
(e.g. 'work_mem', 'autovacuum').
target: Target name from config; omit for the default.
|
| list_extensionsA | [READ] Installed extensions and whether a newer version is available. Args:
target: Target name from config; omit for the default.
|
| list_databasesA | [READ] Databases with owner, encoding and on-disk size (largest first). Args:
target: Target name from config; omit for the default.
|
| list_rolesB | [READ] Roles and their attributes (superuser/login/replication/…). Args:
target: Target name from config; omit for the default.
|
| table_sizesA | [READ] Largest tables by total relation size (table + indexes + TOAST). Args:
limit: Number of tables to return, largest first (default 20).
target: Target name from config; omit for the default.
|
| table_bloatA | [READ] Dead-tuple bloat proxy per table (dead / (live + dead)), worst first. Args:
limit: Number of tables to inspect (default 50).
target: Target name from config; omit for the default.
|
| autovacuum_statusA | [READ] Per-table dead tuples, mods-since-analyze, and last (auto)vacuum times. Args:
limit: Number of tables to inspect (default 50).
target: Target name from config; omit for the default.
|
| undo_listA | [READ] List recorded, not-yet-applied undo tokens (most recent first). Each entry names the original tool, the inverse tool that ``undo_apply``
would run, and a human note. Use the ``undoId`` with ``undo_apply``.
Each entry carries ``effectVerified``. False means the original write
lost its response, so the change it reverses is PROBABLE, not confirmed —
check the live state before applying, and do not report the result as a
restore of a state that may never have been reached.
Args:
limit: Max rows to return (default 50).
target: Unused (undo state is host-local); accepted for CLI uniformity.
|
| undo_applyA | [WRITE][risk=medium] Apply a recorded undo by dispatching its inverse tool. The inverse runs through its own governed tool, so its risk tier and audit
row are recorded there. Pass dry_run=True to preview the inverse call
without executing it. A token can only be applied once.
Args:
undo_id: The undoId from undo_list (or an ``_undo_id`` in a write result).
dry_run: If True, preview the inverse tool + params without running it.
target: Passed through to the inverse tool when it accepts a target.
|