Skip to main content
Glama

search_documents

Escalate document discovery with keyword precision or structured metadata filters, sorting, and aggregates when browsing misses a known document or typed-attribute answer.

Instructions

Escalation tool — never the first discovery step. Always start with browse_documents() (after get_folder_structure() when visible). Pick a mode: • mode="query" — keyword precision when browse missed a known doc by precise term, acronym, or file-name fragment. AND match with graded OR fallback. When results carry relevance (0–1, the chance the document helps answer the query) they are ranked by it, and in a small library a term found only in a document's text still finds it; otherwise they are sorted by upload date — judge relevance yourself. • mode="metadata" — structured filter / sort / aggregates over the declared schema. Use after browse missed a typed-attribute query, OR for counts / averages / extremes browse cannot answer. Call get_metadata_schema() FIRST to confirm field names and types — guessing risks silent zero-match.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "search_documents"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNoSearch mode (default "query"). Pick exactly one based on the user's intent. "query": keyword precision search. Provide `query` (keyword[s], not a sentence). Use as an ESCALATION when `browse_documents(sort="relevance")` + the persistence retries missed a document by precise term, acronym, or file-name fragment. "metadata": structured query against the declared metadata schema. Provide `metadata: { metadata_filter?, sort?, aggregates?, group_by? }`. Use as a FALLBACK after browse paths missed a typed-attribute query, OR DIRECTLY for structural questions `browse_documents()` cannot answer (counts / averages / extremes).
limitNoNumber of documents to return (0-50). Default 10, except when `mode="metadata"` carries `aggregates` — then the default is 0 (skip the docs payload). With `group_by` it caps group rows instead, default 50.
queryNoKeyword query (required when mode="query", forbidden otherwise). Pass the distinctive terms — names, codes, acronyms, file-name fragments — not a sentence; common words are ignored. Keywords are AND-matched against file names and descriptions, with a fallback to the documents matching the most of them. Examples: "machine learning safety" ✓; "NCT04194203" ✓; "万能险账户" ✓.
offsetNoZero-based pagination offset (mode="metadata" only — keyword mode does not paginate). Pass `next_offset` from a previous metadata response to fetch the next page.
metadataNo
folder_idNoFolder scope (default "root"). Pass a specific folder ID to scope into that folder, or "root" to reference the library root. Combine with `recursive` to control breadth. Mirrors browse_documents — copy a folder_id from a browse response verbatim.
recursiveNoWhether to include documents from descendant folders. When true (default), searches the entire subtree of folder_id — for "root" that means the whole library, including the read-only "shared-with-me" and "following" folders. Set false to restrict to the direct contents of folder_id: root-level documents for "root", directly-shared documents for the read-only folders. Guidance differs by mode: • mode="query" (keyword): keep the default (true) for a broad recall; narrow to false only to target a specific folder's direct contents. • mode="metadata": keep recursive=true (default) for any library-wide filter / count / aggregate. recursive=false with folder_id="root" matches only documents that sit DIRECTLY at root with no parent folder (almost always 0). Metadata queries cover your own documents only — shared folders are never included.
metadata_filterNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changedv1.9.0
    • changedInput schema / properties / folder_id / description
      Previous value: -"Folder scope (default \"root\"). Pass a specific folder ID to scope into that folder, or \"root\" to reference the library root. Combine with `recursive` to control breadth. Mirrors browse_documents — copy any folder_id from a browse/tree response verbatim, never construct one. The default root search ALREADY covers the read-only \"shared-with-me\" and \"following\" folders; pass one of those ids (or one of their sub-folder ids) only to narrow the search to shared content."New value: +"Folder scope (default \"root\"). Pass a specific folder ID to scope into that folder, or \"root\" to reference the library root. Combine with `recursive` to control breadth. Mirrors browse_documents — copy a folder_id from a browse response verbatim."
    • removedInput schema / properties / limit / default
      Removed value: -10
    • changedInput schema / properties / limit / description
      Previous value: -"Number of documents to return (1-50, default 10)"New value: +"Number of documents to return (0-50). Default 10, except when `mode=\"metadata\"` carries `aggregates` — then the default is 0 (skip the docs payload). With `group_by` it caps group rows instead, default 50."
    • addedInput schema / properties / metadata
      Added value: +{
      +  "additionalProperties": false,
      +  "properties": {
      +    "aggregates": {
      +      "additionalProperties": false,
      +      "properties": {},
      +      "type": "object"
      +    },
      +    "group_by": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "metadata_filter": {},
      +    "sort": {
      +      "additionalProperties": false,
      +      "properties": {},
      +      "type": "object"
      +    }
      +  },
      +  "type": "object"
      +}
    • addedInput schema / properties / metadata_filter
      Added value: +{}
    • addedInput schema / properties / mode
      Added value: +{
      +  "description": "Search mode (default \"query\"). Pick exactly one based on the user's intent.\n\"query\": keyword precision search. Provide `query` (keyword[s], not a sentence). Use as an ESCALATION when `browse_documents(sort=\"relevance\")` + the persistence retries missed a document by precise term, acronym, or file-name fragment.\n\"metadata\": structured query against the declared metadata schema. Provide `metadata: { metadata_filter?, sort?, aggregates?, group_by? }`. Use as a FALLBACK after browse paths missed a typed-attribute query, OR DIRECTLY for structural questions `browse_documents()` cannot answer (counts / averages / extremes).",
      +  "enum": [
      +    "query",
      +    "metadata"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Zero-based pagination offset (mode=\"metadata\" only — keyword mode does not paginate). Pass `next_offset` from a previous metadata response to fetch the next page.",
      +  "type": "number"
      +}
    • changedInput schema / properties / query / description
      Previous value: -"Keyword query. Pass keyword(s) only — NOT a natural-language sentence. Multiple keywords are AND-matched: every token must appear in the file name or description. Examples: \"machine learning safety\" ✓; \"documents about machine learning safety\" ✗ (stop words \"documents\"/\"about\" will block matches)."New value: +"Keyword query (required when mode=\"query\", forbidden otherwise). Pass the distinctive terms — names, codes, acronyms, file-name fragments — not a sentence; common words are ignored. Keywords are AND-matched against file names and descriptions, with a fallback to the documents matching the most of them. Examples: \"machine learning safety\" ✓; \"NCT04194203\" ✓; \"万能险账户\" ✓."
    • changedInput schema / properties / recursive / description
      Previous value: -"Whether to include documents from descendant folders. When true (default), searches the entire subtree of folder_id — for \"root\" that means the whole library, including the read-only \"shared-with-me\" and \"following\" folders. Set false to restrict to the direct contents of folder_id: root-level documents for \"root\", directly-shared documents for the read-only folders."New value: +"Whether to include documents from descendant folders. When true (default), searches the entire subtree of folder_id — for \"root\" that means the whole library, including the read-only \"shared-with-me\" and \"following\" folders. Set false to restrict to the direct contents of folder_id: root-level documents for \"root\", directly-shared documents for the read-only folders.\nGuidance differs by mode:\n• mode=\"query\" (keyword): keep the default (true) for a broad recall; narrow to false only to target a specific folder's direct contents.\n• mode=\"metadata\": keep recursive=true (default) for any library-wide filter / count / aggregate. recursive=false with folder_id=\"root\" matches only documents that sit DIRECTLY at root with no parent folder (almost always 0). Metadata queries cover your own documents only — shared folders are never included."
    • removedInput schema / required
      Removed value: -[
      -  "query"
      -]
  2. First observedv1.8.2

TDQS

A4.5/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 burden and does a lot: it discloses ranking behavior (relevance 0–1 when present, otherwise upload-date sort, with the agent expected to judge relevance), AND-match with graded OR fallback, and the important scoping caveat that metadata queries cover only own documents and never shared folders. It stops short of describing error behavior or the shape of the response (no output schema exists), so it is strong but not complete.

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 the most decision-relevant sentence, then cleanly bulleted by mode. Some content (mode definitions) is duplicated in the schema's mode description, and the second bullet's parenthetical is dense, but there is no filler.

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 an 8-parameter tool with nested objects, no annotations and no output schema, the description covers the decision logic, ranking semantics, and the biggest scoping pitfall (shared folders excluded from metadata mode). The main remaining gap is the return payload and pagination behavior, which only the schema's offset description addresses.

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 75% and the per-parameter text is already detailed, so the description's added value is mostly in mode selection and behavioral consequences of mode (e.g., metadata mode's document payload being skipped when aggregates are present is in the schema, not reused here). It does add genuine meaning by pointing to get_metadata_schema() before supplying the opaque nested `metadata` object, whose subproperties are effectively undocumented in the schema.

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 precise role statement ('Escalation tool — never the first discovery step') and then defines the two modes as distinct capabilities: keyword precision search vs structured filter/sort/aggregate over the declared schema. An agent can distinguish this from browse_documents and get_metadata_schema without opening any 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?

Explicitly names the prerequisite chain (get_folder_structure then browse_documents) and the conditions that trigger escalation for each mode, including when metadata mode is used directly (counts/averages/extremes). It also names the required precursor get_metadata_schema() and warns that guessing field names risks a silent zero-match.

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