files.search
Find relevant files with full-text keyword search, get ranked matches with excerpts, or combine matched bodies into a single token-budgeted context bundle.
Instructions
Full-text (SQLite FTS5) keyword search across files. Default mode returns ranked matches with inline match_excerpt and title_highlight (no follow-up files.read needed for snippets) plus tags, est_tokens, size_bytes, content_class, and aggregate total_est_tokens. Pass include_bodies: true to instead get a single prompt-ready bundle: matched bodies concatenated into XML <document> blocks or markdown headers + fences (see format/max_tokens), capped at the token budget — files are added in rank order until the next would exceed it, the rest going to meta.skipped[]. Use include_bodies instead of files.search + N×files.read when you need several related files as one context blob. Read-only; no side effects, auth, or rate limits. Ordering: dictionary hits sort above everything else for the same query (dictionary-wins on conflict), then BM25 rank. FTS is tokenised: it WILL miss URLs, hyphenated terms, and partial substrings — fall back to files.regex_search for those. project_id: null searches only the KB; omit the field to span everything; tags[] requires ALL listed tags to match; kind narrows to one content class.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Filter by content class. dictionary = authoritative KB (system IDs, mappings, glossaries), note = informational KB, journal = time-log, project = project file. Omit to see all classes with dictionary-first ordering. | |
| tags | No | Filter by tags (all must match) | |
| query | Yes | Search query | |
| format | No | Bundle format when `include_bodies` is true. xml = Anthropic-recommended <document> tags (default); markdown = ## headers + fenced blocks. Ignored otherwise. | |
| favorite | No | Filter by favorite status | |
| max_tokens | No | Token budget when `include_bodies` is true (default 50000). Files added in rank order until the next would exceed; remainder go to `meta.skipped[]`. Ignored otherwise. | |
| project_id | No | Filter by project ID. Pass null to search ONLY Knowledge Base files. | |
| include_bodies | No | If true, return a single prompt-ready bundle of matched bodies instead of a match list. Response shape changes to `{bundle, meta: {included, skipped, ...}}`. Default false. |