Find text in a PDF
pdf_find_textSearch born-digital PDFs for words, phrases, or regex patterns and return each match's page and bounding box in PDF points, so agents can locate text for stamping.
Instructions
Search a born-digital PDF (one made by software: invoices, statements, reports, contracts, forms) for a word, phrase or pattern and get each hit with its page and box in PDF points from the bottom-left of the page as the viewer sees it, y on the text baseline: the same frame pdf_edit uses, so a hit's x, y, width and height tell you where to stamp. Case-insensitive unless case_sensitive is true. Set regex to treat query as a regular expression from a safe subset (literals, classes, dot, anchors, word boundaries, groups, alternation, quantifiers including lazy ones); backreferences, lookahead, lookbehind, named groups, property escapes and inline flags are rejected. A match never spans lines. Scanned PDFs have no text layer: their pages are listed in pages_without_text (no OCR). While next_page is not null, call again with pages set to next_page followed by a dash (for example 4-) to continue with no gaps or repeated hits. If truncated is true but next_page is null, hits on a page listed in pages_skipped beyond max_hits cannot be retrieved: raise max_hits or narrow the query. Read-only: the source is never modified.
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": {
"pdf_path": "<pdf_path>",
"query": "<query>"
},
"name": "pdf_find_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | No | Pages to search, 1-based: "1-3,5,8-". Default: all pages. At most 200 pages per call. | |
| query | Yes | Text to find, or a pattern when regex is true. At most 200 characters. | |
| regex | No | Treat query as a regular expression (the supported subset). Default false. | |
| max_hits | No | Stop once more hits than this exist. Default 100. | |
| password | No | Password to open the input, only needed for a user-password PDF (owner-locked files with an empty user password open without it). | |
| pdf_path | Yes | PDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. Use a URL or data URI when this server runs remotely (Smithery, hosted gateways) where local paths do not exist. | |
| whole_word | No | Only report matches with no letter, digit, underscore or combining mark directly before or after. Default false. | |
| case_sensitive | No | Default false: matching ignores case. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hits | Yes | ||
| count | Yes | Hits returned | |
| next_page | Yes | First page not fully searched, or null when finished | |
| truncated | Yes | The scan stopped before every selected page was searched; continue from next_page while it is not null; null with truncated means hits beyond max_hits on a page in pages_skipped were dropped | |
| lines_skipped | No | ||
| pages_scanned | Yes | ||
| pages_skipped | No | ||
| pages_without_text | Yes |