document-mcp 4.1.4 → 4.1.5
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 +1 -1
- package/dist/bin.js +6 -29
- package/dist/index.cjs +5 -28
- package/dist/index.js +6 -29
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -214,7 +214,7 @@ Every tool that takes or produces document bytes goes through the same two hybri
|
|
|
214
214
|
| `pdf_inspect` | Parses a PDF and reports a summary (page count, per-page size and item-kind histogram, metadata, embedded image formats), or with `full: true` the entire parsed `LayoutDocument` as plain JSON — no `$schema` stamp, since that family moved to `pdf-codec` at `document-schema.js` 4.0.0 and lost its schema-stamped envelope. |
|
|
215
215
|
| `odm_to_pdf` | Converts a `.odm` (ODF master document) to PDF. A `.odm` never carries its chapters' content inline, so each chapter resolves via a caller-supplied `chapters` href-to-document map and/or a `chaptersDir` searched by basename. |
|
|
216
216
|
| `from_package` | Rebuilds real document bytes in a target format from a `DocumentTree` previously serialised to JSON (e.g. by a conversion tool's own `onDocument`/package-dump step). Only a package genuinely written by a current dump round-trips: the `$schema` URI it carries pins the `document-schema.js` release that wrote it, and a pre-4.0.0 dump (the flat `{ formatVersion, content, pages }` envelope) is rejected with an error naming the pinned release, the flat-to-tree change, and the remedy — a layout-document dump gets its own pointer, naming the move to `pdf-codec`. |
|
|
217
|
-
| `outline_document` | Projects a document's own table of contents as structured JSON: groups (`{ text, level, children }`) for headings, list items, slides, sheets, and draw pages, leaves (`{ kind, text }`) for the content between them. The outline is over the source's own content — read
|
|
217
|
+
| `outline_document` | Projects a document's own table of contents as structured JSON: groups (`{ text, level, children }`) for headings, list items, slides, sheets, and draw pages, leaves (`{ kind, text }`) for the content between them. The outline is over the source's own native content — read directly via `documents.js`'s `readNativeDocumentTree` (no bridging conversion, no discarded output bytes) and built by `document-outline.js`'s `buildOutline`. |
|
|
218
218
|
| `odb_tables` | Lists every table an embedded `.odb` database declares — column names, types, and row data — across every storage tier `documents.js` supports (HSQLDB TEXT/CACHED/BINARY, Firebird gbak backups). |
|
|
219
219
|
| `odb_forms` | Lists every form an `.odb` database declares, with each form's own data source and field-bound controls. |
|
|
220
220
|
| `odb_reports` | Lists every report an `.odb` database declares, with each report's own data-source command, band/group structure, and `rpt:` formula expressions. |
|
package/dist/bin.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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, documentSchemaKindOf, evaluateSelect, extractSourceFontsForFormat, 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, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readNativeDocumentTree, 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
|
import { buildOutline, isOutlineNode, outlineLeafText } from "document-outline.js";
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version = "4.1.
|
|
11
|
+
var version = "4.1.5";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/io/document-input.ts
|
|
14
14
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -776,20 +776,6 @@ function registerOdmTools(server) {
|
|
|
776
776
|
}
|
|
777
777
|
//#endregion
|
|
778
778
|
//#region src/tools/outline.ts
|
|
779
|
-
const OUTLINE_PROBE_TARGETS = {
|
|
780
|
-
csv: "ods",
|
|
781
|
-
docx: "odt",
|
|
782
|
-
odf: "pdf",
|
|
783
|
-
odg: "pdf",
|
|
784
|
-
odt: "docx",
|
|
785
|
-
odp: "pptx",
|
|
786
|
-
ods: "xlsx",
|
|
787
|
-
markdown: "docx",
|
|
788
|
-
pdf: "docx",
|
|
789
|
-
pptx: "odp",
|
|
790
|
-
svg: "odg",
|
|
791
|
-
xlsx: "ods"
|
|
792
|
-
};
|
|
793
779
|
function leafKind(leaf) {
|
|
794
780
|
if ("kind" in leaf) return leaf.kind;
|
|
795
781
|
if ("mathml" in leaf) return "formula";
|
|
@@ -806,27 +792,18 @@ function toOutlineJson(children) {
|
|
|
806
792
|
});
|
|
807
793
|
}
|
|
808
794
|
function registerOutlineTools(server) {
|
|
809
|
-
const converter = createLocalDocumentConverter();
|
|
810
795
|
server.registerTool("outline_document", {
|
|
811
796
|
title: "Outline document",
|
|
812
|
-
description: "Projects a document's table of contents as a structured outline: reads the source
|
|
797
|
+
description: "Projects a document's table of contents as a structured outline: reads the source's own native DocumentTree directly (documents.js's readNativeDocumentTree -- no bridging conversion, no discarded output bytes) and runs document-outline.js's buildOutline over it. Groups carry { text, level, children } (a heading's, list item's, slide's, sheet's, or page's own label plus nested children); leaves carry { kind, text }.",
|
|
813
798
|
inputSchema: z.object({ source: DocumentInputSchema.describe("The document to outline.") })
|
|
814
799
|
}, async ({ source }, ctx) => {
|
|
815
800
|
const { signal } = ctx.mcpReq;
|
|
816
801
|
const { bytes, format } = await resolveDocumentInput(source, { signal });
|
|
817
|
-
const
|
|
818
|
-
const pkg = (await converter.convert({
|
|
819
|
-
source: {
|
|
820
|
-
format,
|
|
821
|
-
bytes
|
|
822
|
-
},
|
|
823
|
-
targetFormat
|
|
824
|
-
}, { signal })).package;
|
|
825
|
-
if (pkg === void 0) throw new Error(`the ${format}-to-${targetFormat} conversion reported no DocumentTree, so there is no tree to outline`);
|
|
802
|
+
const tree = readNativeDocumentTree(format, bytes, { signal });
|
|
826
803
|
const structuredContent = {
|
|
827
804
|
sourceFormat: format,
|
|
828
|
-
kind:
|
|
829
|
-
outline: toOutlineJson(buildOutline(
|
|
805
|
+
kind: tree.kind,
|
|
806
|
+
outline: toOutlineJson(buildOutline(tree))
|
|
830
807
|
};
|
|
831
808
|
return {
|
|
832
809
|
content: [{
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ let node_fs = require("node:fs");
|
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
let document_outline_js = require("document-outline.js");
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "4.1.
|
|
10
|
+
var version = "4.1.5";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/io/document-input.ts
|
|
13
13
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -775,20 +775,6 @@ function registerOdmTools(server) {
|
|
|
775
775
|
}
|
|
776
776
|
//#endregion
|
|
777
777
|
//#region src/tools/outline.ts
|
|
778
|
-
const OUTLINE_PROBE_TARGETS = {
|
|
779
|
-
csv: "ods",
|
|
780
|
-
docx: "odt",
|
|
781
|
-
odf: "pdf",
|
|
782
|
-
odg: "pdf",
|
|
783
|
-
odt: "docx",
|
|
784
|
-
odp: "pptx",
|
|
785
|
-
ods: "xlsx",
|
|
786
|
-
markdown: "docx",
|
|
787
|
-
pdf: "docx",
|
|
788
|
-
pptx: "odp",
|
|
789
|
-
svg: "odg",
|
|
790
|
-
xlsx: "ods"
|
|
791
|
-
};
|
|
792
778
|
function leafKind(leaf) {
|
|
793
779
|
if ("kind" in leaf) return leaf.kind;
|
|
794
780
|
if ("mathml" in leaf) return "formula";
|
|
@@ -805,27 +791,18 @@ function toOutlineJson(children) {
|
|
|
805
791
|
});
|
|
806
792
|
}
|
|
807
793
|
function registerOutlineTools(server) {
|
|
808
|
-
const converter = (0, documents_js.createLocalDocumentConverter)();
|
|
809
794
|
server.registerTool("outline_document", {
|
|
810
795
|
title: "Outline document",
|
|
811
|
-
description: "Projects a document's table of contents as a structured outline: reads the source
|
|
796
|
+
description: "Projects a document's table of contents as a structured outline: reads the source's own native DocumentTree directly (documents.js's readNativeDocumentTree -- no bridging conversion, no discarded output bytes) and runs document-outline.js's buildOutline over it. Groups carry { text, level, children } (a heading's, list item's, slide's, sheet's, or page's own label plus nested children); leaves carry { kind, text }.",
|
|
812
797
|
inputSchema: zod.z.object({ source: DocumentInputSchema.describe("The document to outline.") })
|
|
813
798
|
}, async ({ source }, ctx) => {
|
|
814
799
|
const { signal } = ctx.mcpReq;
|
|
815
800
|
const { bytes, format } = await resolveDocumentInput(source, { signal });
|
|
816
|
-
const
|
|
817
|
-
const pkg = (await converter.convert({
|
|
818
|
-
source: {
|
|
819
|
-
format,
|
|
820
|
-
bytes
|
|
821
|
-
},
|
|
822
|
-
targetFormat
|
|
823
|
-
}, { signal })).package;
|
|
824
|
-
if (pkg === void 0) throw new Error(`the ${format}-to-${targetFormat} conversion reported no DocumentTree, so there is no tree to outline`);
|
|
801
|
+
const tree = (0, documents_js.readNativeDocumentTree)(format, bytes, { signal });
|
|
825
802
|
const structuredContent = {
|
|
826
803
|
sourceFormat: format,
|
|
827
|
-
kind:
|
|
828
|
-
outline: toOutlineJson((0, document_outline_js.buildOutline)(
|
|
804
|
+
kind: tree.kind,
|
|
805
|
+
outline: toOutlineJson((0, document_outline_js.buildOutline)(tree))
|
|
829
806
|
};
|
|
830
807
|
return {
|
|
831
808
|
content: [{
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
-
import { DocumentFormatSchema, OdbReportNotSpecifiedError, OdmUnresolvedSectionError, UnrecognizedDocumentSchemaError, base64ToBytes, buildDocumentBytes, bytesToBase64, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, documentSchemaKindOf, evaluateSelect, extractSourceFontsForFormat, 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, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readNativeDocumentTree, 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
|
import { buildOutline, isOutlineNode, outlineLeafText } from "document-outline.js";
|
|
8
8
|
//#region package.json
|
|
9
|
-
var version = "4.1.
|
|
9
|
+
var version = "4.1.5";
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/io/document-input.ts
|
|
12
12
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -774,20 +774,6 @@ function registerOdmTools(server) {
|
|
|
774
774
|
}
|
|
775
775
|
//#endregion
|
|
776
776
|
//#region src/tools/outline.ts
|
|
777
|
-
const OUTLINE_PROBE_TARGETS = {
|
|
778
|
-
csv: "ods",
|
|
779
|
-
docx: "odt",
|
|
780
|
-
odf: "pdf",
|
|
781
|
-
odg: "pdf",
|
|
782
|
-
odt: "docx",
|
|
783
|
-
odp: "pptx",
|
|
784
|
-
ods: "xlsx",
|
|
785
|
-
markdown: "docx",
|
|
786
|
-
pdf: "docx",
|
|
787
|
-
pptx: "odp",
|
|
788
|
-
svg: "odg",
|
|
789
|
-
xlsx: "ods"
|
|
790
|
-
};
|
|
791
777
|
function leafKind(leaf) {
|
|
792
778
|
if ("kind" in leaf) return leaf.kind;
|
|
793
779
|
if ("mathml" in leaf) return "formula";
|
|
@@ -804,27 +790,18 @@ function toOutlineJson(children) {
|
|
|
804
790
|
});
|
|
805
791
|
}
|
|
806
792
|
function registerOutlineTools(server) {
|
|
807
|
-
const converter = createLocalDocumentConverter();
|
|
808
793
|
server.registerTool("outline_document", {
|
|
809
794
|
title: "Outline document",
|
|
810
|
-
description: "Projects a document's table of contents as a structured outline: reads the source
|
|
795
|
+
description: "Projects a document's table of contents as a structured outline: reads the source's own native DocumentTree directly (documents.js's readNativeDocumentTree -- no bridging conversion, no discarded output bytes) and runs document-outline.js's buildOutline over it. Groups carry { text, level, children } (a heading's, list item's, slide's, sheet's, or page's own label plus nested children); leaves carry { kind, text }.",
|
|
811
796
|
inputSchema: z.object({ source: DocumentInputSchema.describe("The document to outline.") })
|
|
812
797
|
}, async ({ source }, ctx) => {
|
|
813
798
|
const { signal } = ctx.mcpReq;
|
|
814
799
|
const { bytes, format } = await resolveDocumentInput(source, { signal });
|
|
815
|
-
const
|
|
816
|
-
const pkg = (await converter.convert({
|
|
817
|
-
source: {
|
|
818
|
-
format,
|
|
819
|
-
bytes
|
|
820
|
-
},
|
|
821
|
-
targetFormat
|
|
822
|
-
}, { signal })).package;
|
|
823
|
-
if (pkg === void 0) throw new Error(`the ${format}-to-${targetFormat} conversion reported no DocumentTree, so there is no tree to outline`);
|
|
800
|
+
const tree = readNativeDocumentTree(format, bytes, { signal });
|
|
824
801
|
const structuredContent = {
|
|
825
802
|
sourceFormat: format,
|
|
826
|
-
kind:
|
|
827
|
-
outline: toOutlineJson(buildOutline(
|
|
803
|
+
kind: tree.kind,
|
|
804
|
+
outline: toOutlineJson(buildOutline(tree))
|
|
828
805
|
};
|
|
829
806
|
return {
|
|
830
807
|
content: [{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-mcp",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5",
|
|
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": {
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"packageManager": "pnpm@11.6.0",
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
90
|
-
"document-outline.js": "^3.
|
|
91
|
-
"documents.js": "^6.
|
|
90
|
+
"document-outline.js": "^3.2.0",
|
|
91
|
+
"documents.js": "^6.2.0",
|
|
92
92
|
"zod": "^4.2.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@vitest/coverage-v8": "^4.1.10",
|
|
100
100
|
"eslint": "^10.8.0",
|
|
101
101
|
"husky": "^9.1.7",
|
|
102
|
-
"odf.js": "^6.1.
|
|
102
|
+
"odf.js": "^6.1.2",
|
|
103
103
|
"publint": "^0.3.22",
|
|
104
104
|
"semantic-release": "^25.0.8",
|
|
105
105
|
"tsdown": "^0.22.14",
|