Challenge
- Manuals and guidelines sit scattered as PDFs, and finding which page of which document said something takes time
- Keyword search alone misses rephrased questions and documents written in another language
Approach
- The scaffold is a search server that runs character-level full-text search and meaning-based vector search side by side and fuses their rankings
- Each domain rewrites only the single file that reads its documents; indexing, search and the server are shared
Outcome
- Even rephrased questions lead to the right document and page
- A new domain's search server comes up quickly: generate from the scaffold, write the ingest part, build the index, register
The author keeps a document search server per domain, such as product manuals and public clinical guidelines. All are built from the same scaffold and registered so that Claude Code can call them from any project.
No external service is involved: SQLite full-text search and a locally run embedding model are all it needs, so documents never leave the machine.
The full workflow
| Task | Who | Inputs | Outputs |
|---|---|---|---|
| 1. Resolve model | Device ledger MCPdevice-assets | — | Model number |
| 2. Find page | Main session | Model number | Official page |
| 3. List PDFs | Fetch scriptfetch_manual.py | Official page | PDF links |
| 4. Fetch + OCR | Fetch script + OCR + cleanupfetch_manual.py + ocr_pdf.py | PDF links | Clean text, Manifest |
| 5. Rebuild index | Index + embedingest + embed | Clean text, Manifest | Index+vectors |
| 6. Test search | Manual search MCPmanuals-search | Index+vectors | Search test |
| 7. Write back | Fetch script + Device ledger MCPfetch_manual.py + device-assets | Search test | Ledger summary |
7 steps · 5 tools · 1 loop · 27 manuals registered, 25 indexed · 4,146 chunks
Claude Code judges which page is official; scripts do the fetching, OCR and indexing the same way every time; a run ends only when a Chinese question finds the new text.
- The rule of the split: judgement belongs to Claude Code, fixed work to scripts, which give the same result however often they run
- Steps 1–3 settle the right model and the official PDFs, steps 4–5 turn them into indexed text, steps 6–7 check and write back
- The search server itself was made from the shared semantic-search MCP template; this procedure fills it
- Clinical-guideline search uses the same template, with an ingest part that reads each PDF's text layer page by page
Project folders involved (4)
This workflow does not live in one folder: it runs across projects.
- (private) manuals folder
- Original manuals, clean text, the manifest, and the fetch, OCR and cleanup scripts
- semantic-mcp-builder (servers/manuals-search)
- The search server, generated from the shared semantic-search template with only the ingest part written
- home-assets plugin (manual-fetch skill)
- The author's home-assets plugin bundles this skill and the search MCP, so any folder can use them
- (private) device ledger
- The device ledger: model numbers come from it, and the manual summary goes back into it
Step 1 · Device ledger MCP
Resolve modeldevice_resolve
Get the exact model number from the device ledger.
- If the model is missing, ask the author or have them read the label on the device
- Manuals often do not carry over between models of the same series
- If already collected, nothing is fetched again; only missing languages or new editions are added
Common misconceptionGet the model wrong and everything after it is wasted
| Outputs | Model number |
Step 2 · Main session
Find pageweb search
Find the manual page on the maker's own site.
- Only the maker's own domain counts; third-party manual aggregators are never used
- Their PDFs may be re-laid-out, missing pages, or for another model
- When unsure, the candidates are shown to the author to decide
Claude CodeThis is the one judgement call, so the main session does it
| Inputs | Model number |
| Outputs | Official page |
Step 3 · Fetch script
List PDFsdiscover
Parse the page and list every direct PDF link.
- URLs are never guessed from naming patterns: three guessed ones once all turned out not to exist
- Of a manual's language versions only one is kept; adding them all dilutes search
- Language priority: Chinese, then Japanese, then English
| Inputs | Official page |
| Outputs | PDF links |
Step 4 · Fetch script + OCR + cleanup
Fetch + OCRtext / OCR
Download it, read the text layer or run OCR, and write clean text plus a manifest entry.
- The text layer is used if present; otherwise each page goes through OCR
- PDFs whose text layer exists but comes out as garbage are detected and sent to OCR automatically
- Cleanup only drops garbled lines and never alters wording; Chinese search terms in the manifest let Chinese questions reach Japanese originals
Common misconceptionExtractable is not the same as readable: some PDFs give clean English but garbled Chinese
| Inputs | PDF links |
| Outputs | Clean text, Manifest |
Step 5 · Index + embed
Rebuild index--rebuild
Rebuild the index and the vectors.
- Check that "N ingested" equals the number of entries that have text
- If the numbers disagree, stop and investigate before going on
- Each document starts with a block of title plus Chinese and Japanese search terms, so questions in either language can hit
| Inputs | Clean text, Manifest |
| Outputs | Index+vectors |
Step 6 · Manual search MCP
Test searchsearch
Ask a concrete question about the device in Chinese and check that it hits the new text.
- Also check that the text that comes back is not garbled
- Results carry page numbers, leading back to the page in the original PDF
- Documents whose OCR has not been proofread by a person come with an automatic "check numbers against the original" warning
Common misconceptionNo hit means not done; it is never reported as success
| Inputs | Index+vectors |
| Outputs | Search test |
Step 7 · Fetch script + Device ledger MCP
Write backsync-device
Align the status with what is really indexed and write a summary back to the device ledger.
- Only four fields go into the ledger: count, pages, indexed or not, official page
- The official page is the vendor's manual support page, which outlives individual PDF links
- The device ledger is private; serial numbers and the like never enter the manual side
| Inputs | Search test |
| Outputs | Ledger summary |
Loops and rework
- No hit or garbled text → step 4: Fetch another language version or switch to OCR, rebuild the index and ask again
Key points
Never rewrite the original. Image-only PDFs are read with OCR, and the cleaned index text only drops garbled lines without altering wording. Page markers are kept so every hit leads back to the source document and page.
Treat zero documents as a failure. If ingest brings in nothing, it stops with an error instead of quietly serving an empty index. Unchanged documents are skipped by comparing a source signature.
Check that rephrased questions hit before relying on it. After registration, start-up, the tool list and a real search are tested, and the acceptance test is that a question not using the document's own words still finds the right passage.