Skip to main content
Glama

preflight_vector_search

Check pgvector similarity search cost before execution. Flags brute-force scans, oversized top_k, unbounded searches, and filter recall loss using EXPLAIN only.

Instructions

Before running a VECTOR SIMILARITY SEARCH (pgvector: ORDER BY embedding <-> $1 LIMIT k, cosine <=>, inner-product <#>), check its cost WITHOUT running it — for any RAG / semantic-search / nearest-neighbour query you generate. Catches the vector traps a plain SQL check misses: brute-force scan with no HNSW/IVFFlat index (FULL_VECTOR_SCAN), top_k too large (TOP_K_TOO_LARGE), unbounded search (UNBOUNDED_VECTOR_SEARCH), and metadata- filter/ANN recall loss (VECTOR_FILTER_INTERACTION). EXPLAIN only. Pass target= in a multi-DB setup; the target should be a pgvector engine.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
targetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.2/5.0
Behavior4/5

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

No annotations are provided, so the description carries the full burden, and it does well: 'EXPLAIN only' discloses that nothing is executed, and it enumerates the exact findings the agent can expect (FULL_VECTOR_SCAN, TOP_K_TOO_LARGE, UNBOUNDED_VECTOR_SEARCH, VECTOR_FILTER_INTERACTION). It doesn't state permissions or target-connection requirements beyond the multi-DB note.

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?

Front-loads the core instruction ('check its cost WITHOUT running it') before the operator examples and trap list. Dense but nearly every clause carries information; the parenthetical operator enumeration is the only slightly heavy part.

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?

An output schema exists, so return-value detail is unnecessary, yet the description still names the warning categories the agent will see. For a two-parameter read-only diagnostic tool, nothing material is missing.

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 description coverage is 0%, so the description must compensate. It adds real meaning for 'target' (name in a multi-DB setup, should be a pgvector engine) but says nothing about the required 'sql' parameter beyond contextual implication that it is the query to preflight.

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 (check cost) and resource (vector similarity search) and explicitly frames the scope as pre-execution 'WITHOUT running it'. The pgvector operator examples (ORDER BY embedding <-> $1, <=>, <#>) make the target workload unmistakable and distinguish it from generic SQL preflight siblings.

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?

Clearly says when to use it: before running any RAG / semantic-search / nearest-neighbour query, and contrasts it with 'a plain SQL check' which implicitly points to preflight_query. It stops short of naming that sibling explicitly or stating when NOT to use this tool (e.g. non-pgvector targets).

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