Skip to main content
Glama
books-as-data
by kintopp

sgbr_locate_text

sgbr_locate_text
Read-onlyIdempotent

Locate a phrase in a scanned book’s uncorrected OCR: searches content first, then scans pages when needed, returning matching pages, context snippets, and optional regions for image verification.

Instructions

Locate a phrase in a scanned book's OCR and return the page(s) it is on. Asks the platform's content search (whole words, exact accents) and, when that finds nothing, scans the pages' OCR for the phrase as a substring; engine says which answered. For each hit returns the page, a context snippet, and line/word regions with bbox_px + region_pct (feed region_pct to sgbr_inspect_image to crop/verify; regions is best-effort and may be empty — the page and snippet still stand). Text is uncorrected Fraktur OCR, so expect misses. Searches one volume — for a multivolume work it returns the ordered sibling volumes so you can call again with the next scan_id, and unsearched_scans names any other scan the record lists (a volume or another library's copy) that went unsearched. A fold-out plate id is refused (a plate is one page; its scan_id is the parent volume's) — pass the parent scan_id to search the volume.

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": {
      "phrase": "<phrase>"
    },
    "name": "sgbr_locate_text"
  }
}

Input Schema

NameRequiredDescriptionDefault
idNoRecord id from an sgbr_search result. Resolves its scan id automatically and enables sibling-volume enumeration for multivolume works. Provide this OR scan_id.
levelNoRegion granularity for each hit.line
engineNo"auto" (default) asks the platform's content search — the website viewer's search, the whole volume in one call — and falls back to the page scan when it finds nothing or cannot run. "page_scan" also finds the phrase inside longer words, in other accent forms, and split across a line break. "content_search" never falls back.auto
phraseYesText to locate, as a phrase. Content search matches it as whole words, case-insensitively but with exact accents; the page scan matches it as a case/diacritic-insensitive substring of normalized OCR (Fraktur long-ſ folded, hyphen-at-linebreak joined).
scan_idNoScan id directly (e.g. "ZBZ-00123359"), from sgbr_get_record's digital.scan_id. Skips the id→scan lookup but yields no sibling volume list (no record to derive it from). Provide this OR id.
max_hitsNoCap on matching pages returned (default 10, max 50); hOCR is fetched only for these.
max_pagesNoCost cap on pages the page scan reads from start_page (default 500, max 2000); the scan also stops early at the 404 page boundary. Content search always covers the whole volume.
start_pageNo1-based page to begin at (resume within a large volume, or past the last hit).

Output Schema

NameRequiredDescriptionDefault
idYes
hitsYes
levelYes
engineYes
phraseYes
scan_idYes
ocr_noteYes
siblingsYes
warningsNo
truncatedYes
start_pageYes
failed_pagesYes
pages_failedYes
pages_scannedYes
returned_hitsYes
next_start_pageYesThe page after the scan window, set when the scan stopped at max_pages: pass it as start_page to scan further. Null otherwise.
scans_unsearchedYes
unsearched_scansYes
regions_truncatedYes
truncation_reasonYes
volume_page_countYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.30.2

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), so the description's job is added context, and it delivers: best-effort `regions` that may be empty while page/snippet still stand, `engine` reporting which path answered, uncorrected Fraktur OCR meaning expected misses, cost caps, and the fold-out-plate refusal. These are non-obvious behaviors an agent must know to interpret results and avoid dead ends.

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?

Front-loads the core purpose, then the fallback, then result shape, then edge cases in a logical order. Dense with parenthetical asides but nearly every clause carries actionable information; a slightly tighter phrasing of the volume/plate paragraph would earn a 5.

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 an 8-parameter search tool with an output schema, the description covers strategy selection, result shape, failure expectations (Fraktur OCR misses), scope limits, and multivolume follow-up. Nothing an agent needs to invoke it correctly or interpret hits is missing.

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. The description still adds meaning beyond the schema: it ties `engine` to the answer path, explains that `id` (vs `scan_id`) enables sibling-volume enumeration, and explains why a plate `id` is refused. `region_pct` delivery to sgbr_inspect_image is also described. Only the numeric caps are left to the schema.

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?

States a specific verb and resource ('Locate a phrase in a scanned book's OCR and return the page(s)'), plus the two search strategies it uses. This is clearly distinguishable from sgbr_search (find records) and sgbr_get_page_ocr (fetch a page's OCR).

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?

Explicitly explains the fallback: content search first, page scan when it finds nothing; explicitly names `sgbr_inspect_image` as the tool to feed `region_pct` into for cropping/verification. It also routes the agent on id vs scan_id, the multivolume next-call pattern, and the plate-id refusal. Alternatives and conditions are named rather than implied.

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