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
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Search 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). | |
| limit | No | 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. | |
| query | No | 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" ✓; "万能险账户" ✓. | |
| offset | No | 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. | |
| metadata | No | ||
| folder_id | No | 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. | |
| recursive | No | 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. 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_filter | No |