@retiform/paperless-mcp 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,8 +30,9 @@ way to ask for a slice. This fork adds bounded reads:
30
30
  instead of returning a hard 400.
31
31
 
32
32
  We also fix the build so it is idempotent (`tsc` no longer consumes its own
33
- `.d.ts` output on a rebuild). The bounded-read work is offered upstream by pull
34
- request; it is published here in the meantime because agentic clients need it now.
33
+ `.d.ts` output on a rebuild). Upstream was unable to take this work, and agentic
34
+ clients need it now, so it is published here. The delta from `upstream-v2.2.1`
35
+ is small and self-contained if upstream ever wants it.
35
36
 
36
37
  ## Quick Start
37
38
 
@@ -273,6 +273,27 @@ function withDocumentClient(api, run) {
273
273
  });
274
274
  strict_1.default.ok(passage.passage.includes("fish and chips"), `offset ${passage.offset}`);
275
275
  });
276
+ (0, node_test_1.test)("decodes numeric character references so the longest anchor is not skipped", () => {
277
+ // Live shape 3 (2026-11-05, doc 5 of the Kongokai series): the server
278
+ // returns ' for an apostrophe in its highlight HTML. The decoder
279
+ // handled ' and ' but not the numeric/hex forms, so the LONGEST
280
+ // candidate phrase carried a literal entity that never occurs in the
281
+ // stored text. indexOf returned -1 and the search fell through to a SHORT
282
+ // phrase that also occurs near the document head, so the reported offset
283
+ // pointed at a region containing none of the hit.
284
+ const early = "[SPEAKER_01] This is unrelated chatter near the head. ";
285
+ const filler = "z".repeat(1500);
286
+ const hit = "This is pre-living, pre-living, pre-manifesting, pre-living the goal. [SPEAKER_01] I" +
287
+ String.fromCharCode(39) +
288
+ "m getting familiar with it.";
289
+ const doc = (0, paperlessApi_1.createDocument)({ content: early + filler + hit });
290
+ const passage = (0, documents_1.buildSearchPassage)(doc, ["pre", "manifesting"], 600, {
291
+ score: 9.71,
292
+ highlights: "This is <b>pre</b>-living, <b>pre</b>-living, <b>pre</b>-<b>manifesting</b>, <b>pre</b>-living the goal. [SPEAKER_01] I&#x27;m getting familiar with it.",
293
+ });
294
+ strict_1.default.ok(passage.passage.includes("pre-manifesting"), "window anchored at " + passage.offset + " missed the hit");
295
+ strict_1.default.ok(passage.offset >= early.length, "should anchor on the decoded long phrase, not a short phrase near the head");
296
+ });
276
297
  (0, node_test_1.test)("skips very short highlight matches that cannot anchor", () => {
277
298
  const doc = (0, paperlessApi_1.createDocument)({ content: `head a b here ${"w".repeat(800)} a rare anchoring phrase tail` });
278
299
  const passage = (0, documents_1.buildSearchPassage)(doc, ["a", "rare"], 300, {
@@ -166,7 +166,9 @@ function extractHighlightPhrases(highlights) {
166
166
  .replace(/&lt;/g, "<")
167
167
  .replace(/&gt;/g, ">")
168
168
  .replace(/&quot;/g, '"')
169
- .replace(/&#39;|&apos;/g, "'")
169
+ .replace(/&#(\d+);/g, (_, d) => String.fromCharCode(Number(d)))
170
+ .replace(/&#[xX]([0-9a-fA-F]+);/g, (_, h) => String.fromCharCode(parseInt(h, 16)))
171
+ .replace(/&apos;/g, String.fromCharCode(39))
170
172
  .replace(/&nbsp;/g, " ")
171
173
  .replace(/&amp;/g, "&")
172
174
  .replace(/\s+/g, " ")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retiform/paperless-mcp",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "MCP server for Paperless-NGX with bounded content reads - ranged document windows and passage search so agents never flood their context.",
5
5
  "main": "build/index.js",
6
6
  "bin": {
package/paperless-mcp.dxt CHANGED
Binary file