Skip to main content
Glama

run_vector_query

Read-only

Embed a text query and run a vector similarity search against a Couchbase GSI vector index using a required distance metric, with optional SQL++ prefiltering and result limits.

Instructions

Embed a query and run a vector similarity search against a GSI vector index.

Embedding: query_text is embedded using the model configured via CB_MCP_EMBEDDING_MODEL_PROVIDER/CB_MCP_EMBEDDING_MODEL/CB_MCP_EMBEDDING_MODEL_API_KEY/CB_MCP_EMBEDDING_MODEL_ENDPOINT (plus CB_MCP_EMBEDDING_MODEL_AWS_* for provider=bedrock). If no provider is configured, this tool returns {"success": False, "error": ...} explaining what to set -- it is not hidden from tool discovery when unconfigured.

Index selection: this tool queries a Couchbase 8.0+ GSI vector index (Composite Vector Index or Hyperscale Vector Index) via SQL++'s APPROX_VECTOR_DISTANCE(). Unlike Search-service vector search, GSI selects the index automatically from the vector field referenced in the query -- there is no index_name parameter, and none is needed.

distance_metric is required, deliberately with no default: it must match the similarity the index was created with (CREATE INDEX ... WITH {"similarity": ...}), or Couchbase silently falls back to not using the Composite/Hyperscale Vector Index at all (no error -- the query still returns correct results, just unindexed). There is no one value that's usually right, since it depends entirely on how the specific index was created, and this tool has no index_name to look that up automatically (see above) -- call list_indexes first and read the similarity value out of the matching index's definition field (valid values: cosine, dot, l2/euclidean, l2_squared/euclidean_squared).

num_probes/rerank/top_n_scan are Hyperscale Vector Index tuning parameters. num_probes (integer) is the number of centroids to probe -- raise it to improve poor recall. rerank (true/false) re-checks the top candidates against the full vectors; it needs num_probes. top_n_scan (integer) is how many candidates to rerank; it needs num_probes and rerank. num_probes alone, or num_probes + rerank, are both valid. A Composite Vector Index doesn't use any of them. This tool itself has no index_name to check, but list_indexes now reports each index's vector_type ("hyperscale" or "composite") -- check that first if you need to know which shape will actually serve the query.

where is an optional raw SQL++ boolean expression (e.g. "doc.status = 'active'") appended to prefilter candidates before the vector ordering -- this tool only ever emits a SELECT, so, unlike run_sql_plus_plus_query, there is no write-guard for it to bypass. If the index was created with a partial-index condition (create_query_index's condition), where must match or imply it for the planner to actually use that index -- otherwise it falls back to a full scan silently (confirmed via EXPLAIN), the same footgun documented above for a mismatched distance_metric.

select_fields limits the projected document fields; omit it to return the full document. limit defaults to 10, matching the other query/search tools in this server.

Returns {"success": True, "hits": [{"id", "distance", "document": {... selected fields, or the full document}}], "total_hits", "cluster_major_version", and a "warning" key only when the detected cluster major version is below 8 (informational -- a pre-8.0 cluster fails the query naturally with its own "unknown function" error rather than being blocked here)} or {"success": False, "error": ...}. The document is nested under "document" rather than merged into the hit directly -- a document field literally named "id" or "distance" would otherwise silently collide with (and could overwrite) this tool's own id/distance metadata.

Input Schema

NameRequiredDescriptionDefault
limitNo
whereNo
rerankNo
num_probesNo
query_textYes
scope_nameYes
top_n_scanNo
bucket_nameYes
vector_fieldYes
select_fieldsNo
collection_nameYes
distance_metricYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.1.0

TDQS

A4.9/5.0
Behavior5/5

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

readOnlyHint=true is consistent with the stated 'this tool only ever emits a SELECT' and the explanation that no write-guard applies. Beyond annotations it discloses the two silent-fallback footguns (mismatched distance_metric and a `where` that misses the partial-index condition), the unconfigured-provider error shape, the pre-8.0 warning key, and the nested-document return rationale.

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?

Paragraph-per-topic structure with bolded leads makes the long text scannable and front-loaded. It loses a point for repetition, repeating the 'this tool has no index_name to look that up' caveat three separate times, which could be said once.

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?

For a 12-parameter tool with 0% schema coverage and silent-failure modes, the description covers prerequisites, parameter interactions, fallback behavior, and result shape. Return documentation is arguably redundant given the output schema, but the collision-explanation for the nested 'document' key adds real value.

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

Parameters5/5

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

With 0% schema description coverage the description must carry the full burden, and it does: distance_metric has a documented rationale for having no default plus an enumerated value set, num_probes/rerank/top_n_scan have stated meaning and dependency ordering, where gets syntax and prefilter semantics, select_fields/limit are explained with the limit default.

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?

Opens with a specific verb+resource: embed a query and run a vector similarity search against a GSI vector index. It explicitly contrasts with the Search-service sibling (run_vector_search) and states there is no index_name parameter, so an agent can distinguish it from neighboring tools without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete preconditions and routing: call list_indexes first to read the index `similarity` and `vector_type`, and supplies the exact valid values for distance_metric. It also states when tuning params apply (Hyperscale only, not Composite) and what happens when they are omitted or misused.

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