@documonster/mcp 0.10.0 → 0.11.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.
Files changed (73) hide show
  1. package/README.md +170 -51
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +28 -0
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/config.d.ts +1 -1
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +10 -2
  8. package/dist/config.js.map +1 -1
  9. package/dist/tools/diagram-inspect.d.ts +20 -0
  10. package/dist/tools/diagram-inspect.d.ts.map +1 -0
  11. package/dist/tools/diagram-inspect.js +91 -0
  12. package/dist/tools/diagram-inspect.js.map +1 -0
  13. package/dist/tools/diagram-markdown.d.ts +45 -0
  14. package/dist/tools/diagram-markdown.d.ts.map +1 -0
  15. package/dist/tools/diagram-markdown.js +127 -0
  16. package/dist/tools/diagram-markdown.js.map +1 -0
  17. package/dist/tools/diagram-render.d.ts +14 -0
  18. package/dist/tools/diagram-render.d.ts.map +1 -0
  19. package/dist/tools/diagram-render.js +117 -0
  20. package/dist/tools/diagram-render.js.map +1 -0
  21. package/dist/tools/diagram.d.ts +217 -0
  22. package/dist/tools/diagram.d.ts.map +1 -0
  23. package/dist/tools/diagram.js +760 -0
  24. package/dist/tools/diagram.js.map +1 -0
  25. package/dist/tools/doc-convert.d.ts.map +1 -1
  26. package/dist/tools/doc-convert.js +26 -4
  27. package/dist/tools/doc-convert.js.map +1 -1
  28. package/dist/tools/doc-read.d.ts.map +1 -1
  29. package/dist/tools/doc-read.js +32 -4
  30. package/dist/tools/doc-read.js.map +1 -1
  31. package/dist/tools/doc-write.d.ts.map +1 -1
  32. package/dist/tools/doc-write.js +21 -3
  33. package/dist/tools/doc-write.js.map +1 -1
  34. package/dist/tools/document.d.ts +1 -1
  35. package/dist/tools/document.d.ts.map +1 -1
  36. package/dist/tools/document.js +13 -1
  37. package/dist/tools/document.js.map +1 -1
  38. package/dist/tools/help.d.ts +263 -15
  39. package/dist/tools/help.d.ts.map +1 -1
  40. package/dist/tools/help.js +263 -15
  41. package/dist/tools/help.js.map +1 -1
  42. package/dist/tools/image.d.ts +147 -0
  43. package/dist/tools/image.d.ts.map +1 -0
  44. package/dist/tools/image.js +749 -0
  45. package/dist/tools/image.js.map +1 -0
  46. package/dist/tools/index.d.ts.map +1 -1
  47. package/dist/tools/index.js +4 -0
  48. package/dist/tools/index.js.map +1 -1
  49. package/dist/tools/inspect.d.ts.map +1 -1
  50. package/dist/tools/inspect.js +98 -6
  51. package/dist/tools/inspect.js.map +1 -1
  52. package/dist/tools/pdf-edit.d.ts +13 -6
  53. package/dist/tools/pdf-edit.d.ts.map +1 -1
  54. package/dist/tools/pdf-edit.js +93 -8
  55. package/dist/tools/pdf-edit.js.map +1 -1
  56. package/dist/tools/sheet-edit.d.ts.map +1 -1
  57. package/dist/tools/sheet-edit.js +37 -2
  58. package/dist/tools/sheet-edit.js.map +1 -1
  59. package/dist/tools/sheet-image.d.ts +58 -0
  60. package/dist/tools/sheet-image.d.ts.map +1 -0
  61. package/dist/tools/sheet-image.js +156 -0
  62. package/dist/tools/sheet-image.js.map +1 -0
  63. package/dist/tools/sheet-read.d.ts.map +1 -1
  64. package/dist/tools/sheet-read.js +18 -1
  65. package/dist/tools/sheet-read.js.map +1 -1
  66. package/dist/tools/sheet-write.d.ts.map +1 -1
  67. package/dist/tools/sheet-write.js +41 -4
  68. package/dist/tools/sheet-write.js.map +1 -1
  69. package/dist/tools/template.d.ts +19 -0
  70. package/dist/tools/template.d.ts.map +1 -1
  71. package/dist/tools/template.js +436 -11
  72. package/dist/tools/template.js.map +1 -1
  73. package/package.json +3 -3
