@tiwater/office-mcp 0.21.46 → 0.21.48

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.
@@ -93,9 +93,15 @@
93
93
  }, "required": ["prototypeRow", "cells"], "additionalProperties": false
94
94
  }
95
95
  },
96
+ "tableInput": {
97
+ "type": "string",
98
+ "minLength": 1,
99
+ "description": "Absolute path to a JSON file containing exactly table, existingRows, columns, and rows. Use this for a large table replacement so its structure and content stay out of the tool call.",
100
+ "x-tiwater-file-role": "read"
101
+ },
96
102
  "output": { "type": "string", "minLength": 1, "description": "Output DOCX path; may equal input for one atomic in-place update.", "x-tiwater-file-role": "write" },
97
103
  "receiptOutput": { "type": "string", "minLength": 1, "x-tiwater-file-role": "write", "x-tiwater-file-effect": false }
98
104
  },
99
- "required": ["input", "table", "existingRows", "columns", "rows", "output", "receiptOutput"],
105
+ "required": ["input", "output", "receiptOutput"],
100
106
  "additionalProperties": false
101
107
  }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "tiwater.office-mcp-input/docx_set_table_width",
4
+ "type": "object",
5
+ "properties": {
6
+ "input": {
7
+ "type": "string",
8
+ "minLength": 1,
9
+ "x-tiwater-file-role": "read",
10
+ "x-tiwater-document-revision-role": "current"
11
+ },
12
+ "changes": {
13
+ "type": "array",
14
+ "minItems": 1,
15
+ "items": {
16
+ "type": "object",
17
+ "properties": {
18
+ "table": {
19
+ "type": "object",
20
+ "properties": {
21
+ "part": { "type": "string", "minLength": 1, "pattern": "^\\/" },
22
+ "path": { "type": "string", "pattern": "^\\/[A-Za-z_][A-Za-z0-9_.-]*:[A-Za-z_][A-Za-z0-9_.-]*\\[[1-9][0-9]*\\](?:\\/[A-Za-z_][A-Za-z0-9_.-]*:[A-Za-z_][A-Za-z0-9_.-]*\\[[1-9][0-9]*\\])*$" }
23
+ },
24
+ "required": ["part", "path"],
25
+ "additionalProperties": false
26
+ },
27
+ "width": {
28
+ "oneOf": [
29
+ {
30
+ "type": "object",
31
+ "properties": {
32
+ "type": { "type": "string", "enum": ["dxa", "pct"] },
33
+ "value": { "type": "string", "pattern": "^[1-9][0-9]*$" }
34
+ },
35
+ "required": ["type", "value"],
36
+ "additionalProperties": false
37
+ },
38
+ {
39
+ "type": "object",
40
+ "properties": {
41
+ "type": { "type": "string", "enum": ["auto", "nil"] },
42
+ "value": { "type": "string", "const": "0" }
43
+ },
44
+ "required": ["type", "value"],
45
+ "additionalProperties": false
46
+ }
47
+ ]
48
+ }
49
+ },
50
+ "required": ["table", "width"],
51
+ "additionalProperties": false
52
+ }
53
+ },
54
+ "output": {
55
+ "type": "string",
56
+ "minLength": 1,
57
+ "description": "Output DOCX path; may equal input for an atomic in-place update.",
58
+ "x-tiwater-file-role": "write"
59
+ },
60
+ "receiptOutput": {
61
+ "type": "string",
62
+ "minLength": 1,
63
+ "x-tiwater-file-role": "write",
64
+ "x-tiwater-file-effect": false
65
+ }
66
+ },
67
+ "required": ["input", "changes", "output", "receiptOutput"],
68
+ "additionalProperties": false
69
+ }
@@ -34,6 +34,11 @@
34
34
  },
