document-mcp 1.2.2 → 1.3.0
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 +9 -4
- package/dist/index.cjs +9 -4
- package/dist/index.js +9 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Requires Node.js `>=20` and pnpm `11.6.0` (pinned via `packageManager` in `packa
|
|
|
52
52
|
pnpm install
|
|
53
53
|
pnpm build # tsdown -> dist/ (ESM + CJS + .d.ts)
|
|
54
54
|
pnpm typecheck # tsc --noEmit
|
|
55
|
-
pnpm lint # eslint . --max-warnings 0
|
|
55
|
+
pnpm lint # eslint . --fix --cache --max-warnings 0
|
|
56
56
|
pnpm test # vitest run --project unit
|
|
57
57
|
pnpm test:smoke # rebuilds dist/, then spawns dist/bin.js as a real subprocess and drives it over genuine MCP stdio
|
|
58
58
|
```
|
package/dist/bin.js
CHANGED
|
@@ -8,7 +8,7 @@ import { readFontFace } from "pdf-codec";
|
|
|
8
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
import { basename, join } from "node:path";
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version = "1.
|
|
11
|
+
var version = "1.3.0";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/io/document-input.ts
|
|
14
14
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -129,7 +129,8 @@ const ConvertDocumentInputSchema = z.object({
|
|
|
129
129
|
targetFormat: DocumentFormatSchema.describe("The format to convert the document to. Not every (source, targetFormat) pair is supported directly -- call list_document_conversions first to confirm this one is."),
|
|
130
130
|
output: DocumentOutputSchema.optional().describe("Where to write the converted document. Omit entirely to receive the bytes inline, base64-encoded, instead."),
|
|
131
131
|
fonts: z.array(FontInputSchema$1).optional().describe("Extra font faces to make available to the conversion, for a family the source document does not already embed. Only consulted by a conversion that runs a layout engine (a <format>-to-pdf conversion); every other conversion ignores this option entirely."),
|
|
132
|
-
onSubstitutionDiagnostics: z.boolean().optional().describe("When true, additionally report each individual font-substitution event as structured fontSubstitutions (which family/weight/style was requested, what it resolved to instead, and why). Every substitution is always reported as a plain diagnostic in `diagnostics` regardless of this flag -- this only controls whether the fuller, structured event is also collected.")
|
|
132
|
+
onSubstitutionDiagnostics: z.boolean().optional().describe("When true, additionally report each individual font-substitution event as structured fontSubstitutions (which family/weight/style was requested, what it resolved to instead, and why). Every substitution is always reported as a plain diagnostic in `diagnostics` regardless of this flag -- this only controls whether the fuller, structured event is also collected."),
|
|
133
|
+
images: z.record(z.string(), z.string()).optional().describe("A map from a markdown image destination (the part in the parentheses of ) to its base64-encoded PNG/JPEG bytes, for resolving a markdown source's own non-data: images. Only consulted by a markdown-sourced conversion; every other conversion ignores it. A destination absent from the map degrades to alt text, matching documents.js's own MarkdownImageResolver port -- an MCP caller has no filesystem context to read a relative path from, so any image that is not a data: URI must be supplied here explicitly to be embedded.")
|
|
133
134
|
});
|
|
134
135
|
const ConvertDocumentOutputSchema = z.object({
|
|
135
136
|
targetFormat: DocumentFormatSchema,
|
|
@@ -148,7 +149,7 @@ function registerConvertTools(server) {
|
|
|
148
149
|
description: "Converts a document from one supported format to another via documents.js's DocumentConverter port -- docx, pptx, xlsx, odt, odp, ods, odg, odf, markdown, and pdf. Not every (source, targetFormat) pair is supported directly (odf, for instance, only ever converts to pdf); call list_document_conversions first to see which pairs actually are.",
|
|
149
150
|
inputSchema: ConvertDocumentInputSchema,
|
|
150
151
|
outputSchema: ConvertDocumentOutputSchema
|
|
151
|
-
}, async ({ source, targetFormat, output, fonts, onSubstitutionDiagnostics }, ctx) => {
|
|
152
|
+
}, async ({ source, targetFormat, output, fonts, onSubstitutionDiagnostics, images }, ctx) => {
|
|
152
153
|
const { signal } = ctx.mcpReq;
|
|
153
154
|
const { bytes, format } = await resolveDocumentInput(source, { signal });
|
|
154
155
|
const fontSubstitutions = [];
|
|
@@ -166,7 +167,11 @@ function registerConvertTools(server) {
|
|
|
166
167
|
italic: font.italic,
|
|
167
168
|
bytes: base64ToBytes(font.bytesBase64)
|
|
168
169
|
})),
|
|
169
|
-
onFontSubstitution: onSubstitutionDiagnostics === true ? (substitution) => fontSubstitutions.push(substitution) : void 0
|
|
170
|
+
onFontSubstitution: onSubstitutionDiagnostics === true ? (substitution) => fontSubstitutions.push(substitution) : void 0,
|
|
171
|
+
images: images === void 0 ? void 0 : (destination) => {
|
|
172
|
+
const base64 = images[destination];
|
|
173
|
+
return base64 === void 0 ? void 0 : { bytes: base64ToBytes(base64) };
|
|
174
|
+
}
|
|
170
175
|
});
|
|
171
176
|
const resolvedOutput = await resolveDocumentOutput(result.document.bytes, output ?? {});
|
|
172
177
|
const structuredContent = {
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ let pdf_codec = require("pdf-codec");
|
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "1.
|
|
10
|
+
var version = "1.3.0";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/io/document-input.ts
|
|
13
13
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -128,7 +128,8 @@ const ConvertDocumentInputSchema = zod.z.object({
|
|
|
128
128
|
targetFormat: documents_js.DocumentFormatSchema.describe("The format to convert the document to. Not every (source, targetFormat) pair is supported directly -- call list_document_conversions first to confirm this one is."),
|
|
129
129
|
output: DocumentOutputSchema.optional().describe("Where to write the converted document. Omit entirely to receive the bytes inline, base64-encoded, instead."),
|
|
130
130
|
fonts: zod.z.array(FontInputSchema$1).optional().describe("Extra font faces to make available to the conversion, for a family the source document does not already embed. Only consulted by a conversion that runs a layout engine (a <format>-to-pdf conversion); every other conversion ignores this option entirely."),
|
|
131
|
-
onSubstitutionDiagnostics: zod.z.boolean().optional().describe("When true, additionally report each individual font-substitution event as structured fontSubstitutions (which family/weight/style was requested, what it resolved to instead, and why). Every substitution is always reported as a plain diagnostic in `diagnostics` regardless of this flag -- this only controls whether the fuller, structured event is also collected.")
|
|
131
|
+
onSubstitutionDiagnostics: zod.z.boolean().optional().describe("When true, additionally report each individual font-substitution event as structured fontSubstitutions (which family/weight/style was requested, what it resolved to instead, and why). Every substitution is always reported as a plain diagnostic in `diagnostics` regardless of this flag -- this only controls whether the fuller, structured event is also collected."),
|
|
132
|
+
images: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("A map from a markdown image destination (the part in the parentheses of ) to its base64-encoded PNG/JPEG bytes, for resolving a markdown source's own non-data: images. Only consulted by a markdown-sourced conversion; every other conversion ignores it. A destination absent from the map degrades to alt text, matching documents.js's own MarkdownImageResolver port -- an MCP caller has no filesystem context to read a relative path from, so any image that is not a data: URI must be supplied here explicitly to be embedded.")
|
|
132
133
|
});
|
|
133
134
|
const ConvertDocumentOutputSchema = zod.z.object({
|
|
134
135
|
targetFormat: documents_js.DocumentFormatSchema,
|
|
@@ -147,7 +148,7 @@ function registerConvertTools(server) {
|
|
|
147
148
|
description: "Converts a document from one supported format to another via documents.js's DocumentConverter port -- docx, pptx, xlsx, odt, odp, ods, odg, odf, markdown, and pdf. Not every (source, targetFormat) pair is supported directly (odf, for instance, only ever converts to pdf); call list_document_conversions first to see which pairs actually are.",
|
|
148
149
|
inputSchema: ConvertDocumentInputSchema,
|
|
149
150
|
outputSchema: ConvertDocumentOutputSchema
|
|
150
|
-
}, async ({ source, targetFormat, output, fonts, onSubstitutionDiagnostics }, ctx) => {
|
|
151
|
+
}, async ({ source, targetFormat, output, fonts, onSubstitutionDiagnostics, images }, ctx) => {
|
|
151
152
|
const { signal } = ctx.mcpReq;
|
|
152
153
|
const { bytes, format } = await resolveDocumentInput(source, { signal });
|
|
153
154
|
const fontSubstitutions = [];
|
|
@@ -165,7 +166,11 @@ function registerConvertTools(server) {
|
|
|
165
166
|
italic: font.italic,
|
|
166
167
|
bytes: (0, documents_js.base64ToBytes)(font.bytesBase64)
|
|
167
168
|
})),
|
|
168
|
-
onFontSubstitution: onSubstitutionDiagnostics === true ? (substitution) => fontSubstitutions.push(substitution) : void 0
|
|
169
|
+
onFontSubstitution: onSubstitutionDiagnostics === true ? (substitution) => fontSubstitutions.push(substitution) : void 0,
|
|
170
|
+
images: images === void 0 ? void 0 : (destination) => {
|
|
171
|
+
const base64 = images[destination];
|
|
172
|
+
return base64 === void 0 ? void 0 : { bytes: (0, documents_js.base64ToBytes)(base64) };
|
|
173
|
+
}
|
|
169
174
|
});
|
|
170
175
|
const resolvedOutput = await resolveDocumentOutput(result.document.bytes, output ?? {});
|
|
171
176
|
const structuredContent = {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { readFontFace } from "pdf-codec";
|
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
import { basename, join } from "node:path";
|
|
8
8
|
//#region package.json
|
|
9
|
-
var version = "1.
|
|
9
|
+
var version = "1.3.0";
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/io/document-input.ts
|
|
12
12
|
const EXTENSION_TO_FORMAT = {
|
|
@@ -127,7 +127,8 @@ const ConvertDocumentInputSchema = z.object({
|
|
|
127
127
|
targetFormat: DocumentFormatSchema.describe("The format to convert the document to. Not every (source, targetFormat) pair is supported directly -- call list_document_conversions first to confirm this one is."),
|
|
128
128
|
output: DocumentOutputSchema.optional().describe("Where to write the converted document. Omit entirely to receive the bytes inline, base64-encoded, instead."),
|
|
129
129
|
fonts: z.array(FontInputSchema$1).optional().describe("Extra font faces to make available to the conversion, for a family the source document does not already embed. Only consulted by a conversion that runs a layout engine (a <format>-to-pdf conversion); every other conversion ignores this option entirely."),
|
|
130
|
-
onSubstitutionDiagnostics: z.boolean().optional().describe("When true, additionally report each individual font-substitution event as structured fontSubstitutions (which family/weight/style was requested, what it resolved to instead, and why). Every substitution is always reported as a plain diagnostic in `diagnostics` regardless of this flag -- this only controls whether the fuller, structured event is also collected.")
|
|
130
|
+
onSubstitutionDiagnostics: z.boolean().optional().describe("When true, additionally report each individual font-substitution event as structured fontSubstitutions (which family/weight/style was requested, what it resolved to instead, and why). Every substitution is always reported as a plain diagnostic in `diagnostics` regardless of this flag -- this only controls whether the fuller, structured event is also collected."),
|
|
131
|
+
images: z.record(z.string(), z.string()).optional().describe("A map from a markdown image destination (the part in the parentheses of ) to its base64-encoded PNG/JPEG bytes, for resolving a markdown source's own non-data: images. Only consulted by a markdown-sourced conversion; every other conversion ignores it. A destination absent from the map degrades to alt text, matching documents.js's own MarkdownImageResolver port -- an MCP caller has no filesystem context to read a relative path from, so any image that is not a data: URI must be supplied here explicitly to be embedded.")
|
|
131
132
|
});
|
|
132
133
|
const ConvertDocumentOutputSchema = z.object({
|
|
133
134
|
targetFormat: DocumentFormatSchema,
|
|
@@ -146,7 +147,7 @@ function registerConvertTools(server) {
|
|
|
146
147
|
description: "Converts a document from one supported format to another via documents.js's DocumentConverter port -- docx, pptx, xlsx, odt, odp, ods, odg, odf, markdown, and pdf. Not every (source, targetFormat) pair is supported directly (odf, for instance, only ever converts to pdf); call list_document_conversions first to see which pairs actually are.",
|
|
147
148
|
inputSchema: ConvertDocumentInputSchema,
|
|
148
149
|
outputSchema: ConvertDocumentOutputSchema
|
|
149
|
-
}, async ({ source, targetFormat, output, fonts, onSubstitutionDiagnostics }, ctx) => {
|
|
150
|
+
}, async ({ source, targetFormat, output, fonts, onSubstitutionDiagnostics, images }, ctx) => {
|
|
150
151
|
const { signal } = ctx.mcpReq;
|
|
151
152
|
const { bytes, format } = await resolveDocumentInput(source, { signal });
|
|
152
153
|
const fontSubstitutions = [];
|
|
@@ -164,7 +165,11 @@ function registerConvertTools(server) {
|
|
|
164
165
|
italic: font.italic,
|
|
165
166
|
bytes: base64ToBytes(font.bytesBase64)
|
|
166
167
|
})),
|
|
167
|
-
onFontSubstitution: onSubstitutionDiagnostics === true ? (substitution) => fontSubstitutions.push(substitution) : void 0
|
|
168
|
+
onFontSubstitution: onSubstitutionDiagnostics === true ? (substitution) => fontSubstitutions.push(substitution) : void 0,
|
|
169
|
+
images: images === void 0 ? void 0 : (destination) => {
|
|
170
|
+
const base64 = images[destination];
|
|
171
|
+
return base64 === void 0 ? void 0 : { bytes: base64ToBytes(base64) };
|
|
172
|
+
}
|
|
168
173
|
});
|
|
169
174
|
const resolvedOutput = await resolveDocumentOutput(result.document.bytes, output ?? {});
|
|
170
175
|
const structuredContent = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsdown",
|
|
44
44
|
"prepublishOnly": "pnpm run lint && pnpm run typecheck && tsdown && publint && attw --pack",
|
|
45
|
-
"lint": "eslint . --max-warnings 0",
|
|
45
|
+
"lint": "eslint . --fix --cache --max-warnings 0",
|
|
46
46
|
"typecheck": "tsc --noEmit",
|
|
47
47
|
"test": "vitest run --project unit",
|
|
48
48
|
"test:watch": "vitest --project unit",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"packageManager": "pnpm@11.6.0",
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
72
|
-
"documents.js": "^1.
|
|
72
|
+
"documents.js": "^1.90.0",
|
|
73
73
|
"pdf-codec": "^1.11.0",
|
|
74
74
|
"zod": "^4.2.0"
|
|
75
75
|
},
|