@@ -20,8 +20,8 @@ export declare const HELP_TOPICS: {
20
20
  readonly summary: "What this server can do and the order to do it in.";
21
21
  readonly body: `# documonster MCP server
22
22
 
23
- Reads, writes and converts Excel, Word, PDF, CSV and ZIP documents on the local
24
- filesystem. All work happens server-side: you send structure and parameters,
23
+ Reads, writes and converts Excel, Word, PDF, CSV, ZIP and Mermaid documents on the
24
+ local filesystem. All work happens server-side: you send structure and parameters,
25
25
  never document bytes.
26
26
 
27
27
  ## Working discipline
@@ -73,24 +73,33 @@ widened.`;
73
73
 
74
74
  ## Spreadsheets
75
75
  - \`sheet_read\` — read a bounded window.
76
- - \`sheet_write\` — create an .xlsx from a spec.
77
- - \`sheet_edit\` — patch an existing .xlsx.
76
+ - \`sheet_write\` — create an .xlsx from a spec, images included.
77
+ - \`sheet_edit\` — patch an existing .xlsx; \`add_image\` places a picture.
78
78
  - \`formula_evaluate\` — evaluate a formula against supplied values.
79
79
 
80
80
  ## Documents
81
- - \`doc_read\` — read .docx / .pdf / .md / .txt.
81
+ - \`doc_read\` — read .docx / .pdf / .md / .txt / .mmd.
82
82
  - \`doc_write\` — create a .docx or .pdf from Markdown.
83
83
  - \`doc_edit\` — find and replace text in a .docx.
84
84
  - \`doc_search\` — find text, or find text by its formatting.
85
85
  - \`doc_paginate\` — real page counts and per-heading page numbers.
86
86
  - \`doc_review\` — compare two versions, or review tracked changes.
87
87
  - \`doc_convert\` — convert between formats.
88
- - \`pdf_edit\` — watermark, number, stamp, rotate, delete/keep pages, append.
88
+ - \`pdf_edit\` — watermark, number, stamp, draw a diagram, rotate, delete/keep
89
+ pages, append.
89
90
 
90
91
  ## Forms and templates
91
- - \`template_inspect\` / \`template_fill\` — Word {{placeholder}} templates.
92
+ - \`template_inspect\` / \`template_fill\` — Word {{placeholder}} templates,
93
+ including {{%image}} placeholders.
92
94
  - \`form_fill\` — Word form fields and PDF AcroForms.
93
95
 
96
+ ## Diagrams
97
+ - \`diagram_inspect\` — parse Mermaid text and report what it means. Writes nothing.
98
+ - \`diagram_render\` — draw it as .svg / .png / .pdf.
99
+ - A \`\`\`mermaid fence in \`doc_write\` / \`doc_convert\` Markdown becomes an
100
+ embedded picture, not a code block.
101
+ - \`pdf_edit\` with \`op: "diagram"\` draws one onto a page of an existing PDF.
102
+
94
103
  ## Archives
95
104
  - \`archive_read\` — list or extract a .zip/.tar.
96
105
  - \`archive_write\` — package files into a .zip/.tar.
@@ -100,7 +109,9 @@ widened.`;
100
109
  - PDF → Word, or any conversion with a PDF as the source
101
110
  - OCR: a scanned PDF page yields no text, and a scanned form has no fields
102
111
  - legacy binary .doc / .xls
103
- - pivot tables and image insertion (the library supports them; no tool does yet)
112
+ - pivot tables (the library supports them; no tool does yet)
113
+ - an image in a Word **header or footer** placeholder — the template engine
114
+ substitutes images in the body only
104
115
 
105
116
  ## Choosing between similar tools
106
117
  - A Word file with \`{{placeholders}}\` → \`template_fill\`, not \`doc_edit\`.
@@ -109,9 +120,240 @@ widened.`;
109
120
  - Producing a PDF → make a .docx or .xlsx first, then \`doc_convert\`.
110
121
  \`pdf_edit\` changes an existing PDF; it does not create content.
111
122
  - Two versions of a document → \`doc_review\`, not two \`doc_read\` calls.
112
- - A chart → a \`charts\` entry in \`sheet_write\`, or an \`add_chart\` op in
113
- \`sheet_edit\`. There is no separate chart tool.
114
- - Test data \`generate\` in \`sheet_write\`. Never emit thousands of rows yourself.`;
123
+ - A chart of *numbers* → a \`charts\` entry in \`sheet_write\`, or an \`add_chart\` op
124
+ in \`sheet_edit\`. There is no separate chart tool.
125
+ - A diagram of *relationships* a flow, a sequence, a state machine, an ER model
126
+ → \`diagram_render\` with Mermaid text.
127
+ - Test data → \`generate\` in \`sheet_write\`. Never emit thousands of rows yourself.
128
+ - A picture in a document → see the \`images\` topic. Every destination takes the
129
+ same source shape, and a Mermaid diagram is one of the sources.`;
130
+ };
131
+ readonly images: {
132
+ readonly summary: "Putting a picture in a workbook, a template or a PDF — one source shape.";
133
+ readonly body: `# Images
134
+
135
+ Four destinations take a picture, and they all take it the **same way**:
136
+
137
+ | Destination | How |
138
+ | --- | --- |
139
+ | a worksheet | \`images\` in \`sheet_write\`, or \`op: "add_image"\` in \`sheet_edit\` |
140
+ | a Word template's \`{{%name}}\` | \`images\` in \`template_fill\` |
141
+ | a page of an existing PDF | \`op: "diagram"\` in \`pdf_edit\` (diagrams only) |
142
+ | a Word/PDF document you write | a \`\`\`mermaid fence in \`doc_write\`'s Markdown |
143
+
144
+ ## The source shape
145
+
146
+ Every one of them accepts the same fields, and the **extension decides** what
147
+ happens — there is no format argument to get wrong:
148
+
149
+ - \`from: "logo.png"\` — a \`.png\` / \`.jpg\` / \`.gif\`, embedded as it is.
150
+ - \`from: "flow.mmd"\` — a Mermaid file, drawn server-side.
151
+ - \`from: "design.md"\` (+ \`index\`) — a \`\`\`mermaid fence out of a Markdown file.
152
+ - \`source: "flowchart LR\\n A --> B"\` — Mermaid text you write.
153
+
154
+ Plus \`width\` / \`height\` in **points** (72 per inch), \`altText\`, and — for
155
+ diagram sources — \`theme\` and \`background\`.
156
+
157
+ A Mermaid diagram is deliberately just *one source of an image* here rather than a
158
+ feature of its own. A caller with a PNG on disk has the same route as a caller with
159
+ a diagram, and neither has to know how the other works.
160
+
161
+ These fields work whether or not the \`diagram\` tool group is enabled: that group
162
+ governs which tools are listed, and whether a \`\`\`mermaid fence in \`doc_write\`'s
163
+ Markdown is *implicitly* turned into a picture. Naming a diagram in \`images\` is an
164
+ explicit request, so nothing gates it.
165
+
166
+ ## Sizing
167
+
168
+ Give **one** of \`width\`/\`height\` and the other follows, keeping the aspect ratio —
169
+ an image squashed to a ratio nobody asked for is a defect you cannot see. Give both
170
+ and they are taken literally. Give neither and the file's own size is used: its pixels
171
+ at the resolution it declares (a PNG's \`pHYs\`, a JPEG's JFIF density), or 96 per inch
172
+ when it declares none. A diagram uses its own layout size.
173
+
174
+ Sizes are in **points**, 72 to the inch. That is not what a worksheet anchor or a Word
175
+ drawing stores — those want CSS pixels at 96 and EMU at 914400 — but the conversion is
176
+ this server's problem, not yours.
177
+
178
+ ## Damaged files are refused
179
+
180
+ A file's header parsing is not evidence it works: the first bytes of a truncated PNG
181
+ are identical to a whole one's. Every image is checked for integrity before it enters
182
+ a document — each PNG chunk's CRC-32, and that its compressed data inflates to exactly
183
+ the scanlines its size needs; a JPEG's segment chain reaching its end-of-image marker;
184
+ a GIF's block chain reaching its trailer. Truncation is how images actually arrive
185
+ broken, and embedding one produces a document showing a broken-image box that no tool
186
+ here could ever see. \`doc_inspect\` reports the same damage rather than only refusing
187
+ it later.
188
+
189
+ This is an integrity check, not a decoder: a complete, uncorrupted container whose
190
+ pixels a viewer still rejects is a decoder bug rather than a damaged file.
191
+
192
+ ## Limits
193
+
194
+ One call may place at most **20 pictures**, totalling 64 MiB of source and 80 million
195
+ decoded pixels; a Markdown document may embed at most 20 diagrams. These are aggregate,
196
+ because twenty images each just under a per-file limit is the same memory as one
197
+ enormous one, and every picture is held until the file is written. Split a bigger job
198
+ across calls.
199
+
200
+ In a Word template the width is capped to the 468-point text column, because Word
201
+ does not shrink an oversized inline image — it runs it off the paper.
202
+
203
+ ## Anchoring in a worksheet
204
+
205
+ \`at\` decides which of two genuinely different things you get:
206
+
207
+ - **A single cell**, \`at: "F2"\` — the picture keeps its own size and hangs from
208
+ that corner. This is "put the logo at F2".
209
+ - **A range**, \`at: "A10:H30"\` — the picture is bound to those cells and moves and
210
+ resizes with them. This is "fill this block with the diagram".
211
+
212
+ ## Verifying
213
+
214
+ Nothing here can show you a picture, so verification is indirect and you have to
215
+ know where to look.
216
+
217
+ - The **write** report names the source, the size and the anchor. For a diagram it
218
+ also reports what the parser recognised — \`flowchart — 5 node(s), 4 edge(s)\` —
219
+ which is the only check there is on the content. See the \`diagrams\` topic.
220
+ - **\`sheet_read\`** reports \`images: N\` with each anchor, because a picture
221
+ occupies no cell and so cannot appear in the grid it prints.
222
+ - **\`doc_inspect\`** counts them per sheet for a workbook, and \`doc_read\` reports
223
+ \`images: N\` for a Word document.
224
+
225
+ An anchor is reported as the range you asked for. The file stores the bottom-right
226
+ as an *edge* one cell past the last one covered, so a raw reading of it would report
227
+ \`A6:H26\` back as \`A6:I27\` — which looks like an off-by-one in the placement rather
228
+ than in the description.
229
+
230
+ ## Naming a template image
231
+
232
+ The key is the placeholder's path without the \`%\`, and a **dotted key is a path**:
233
+ \`{{%client.logo}}\` takes \`images: { "client.logo": … }\`.
234
+
235
+ Images share the engine's data namespace, so a name cannot be both text and a picture.
236
+ \`data.logo\` together with \`images.logo\` is refused rather than silently resolved —
237
+ it used to render the entire image object, pixel bytes and all, as JSON into the
238
+ document.
239
+
240
+ ## Where a template's \`{{%name}}\` may sit
241
+
242
+ **A paragraph of its own** — in the body, in a table cell, or in a header or footer.
243
+ Nested tables work too.
244
+
245
+ One placement remains impossible: scoped to a \`{{#each}}\` item (\`{{%.photo}}\`).
246
+ Images are substituted before loops are expanded, so there is no current item to read
247
+ from, and one picture per row is not expressible. \`template_fill\` refuses it up
248
+ front and \`template_inspect\` marks it \`cannot be filled\` rather than inventing an
249
+ \`images\` key for it. Put the picture outside the loop, or have the template author
250
+ place the row images directly.
251
+
252
+ ## One report worth reading carefully
253
+
254
+ Images are substituted **before** conditionals are evaluated, so a \`{{%logo}}\`
255
+ inside a \`{{#if}}\` whose condition turns out false is put in and then removed with
256
+ its block. The fill succeeds. \`template_fill\` says so — **not in the output** —
257
+ because otherwise the report would claim a picture that is not there, and you would
258
+ pass that claim on. Its bytes are dropped from the package too: a picture the document
259
+ withholds must not be recoverable by unzipping it.
260
+
261
+ Every placeholder's picture is verified by **re-opening the written file**, not by
262
+ trusting the document that was handed to the writer. If a report says a picture
263
+ \`could not be verified\`, read the file with \`doc_read\` before relying on it.`;
264
+ };
265
+ readonly diagrams: {
266
+ readonly summary: "Mermaid: which diagram types work, and how to verify one you cannot see.";
267
+ readonly body: `# Diagrams
268
+
269
+ \`diagram_render\` and \`diagram_inspect\` take **Mermaid** text. \`doc_write\` and
270
+ \`doc_convert\` also render \`\`\`mermaid fences found in their Markdown.
271
+
272
+ ## Verify, because you cannot look at it
273
+
274
+ This is the one place in this server where reading the output back is impossible —
275
+ you cannot see a picture. So both tools report the **parsed structure** instead:
276
+ every node, edge, participant, task or slice the parser recognised.
277
+
278
+ Read that list. The parser implements a subset of Mermaid, and a subset fails by
279
+ *silently dropping* what it did not understand — a mistyped arrow yields one fewer
280
+ edge, not an error. A missing entry in that list is the only symptom, and nothing
281
+ about the file itself will look wrong.
282
+
283
+ Use \`diagram_inspect\` before rendering when the diagram is long or generated: it
284
+ writes nothing, works under \`--readonly\`, and tells you the size it would render
285
+ at.
286
+
287
+ ## Supported diagram types
288
+
289
+ \`flowchart\` / \`graph\`, \`sequenceDiagram\`, \`classDiagram\`, \`stateDiagram\`,
290
+ \`erDiagram\`, \`gantt\`, \`gitGraph\`, \`mindmap\`, \`timeline\`, \`journey\`,
291
+ \`kanban\`, \`quadrantChart\`, \`xychart\`, \`radar\`, \`sankey\`, \`packet\`,
292
+ \`block\`, \`pie\`, \`C4Context\` (and the other C4 forms), \`requirementDiagram\`,
293
+ \`architecture\`.
294
+
295
+ The first non-empty line chooses the type. Anything else is rejected with a list of
296
+ what is possible, so a wrong guess costs one turn rather than a retry loop.
297
+
298
+ ## Choosing a format
299
+
300
+ - **\`.svg\`** — smallest, resolution-independent, text stays selectable. The right
301
+ default for anything that will be viewed on a screen or edited later.
302
+ - **\`.png\`** — pastes into anything. \`scale\` sets pixels per point; the default
303
+ of 2 is 144 DPI. This is what a \`\`\`mermaid fence becomes inside a document.
304
+ - **\`.pdf\`** — one page sized to the diagram, drawn as vectors rather than pixels.
305
+
306
+ All three come from the *same* display list, so they are the same picture rather
307
+ than three renderings that might disagree.
308
+
309
+ ## Colour
310
+
311
+ \`theme\` picks a colour set: \`default\` reproduces Mermaid's own base theme token
312
+ for token; \`dark\` and \`neutral\` are this server's own and are not Mermaid's
313
+ themes of those names. \`themeOverrides\` sets individual tokens on top —
314
+ \`nodeFill\`, \`nodeStroke\`, \`nodeText\`, \`edge\`, \`groupFill\`, \`palette\` and
315
+ the rest. \`palette\` is what colours the slices of a pie, the series of an
316
+ xychart or radar, and the bands of a journey or quadrant.
317
+
318
+ \`background\` defaults to **white**, not transparent: a transparent PNG is
319
+ invisible in a dark viewer, and that is a failure you would never see. Pass
320
+ \`"transparent"\` explicitly if you are compositing it onto something else.
321
+
322
+ ## Layout
323
+
324
+ \`rankGap\`, \`nodeGap\`, \`maxLabelWidth\` and \`padding\` tune the graph diagrams
325
+ (flowchart, state, class, ER, requirement, C4, architecture). Reach for
326
+ \`maxLabelWidth\` first when a diagram comes out too wide — long labels, not the
327
+ graph, are usually the cause.
328
+
329
+ ## Embedding in a document
330
+
331
+ Put a \`\`\`mermaid fence in the Markdown you pass to \`doc_write\`. It is rendered
332
+ and embedded as a picture, scaled down if needed to fit the text column — Word does
333
+ not shrink an oversized image, it runs it off the page. A fence that fails to parse
334
+ is left as a code block and reported, so one bad diagram does not lose the document.
335
+ Pass \`diagrams: false\` to keep every fence as code.
336
+
337
+ ## Adding one to a PDF that already exists
338
+
339
+ \`pdf_edit\` takes \`{ op: "diagram", source | from, pages, x, y, width, height }\`.
340
+ It draws **vectors** onto the page rather than pasting a picture, so the diagram
341
+ stays sharp at any zoom, and the file is saved as an incremental update — bookmarks,
342
+ form fields and signature bytes survive.
343
+
344
+ Two defaults differ from \`diagram_render\`, both because this draws *over* content
345
+ that is already there:
346
+
347
+ - \`background\` is \`"transparent"\`. A white plate would hide the page beneath it.
348
+ - Omitting \`x\`/\`y\` centres it, and omitting \`width\`/\`height\` uses the diagram's
349
+ natural size **shrunk to fit** the page. So \`{ op: "diagram", source, pages: [3] }\`
350
+ lands on the page rather than off the edge of it.
351
+
352
+ ## Everywhere else a diagram can go
353
+
354
+ A worksheet, and a Word template's \`{{%name}}\` placeholder. Both go through the
355
+ generic image source described in the \`images\` topic, where a diagram is one
356
+ source among several rather than a special case.`;
115
357
  };
