Skip to main content
Glama

run_search

Read-only

Executes full-text search queries against Couchbase Search indexes, returning relevance-scored hits, facets, and highlighting, or fetches execution plans for debugging.

Instructions

Run an FTS (Search) query against a Search index, or fetch its execution plan.

Use this instead of run_sql_plus_plus_query's SEARCH() function when you need relevance-scored, fuzzy, or linguistic full-text matching (scoring, highlighting, faceting, fuzzy/phrase/wildcard matching) — SQL++ can invoke FTS predicates too, but this tool gives clearer tracing of what data was searched and keeps FTS-specific result shape (score, fragments, facets) out of general query results.

query is the raw FTS query JSON body, passed through unvalidated to the Search service — this supports every non-vector FTS query type, e.g.:

  • {"match": "ale", "field": "type"}

  • {"conjuncts": [{"match": "ale"}, {"term": "beer", "field": "type"}]}

  • {"query": "type:beer +name:ale"} (query_string) Vector search is NOT supported by this tool (separate feature).

Pass both bucket_name and scope_name together to query a scope-level (scoped) index, or omit both to query a cluster-level ("legacy") index. Passing only one is invalid. Confirm the index's exact name/location first with list_search_indexes. Don't guess which fields a query body can target — if you don't already know what the index maps and how those fields are analyzed, call get_search_index_definition first; a field-scoped query against an unmapped field matches nothing rather than erroring. Note this only works for indexes with explicit static field mappings — a dynamically mapped index (dynamic: true) has no fixed field list to inspect, since it indexes whatever fields appear in each document; for those, look at actual document contents instead to know what's queryable.

explain: if True, fetches the execution plan instead of normal results. The Search service exposes the query plan per matched document, not as a separate plan-only/ dry-run call — so explain=True still executes the query (with explain enabled) and returns the explanation for each returned hit. limit defaults to 1 in this mode to keep it cheap (pass a larger limit to see the plan for more matched documents), and skip/fields/sort/facets/highlight_fields/disable_scoring/raw are ignored — they only apply when explain=False.

limit/skip/fields/sort/facets/highlight_fields/disable_scoring map to the equivalent Search options. limit defaults to 10 when explain=False (matching the other query tools in this server) and to 1 when explain=True. raw is a passthrough dict for any other SearchOptions field not exposed directly (e.g. highlight_style, consistent_with).

Returns {"success": True, "index_name", "explain", "limit" (the limit actually applied, since it defaults differently depending on explain), "total_hits", "hits", "facets", "metadata": {"errors","metrics"}} on success, or {"success": False, "error": ...} if the input is invalid or the query fails (e.g. bad query syntax, index not found). total_hits counts the hits actually returned, so it is capped by limit — for how many documents matched overall, read metadata.metrics.total_rows instead, and don't report total_hits as the size of the match set. hits entries are {"id","score","fields","fragments"} when explain=False, or {"id","score","explanation"} when explain=True (facets is empty in that case).

Input Schema

NameRequiredDescriptionDefault
rawNo
skipNo
sortNo
limitNo
queryYes
facetsNo
fieldsNo
explainNo
index_nameYes
scope_nameNo
bucket_nameNo
disable_scoringNo
highlight_fieldsNo

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?

Annotations only supply readOnlyHint=true; the description adds substantial behavior the annotation cannot: the query body is passed through unvalidated, explain=True still executes and returns per-hit plans with limit defaulting to 1, skip/fields/sort/facets/highlight_fields/disable_scoring/raw are silently ignored in explain mode, and total_hits is capped by limit so metadata.metrics.total_rows must be read for the true match set.

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-loaded with purpose and the SQL++ alternative, then parameter semantics, then return shape — a sensible ordering with no filler sentences. It is dense and long, but nearly every clause carries operational information; only mild trimming (e.g. the explanatory aside about dynamically mapped indexes) would tighten it.

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 13-parameter tool with nested free-form objects, undocumented schema, and divergent explain-mode behavior, the description covers index location, query body form, mode-dependent defaults and ignored parameters, error cases, and return shape. Nothing material for correct invocation is missing.

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 carries the full burden and does it: concrete FTS query body examples (match, conjuncts, query_string), the bucket_name+scope_name pairing rule and its invalid case, per-parameter mapping to SearchOptions, differential limit defaults (10 vs 1), and raw as the escape hatch for unexposed options like highlight_style.

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 and resource: run an FTS query against a Search index, or fetch its execution plan. It explicitly demarcates itself from run_sql_plus_plus_query's SEARCH() function and from vector search ('Vector search is NOT supported by this tool'), which is exactly the differentiation an agent needs among these siblings.

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 explicit when-to-use (relevance scoring, fuzzy/phrase/wildcard, faceting, tracing) versus the SQL++ alternative, states prerequisites (confirm index with list_search_indexes, inspect mappings with get_search_index_definition, note that explain executes the query rather than dry-running), and covers the bucket_name/scope_name combination rule with the invalid single-argument case named.

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