Skip to main content
Glama
MOmayr
by MOmayr

vector_search

Perform nearest-neighbor search on PostgreSQL vector columns by embedding query text and ranking with pgvector. Supports hybrid fusion with lexical search.

Instructions

Nearest-neighbor search. Embeds each query string and ranks with pgvector. query is an array: one element runs one search; multiple elements run the same search (same table, where, columns, limit) once per element and return grouped results. Pass text_column to fuse each ranking with a lexical list using reciprocal rank fusion (k=60). lexical=fts (default) uses English full text: stems, drops stop words, keeps Arabic, and drops query terms that appear in more than 40% of rows. lexical=trgm uses pg_trgm word_similarity above pg_trgm.word_similarity_threshold. Omit text_column for dense search only. A where clause sets hnsw.iterative_scan=strict_order for that query. hnsw.ef_search is raised when the candidate limit is above 40. Default payload omits embedding and *hash. include_scores defaults to true and adds distance, plus rrf, dense_rank, and lexical_rank when hybrid. Set include_scores false to omit those columns. response_format=markdown returns one markdown table per query element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMax rows (default 10, max 100)
queryYesSearch strings (max 20). One element searches that text. Multiple elements each return their own group, tagged Results for {text}. A single string is accepted as one element.
tableYesTable name
whereNoSQL WHERE fragment applied before ranking (no WHERE keyword)
metricNocosine (default), l2, or ip. Must match the HNSW opclass to use the index.
schemaNoSchema (default: public)
columnsNoPayload columns. Omit for all except embedding and *hash.
lexicalNofts (default) or trgm. Requires text_column. fts for passages. trgm for short names that have a trigram index.
text_columnNoText column for hybrid search. Use the passage column for fts, or the short name column for trgm. Omit for dense search only.
include_scoresNoDefault true. When false, omit distance, and omit rrf, dense_rank, and lexical_rank on hybrid search. Ranking is unchanged.
response_formatNoEmpty for JSON. "markdown" returns one table per query element, headed Results for {text}, using the same columns as the JSON rows.
embedding_columnYesvector or halfvec column

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.3

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden and does so well: it discloses that a where clause forces hnsw.iterative_scan=strict_order, that ef_search is raised above a 40-candidate limit, that the default payload omits embedding and *hash, and how include_scores toggles output columns without changing ranking. It stops short of stating auth requirements, cost/latency, or pagination behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The content is dense and front-loaded, but it reads as an undifferentiated wall of parameter behavior with no grouping or structure, which makes it hard to scan for the one fact needed at call time. Most sentences earn their place individually, but the lack of structure costs it.

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?

For a 12-parameter, no-annotation tool with no output schema, the description is largely sufficient: it covers return shape (default payload, score columns, markdown format), the array grouping model, and the tuning side effects. Minor gaps remain around failure modes and resource limits.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond the schema: it explains the query-array semantics (one element = one search; N elements = N grouped results), the RRF fusion behavior when text_column is set, and the exact columns include_scores adds. This goes past restating parameter descriptions.

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?

Opens with a specific verb+resource ('Nearest-neighbor search') and immediately names the mechanism (embeds query strings, ranks with pgvector), so an agent knows exactly what the tool produces. It does not, however, distinguish itself from siblings like vector_execute or query, leaving the agent to infer which retrieval tool applies.

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?

There is meaningful parameter-level guidance ('Omit text_column for dense search only', 'fts for passages. trgm for short names that have a trigram index'), which tells the agent when to choose each mode. But there is no tool-level when-to-use guidance or exclusion relative to alternatives such as vector_execute, so routing between siblings is left implicit.

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