Skip to content

v3.5.0: Corpus keyword search, from the first call

Choose a tag to compare

@jztan jztan released this 03 Oct 02:29
· 133 commits to develop since this release

Highlights

Corpus keyword search, from the first call

Three changes to pdf_corpus_search make the keyword arm a first-class ranking over a folder of PDFs, and make it available from the very first call.

Every document on the first call (#73). The first call over a new folder used to search only the documents whose embeddings finished inside the time budget: on a 100-PDF test set, a cold first call took about 50 s and searched 42 of the 100. Text is now warmed for every document before any is embedded, and while embeddings are still pending, mode="auto" answers by keyword across all of them, in about 23 s.

One ranking across the whole corpus (#70). The keyword arm used to rank pages inside each document and interleave the lists, so the top of the ranking held one page per document and a document that clearly matched best could not take a second slot. It now runs one BM25 ranking over every page of the corpus: pages holding the query as a phrase first, then pages holding every term, and, only when no document holds every term, pages holding some of them. Keyword score is now comparable across documents. CJK queries and German FTS mode keep the per-document ranking.

Full matches count in hybrid (#72). When the keyword arm matched the query as a phrase or every term, its ranking now counts double in fusion, so a page matching every term no longer falls below each document's best semantic page. Partial matches keep equal weight, so question-shaped queries rank exactly as before.

On the 184-query corpus benchmark over 100 documents:

before after
cold first answer, page NDCG@10 0.260 0.468 (+0.208, CI [+0.150, +0.266])
cold first answer, doc-hit@3 0.446 0.777
cold first answer, wall time ~50 s, 42 of 100 docs ~23 s, all 100
hybrid page NDCG@10, corpus-wide ranking 0.408 0.462 (+0.054, CI [+0.030, +0.080])
hybrid page NDCG@10, full-match weighting on top +0.022 (CI [+0.011, +0.034]); +0.073 on multi-document queries
keyword page NDCG@10 0.338 0.465
hybrid latency 0.31 s/query 0.20 s/query

Document routing is unchanged (doc-hit@3 0.848 vs 0.842, CI includes zero). The evidence an agent reads moved less than the ranking: with the default paragraph excerpts at a 2,000-token budget, answer-span recall rose on question-shaped queries (0.289 to 0.313), exact-term queries (0.806 to 0.839) and multi-document queries (0.622 to 0.689), held on the rest, and no query lost evidence.

The response says which state it is in. A keyword-only first answer carries semantic_pending, keyword_match, a one-line hint, embeddings_pending, and next_call, the pdf_corpus_warm call that finishes the embeddings; warm_complete stays false until every document is embedded, and from then on the ranking is the hybrid one. In hybrid mode a page the keyword arm found on partial matches alone counts as a semantic hit for its excerpt and low_confidence.

Fixes

hidden_text no longer fires on ordinary visible text

Since 3.0.0 the flag, along with hidden_text_detected and the pdf_info(content_trust=true) counts, was true on most pages of many documents: every hit for "total revenue" in Microsoft's FY2024 10-K, and every page of some federal reports. Four causes are fixed: a font set at 1 pt and scaled up read as unreadably small, white text on a coloured band was compared against a white page because fill shapes were never read, a header drawn twice (once visible, once invisible) counted as hidden, and runs of blank spaces counted as off-page text.

Across 27 real PDFs (24 10-K filings, an annual report, a Federal Reserve report and a statute), flagged pages fell from 1,092 to 37. Every hidden-text attack in the test corpus is still caught.

The server no longer exits when a second instance starts on the same cache (#74)

Claude Desktop launches the server twice at once. On Windows, when both instances removed the same expired image files, the one that lost the race got PermissionError and exited before answering initialize, so the client reported "Couldn't start". Removing a cached image or render file is now best-effort everywhere: a file that cannot be deleted is left behind while its cache rows still go, and a failed cleanup at startup is logged instead of stopping the server.

Also in this release

Added

  • Every keyword-mode response from pdf_search and pdf_corpus_search now carries keyword_match: "full", "partial" (hits may lack some of the words, as when a query of three or more words that no page fully matches is retried OR-joined) or "none". It appears whenever search_mode is "keyword", including mode="auto" answered by keyword. Ranking is unchanged.

Changed

  • With excerpt_style="paragraph" (the default for pdf_search and pdf_corpus_search), a list's lead-in and its items now count as one unit. When the lead-in wins, or the list as a whole matches the query better than the block that won, the excerpt is the lead-in plus the items with one bbox covering them; a single matching item is still returned alone. On 22 list questions over public-domain government reports, paragraph excerpts held the answer for 17 instead of 13 with no question lost. Those excerpts are longer, since they carry the whole list.

Security

  • Bumped transitive urllib3 2.7.0 → 2.8.0 (CVE-2026-97687, -97688, -97689; reached via requests and fastembed) and pyjwt 2.13.0 → 2.15.1 (CVE-2026-101917, -101918, -102265 to -102274; reached via mcp[crypto]); lockfile-only, no change to pyproject.toml constraints, and the Claude Desktop bundle installs the locked versions.
  • Bumped pypdf 6.16.1 → 6.19.0 (PYSEC-2026-4153 to -4160; a direct dependency, used to read content streams on tiling-pattern pages). Lockfile-only, the pyproject.toml floor (>=5.0) is unchanged.

After upgrading

  • A first pdf_corpus_search over a not-yet-embedded folder answers by keyword with semantic_pending set and warm_complete still false; run the pdf_corpus_warm call given in next_call to finish the embeddings. pdf_corpus_warm reports a document whose embeddings have not started as "text_only".
  • Keyword score values in pdf_corpus_search are now comparable across documents, so they differ from the per-document scores of earlier releases.
  • Keyword-mode responses from pdf_search and pdf_corpus_search carry a new keyword_match field.
  • Cached hidden_text flags are recomputed on first use, so the first pdf_info(content_trust=true) or search over an already-cached document may report different counts.
  • Default paragraph excerpts that land in a list are longer, since they carry the lead-in plus the items under one bbox.

Contributors

  • @bbulkow: reported the startup crash when two instances clean one cache, with a reproduction script (#74)

Upgrading

Claude Desktop: download pdf-mcp.mcpb again and drag it onto
Settings > Extensions. It replaces the installed version in place.

Claude Code and other MCP clients:

uv tool upgrade pdf-mcp     # or: pipx upgrade pdf-mcp

(pip install -U pdf-mcp also works inside a virtual environment.)

Links