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

MCPg - Production-grade PostgreSQL MCP Server

Recommend efficiency thresholds

recommend_efficiency_thresholds
Read-only

Computes corpus-percentile efficiency thresholds from stored observation history, filtered by time window, backend, metric, or k, and falls back to defaults when data is insufficient.

Instructions

Compute corpus-percentile thresholds from accumulated mcpg_rag.efficiency_observations history. Phase E currently adapts three thresholds: baseline_recall_low (p10 of recall_baseline), ranking_degraded_spearman (p10 of spearman), and pruning_ineffective (p10 of pages_pruned_ratio_p50). The remaining four thresholds stay at their hardcoded defaults. Filters by days window + optional backend / metric / k so callers can ask 'what's normal for HNSW+cosine+k=10 in this deployment' vs 'what's normal globally'. Falls back to defaults (with derived_from_corpus=false) when the corpus is smaller than the minimum required. Returns an object with corpus_size, derived_from_corpus (bool), and the threshold fields (baseline_recall_low, baseline_recall_low_adapted, ranking_degraded_spearman, ranking_degraded_spearman_adapted, pruning_ineffective, pruning_ineffective_adapted, rerank_lift_flat_delta, rerank_lift_steep_low, rerank_lift_steep_high, and ranking_degraded_recall).

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_efficiency_thresholds"
  }
}

Input Schema

NameRequiredDescriptionDefault
kNo
daysNo
metricNo
backendNo
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
corpus_sizeYes
baseline_recall_lowYes
derived_from_corpusYes
pruning_ineffectiveYes
rerank_lift_steep_lowYes
rerank_lift_flat_deltaYes
rerank_lift_steep_highYes
ranking_degraded_recallYes
ranking_degraded_spearmanYes
baseline_recall_low_adaptedYes
pruning_ineffective_adaptedYes
ranking_degraded_spearman_adaptedYes

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?

Annotations already declare readOnlyHint=true and openWorldHint=false, but the description adds substantial behavior: the fallback-to-defaults path is flagged via derived_from_corpus=false when the corpus is below a minimum, and it clarifies that only three of seven thresholds are actually adapted. The actual minimum corpus size is never stated, which is the one meaningful gap.

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

Conciseness3/5

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

Purpose and adaptation scope are front-loaded and earned, but the tail of the description enumerates ten return fields already covered by the existing output schema, which is redundant bulk. The heavy backtick styling and multi-clause sentences make it denser than necessary.

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 the computational model, filter scoping, degradation fallback, and adaptation scope for a moderately complex aggregating tool; return values are also spelled out despite an output schema existing. Missing only the minimum corpus-size requirement that determines the fallback.

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 20% (only database is documented in the schema), so the description must compensate, and it largely does: days is a time window, and backend/metric/k are scoping filters with a concrete example of their combined meaning. It does not explain k's semantics (top-k) or value ranges, leaving some inference.

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: compute corpus-percentile thresholds from efficiency_observations history. It names exactly which three thresholds are adapted (baseline_recall_low, ranking_degraded_spearman, pruning_ineffective) and that four remain hardcoded, which clearly separates it from sibling analysis tools like analyze_vector_search_efficiency or recommend_hnsw_ef_search.

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 an explicit usage context — slicing by days/backend/metric/k to answer 'what's normal for HNSW+cosine+k=10 in this deployment' versus globally — which tells an agent when to apply filters. It stops short of naming when NOT to call it or pointing to a specific sibling alternative.

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