35
35
  "text": {
36
36
  "type": "string"
37
+ },
38
+ "fontName": {
39
+ "type": "string",
40
+ "minLength": 1,
41
+ "description": "Optional Latin and complex-script font family for the replacement run. East Asian font settings remain inherited from the target."
37
42
  }
38
43
  },
39
44
  "required": [
@@ -2,7 +2,7 @@
2
2
  "schema": "tiwater.office-provider-contract-manifest/v1",
3
3
  "provider": {
4
4
  "id": "@tiwater/office-mcp",
5
- "version": "0.21.46"
5
+ "version": "0.21.48"
6
6
  },
7
7
  "tools": [
8
8
  {
@@ -207,22 +207,33 @@
207
207
  "name": "docx_set_table",
208
208
  "providerContract": {
209
209
  "source": "packages/docx-cli/contracts/mcp-input/docx_set_table.schema.json",
210
- "sha256": "d9a9f09ee3ca13764120bcf58e501a3edc508333b01aa4e6d299db8ba7bf2834"
210
+ "sha256": "d04c40174ce3427689c970b26dd3a282f9d9f6889e4c5ac737eca5926ef709b9"
211
211
  },
212
212
  "inputContract": {
213
213
  "path": "office/contracts/docx_set_table.schema.json",
214
- "sha256": "d9a9f09ee3ca13764120bcf58e501a3edc508333b01aa4e6d299db8ba7bf2834"
214
+ "sha256": "d04c40174ce3427689c970b26dd3a282f9d9f6889e4c5ac737eca5926ef709b9"
215
+ }
216
+ },
217
+ {
218
+ "name": "docx_set_table_width",
219
+ "providerContract": {
220
+ "source": "packages/docx-cli/contracts/mcp-input/docx_set_table_width.schema.json",
221
+ "sha256": "7a51a25a139ffa57c76eeed43dc2a8b9252fafdc0d299ede995f68d44021a3a6"
222
+ },
223
+ "inputContract": {
224
+ "path": "office/contracts/docx_set_table_width.schema.json",
225
+ "sha256": "7a51a25a139ffa57c76eeed43dc2a8b9252fafdc0d299ede995f68d44021a3a6"
215
226
  }
216
227
  },
217
228
  {
218
229
  "name": "docx_set_text",
219
230
  "providerContract": {
220
231
  "source": "packages/docx-cli/contracts/mcp-input/docx_set_text.schema.json",
221
- "sha256": "4d6f69ef474c0a3ceade95cce362fba7e000946bb890e64119177c5519524db2"
232
+ "sha256": "45d8aa5d95402ac5b17fe07540355f81afa0804214ef319f33d7da11cf3c56cc"
222
233
  },
223
234
  "inputContract": {
224
235
  "path": "office/contracts/docx_set_text.schema.json",
225
- "sha256": "4d6f69ef474c0a3ceade95cce362fba7e000946bb890e64119177c5519524db2"
236
+ "sha256": "45d8aa5d95402ac5b17fe07540355f81afa0804214ef319f33d7da11cf3c56cc"
226
237
  }
227
238
  },
228
239
  {
@@ -0,0 +1,31 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ const tableFields = ['table', 'existingRows', 'columns', 'rows'];
5
+
6
+ function hasInlineTable(args) {
7
+ return tableFields.every((field) => args?.[field] !== undefined);
8
+ }
9
+
10
+ export async function resolveFileBackedTable(args) {
11
+ const hasInline = hasInlineTable(args);
12
+ const hasFile = typeof args?.tableInput === 'string' && args.tableInput.trim().length > 0;
13
+ if (!hasInline && !hasFile) throw new Error('provide-inline-table-or-tableInput');
14
+ if (hasInline && hasFile) throw new Error('provide-only-one-table-input');
15
+ if (hasInline) return args;
16
+
17
+ let tableRequest;
18
+ try {
19
+ tableRequest = JSON.parse(await readFile(path.resolve(args.tableInput), 'utf8'));
20
+ } catch (error) {
21
+ throw new Error(`tableInput-invalid: ${error.message}`);
22
+ }
23
+ if (!tableRequest || typeof tableRequest !== 'object' || Array.isArray(tableRequest)
24
+ || !tableFields.every((field) => tableRequest[field] !== undefined)
25
+ || Object.keys(tableRequest).some((field) => !tableFields.includes(field))) {
26
+ throw new Error('tableInput-must-contain-table-existingRows-columns-and-rows');
27
+ }
28
+ const resolved = { ...args, ...tableRequest };
29
+ delete resolved.tableInput;
30
+ return resolved;
31
+ }
package/office/index.mjs CHANGED
@@ -31,6 +31,7 @@ import {
31
31
  } from '../_shared/effect-kind.mjs';
32
32
  import { compactDocxObjectIdentity } from './docx-object-identity.mjs';
33
33
  import { resolveFileBackedChanges } from './file-backed-changes.mjs';
34
+ import { resolveFileBackedTable } from './file-backed-table.mjs';
34
35
 
35
36
  const packageMetadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
36
37
  const inputContractManifest = JSON.parse(await readFile(
@@ -496,6 +497,10 @@ const docxTableReadOutput = docxObservationOutput('docx_read_table').extend({
496
497
  address: docxAddress,
497
498
  rowCount: z.number().int().nonnegative(),
498
499
  columnCount: z.number().int().nonnegative(),
500
+ tableWidth: z.object({
501
+ type: z.enum(['auto', 'dxa', 'nil', 'pct']),
502
+ value: z.string(),
503
+ }).strict().nullable(),
499
504
  gridColumns: z.array(z.object({
500
505
  address: docxAddress,
501
506
  widthTwips: z.number().int().positive().nullable(),
@@ -600,7 +605,7 @@ const tools = [
600
605
  {
601
606
  name: 'docx_set_text',
602
607
  effectKind: 'document-mutation',
603
- description: 'Replace the whole text content of paragraph or cell objects observed from this exact input DOCX while retaining target formatting, bookmarks, spans, and vertical merges. For a vertically merged logical cell, write its visible text to the restart cell rather than a continue cell. Tabs and line breaks remain native document text controls; targets containing non-text objects are rejected. Use this only for newly derived text. Content copied or selected from a source DOCX uses docx_replace_content_from_source so native runs such as superscript and subscript are retained. This does not insert objects, change table structure, copy source formatting, or decide business wording.',
608
+ description: 'Replace the whole text content of paragraph or cell objects observed from this exact input DOCX while retaining target formatting, bookmarks, spans, and vertical merges. A change may explicitly set the Latin and complex-script font family of its nonempty replacement run; East Asian font settings remain inherited from the target. For a vertically merged logical cell, write its visible text to the restart cell rather than a continue cell. Tabs and line breaks remain native document text controls; targets containing non-text objects are rejected. Use this only for newly derived text. Content copied or selected from a source DOCX uses docx_replace_content_from_source so native runs such as superscript and subscript are retained. This does not insert objects, change table structure, copy source formatting, or decide business wording.',
604
609
  inputSchema: inputContract('docx_set_text'),
605
610
  outputSchema: fixedEditOutput('docx_set_text'),
606
611
  handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
@@ -613,13 +618,21 @@ const tools = [
613
618
  outputSchema: fixedEditOutput('docx_set_paragraph_pagination'),
614
619
  handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
615
620
  },
621
+ {
622
+ name: 'docx_set_table_width',
623
+ effectKind: 'document-mutation',
624
+ description: 'Set the explicit native width of one or more selected current DOCX tables. Width type is pct, dxa, auto, or nil; pct/dxa take an exact positive Open XML value and auto/nil take 0. This does not change grid-column widths, autofit behavior, cell widths, table structure, content, or business meaning.',
625
+ inputSchema: inputContract('docx_set_table_width'),
626
+ outputSchema: fixedEditOutput('docx_set_table_width'),
627
+ handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
628
+ },
616
629
  {
617
630
  name: 'docx_set_table',
618
631
  effectKind: 'document-mutation',
619
632
  description: 'Atomically replace one exact current target-table row range with a fully specified table body. Name every target grid column in native order. Every rows[] item must contain its own prototypeRow; there is no table-level prototypeRow. Every cell must contain text: use a string for derived plain text, or null together with sourceInput and exact native sourceSelections. Each explicit cell occupies contiguous columns and may span logical rows; covered columns are omitted from following rows. Native source selections retain run formatting such as superscript and subscript. The provider retains the target table, target cell styles, grid widths, and all content outside the replaced range, and exposes no intermediate document. It does not select source rows, map business columns, infer target shape, derive wording, or copy a source table wholesale.',
620
633
  inputSchema: inputContract('docx_set_table'),
621
634
  outputSchema: fixedEditOutput('docx_set_table'),
622
- handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
635
+ handler: async (args, tool) => fixedEdit(tool, await resolveFileBackedTable(args), docxCandidates),
623
636
  },
624
637
  {
625
638
  name: 'docx_insert_objects',
@@ -1102,6 +1115,7 @@ async function docxObservation(tool, args) {
1102
1115
  address: payload.address,
1103
1116
  rowCount: payload.rowCount,
1104
1117
  columnCount: payload.columnCount,
1118
+ tableWidth: payload.tableWidth,
1105
1119
  gridColumns: payload.gridColumns,
1106
1120
  precedingParagraph: payload.precedingParagraph,
1107
1121
  followingParagraph: payload.followingParagraph,
@@ -1119,6 +1133,7 @@ async function docxObservation(tool, args) {
1119
1133
  address: payload.address,
1120
1134
  rowCount: payload.rowCount,
1121
1135
  columnCount: payload.columnCount,
1136
+ tableWidth: payload.tableWidth,
1122
1137
  gridColumns: payload.gridColumns,
1123
1138
  precedingParagraph: payload.precedingParagraph,
1124
1139
  followingParagraph: payload.followingParagraph,
@@ -1174,6 +1189,7 @@ async function docxObservation(tool, args) {
1174
1189
  address: payload.address,
1175
1190
  rowCount: payload.rowCount,
1176
1191
  columnCount: payload.columnCount,
1192
+ tableWidth: payload.tableWidth,
1177
1193
  gridColumns: payload.gridColumns,
1178
1194
  precedingParagraph: payload.precedingParagraph,
1179
1195
  followingParagraph: payload.followingParagraph,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiwater/office-mcp",
3
- "version": "0.21.46",
3
+ "version": "0.21.48",
4
4
  "description": "Published MCP distribution for independent Tiwater Office, PDF, and Text document capabilities",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,6 +27,7 @@
27
27
  "office/index.mjs",
28
28
  "office/docx-object-identity.mjs",
29
29
  "office/file-backed-changes.mjs",
30
+ "office/file-backed-table.mjs",
30
31
  "office/README.md",
31
32
  "office/contracts/tiwater-office-provider-contract-manifest-v1.json",
32
33
  "office/contracts/*.schema.json",
@@ -2,7 +2,7 @@
2
2
  "schema": "tiwater.pdf-provider-contract-manifest/v1",
3
3
  "provider": {
4
4
  "id": "@tiwater/office-mcp",
5
- "version": "0.21.46"
5
+ "version": "0.21.48"
6
6
  },
7
7
  "runtime": {
8
8
  "command": "tiwater-pdf"
@@ -2,7 +2,7 @@
2
2
  "schema": "tiwater.text-provider-contract-manifest/v1",
3
3
  "provider": {
4
4
  "id": "@tiwater/office-mcp",
5
- "version": "0.21.46"
5
+ "version": "0.21.48"
6
6
  },
7
7
  "tools": [
8
8
  {