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

MCPg - Production-grade PostgreSQL MCP Server

Read PG stat recovery

read_pg_stat_recovery
Read-only

Read PostgreSQL 19 standby recovery stats—replay LSN, lag, last replay time, and startup state—to monitor replication progress; returns empty when unavailable or not in recovery.

Instructions

Return rows from PG 19's pg_stat_recovery view — replay progress, lag, and startup state for a standby. Empty list on PG < 19, when the view isn't present, or when the server isn't in recovery (a primary running standalone returns no rows). Returns a list of objects with replay_lsn, replay_lag_seconds, last_replayed_at, and startup_state (any of which may be null when not applicable).

Example: read_pg_stat_recovery()

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "read_pg_stat_recovery"
  }
}

Input Schema

NameRequiredDescriptionDefault
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.

Output Schema

NameRequiredDescriptionDefault
resultYes

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.2/5.0
Behavior4/5

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

With readOnlyHint/openWorldHint already declaring a safe local read, the description still adds real behavioral context: version gating (PG < 19), absence-of-view handling, and the empty-list-on-primary semantics. It also warns that individual fields may be null when not applicable, which is the kind of nuance an agent needs to avoid misreading results. It stops short of stating cost or pagination behavior.

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 view and purpose, then version/empty-result caveats, then a compact call example — no wasted framing. The enumeration of returned fields partly duplicates the existing output schema, which is the only redundancy.

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

Completeness5/5

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

For a zero-required-parameter read tool with an output schema and full annotation coverage, everything needed to call it correctly and interpret an empty result is present. The database-targeting semantics live in the schema, and return values are formally described by the output schema.

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

Parameters3/5

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

Schema description coverage is 100% and the single optional `database` parameter is fully documented in the schema (targeting a configured secondary read-only database). The description adds no meaning beyond that and never mentions the parameter, so baseline 3 applies.

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

Purpose5/5

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

States a specific verb and resource ('Return rows from PG 19's pg_stat_recovery view') and immediately scopes it to 'replay progress, lag, and startup state for a standby'. That scope separates it cleanly from siblings like read_pg_wal_stats, get_wal_archive_status, or get_logical_replication_status.

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

Usage Guidelines4/5

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

The description gives clear applicability conditions: it only has meaningful content on PG 19+, when the view exists, and when the server is in recovery, so a primary returns no rows. It does not name alternative tools for adjacent questions (e.g. list_replicas for topology, get_wal_archive_status for archiving), so routing among siblings is left 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