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

MCPg - Production-grade PostgreSQL MCP Server

Analyze HNSW recall

analyze_hnsw_recall
Read-only

Sweeps ef_search values to measure latency and recall trade-offs for pgvector HNSW queries against exact ground truth, returning recall@k and mean/p95 latency per setting.

Instructions

Sweeps ef_search values to measure the latency and recall trade-off curve for a given pgvector query vector against exact brute-force ground truth. Requires the vector extension. Returns a list of objects with ef_search, recall_at_k, mean_latency_ms, and p95_latency_ms — one row per ef_search value tested.

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>",
      "query_vector": "<query_vector>"
    },
    "name": "analyze_hnsw_recall"
  }
}

Input Schema

NameRequiredDescriptionDefault
kNo
tableYes
columnYes
metricNol2
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.
query_vectorYes

Output Schema

NameRequiredDescriptionDefault
resultYes

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

B3.4/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, so the safety profile is covered. The description adds genuinely new behavioral context: it requires the vector extension and computes 'exact brute-force ground truth', which signals an expensive exact scan, and it states that the output is one row per ef_search value tested. It stops short of warning about runtime cost, sweep size, or row limits.

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?

Two sentences, front-loaded with the operation and its measurement, then the return contract. The field list is dense but earns its space by describing the row shape. Minor redundancy with the output schema, which already defines those columns.

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 repeating the return columns is optional rather than necessary, and annotations cover read-only safety. However, for a 7-parameter analytical tool with 14% schema coverage, the description leaves the semantics of k, metric, and the swept ef_search range unexplained, which is the main gap an agent would hit when invoking it.

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 14%, so the description must carry almost all the weight, and it does not. It never explains what k, metric, table, or column do, nor what range of ef_search values is actually swept (ef_search is not even an input parameter). Only the query vector and the extension prerequisite get any narrative support.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific action ('sweeps ef_search values') plus the measured quantity ('latency and recall trade-off curve') and the ground-truth baseline, so the agent knows exactly what the tool produces. It does not distinguish itself from nearby siblings such as vector_recall_at_k or recommend_hnsw_ef_search, leaving the agent to infer the difference from the output shape.

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 only routing guidance is the prerequisite 'Requires the vector extension', which is a condition for success rather than a when-to-use rule. There is no statement of when to prefer this sweep over vector_recall_at_k (single-k recall) or recommend_hnsw_ef_search (a recommendation), so selection among these siblings is only implied by the description's emphasis on a full curve.

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