document-mcp 1.4.0 → 1.4.2
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 +10 -5
- package/dist/bin.js +4 -5
- package/dist/index.cjs +3 -4
- package/dist/index.js +4 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -54,11 +54,12 @@ Requires Node.js `>=20` and pnpm `11.6.0` (pinned via `packageManager` in `packa
|
|
|
54
54
|
|
|
55
55
|
```sh
|
|
56
56
|
pnpm install
|
|
57
|
-
pnpm build # tsdown -> dist/ (ESM + CJS + .d.ts)
|
|
58
|
-
pnpm typecheck # tsc --noEmit
|
|
59
|
-
pnpm lint # eslint . --fix --cache --max-warnings 0
|
|
60
|
-
pnpm test # vitest run --project unit
|
|
61
|
-
pnpm test:
|
|
57
|
+
pnpm build # turbo -> tsdown -> dist/ (ESM + CJS + .d.ts)
|
|
58
|
+
pnpm typecheck # turbo -> tsc --noEmit
|
|
59
|
+
pnpm lint # turbo -> eslint . --fix --cache --max-warnings 0
|
|
60
|
+
pnpm test # turbo -> vitest run --project unit
|
|
61
|
+
pnpm test:workers # turbo -> vitest under the real Cloudflare Workers runtime (workerd) via @cloudflare/vitest-pool-workers, driving createServer() through an in-memory JSON-RPC pair
|
|
62
|
+
pnpm test:smoke # turbo -> tsdown then vitest --project smoke -- spawns dist/bin.js as a real subprocess driven over genuine MCP stdio
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
Once published, run the server directly via `npx document-mcp` (stdio transport, no install step needed).
|
|
@@ -127,6 +128,10 @@ Every tool that takes or produces document bytes goes through the same two hybri
|
|
|
127
128
|
- [document-cli](https://github.com/ExaDev/document-cli) — the sibling CLI/TUI over the same library, whose toolchain this repository's scaffold mirrors.
|
|
128
129
|
- [Model Context Protocol](https://modelcontextprotocol.io) — the protocol this server implements, via [`@modelcontextprotocol/server`](https://www.npmjs.com/package/@modelcontextprotocol/server).
|
|
129
130
|
|
|
131
|
+
## Gotchas
|
|
132
|
+
|
|
133
|
+
- **Runtime dependencies are `documents.js` + `@modelcontextprotocol/server` + `zod` only; `pdf-codec` and `odf.js` are devDependencies (test-support only).** Every runtime reach into either — `ProvidedFont`/`FontSubstitution`/`describeFontFace`/the `WinAnsi` substitution shape — goes through `documents.js`'s own re-exports, so a published install pulls in no direct `pdf-codec`/`odf.js` dependency. `odf.js` survives in `devDependencies` solely because `src/test-support/odm-fixture.ts` and `src/test-support/embedded-font-fixture.ts` build real ODF package fixtures from its low-level XML primitives (`zipPackage`/`el`/`rootElement`), and `src/test-support/` is excluded from the `tsdown` build — only `src/index.ts` and `src/bin.ts` are entry points — so neither fixture module ever ships in `dist/`.
|
|
134
|
+
|
|
130
135
|
## License
|
|
131
136
|
|
|
132
137
|
MIT
|
package/dist/bin.js
CHANGED
|
@@ -1,14 +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, 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, 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
|
-
import { readFontFace } from "pdf-codec";
|
|
8
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
8
|
import { basename, join } from "node:path";
|
|
10
9
|
//#region package.json
|
|
11
|
-
var version = "1.4.
|
|
10
|
+
var version = "1.4.2";
|
|
12
11
|
//#endregion
|
|
13
12
|
//#region src/io/document-input.ts
|
|
14
13
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -252,7 +251,7 @@ function errorResult$1(message) {
|
|
|
252
251
|
isError: true
|
|
253
252
|
};
|
|
254
253
|
}
|
|
255
|
-
/** errorResult's counterpart for a caught exception: UnsupportedFontSourceFormatError (extractSourceFontsForFormat rejecting a format with no source-embedded-font concept -- xlsx/pdf/markdown/odf) and FontFaceParseError (
|
|
254
|
+
/** errorResult's counterpart for a caught exception: UnsupportedFontSourceFormatError (extractSourceFontsForFormat rejecting a format with no source-embedded-font concept -- xlsx/pdf/markdown/odf) and FontFaceParseError (describeFontFace rejecting bytes that are not a recognised sfnt font, or a .ttc collection) both carry a self-contained, already-actionable message, so there is nothing to add beyond surfacing it verbatim. */
|
|
256
255
|
function toErrorResult$1(error) {
|
|
257
256
|
return errorResult$1(error instanceof Error ? error.message : String(error));
|
|
258
257
|
}
|
|
@@ -291,7 +290,7 @@ function registerFontTools(server) {
|
|
|
291
290
|
}, async ({ source }) => {
|
|
292
291
|
try {
|
|
293
292
|
const { bytes, source: label } = await resolveFontFileInput(source);
|
|
294
|
-
const face =
|
|
293
|
+
const face = describeFontFace(bytes, label);
|
|
295
294
|
return jsonResult({
|
|
296
295
|
family: face.family,
|
|
297
296
|
bold: face.bold,
|
package/dist/index.cjs
CHANGED
|
@@ -3,11 +3,10 @@ let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
|
3
3
|
let documents_js = require("documents.js");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
6
|
-
let pdf_codec = require("pdf-codec");
|
|
7
6
|
let node_fs = require("node:fs");
|
|
8
7
|
let node_path = require("node:path");
|
|
9
8
|
//#region package.json
|
|
10
|
-
var version = "1.4.
|
|
9
|
+
var version = "1.4.2";
|
|
11
10
|
//#endregion
|
|
12
11
|
//#region src/io/document-input.ts
|
|
13
12
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -251,7 +250,7 @@ function errorResult$1(message) {
|
|
|
251
250
|
isError: true
|
|
252
251
|
};
|
|
253
252
|
}
|
|
254
|
-
/** errorResult's counterpart for a caught exception: UnsupportedFontSourceFormatError (extractSourceFontsForFormat rejecting a format with no source-embedded-font concept -- xlsx/pdf/markdown/odf) and FontFaceParseError (
|
|
253
|
+
/** errorResult's counterpart for a caught exception: UnsupportedFontSourceFormatError (extractSourceFontsForFormat rejecting a format with no source-embedded-font concept -- xlsx/pdf/markdown/odf) and FontFaceParseError (describeFontFace rejecting bytes that are not a recognised sfnt font, or a .ttc collection) both carry a self-contained, already-actionable message, so there is nothing to add beyond surfacing it verbatim. */
|
|
255
254
|
function toErrorResult$1(error) {
|
|
256
255
|
return errorResult$1(error instanceof Error ? error.message : String(error));
|
|
257
256
|
}
|
|
@@ -290,7 +289,7 @@ function registerFontTools(server) {
|
|
|
290
289
|
}, async ({ source }) => {
|
|
291
290
|
try {
|
|
292
291
|
const { bytes, source: label } = await resolveFontFileInput(source);
|
|
293
|
-
const face = (0,
|
|
292
|
+
const face = (0, documents_js.describeFontFace)(bytes, label);
|
|
294
293
|
return jsonResult({
|
|
295
294
|
family: face.family,
|
|
296
295
|
bold: face.bold,
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
-
import { DocumentFormatSchema, OdbReportNotSpecifiedError, OdmUnresolvedSectionError, UnrecognizedDocumentSchemaError, base64ToBytes, buildDocumentBytes, bytesToBase64, createLocalDocumentConverter, decodeOdbPackage, decodePackage, 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, 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
|
-
import { readFontFace } from "pdf-codec";
|
|
6
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
6
|
import { basename, join } from "node:path";
|
|
8
7
|
//#region package.json
|
|
9
|
-
var version = "1.4.
|
|
8
|
+
var version = "1.4.2";
|
|
10
9
|
//#endregion
|
|
11
10
|
//#region src/io/document-input.ts
|
|
12
11
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -250,7 +249,7 @@ function errorResult$1(message) {
|
|
|
250
249
|
isError: true
|
|
251
250
|
};
|
|
252
251
|
}
|
|
253
|
-
/** errorResult's counterpart for a caught exception: UnsupportedFontSourceFormatError (extractSourceFontsForFormat rejecting a format with no source-embedded-font concept -- xlsx/pdf/markdown/odf) and FontFaceParseError (
|
|
252
|
+
/** errorResult's counterpart for a caught exception: UnsupportedFontSourceFormatError (extractSourceFontsForFormat rejecting a format with no source-embedded-font concept -- xlsx/pdf/markdown/odf) and FontFaceParseError (describeFontFace rejecting bytes that are not a recognised sfnt font, or a .ttc collection) both carry a self-contained, already-actionable message, so there is nothing to add beyond surfacing it verbatim. */
|
|
254
253
|
function toErrorResult$1(error) {
|
|
255
254
|
return errorResult$1(error instanceof Error ? error.message : String(error));
|
|
256
255
|
}
|
|
@@ -289,7 +288,7 @@ function registerFontTools(server) {
|
|
|
289
288
|
}, async ({ source }) => {
|
|
290
289
|
try {
|
|
291
290
|
const { bytes, source: label } = await resolveFontFileInput(source);
|
|
292
|
-
const face =
|
|
291
|
+
const face = describeFontFace(bytes, label);
|
|
293
292
|
return jsonResult({
|
|
294
293
|
family: face.family,
|
|
295
294
|
bold: face.bold,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-mcp",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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,8 +85,7 @@
|
|
|
85
85
|
"packageManager": "pnpm@11.6.0",
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
88
|
-
"documents.js": "^1.
|
|
89
|
-
"pdf-codec": "^2.0.0",
|
|
88
|
+
"documents.js": "^1.95.1",
|
|
90
89
|
"zod": "^4.2.0"
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
@@ -105,6 +104,7 @@
|
|
|
105
104
|
"husky": "^9.1.7",
|
|
106
105
|
"lint-staged": "^17.3.0",
|
|
107
106
|
"odf.js": "^2.3.1",
|
|
107
|
+
"pdf-codec": "^2.1.3",
|
|
108
108
|
"publint": "^0.3.22",
|
|
109
109
|
"semantic-release": "^25.0.8",
|
|
110
110
|
"tsdown": "^0.22.14",
|