document-mcp 1.5.100 → 1.5.102

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/dist/bin.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
3
3
  import { McpServer } from "@modelcontextprotocol/server";
4
- import { DocumentFormatSchema, OdbReportNotSpecifiedError, OdmUnresolvedSectionError, UnrecognizedDocumentSchemaError, base64ToBytes, buildDocumentBytes, bytesToBase64, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, evaluateSelect, extractSourceFontsForFormat, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
4
+ import { DocumentFormatSchema, OdbReportNotSpecifiedError, OdmUnresolvedSectionError, UnrecognizedDocumentSchemaError, base64ToBytes, buildDocumentBytes, bytesToBase64, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, documentSchemaKindOf, evaluateSelect, extractSourceFontsForFormat, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
5
5
  import { z } from "zod";
6
6
  import { readFile, writeFile } from "node:fs/promises";
7
7
  import { existsSync, readFileSync } from "node:fs";
8
8
  import { basename, join } from "node:path";
9
9
  //#region package.json
10
- var version = "1.5.100";
10
+ var version = "1.5.102";
11
11
  //#endregion
12
12
  //#region src/io/document-input.ts
13
13
  const EXTENSION_TO_FORMAT = {
@@ -319,6 +319,13 @@ function errorResult(message) {
319
319
  isError: true
320
320
  };
321
321
  }
322
+ function isRecord(value) {
323
+ return typeof value === "object" && value !== null && !Array.isArray(value);
324
+ }
325
+ function isLegacyPackageDump(value) {
326
+ if (!isRecord(value) || documentSchemaKindOf(value) !== "DocumentPackage") return false;
327
+ return value.formatVersion === 1 || "layout" in value && value.formatVersion !== 2;
328
+ }
322
329
  function registerFromPackageTools(server) {
323
330
  server.registerTool("from_package", {
324
331
  title: "Build document from package",
@@ -329,10 +336,10 @@ function registerFromPackageTools(server) {
329
336
  output: DocumentOutputSchema.optional().describe("Where to write the resulting document. Omit entirely (or omit outputPath within it) to receive the bytes inline instead.")
330
337
  })
331
338
  }, async ({ source, targetFormat, output }) => {
339
+ let parsed;
332
340
  try {
333
341
  const bytes = await readSourceBytes(source);
334
342
  const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
335
- let parsed;
336
343
  try {
337
344
  parsed = JSON.parse(text);
338
345
  } catch (error) {
@@ -350,6 +357,8 @@ function registerFromPackageTools(server) {
350
357
  };
351
358
  } catch (error) {
352
359
  if (error instanceof UnrecognizedDocumentSchemaError) return errorResult("'source' has no recognised $schema -- only a file carrying a real DocumentPackage (e.g. written by a caller's own --dump-package-equivalent step) can be read back by this tool");
360
+ if (error instanceof z.ZodError && isLegacyPackageDump(parsed)) return errorResult("'source' is a DocumentPackage dump in the old formatVersion 1 shape: a 'layout' half beside 'content'. documents.js 2.0.0 fused the two into formatVersion 2 ('content' + 'pages', with per-node 'frames' carrying the layout positions) and no longer parses the old shape -- regenerate the dump with a current documents.js (e.g. re-run the conversion whose package dump produced it) and read that back instead");
361
+ if (error instanceof z.ZodError) return errorResult(`'source' failed ${documentSchemaKindOf(parsed) ?? "document schema"} validation: ${error.message}`);
353
362
  return errorResult(error instanceof Error ? error.message : String(error));
354
363
  }
355
364
  });
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ let node_fs_promises = require("node:fs/promises");
6
6
  let node_fs = require("node:fs");
7
7
  let node_path = require("node:path");
8
8
  //#region package.json
9
- var version = "1.5.100";
9
+ var version = "1.5.102";
10
10
  //#endregion
11
11
  //#region src/io/document-input.ts
12
12
  const EXTENSION_TO_FORMAT = {
@@ -318,6 +318,13 @@ function errorResult(message) {
318
318
  isError: true
319
319
  };
320
320
  }
321
+ function isRecord(value) {
322
+ return typeof value === "object" && value !== null && !Array.isArray(value);
323
+ }
324
+ function isLegacyPackageDump(value) {
325
+ if (!isRecord(value) || (0, documents_js.documentSchemaKindOf)(value) !== "DocumentPackage") return false;
326
+ return value.formatVersion === 1 || "layout" in value && value.formatVersion !== 2;
327
+ }
321
328
  function registerFromPackageTools(server) {
322
329
  server.registerTool("from_package", {
323
330
  title: "Build document from package",
@@ -328,10 +335,10 @@ function registerFromPackageTools(server) {
328
335
  output: DocumentOutputSchema.optional().describe("Where to write the resulting document. Omit entirely (or omit outputPath within it) to receive the bytes inline instead.")
329
336
  })
330
337
  }, async ({ source, targetFormat, output }) => {
338
+ let parsed;
331
339
  try {
332
340
  const bytes = await readSourceBytes(source);
333
341
  const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
334
- let parsed;
335
342
  try {
336
343
  parsed = JSON.parse(text);
337
344
  } catch (error) {
@@ -349,6 +356,8 @@ function registerFromPackageTools(server) {
349
356
  };
350
357
  } catch (error) {
351
358
  if (error instanceof documents_js.UnrecognizedDocumentSchemaError) return errorResult("'source' has no recognised $schema -- only a file carrying a real DocumentPackage (e.g. written by a caller's own --dump-package-equivalent step) can be read back by this tool");
359
+ if (error instanceof zod.z.ZodError && isLegacyPackageDump(parsed)) return errorResult("'source' is a DocumentPackage dump in the old formatVersion 1 shape: a 'layout' half beside 'content'. documents.js 2.0.0 fused the two into formatVersion 2 ('content' + 'pages', with per-node 'frames' carrying the layout positions) and no longer parses the old shape -- regenerate the dump with a current documents.js (e.g. re-run the conversion whose package dump produced it) and read that back instead");
360
+ if (error instanceof zod.z.ZodError) return errorResult(`'source' failed ${(0, documents_js.documentSchemaKindOf)(parsed) ?? "document schema"} validation: ${error.message}`);
352
361
  return errorResult(error instanceof Error ? error.message : String(error));
353
362
  }
354
363
  });
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { McpServer } from "@modelcontextprotocol/server";
2
- import { DocumentFormatSchema, OdbReportNotSpecifiedError, OdmUnresolvedSectionError, UnrecognizedDocumentSchemaError, base64ToBytes, buildDocumentBytes, bytesToBase64, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, evaluateSelect, extractSourceFontsForFormat, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
2
+ import { DocumentFormatSchema, OdbReportNotSpecifiedError, OdmUnresolvedSectionError, UnrecognizedDocumentSchemaError, base64ToBytes, buildDocumentBytes, bytesToBase64, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, documentSchemaKindOf, evaluateSelect, extractSourceFontsForFormat, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
3
3
  import { z } from "zod";
4
4
  import { readFile, writeFile } from "node:fs/promises";
5
5
  import { existsSync, readFileSync } from "node:fs";
6
6
  import { basename, join } from "node:path";
7
7
  //#region package.json
8
- var version = "1.5.100";
8
+ var version = "1.5.102";
9
9
  //#endregion
10
10
  //#region src/io/document-input.ts
11
11
  const EXTENSION_TO_FORMAT = {
@@ -317,6 +317,13 @@ function errorResult(message) {
317
317
  isError: true
318
318
  };
319
319
  }
320
+ function isRecord(value) {
321
+ return typeof value === "object" && value !== null && !Array.isArray(value);
322
+ }
323
+ function isLegacyPackageDump(value) {
324
+ if (!isRecord(value) || documentSchemaKindOf(value) !== "DocumentPackage") return false;
325
+ return value.formatVersion === 1 || "layout" in value && value.formatVersion !== 2;
326
+ }
320
327
  function registerFromPackageTools(server) {
321
328
  server.registerTool("from_package", {
322
329
  title: "Build document from package",
@@ -327,10 +334,10 @@ function registerFromPackageTools(server) {
327
334
  output: DocumentOutputSchema.optional().describe("Where to write the resulting document. Omit entirely (or omit outputPath within it) to receive the bytes inline instead.")
328
335
  })
329
336
  }, async ({ source, targetFormat, output }) => {
337
+ let parsed;
330
338
  try {
331
339
  const bytes = await readSourceBytes(source);
332
340
  const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
333
- let parsed;
334
341
  try {
335
342
  parsed = JSON.parse(text);
336
343
  } catch (error) {
@@ -348,6 +355,8 @@ function registerFromPackageTools(server) {
348
355
  };
349
356
  } catch (error) {
350
357
  if (error instanceof UnrecognizedDocumentSchemaError) return errorResult("'source' has no recognised $schema -- only a file carrying a real DocumentPackage (e.g. written by a caller's own --dump-package-equivalent step) can be read back by this tool");
358
+ if (error instanceof z.ZodError && isLegacyPackageDump(parsed)) return errorResult("'source' is a DocumentPackage dump in the old formatVersion 1 shape: a 'layout' half beside 'content'. documents.js 2.0.0 fused the two into formatVersion 2 ('content' + 'pages', with per-node 'frames' carrying the layout positions) and no longer parses the old shape -- regenerate the dump with a current documents.js (e.g. re-run the conversion whose package dump produced it) and read that back instead");
359
+ if (error instanceof z.ZodError) return errorResult(`'source' failed ${documentSchemaKindOf(parsed) ?? "document schema"} validation: ${error.message}`);
351
360
  return errorResult(error instanceof Error ? error.message : String(error));
352
361
  }
353
362
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-mcp",
3
- "version": "1.5.100",
3
+ "version": "1.5.102",
4
4
  "description": "MCP (Model Context Protocol) server exposing documents.js's document-conversion, .odb, metadata, and font tooling as MCP tools.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -85,7 +85,7 @@
85
85
  "packageManager": "pnpm@11.6.0",
86
86
  "dependencies": {
87
87
  "@modelcontextprotocol/server": "^2.0.0",
88
- "documents.js": "^2.0.0",
88
+ "documents.js": "^2.1.0",
89
89
  "zod": "^4.2.0"
90
90
  },
91
91
  "devDependencies": {