116
358
  readonly formulas: {
117
359
  readonly summary: "Formula syntax notes and one engine limitation worth knowing.";
@@ -157,9 +399,14 @@ In \`sheet_write\`, a formula may reference another sheet in the same spec:
157
399
 
158
400
  ## Reading
159
401
 
160
- \`doc_read\` handles .docx, .pdf, .md and .txt. Word comes back as **Markdown**, so
161
- headings, lists and tables survive. Use \`outline: true\` on a long Word file to
162
- get just the headings before deciding what to read.
402
+ \`doc_read\` handles .docx, .pdf, .md, .txt and .mmd. Word comes back as
403
+ **Markdown**, so headings, lists and tables survive. Use \`outline: true\` on a long
404
+ Word file to get just the headings before deciding what to read.
405
+
406
+ A Markdown file's \`\`\`mermaid fences come back as source, because this tool's
407
+ output is text — but they are **indexed** in a footer. Draw one with
408
+ \`diagram_render({ from, index, to })\`; do not copy the source out through your own
409
+ reply to pass it back as \`source\`.
163
410
 
164
411
  PDFs are reported page by page with \`## Page N\` markers, so you can cite a page.
165
412
  There is **no OCR**: a scanned page reports no extractable text. \`doc_inspect\`
@@ -168,7 +415,8 @@ tells you up front whether a PDF has any text at all.
168
415
  ## Writing
169
416
 
170
417
  \`doc_write\` takes **Markdown** and produces .docx or .pdf. Write the content as
171
- Markdown — that is the input language.
418
+ Markdown — that is the input language. A \`\`\`mermaid fence in it becomes a real
419
+ embedded diagram rather than a code block; see the \`diagrams\` topic.
172
420
 
173
421
  ## Converting
174
422
 
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/tools/help.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;;iBAEpB,OAAO,EAAE,oDAAoD;iBAC7D,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;0EA4BgE;;;iBAItE,OAAO,EAAE,mDAAmD;iBAC5D,IAAI,EAAE;;;;;;;;;;;SAWD;;;iBAIL,OAAO,EAAE,sCAAsC;iBAC/C,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sFA8C4E;;;iBAIlF,OAAO,EAAE,+DAA+D;iBACxE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gFAkCsE;;;iBAI5E,OAAO,EAAE,0DAA0D;iBACnE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAiCoD;;;iBAI1D,OAAO,EAAE,wCAAwC;iBACjD,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BO;;CAE6B,CAAC;AAe/C,eAAO,MAAM,QAAQ,wCA8BnB,CAAC"}
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/tools/help.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;;iBAEpB,OAAO,EAAE,oDAAoD;iBAC7D,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;0EA4BgE;;;iBAItE,OAAO,EAAE,mDAAmD;iBAC5D,IAAI,EAAE;;;;;;;;;;;SAWD;;;iBAIL,OAAO,EAAE,sCAAsC;iBAC/C,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEA6DwD;;;iBAI9D,OAAO,EAAE,0EAA0E;iBACnF,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iFAkIuE;;;iBAI7E,OAAO,EAAE,0EAA0E;iBACnF,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAyFuC;;;iBAI7C,OAAO,EAAE,+DAA+D;iBACxE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gFAkCsE;;;iBAI5E,OAAO,EAAE,0DAA0D;iBACnE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAuCoD;;;iBAI1D,OAAO,EAAE,wCAAwC;iBACjD,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BO;;CAE6B,CAAC;AAe/C,eAAO,MAAM,QAAQ,wCA8BnB,CAAC"}
@@ -19,8 +19,8 @@ export const HELP_TOPICS = {
19
19
  summary: "What this server can do and the order to do it in.",
20
20
  body: `# documonster MCP server
21
21
 
22
- Reads, writes and converts Excel, Word, PDF, CSV and ZIP documents on the local
23
- filesystem. All work happens server-side: you send structure and parameters,
22
+ Reads, writes and converts Excel, Word, PDF, CSV, ZIP and Mermaid documents on the
23
+ local filesystem. All work happens server-side: you send structure and parameters,
24
24
  never document bytes.
25
25
 
26
26
  ## Working discipline
@@ -72,24 +72,33 @@ widened.`
72
72
 
73
73
  ## Spreadsheets
74
74
  - \`sheet_read\` — read a bounded window.
75
- - \`sheet_write\` — create an .xlsx from a spec.
76
- - \`sheet_edit\` — patch an existing .xlsx.
75
+ - \`sheet_write\` — create an .xlsx from a spec, images included.
76
+ - \`sheet_edit\` — patch an existing .xlsx; \`add_image\` places a picture.
77
77
  - \`formula_evaluate\` — evaluate a formula against supplied values.
78
78
 
79
79
  ## Documents
80
- - \`doc_read\` — read .docx / .pdf / .md / .txt.
80
+ - \`doc_read\` — read .docx / .pdf / .md / .txt / .mmd.
81
81
  - \`doc_write\` — create a .docx or .pdf from Markdown.
82
82
  - \`doc_edit\` — find and replace text in a .docx.
83
83
  - \`doc_search\` — find text, or find text by its formatting.
84
84
  - \`doc_paginate\` — real page counts and per-heading page numbers.
85
85
  - \`doc_review\` — compare two versions, or review tracked changes.
86
86
  - \`doc_convert\` — convert between formats.
87
- - \`pdf_edit\` — watermark, number, stamp, rotate, delete/keep pages, append.
87
+ - \`pdf_edit\` — watermark, number, stamp, draw a diagram, rotate, delete/keep
88
+ pages, append.
88
89
 
89
90
  ## Forms and templates
90
- - \`template_inspect\` / \`template_fill\` — Word {{placeholder}} templates.
91
+ - \`template_inspect\` / \`template_fill\` — Word {{placeholder}} templates,
92
+ including {{%image}} placeholders.
91
93
  - \`form_fill\` — Word form fields and PDF AcroForms.
92
94
 
95
+ ## Diagrams
96
+ - \`diagram_inspect\` — parse Mermaid text and report what it means. Writes nothing.
97
+ - \`diagram_render\` — draw it as .svg / .png / .pdf.
98
+ - A \`\`\`mermaid fence in \`doc_write\` / \`doc_convert\` Markdown becomes an
99
+ embedded picture, not a code block.
100
+ - \`pdf_edit\` with \`op: "diagram"\` draws one onto a page of an existing PDF.
101
+
93
102
  ## Archives
94
103
  - \`archive_read\` — list or extract a .zip/.tar.
95
104
  - \`archive_write\` — package files into a .zip/.tar.
@@ -99,7 +108,9 @@ widened.`
99
108
  - PDF → Word, or any conversion with a PDF as the source
100
109
  - OCR: a scanned PDF page yields no text, and a scanned form has no fields
101
110
  - legacy binary .doc / .xls
102
- - pivot tables and image insertion (the library supports them; no tool does yet)
111
+ - pivot tables (the library supports them; no tool does yet)
112
+ - an image in a Word **header or footer** placeholder — the template engine
113
+ substitutes images in the body only
103
114
 
104
115
  ## Choosing between similar tools
105
116
  - A Word file with \`{{placeholders}}\` → \`template_fill\`, not \`doc_edit\`.
@@ -108,9 +119,240 @@ widened.`
108
119
  - Producing a PDF → make a .docx or .xlsx first, then \`doc_convert\`.
109
120
  \`pdf_edit\` changes an existing PDF; it does not create content.
110
121
  - Two versions of a document → \`doc_review\`, not two \`doc_read\` calls.
111
- - A chart → a \`charts\` entry in \`sheet_write\`, or an \`add_chart\` op in
112
- \`sheet_edit\`. There is no separate chart tool.
113
- - Test data \`generate\` in \`sheet_write\`. Never emit thousands of rows yourself.`
122
+ - A chart of *numbers* → a \`charts\` entry in \`sheet_write\`, or an \`add_chart\` op
123
+ in \`sheet_edit\`. There is no separate chart tool.
124
+ - A diagram of *relationships* a flow, a sequence, a state machine, an ER model
125
+ → \`diagram_render\` with Mermaid text.
126
+ - Test data → \`generate\` in \`sheet_write\`. Never emit thousands of rows yourself.
127
+ - A picture in a document → see the \`images\` topic. Every destination takes the
128
+ same source shape, and a Mermaid diagram is one of the sources.`
129
+ },
130
+ images: {
131
+ summary: "Putting a picture in a workbook, a template or a PDF — one source shape.",
132
+ body: `# Images
133
+
134
+ Four destinations take a picture, and they all take it the **same way**:
135
+
136
+ | Destination | How |
137
+ | --- | --- |
138
+ | a worksheet | \`images\` in \`sheet_write\`, or \`op: "add_image"\` in \`sheet_edit\` |
139
+ | a Word template's \`{{%name}}\` | \`images\` in \`template_fill\` |
140
+ | a page of an existing PDF | \`op: "diagram"\` in \`pdf_edit\` (diagrams only) |
141
+ | a Word/PDF document you write | a \`\`\`mermaid fence in \`doc_write\`'s Markdown |
142
+
143
+ ## The source shape
144
+
145
+ Every one of them accepts the same fields, and the **extension decides** what
146
+ happens — there is no format argument to get wrong:
147
+
148
+ - \`from: "logo.png"\` — a \`.png\` / \`.jpg\` / \`.gif\`, embedded as it is.
149
+ - \`from: "flow.mmd"\` — a Mermaid file, drawn server-side.
150
+ - \`from: "design.md"\` (+ \`index\`) — a \`\`\`mermaid fence out of a Markdown file.
151
+ - \`source: "flowchart LR\\n A --> B"\` — Mermaid text you write.
152
+
153
+ Plus \`width\` / \`height\` in **points** (72 per inch), \`altText\`, and — for
154
+ diagram sources — \`theme\` and \`background\`.
155
+
156
+ A Mermaid diagram is deliberately just *one source of an image* here rather than a
157
+ feature of its own. A caller with a PNG on disk has the same route as a caller with
158
+ a diagram, and neither has to know how the other works.
159
+
160
+ These fields work whether or not the \`diagram\` tool group is enabled: that group
161
+ governs which tools are listed, and whether a \`\`\`mermaid fence in \`doc_write\`'s
162
+ Markdown is *implicitly* turned into a picture. Naming a diagram in \`images\` is an
163
+ explicit request, so nothing gates it.
164
+
165
+ ## Sizing
166
+
167
+ Give **one** of \`width\`/\`height\` and the other follows, keeping the aspect ratio —
168
+ an image squashed to a ratio nobody asked for is a defect you cannot see. Give both
169
+ and they are taken literally. Give neither and the file's own size is used: its pixels
170
+ at the resolution it declares (a PNG's \`pHYs\`, a JPEG's JFIF density), or 96 per inch
171
+ when it declares none. A diagram uses its own layout size.
172
+
173
+ Sizes are in **points**, 72 to the inch. That is not what a worksheet anchor or a Word
174
+ drawing stores — those want CSS pixels at 96 and EMU at 914400 — but the conversion is
175
+ this server's problem, not yours.
176
+
177
+ ## Damaged files are refused
178
+
179
+ A file's header parsing is not evidence it works: the first bytes of a truncated PNG
180
+ are identical to a whole one's. Every image is checked for integrity before it enters
181
+ a document — each PNG chunk's CRC-32, and that its compressed data inflates to exactly
182
+ the scanlines its size needs; a JPEG's segment chain reaching its end-of-image marker;
183
+ a GIF's block chain reaching its trailer. Truncation is how images actually arrive
184
+ broken, and embedding one produces a document showing a broken-image box that no tool
185
+ here could ever see. \`doc_inspect\` reports the same damage rather than only refusing
186
+ it later.
187
+
188
+ This is an integrity check, not a decoder: a complete, uncorrupted container whose
189
+ pixels a viewer still rejects is a decoder bug rather than a damaged file.
190
+
191
+ ## Limits
192
+
193
+ One call may place at most **20 pictures**, totalling 64 MiB of source and 80 million
194
+ decoded pixels; a Markdown document may embed at most 20 diagrams. These are aggregate,
195
+ because twenty images each just under a per-file limit is the same memory as one
196
+ enormous one, and every picture is held until the file is written. Split a bigger job
197
+ across calls.
198
+
199
+ In a Word template the width is capped to the 468-point text column, because Word
200
+ does not shrink an oversized inline image — it runs it off the paper.
201
+
202
+ ## Anchoring in a worksheet
203
+
204
+ \`at\` decides which of two genuinely different things you get:
205
+
206
+ - **A single cell**, \`at: "F2"\` — the picture keeps its own size and hangs from
207
+ that corner. This is "put the logo at F2".
208
+ - **A range**, \`at: "A10:H30"\` — the picture is bound to those cells and moves and
209
+ resizes with them. This is "fill this block with the diagram".
210
+
211
+ ## Verifying
212
+
213
+ Nothing here can show you a picture, so verification is indirect and you have to
214
+ know where to look.
215
+
216
+ - The **write** report names the source, the size and the anchor. For a diagram it
217
+ also reports what the parser recognised — \`flowchart — 5 node(s), 4 edge(s)\` —
218
+ which is the only check there is on the content. See the \`diagrams\` topic.
219
+ - **\`sheet_read\`** reports \`images: N\` with each anchor, because a picture
220
+ occupies no cell and so cannot appear in the grid it prints.
221
+ - **\`doc_inspect\`** counts them per sheet for a workbook, and \`doc_read\` reports
222
+ \`images: N\` for a Word document.
223
+
224
+ An anchor is reported as the range you asked for. The file stores the bottom-right
225
+ as an *edge* one cell past the last one covered, so a raw reading of it would report
226
+ \`A6:H26\` back as \`A6:I27\` — which looks like an off-by-one in the placement rather
227
+ than in the description.
228
+
229
+ ## Naming a template image
230
+
231
+ The key is the placeholder's path without the \`%\`, and a **dotted key is a path**:
232
+ \`{{%client.logo}}\` takes \`images: { "client.logo": … }\`.
233
+
234
+ Images share the engine's data namespace, so a name cannot be both text and a picture.
235
+ \`data.logo\` together with \`images.logo\` is refused rather than silently resolved —
236
+ it used to render the entire image object, pixel bytes and all, as JSON into the
237
+ document.
238
+
239
+ ## Where a template's \`{{%name}}\` may sit
240
+
241
+ **A paragraph of its own** — in the body, in a table cell, or in a header or footer.
242
+ Nested tables work too.
243
+
244
+ One placement remains impossible: scoped to a \`{{#each}}\` item (\`{{%.photo}}\`).
245
+ Images are substituted before loops are expanded, so there is no current item to read
246
+ from, and one picture per row is not expressible. \`template_fill\` refuses it up
247
+ front and \`template_inspect\` marks it \`cannot be filled\` rather than inventing an
248
+ \`images\` key for it. Put the picture outside the loop, or have the template author
249
+ place the row images directly.
250
+
251
+ ## One report worth reading carefully
252
+
253
+ Images are substituted **before** conditionals are evaluated, so a \`{{%logo}}\`
254
+ inside a \`{{#if}}\` whose condition turns out false is put in and then removed with
255
+ its block. The fill succeeds. \`template_fill\` says so — **not in the output** —
256
+ because otherwise the report would claim a picture that is not there, and you would
257
+ pass that claim on. Its bytes are dropped from the package too: a picture the document
258
+ withholds must not be recoverable by unzipping it.
259
+
260
+ Every placeholder's picture is verified by **re-opening the written file**, not by
261
+ trusting the document that was handed to the writer. If a report says a picture
262
+ \`could not be verified\`, read the file with \`doc_read\` before relying on it.`
263
+ },
264
+ diagrams: {
265
+ summary: "Mermaid: which diagram types work, and how to verify one you cannot see.",
266
+ body: `# Diagrams
267
+
268
+ \`diagram_render\` and \`diagram_inspect\` take **Mermaid** text. \`doc_write\` and
269
+ \`doc_convert\` also render \`\`\`mermaid fences found in their Markdown.
270
+
271
+ ## Verify, because you cannot look at it
272
+
273
+ This is the one place in this server where reading the output back is impossible —
274
+ you cannot see a picture. So both tools report the **parsed structure** instead:
275
+ every node, edge, participant, task or slice the parser recognised.
276
+
277
+ Read that list. The parser implements a subset of Mermaid, and a subset fails by
278
+ *silently dropping* what it did not understand — a mistyped arrow yields one fewer
279
+ edge, not an error. A missing entry in that list is the only symptom, and nothing
280
+ about the file itself will look wrong.
281
+
282
+ Use \`diagram_inspect\` before rendering when the diagram is long or generated: it
283
+ writes nothing, works under \`--readonly\`, and tells you the size it would render
284
+ at.
285
+
286
+ ## Supported diagram types
287
+
288
+ \`flowchart\` / \`graph\`, \`sequenceDiagram\`, \`classDiagram\`, \`stateDiagram\`,
289
+ \`erDiagram\`, \`gantt\`, \`gitGraph\`, \`mindmap\`, \`timeline\`, \`journey\`,
290
+ \`kanban\`, \`quadrantChart\`, \`xychart\`, \`radar\`, \`sankey\`, \`packet\`,
291
+ \`block\`, \`pie\`, \`C4Context\` (and the other C4 forms), \`requirementDiagram\`,
292
+ \`architecture\`.
293
+
294
+ The first non-empty line chooses the type. Anything else is rejected with a list of
295
+ what is possible, so a wrong guess costs one turn rather than a retry loop.
296
+
297
+ ## Choosing a format
298
+
299
+ - **\`.svg\`** — smallest, resolution-independent, text stays selectable. The right
300
+ default for anything that will be viewed on a screen or edited later.
301
+ - **\`.png\`** — pastes into anything. \`scale\` sets pixels per point; the default
302
+ of 2 is 144 DPI. This is what a \`\`\`mermaid fence becomes inside a document.
303
+ - **\`.pdf\`** — one page sized to the diagram, drawn as vectors rather than pixels.
304
+
305
+ All three come from the *same* display list, so they are the same picture rather
306
+ than three renderings that might disagree.
307
+
308
+ ## Colour
309
+
310
+ \`theme\` picks a colour set: \`default\` reproduces Mermaid's own base theme token
311
+ for token; \`dark\` and \`neutral\` are this server's own and are not Mermaid's
312
+ themes of those names. \`themeOverrides\` sets individual tokens on top —
313
+ \`nodeFill\`, \`nodeStroke\`, \`nodeText\`, \`edge\`, \`groupFill\`, \`palette\` and
314
+ the rest. \`palette\` is what colours the slices of a pie, the series of an
315
+ xychart or radar, and the bands of a journey or quadrant.
316
+
317
+ \`background\` defaults to **white**, not transparent: a transparent PNG is
318
+ invisible in a dark viewer, and that is a failure you would never see. Pass
319
+ \`"transparent"\` explicitly if you are compositing it onto something else.
320
+
321
+ ## Layout
322
+
323
+ \`rankGap\`, \`nodeGap\`, \`maxLabelWidth\` and \`padding\` tune the graph diagrams
324
+ (flowchart, state, class, ER, requirement, C4, architecture). Reach for
325
+ \`maxLabelWidth\` first when a diagram comes out too wide — long labels, not the
326
+ graph, are usually the cause.
327
+
328
+ ## Embedding in a document
329
+
330
+ Put a \`\`\`mermaid fence in the Markdown you pass to \`doc_write\`. It is rendered
331
+ and embedded as a picture, scaled down if needed to fit the text column — Word does
332
+ not shrink an oversized image, it runs it off the page. A fence that fails to parse
333
+ is left as a code block and reported, so one bad diagram does not lose the document.
334
+ Pass \`diagrams: false\` to keep every fence as code.
335
+
336
+ ## Adding one to a PDF that already exists
337
+
338
+ \`pdf_edit\` takes \`{ op: "diagram", source | from, pages, x, y, width, height }\`.
339
+ It draws **vectors** onto the page rather than pasting a picture, so the diagram
340
+ stays sharp at any zoom, and the file is saved as an incremental update — bookmarks,
341
+ form fields and signature bytes survive.
342
+
343
+ Two defaults differ from \`diagram_render\`, both because this draws *over* content
344
+ that is already there:
345
+
346
+ - \`background\` is \`"transparent"\`. A white plate would hide the page beneath it.
347
+ - Omitting \`x\`/\`y\` centres it, and omitting \`width\`/\`height\` uses the diagram's
348
+ natural size **shrunk to fit** the page. So \`{ op: "diagram", source, pages: [3] }\`
349
+ lands on the page rather than off the edge of it.
350
+
351
+ ## Everywhere else a diagram can go
352
+
353
+ A worksheet, and a Word template's \`{{%name}}\` placeholder. Both go through the
354
+ generic image source described in the \`images\` topic, where a diagram is one
355
+ source among several rather than a special case.`
114
356
  },
