Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Wait for LSN

wait_for_lsn
Read-only

Blocks 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

NameRequiredDescriptionDefault
lsnYes
databaseNoOptional: 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_msNo

Output Schema

NameRequiredDescriptionDefault
lsnYes
wait_sqlYes
timed_outYes
timeout_msYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"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."
  2. First observedv0.6.8

TDQS

A4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Well beyond the readOnlyHint/openWorldHint annotations, it discloses that the call blocks, that timeout_ms=0 waits indefinitely, that timeouts are returned rather than raised, that the LSN is strictly validated before SQL composition, and that PG 19+ is required with a raise plus poll-loop fallback hint on older servers. That is exactly the operational context an agent needs before invoking a blocking call.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the actual SQL it issues, then semantics, then failure modes. Slightly padded by re-enumerating the return object fields (`lsn`, `timeout_ms`, `timed_out`, `wait_sql`) even though an output schema exists, plus a redundant example line.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers blocking behavior, timeout semantics, version gating, and error behavior for a mutation-adjacent blocking tool. The secondary/read-only `database` targeting is only documented in the schema, and the return-field listing duplicates the output schema, so nothing essential is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is only 33% and the two otherwise undocumented parameters — `lsn` and `timeout_ms` — are both addressed in prose: strict `hex/hex` validation for lsn and the default-0/indefinite-wait meaning plus bound behavior for timeout_ms. Only `database` is left solely to the schema, so the description largely compensates for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and mechanism — issues `WAIT FOR LSN '<lsn>' TIMEOUT <ms>` and blocks until WAL replay catches up — so the purpose is unmistakable. It does not differentiate from related siblings such as get_wait_for_lsn_status, get_current_wal_lsn, or check_pitr_readiness, which keeps it out of 5 territory.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explains the timeout decision path (returns `timed_out=true` so the caller can retry or fall through), which implies a read-your-writes / catch-up use case. But it never states when to reach for this versus the sibling status or PITR-check tools, leaving alternative selection to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools