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

MCPg - Production-grade PostgreSQL MCP Server

Recommend Redis cache targets

recommend_redis_cache_targets
Read-only

Analyze pg_stat_user_tables to identify read-heavy, low-write PostgreSQL tables suited for Redis caching, returning candidate tables with metrics and a ready-to-run CREATE FOREIGN TABLE stub.

Instructions

Recommend tables that would benefit from a Redis cache layer. Inspects pg_stat_user_tables for read-heavy, low-write relations whose working set fits comfortably in Redis (default: read/write ratio ≥ 10, ≥ 1000 reads, ≤ 1M rows). When server is provided the generated ready_to_run_sql stub targets that server name; otherwise the stub uses a placeholder operators must substitute. Advisor is read-only — never touches Redis itself. Returns an object with server and candidates — a list of objects with schema, table, reads, writes, read_write_ratio, estimated_row_count, reason (read_only_lookup_table / small_hot_relation / read_heavy_low_write / moderate_read_dominant), and ready_to_run_sql (a CREATE FOREIGN TABLE stub).

Example: recommend_redis_cache_targets(server='redis_primary', 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_redis_cache_targets"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
serverNo
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.
max_rowsNo
min_reads_per_dayNo
min_read_write_ratioNo

Output Schema

NameRequiredDescriptionDefault
serverYes
candidatesYes

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

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description reinforces this with 'Advisor is read-only — never touches Redis itself', so there is no contradiction. It goes further by disclosing the data source (pg_stat_user_tables), the default thresholds, and the important operational caveat that the returned SQL stub uses a placeholder unless `server` is supplied.

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 purpose and criteria, then the server caveat, then return shape, then a concrete example — a sensible order. The long enumeration of every candidate field and reason enum is partly wasted since an output schema exists, which is the main thing keeping this from a 5.

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?

Six optional parameters, an output schema, and annotations are all in place, and the description covers the ranking criteria, the stub-generation caveat, and the return shape adequately. The remaining hole is `limit` — nothing anywhere tells an agent what it caps or how results are ordered before truncation.

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 only 17% (only `database` is documented), so the description must compensate, and it partly does: it explains `server`'s effect on the generated stub and gives human-readable meaning for the three threshold parameters (ratio ≥ 10, ≥ 1000 reads, ≤ 1M rows). However, `limit` is never explained anywhere, and the thresholds are stated as fixed defaults rather than as tunable knobs, leaving real gaps.

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 tables that would benefit from a Redis cache layer') and immediately narrows the target population with concrete criteria (read-heavy, low-write, working set fits in Redis). This distinguishes it clearly from near-siblings like recommend_prewarm_targets, recommend_indexes, and list_redis_foreign_servers.

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?

Gives a clear condition for use — relations that are read-heavy with a low write volume and a small working set — plus the effect of supplying versus omitting `server`. It does not explicitly name an alternative tool (e.g. recommend_indexes for query-level tuning) or state when *not* to use this advisor, so it falls short of full when/when-not 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