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

MCPg - Production-grade PostgreSQL MCP Server

Analyze rerank NDCG

analyze_rerank_ndcg
Read-only

Compare NDCG@k for bi-encoder vs cross-encoder ordering on labeled queries and report the delta, showing whether reranking improves or harms ranking quality.

Instructions

NDCG@k under bi-encoder ordering vs cross-encoder ordering, averaged across labeled queries (ground_truth_relevance IS NOT NULL). Reports the delta (cross - bi) — positive = the rerank is adding real ranking quality, negative = it's hurting. Surfaces rerank_hurts_ndcg (CRITICAL) or rerank_lifts_ndcg (GOOD evidence). Reads from mcpg_rag.rerank_events; returns zero counts when no labeled rows exist in the window.

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

Input Schema

NameRequiredDescriptionDefault
kNo
daysNo
modelNo
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.
retrieval_indexNo

Output Schema

NameRequiredDescriptionDefault
kYes
deltaYes
modelYes
findingsYes
window_daysYes
retrieval_indexYes
labeled_query_countYes
ndcg_at_k_under_bi_orderYes
ndcg_at_k_under_cross_orderYes

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.9/5.0
Behavior5/5

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

Adds substantial behavior beyond the readOnly annotation: source table mcpg_rag.rerank_events, the labeling precondition (ground_truth_relevance IS NOT NULL), the emitted finding names with severities (rerank_hurts_ndcg CRITICAL, rerank_lifts_ndcg GOOD evidence), and the zero-count edge case when no labeled rows exist.

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?

Dense but front-loaded: metric and comparison first, delta semantics next, then findings and data-source caveats. Terminology like 'bi-encoder ordering vs cross-encoder ordering' is necessary; no filler sentences.

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?

An output schema exists, so return shape need not be spelled out, and behavioral coverage is strong. However, with five parameters and four of them undocumented anywhere, the description is not complete enough for an agent to size the window, tune `k`, or scope by `model` without guessing.

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 description coverage is only 20% (only `database` is documented). The description never explains `k`, `days`, `model`, or `retrieval_index`; only 'in the window' loosely implies `days` is a time range. An agent must guess what `k` sets and how `model` filters.

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 metric (NDCG@k), the two orderings being compared (bi-encoder vs cross-encoder), the aggregation unit (labeled queries), and the reported quantity (delta = cross - bi). This is clearly distinct from siblings like analyze_reranker_lift and analyze_rerank_score_distribution.

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?

The sign interpretation ('positive = adding real ranking quality, negative = hurting') gives result-reading guidance, but there is no explicit statement of when to choose this over analyze_reranker_lift or recommend_rerank_strategy. Usage is implied rather than directed.

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