Skip to main content
Glama

search_files

Search a MemDrive memory library by keyword, ranking matches by relevance with path, heading, score, and highlighted snippet; filter by file type, tags, date, or exact phrase.

Instructions

Search the memory library by keyword, ranked by relevance (full-text index + BM25; Chinese queries are segmented, so 1–2 character terms match). Returns one hit per matching file (its best-matching chunk) with the file path, section heading, relevance score, and a snippet with the matched term highlighted as term. Filename matches are included too: a substring of a filename finds the file, including non-text files such as images. Results are paginated: limit defaults to 20, pass offset for the next page. Filters: file_types (e.g. [".md"]), tags (a file must carry at least one), date_from/date_to (file date: front matter > filename > modification time; a date-only upper bound covers the whole day), modified_after/modified_before (modification time). exact_phrase requires the phrase to appear verbatim. diagnostics_only returns a read-only library report (empty files, duplicate content, broken image references, unreferenced attachments older than 24h) and never modifies anything; keyword is not needed for it. rebuild_index forces a full index rebuild first (use after a bulk import or a cache clear). On the first search after startup the index may still be building in the background; the result then says so and falls back to a direct scan (keyword, path, and file types only — tags, dates, and exact_phrase are not applied there, and the result says so). Paths are relative to the library root (MEMDRIVE_ROOT). Omit path or pass "" to search the whole library.

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_files"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathNoDirectory to search under, relative to the library root. Omit or pass "" for the whole library.
tagsNoA file must carry at least one of these tags (YAML front matter `tags:` or body `#tag`). Omit for all.
limitNoMaximum files to return (default 20, max 200).
offsetNoFiles to skip for pagination (default 0).
date_toNoLatest file date (ISO date, e.g. "2026-12-31"). A date-only value covers that whole calendar day in the server's local timezone.
keywordNoKeyword to search for (case-insensitive; Chinese terms are segmented). Required unless diagnostics_only is true.
date_fromNoEarliest file date (ISO date, e.g. "2026-01-01"). File date is front matter date, then filename date, then modification time. A date-only value means that calendar day in the server's local timezone.
file_typesNoFile extensions to include, e.g. [".md", ".txt"]. Omit for all types.
exact_phraseNoPhrase that must appear verbatim in a matching chunk (in addition to the keyword).
rebuild_indexNoForce a full index rebuild before searching (default false).
modified_afterNoEarliest modification time (ISO date). A date-only value means the start of that calendar day in the server's local timezone.
modified_beforeNoLatest modification time (ISO date). A date-only value covers that whole calendar day in the server's local timezone.
diagnostics_onlyNoReturn the read-only library diagnostics report instead of searching (default false).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.8.4
    • changedInput schema / properties / date_from / description
      Previous value: -"Earliest file date (ISO date, e.g. \"2026-01-01\"). File date is front matter date, then filename date, then modification time."New value: +"Earliest file date (ISO date, e.g. \"2026-01-01\"). File date is front matter date, then filename date, then modification time. A date-only value means that calendar day in the server's local timezone."
    • changedInput schema / properties / date_to / description
      Previous value: -"Latest file date (ISO date, e.g. \"2026-12-31\")."New value: +"Latest file date (ISO date, e.g. \"2026-12-31\"). A date-only value covers that whole calendar day in the server's local timezone."
    • changedInput schema / properties / modified_after / description
      Previous value: -"Earliest modification time (ISO date)."New value: +"Earliest modification time (ISO date). A date-only value means the start of that calendar day in the server's local timezone."
    • changedInput schema / properties / modified_before / description
      Previous value: -"Latest modification time (ISO date)."New value: +"Latest modification time (ISO date). A date-only value covers that whole calendar day in the server's local timezone."
  2. Changed14 schema fields changedv0.8.2
    • addedInput schema / properties / date_from
      Added value: +{
      +  "description": "Earliest file date (ISO date, e.g. \"2026-01-01\"). File date is front matter date, then filename date, then modification time.",
      +  "type": "string"
      +}
    • addedInput schema / properties / date_to
      Added value: +{
      +  "description": "Latest file date (ISO date, e.g. \"2026-12-31\").",
      +  "type": "string"
      +}
    • addedInput schema / properties / diagnostics_only
      Added value: +{
      +  "description": "Return the read-only library diagnostics report instead of searching (default false).",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / exact_phrase
      Added value: +{
      +  "description": "Phrase that must appear verbatim in a matching chunk (in addition to the keyword).",
      +  "type": "string"
      +}
    • addedInput schema / properties / file_types
      Added value: +{
      +  "description": "File extensions to include, e.g. [\".md\", \".txt\"]. Omit for all types.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • changedInput schema / properties / keyword / description
      Previous value: -"Keyword to search for (case-insensitive substring)."New value: +"Keyword to search for (case-insensitive; Chinese terms are segmented). Required unless diagnostics_only is true."
    • removedInput schema / properties / keyword / minLength
      Removed value: -1
    • addedInput schema / properties / limit
      Added value: +{
      +  "description": "Maximum files to return (default 20, max 200).",
      +  "maximum": 200,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedInput schema / properties / modified_after
      Added value: +{
      +  "description": "Earliest modification time (ISO date).",
      +  "type": "string"
      +}
    • addedInput schema / properties / modified_before
      Added value: +{
      +  "description": "Latest modification time (ISO date).",
      +  "type": "string"
      +}
    • addedInput schema / properties / offset
      Added value: +{
      +  "description": "Files to skip for pagination (default 0).",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / rebuild_index
      Added value: +{
      +  "description": "Force a full index rebuild before searching (default false).",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / tags
      Added value: +{
      +  "description": "A file must carry at least one of these tags (YAML front matter `tags:` or body `#tag`). Omit for all.",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • removedInput schema / required
      Removed value: -[
      -  "keyword"
      -]
  3. First observedv0.6.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations at all, the description carries the full burden and does so well: it discloses ranking behavior (BM25, Chinese segmentation), one-hit-per-file deduplication, pagination defaults, the date-fallback hierarchy, that diagnostics_only is read-only and never modifies anything, that rebuild_index forces a full rebuild, and that the first post-startup search may silently degrade to a direct scan where tags, dates, and exact_phrase are not applied.

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?

It is front-loaded with the core operation and return shape, then moves to filters, then to edge cases in a logical order. A few clauses, notably the parenthetical restatement of each filter already documented in the schema, could be trimmed without loss.

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 no output schema and no annotations, the description supplies the missing pieces: return shape, ranking, pagination, path semantics, and the fallback behavior that changes which filters apply. An agent has enough to call this correctly on the first attempt.

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 and most of the filter prose merely restates schema text (file_types, tags, exact_phrase, date bounds). The description does add genuinely new meaning the schema does not: the degraded startup-scan mode in which tags, dates, and exact_phrase are ignored, and that keyword is not needed when diagnostics_only is set.

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?

The first sentence states a specific verb and resource ("Search the memory library by keyword") plus the ranking mechanism, and the description then spells out exactly what a hit contains (file path, heading, score, highlighted snippet). This is unambiguously a keyword search over library content, clearly distinct from siblings like list_directory, read_file, and open_image.

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

Usage Guidelines4/5

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

It gives explicit mode-selection guidance: use diagnostics_only for a library report (keyword not needed), rebuild_index after a bulk import or cache clear, and clarify that path="" means the whole library. What is absent is a statement of when to prefer this over reading a directory listing or reading a known file directly, so there are no explicit exclusions.

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