grep
Locate exact lines in a single document using a regex pattern, especially when no outline is available. Use after search to pinpoint names, dates, terms, or identifiers, then read surrounding context.
Instructions
[Workflow: search → grep or outline → read] Locate specific lines within a single document by regex pattern. Best for documents with has_outline=false where outline is unavailable. Use after 'search' to pinpoint exact positions of names, dates, terms, identifiers, or any pattern — then use 'read' with offset to see full context. Works on all document types, including text derived from images and scanned PDFs (OCR) and from audio and video (transcripts). Requires a doc_id from a previous search result. For searching across multiple documents, call grep once per document.
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": {
"pattern": "<pattern>",
"doc_id": "<doc_id>"
},
"name": "grep"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | Lines of context to keep after each match. Falls back to `context` (default 3) when omitted. | |
| limit | No | Maximum number of matching lines to return (default: 20, max: 100) | |
| before | No | Lines of context to keep before each match. Falls back to `context` (default 3) when omitted. | |
| doc_id | Yes | Document ID to search within (obtained from search results). Opaque string — pass through verbatim from `search`. Local documents take the form `local://<integer>`; bare integer IDs from older clients remain accepted. | |
| offset | No | Number of matches to skip for pagination (default: 0) | |
| context | No | Lines of context before and after each match (default: 3) | |
| pattern | Yes | Regular expression to match. RE2-compatible syntax — no lookahead or backreference. Combine multiple alternatives in a single pattern with `|`; per-branch hit counts are returned. | |
| output_mode | No | Output mode: "content" (matching lines with context, default) or "count" (match count only, useful to preview totals before paginating) | |
| output_format | No | Output format. Defaults to "markdown" (human-readable); set to "json" for structured JSON (machine-parseable). Sending `null` or omitting the field both yield the default. | |
| case_insensitive | No | Case-insensitive matching (default: false) | |
| fuzzy_whitespace | No | Fuzzy whitespace matching for PDF noise tolerance. null/omit = auto (PDF on, others off), true = force on, false = force off |