Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Recommend HNSW ef search

recommend_hnsw_ef_search
Read-only

Recommends the smallest ef_search value that achieves a target recall@k for an HNSW index, by sampling queries, building exact ground truth, and sweeping ef values.

Instructions

Recommend an hnsw.ef_search value for a target recall@k — the actionable companion to analyze_hnsw_recall. Samples sample_queries rows (default 10) as query vectors, builds an exact brute-force top-k ground truth per query, sweeps ef_values (default 16/32/64/128/256) measuring mean recall@k and p50/p95 latency at each, and recommends the smallest value clearing target_recall (default 0.95). Unlike the single-query curve tool, this VERIFIES an HNSW index actually exists on the column (returns has_hnsw_index=false with guidance otherwise — a sweep without one just measures sequential scans). The query row is excluded from its own results. Requires the vector extension. Returns an object with available, has_hnsw_index, index_name, metric, k, target_recall, sample_queries, recommended_ef_search (int or null), detail, and sweep (list of objects with ef_search, mean_recall_at_k, p50_latency_ms, p95_latency_ms, meets_target).

Example: recommend_hnsw_ef_search(schema='public', table='docs', column='embedding', k=10, target_recall=0.95)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNo
tableYes
columnYes
metricNol2
schemaYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.
target_recallNo
sample_queriesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
kYes
sweepYes
detailNo
metricYes
availableYes
index_nameYes
target_recallYes
has_hnsw_indexYes
sample_queriesYes
recommended_ef_searchYes
Behavior4/5

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

Beyond the readOnlyHint annotation, the description details behavioral aspects: sampling queries, building ground truth, sweeping ef values, excluding the query row from results, and verifying HNSW index. No contradictions with annotations.

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?

The description is front-loaded with the main purpose and is informative, but includes some extra phrasing like 'the actionable companion to analyze_hnsw_recall' which could be trimmed. Still, it is efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, procedural logic), the description covers purpose, behavior, prerequisites, and error handling. The output schema is explained in detail in the return object, making the description complete.

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 coverage is only 13%, but the description explains defaults for sample_queries and target_recall, and provides an example call. However, it does not describe all 8 parameters, leaving gaps that the schema does not fill.

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?

The description clearly states the tool recommends an ef_search value for a target recall@k, with specific actions like sampling queries and sweeping ef values. It distinguishes itself from analyze_hnsw_recall by being the 'actionable companion'.

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?

The tool is positioned as the actionable companion to analyze_hnsw_recall, and it notes that it verifies HNSW index existence. It provides context on when to use and references prerequisites like the vector extension, but lacks explicit 'when not to use' guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/devopam/MCPg'

If you have feedback or need assistance with the MCP directory API, please join our Discord server