Wait for LSN
wait_for_lsnBlocks until PostgreSQL WAL replay reaches a given LSN; optional timeout returns timed_out=true instead of raising. Validates LSN format and requires PostgreSQL 19+.
Instructions
Issue WAIT FOR LSN '<lsn>' TIMEOUT <ms> and block until WAL replay catches up on the connected backend. timeout_ms defaults to 0 (wait indefinitely); a positive value bounds the wait — on timeout the helper returns timed_out=true rather than raising so the caller can decide whether to retry or fall through. LSN format is strictly validated (hex/hex) before any SQL is composed. Requires PG 19+; raises on older servers with the poll-loop fallback in the message. Returns an object with lsn, timeout_ms (int), timed_out (bool), and wait_sql (the rendered statement).
Example: wait_for_lsn(lsn='0/1234ABCD', timeout_ms=5000)
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": {
"lsn": "<lsn>"
},
"name": "wait_for_lsn"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lsn | Yes | ||
| database | No | Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected. | |
| timeout_ms | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lsn | Yes | ||
| wait_sql | Yes | ||
| timed_out | Yes | ||
| timeout_ms | Yes |