Semantic document search MCP workflow

Turns document sets such as manuals and clinical guidelines into meaning-based search MCPs using one shared scaffold.

#MCP#full-text search#vector search#SQLite FTS5#scaffold
Shared scaffold for document search MCPs

WorkflowShared scaffold for document search MCPs

Research & knowledge bases Claude Code / Claude Desktop

A pattern that extracts text from PDF or web documents and serves it through a search server (MCP) combining full-text and vector search. Product manuals, public clinical guidelines and other domains reuse it, rewriting only the ingest part.

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

TaskWhoInputsOutputs
1. Resolve modelDevice ledger MCPdevice-assets—Model number
2. Find pageMain sessionModel numberOfficial page
3. List PDFsFetch scriptfetch_manual.pyOfficial pagePDF links
4. Fetch + OCRFetch script + OCR + cleanupfetch_manual.py + ocr_pdf.pyPDF linksClean text, Manifest
5. Rebuild indexIndex + embedingest + embedClean text, ManifestIndex+vectors
6. Test searchManual search MCPmanuals-searchIndex+vectorsSearch test
7. Write backFetch script + Device ledger MCPfetch_manual.py + device-assetsSearch testLedger summary
Shared scaffold for document search MCPs

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
Resolve model

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

OutputsModel number
Find page

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

InputsModel number
OutputsOfficial page
List PDFs

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
InputsOfficial page
OutputsPDF links
Fetch + OCR

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

InputsPDF links
OutputsClean text, Manifest
Rebuild index

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
InputsClean text, Manifest
OutputsIndex+vectors
Test search

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

InputsIndex+vectors
OutputsSearch test
Write back

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
InputsSearch test
OutputsLedger 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.