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

MCPg - Production-grade PostgreSQL MCP Server

Recommend prewarm targets

recommend_prewarm_targets
Read-only

Recommends PostgreSQL relations whose first-query latency would benefit from pg_prewarm by analyzing cold-miss rates and seq_scan dominance, capped to a shared_buffers budget.

Instructions

Recommend relations whose first-query latency would benefit from pg_prewarm. Inspects pg_stat_user_tables + pg_statio_user_tables to find high cold-miss-rate / seq_scan-dominant relations, and caps the cumulative cost at shared_buffers_budget_pct * shared_buffers so the recommendation never silently exceeds shared_buffers. The advisor is read-only — never invokes pg_prewarm itself. Returns an object with shared_buffers_blocks (configured shared_buffers in 8 KiB pages), budget_blocks (the cap), total_cost_blocks (sum of recommendations actually returned), and candidates — a list of objects with schema, relation, reason (seq_scan_dominant / high_cold_miss_rate / small_hot_relation_uncached / index_in_critical_path), prewarm_mode, estimated_buffer_cost, heap_blks_read, heap_blks_hit, cache_miss_ratio, and ready_to_run_sql.

Example: recommend_prewarm_targets(shared_buffers_budget_pct=60.0, limit=10)

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": "recommend_prewarm_targets"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
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.
prewarm_modeNobuffer
min_heap_blks_readNo
shared_buffers_budget_pctNo

Output Schema

NameRequiredDescriptionDefault
candidatesYes
budget_blocksYes
total_cost_blocksYes
shared_buffers_blocksYes

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

A3.7/5.0
Behavior4/5

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

Annotations already cover the read-only and closed-world profile, yet the description adds real value: it names the source tables inspected, the detection heuristics (seq_scan-dominant, high cold-miss-rate), and the key side-effect-free guarantee that the budget cap prevents recommendations from exceeding shared_buffers. It does not discuss cost of the scan itself or ordering guarantees of candidates, which keeps it short of a 5.

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?

One dense but front-loaded paragraph: purpose first, then methodology, then the return contract, then a usage example. The long enumeration of return fields is slightly redundant given an output schema exists, but every sentence otherwise earns its place.

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

Completeness3/5

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

The methodology and budget semantics are well covered and the output schema relieves the description of explaining return values. The gap is parameter behavior: three of five inputs, including the mode selector and the threshold that drives candidate selection, are undocumented anywhere, which is material for a tuning advisory tool.

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

Parameters2/5

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

Schema coverage is only 20%, so the description carries most of the burden, but it only explains shared_buffers_budget_pct (via the cap formula) and limit (via the example). prewarm_mode (default 'buffer'), min_heap_blks_read, and the units/meaning of limit are left entirely undefined; only database is covered, and that is by the schema, not the description.

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 ('Recommend relations whose first-query latency would benefit from pg_prewarm') and grounds it in concrete catalog tables. An agent can distinguish this advisory tool from siblings like list_prewarmed_relations or get_prewarm_extension_status without opening any schema.

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?

Usage is implied via 'The advisor is read-only — never invokes pg_prewarm itself', which tells the agent this is a recommendation step and not an execution step. However, it never states when to prefer this over list_prewarmed_relations or get_prewarm_extension_status, nor any prerequisite such as having the extension installed, so the agent must infer the routing.

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