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

MCPg - Production-grade PostgreSQL MCP Server

Analyze vector search efficiency

analyze_vector_search_efficiency
Read-only

Measure pgvector ANN index retrieval quality by sweeping backend-specific search parameters, computing recall@k against exact brute-force results, rank correlation, and latency percentiles to diagnose ranking degradation.

Instructions

Cross-backend retrieval-quality report for a pgvector or pg_turboquant ANN index. Detects the backend (HNSW / IVFFlat / turboquant), sweeps the matching per-backend knob (ef_search / probes / candidate_limit) across a multiplier curve, computes recall@k vs a brute-force exact baseline, Spearman + Kendall rank correlation, per-query p50/p95 wall-clock latency, and (for turboquant) the page-pruning ratio from tq_last_scan_stats. Emits findings: baseline_recall_low (CRITICAL), rerank_lift_flat / rerank_lift_steep / ranking_degraded / pruning_ineffective (WARNING). Burns sample_size x (1 + len(candidate_multipliers)) queries; ad-hoc diagnostic, not a cron tool. Requires the vector extension; turboquant-arm metrics require pg_turboquant.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "schema": "<schema>",
      "table": "<table>",
      "column": "<column>",
      "id_column": "<id_column>"
    },
    "name": "analyze_vector_search_efficiency"
  }
}

Input Schema

NameRequiredDescriptionDefault
kNo
tableYes
columnYes
metricNocosine
schemaYes
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.
id_columnYes
index_nameNo
sample_sizeNo
candidate_multipliersNo

Output Schema

NameRequiredDescriptionDefault
kYes
tableYes
columnYes
metricYes
schemaYes
backendYes
findingsYes
index_nameYes
sample_sizeYes
rerank_lift_curveYes
recall_at_k_baselineYes
pages_pruned_ratio_p50Yes
score_rank_correlation_kendallYes
score_rank_correlation_spearmanYes

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
Behavior5/5

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

Beyond the readOnlyHint/openWorldHint annotations, the description discloses scan mechanics (detects backend, sweeps the matching knob across a multiplier curve), emitted finding codes with severities, and cost — sample_size × (1 + len(candidate_multipliers)) queries burned. It also flags read scoping and extension dependencies that annotations alone do not convey.

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 well-ordered paragraph: purpose first, then method, then outputs, then cost and prerequisites. Every clause carries information, though the parenthetical enumeration of finding codes and metric lists makes it heavier than necessary for an at-a-glance read.

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?

An output schema exists, so return values need not be spelled out, yet the description still usefully summarizes finding codes and severities. For a complex diagnostic tool with read-only annotations, the main remaining gaps are parameter-level semantics and explicit sibling routing rather than missing behavioral context.

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 10% across 10 parameters, so the description must carry the load. It implicitly explains k (recall@k), sample_size (query cost), and candidate_multipliers (curve), but leaves metric (cosine/l2/ip options), id_column, index_name, schema/table/column, and database targeting unaddressed — and database semantics live only in the schema.

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 — a cross-backend retrieval-quality report for a pgvector or pg_turboquant ANN index — and immediately names the scope (HNSW / IVFFlat / turboquant) and what is computed. An agent can distinguish it from siblings like vector_recall_at_k, analyze_hnsw_recall, or recommend_hnsw_ef_search without opening a schema.

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 explicit when-not guidance ("ad-hoc diagnostic, not a cron tool") and prerequisites (vector extension required; turboquant-arm metrics require pg_turboquant). It does not name the narrower sibling tools (e.g. analyze_hnsw_recall or recommend_hnsw_ef_search) that an agent might prefer for single-backend knob tuning, so routing is only partially covered.

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