115
357
  formulas: {
116
358
  summary: "Formula syntax notes and one engine limitation worth knowing.",
@@ -156,9 +398,14 @@ In \`sheet_write\`, a formula may reference another sheet in the same spec:
156
398
 
157
399
  ## Reading
158
400
 
159
- \`doc_read\` handles .docx, .pdf, .md and .txt. Word comes back as **Markdown**, so
160
- headings, lists and tables survive. Use \`outline: true\` on a long Word file to
161
- get just the headings before deciding what to read.
401
+ \`doc_read\` handles .docx, .pdf, .md, .txt and .mmd. Word comes back as
402
+ **Markdown**, so headings, lists and tables survive. Use \`outline: true\` on a long
403
+ Word file to get just the headings before deciding what to read.
404
+
405
+ A Markdown file's \`\`\`mermaid fences come back as source, because this tool's
406
+ output is text — but they are **indexed** in a footer. Draw one with
407
+ \`diagram_render({ from, index, to })\`; do not copy the source out through your own
408
+ reply to pass it back as \`source\`.
162
409
 
163
410
  PDFs are reported page by page with \`## Page N\` markers, so you can cite a page.
164
411
  There is **no OCR**: a scanned page reports no extractable text. \`doc_inspect\`
@@ -167,7 +414,8 @@ tells you up front whether a PDF has any text at all.
167
414
  ## Writing
168
415
 
169
416
  \`doc_write\` takes **Markdown** and produces .docx or .pdf. Write the content as
170
- Markdown — that is the input language.
417
+ Markdown — that is the input language. A \`\`\`mermaid fence in it becomes a real
418
+ embedded diagram rather than a code block; see the \`diagrams\` topic.
171
419
 
172
420
  ## Converting
173
421