@retiform/paperless-mcp 2.3.2 → 2.3.4

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
@@ -848,14 +848,17 @@ Want to contribute or modify the server? Here's what you need to know:
848
848
  npm install
849
849
  ```
850
850
 
851
- 3. Make your changes to server.js
852
- 4. Test locally:
851
+ 3. Make your changes in `src/`
852
+ 4. Build and test locally:
853
853
  ```bash
854
- node server.js http://localhost:8000 your-test-token
854
+ npm run build
855
+ node build/index.js http://localhost:8000 your-test-token
855
856
  ```
856
857
 
858
+ Run the test suite with `npm test`.
859
+
857
860
  The server is built with:
858
- - [litemcp](https://github.com/wong2/litemcp): A TypeScript framework for building MCP servers
861
+ - [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk): the official TypeScript SDK for MCP servers
859
862
  - [zod](https://github.com/colinhacks/zod): TypeScript-first schema validation
860
863
 
861
864
  ## API Documentation
@@ -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.2",
3
+ "version": "2.3.4",
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