Skip to main content
Glama

Search inside a document

distill_search
Read-onlyIdempotent

Find where a word, number, or phrase appears in a local document or URL without reading it all; returns matching lines with page, heading, and context.

Instructions

Find where a word, number or phrase appears in one document without reading it: use it instead of reading a long document whole, and instead of shelling out to pdftotext or grep. Takes a local path (same formats as distill_file) or a url (same as distill_url); the document is converted once and the cached Markdown is searched. Matching is case-insensitive, ignores line wraps and extra whitespace, and finds numbers split across lines; set regex for a JavaScript regular expression (at most 200 characters; a regex that runs longer than 2 s is stopped with bad_request). Each hit has the line, the physical page number (1-based position in the PDF, not the printed label; absent for documents without pages), the nearest heading above it and a few lines of context; neighbouring matches are merged into one hit. Next step after a hit: read around it with distill_file using section (the hit's heading) or offset/limit (from the hit's line), or look at the original page with distill_page_image. Read-only: never modifies or uploads anything. A path stays on this machine; only a url reaches the internet (public pages only, with the safety rules of distill_url), which is why the tool is marked as open-world. Fails like distill_file or distill_url (password_protected, needs_libreoffice, forbidden, too_large over 100 MB for documents, 2 GB for audio and video, parse_failed, fetch_failed) or with bad_request (neither or both of path and url, an invalid or over-long regex, or one using lookarounds or backreferences).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "distill_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
urlNoAbsolute http or https URL of a page. Pass either path or url
pathNoAbsolute path, or relative to the server's working directory. Pass either path or url
queryYesText to find. Plain text by default: case-insensitive, whitespace-insensitive, matches across line wraps
regexNoTreat query as an RE2 regular expression (case-insensitive, at most 200 characters; JavaScript-like syntax but no lookarounds or backreferences, always linear time)
contextNoLines of context before and after each match (default 2)
maxHitsNoMaximum number of hits to return (default 20); total says how many there are

Output Schema

NameRequiredDescriptionDefault
hitsYes
noteNo
totalYes
tokensYes
truncatedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare read-only, idempotent, open-world, non-destructive, but the description adds genuine behavior: the document is converted once and the cached Markdown is searched, matching ignores line wraps and finds numbers split across lines, neighbouring matches merge, regex is capped at 200 chars with a 2 s bad_request abort, and the locality distinction that a path never leaves the machine while only a url reaches the internet. It also enumerates failure modes and size limits (100 MB documents, 2 GB audio/video), which the annotations do not convey.

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?

Purpose and the anti-alternatives are front-loaded in the first sentence, and nearly every clause carries operational information. It is a dense single block of prose with no visual separation between matching rules, hit structure, next steps and error taxonomy, which makes it heavier to scan than its content requires.

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 six-parameter search tool with an output schema, it covers conversion/caching, match semantics, hit contents (line, physical vs printed page number, nearest heading, merged neighbours), follow-up paths, locality/security, and the full error set. An agent could call this correctly and interpret results without consulting anything else.

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 the description earns above it by explaining that path accepts the same formats as distill_file and url the same as distill_url, that path and url are mutually exclusive (neither or both yields bad_request), and by spelling out regex constraints including the lookaround/backreference prohibition. It adds less for context and maxHits, which are left to the schema, and its 'JavaScript regular expression' phrasing is slightly looser than the schema's RE2 wording.

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 specific verb+resource: 'Find where a word, number or phrase appears in one document'. It explicitly scopes to a single document and contrasts against reading whole documents and against pdftotext/grep, so an agent can distinguish it from distill_file and distill_outline immediately.

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 ('instead of reading a long document whole') and when-to-use-an-alternative ('instead of shelling out to pdftotext or grep'), plus a concrete next-step chain after a hit: distill_file with section or offset/limit, or distill_page_image for the original page. Nothing is left to inference about routing.

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