@tiwater/office-mcp 0.18.10 → 0.18.11

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.
@@ -17,6 +17,18 @@
17
17
  "required": ["part", "path"],
18
18
  "additionalProperties": false
19
19
  },
20
+ "limit": {
21
+ "type": "integer",
22
+ "minimum": 1,
23
+ "maximum": 9007199254740991,
24
+ "description": "Maximum number of table rows requested in this response page. The provider may return fewer to keep the machine response bounded."
25
+ },
26
+ "offset": {
27
+ "type": "integer",
28
+ "minimum": 0,
29
+ "maximum": 9007199254740991,
30
+ "description": "Zero-based row offset. Continue from receipt.nextOffset until it is null."
31
+ },
20
32
  "output": {
21
33
  "type": "string",
22
34
  "minLength": 1,
@@ -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.18.10"
5
+ "version": "0.18.11"
6
6
  },
7
7
  "tools": [
8
8
  {
@@ -130,11 +130,11 @@
130
130
  "name": "docx_read_table",
131
131
  "providerContract": {
132
132
  "source": "packages/docx-cli/contracts/mcp-input/docx_read_table.schema.json",
133
- "sha256": "3b85fb6bc390053abdcdbcf4d5a2a4f958a06154286a0327676144324706af83"
133
+ "sha256": "c9c2bbab97bd58cb1426418f022f9c78be802eefb509e951fc4efa35e0096b63"
134
134
  },
135
135
  "inputContract": {
136
136
  "path": "office/contracts/docx_read_table.schema.json",
137
- "sha256": "3b85fb6bc390053abdcdbcf4d5a2a4f958a06154286a0327676144324706af83"
137
+ "sha256": "c9c2bbab97bd58cb1426418f022f9c78be802eefb509e951fc4efa35e0096b63"
138
138
  }
139
139
  },
140
140
  {
package/office/index.mjs CHANGED
@@ -247,6 +247,15 @@ const docxTableIndexOutput = artifactOutput('docx_table_index').extend({
247
247
 
248
248
  const docxTableReadOutput = artifactOutput('docx_read_table').extend({
249
249
  schema: z.literal('tiwater.docx-table-read/v1'),
250
+ receipt: z.object({
251
+ schema: z.literal('tiwater.docx-table-read-receipt/v1'),
252
+ totalRowCount: z.number().int().nonnegative(),
253
+ returnedRowCount: z.number().int().nonnegative(),
254
+ remaining: z.number().int().nonnegative(),
255
+ nextOffset: z.number().int().nonnegative().nullable(),
256
+ inlineTextNodesOmitted: z.literal(true),
257
+ narrowingRequired: z.boolean(),
258
+ }).strict(),
250
259
  address: docxAddress,
251
260
  rowCount: z.number().int().nonnegative(),
252
261
  columnCount: z.number().int().nonnegative(),
@@ -281,7 +290,14 @@ const docxTableReadOutput = artifactOutput('docx_read_table').extend({
281
290
  }).strict();
282
291
 
283
292
  const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
284
- observations: z.array(docxObservationNode).min(1),
293
+ receipt: z.object({
294
+ schema: z.literal('tiwater.docx-read-object-receipt/v1'),
295
+ observationCount: z.number().int().positive(),
296
+ returnedCount: z.number().int().nonnegative(),
297
+ responseComplete: z.boolean(),
298
+ narrowingRequired: z.boolean(),
299
+ }).strict(),
300
+ observations: z.array(docxObservationNode),
285
301
  }).strict();
286
302
 
287
303
  const tools = [
@@ -311,7 +327,7 @@ const tools = [
311
327
  },
312
328
  {
313
329
  name: 'docx_read_object',
314
- description: 'Read selected rows, cells, or paragraphs from one native DOCX in one call and return their requested descendants in address order. Use docx_read_table when the current task needs one complete table. For exact inline content, use an observed cell or paragraph address and request run or text.',
330
+ description: 'Read selected rows, cells, or paragraphs from one native DOCX and retain the complete result at output. The response returns compact requested descendants when bounded; if receipt.narrowingRequired is true, request fewer observed addresses or descendants. Use docx_read_table for a table.',
315
331
  inputSchema: inputContract('docx_read_object'),
316
332
  outputSchema: docxReadObjectOutput,
317
333
  annotations: { readOnlyHint: true, idempotentHint: true },
@@ -319,7 +335,7 @@ const tools = [
319
335
  },
320
336
  {
321
337
  name: 'docx_read_table',
322
- description: 'Read exactly one table selected from docx_table_index by native OpenXML address. Returns its nearest non-empty paragraph before and after the table, rows, cells, spans, vertical merges, paragraphs, text nodes, and reusable addresses in document order. It does not locate a table or decide business meaning.',
338
+ description: 'Read exactly one table selected from docx_table_index by native OpenXML address. Writes the complete table, including text nodes, to output and returns a bounded row page with cells, spans, vertical merges, paragraph text, and reusable addresses. Continue with receipt.nextOffset. If receipt.narrowingRequired is true, list rows under the same table and read smaller objects. It does not locate a table or decide business meaning.',
323
339
  inputSchema: inputContract('docx_read_table'),
324
340
  outputSchema: docxTableReadOutput,
325
341
  annotations: { readOnlyHint: true, idempotentHint: true },
@@ -663,7 +679,50 @@ async function docxObservation(tool, args) {
663
679
  tables,
664
680
  };
665
681
  }
666
- if (tool === 'docx_read_table') return { ...retained, ...payload };
682
+ if (tool === 'docx_read_table') {
683
+ const totalRowCount = payload.rows.length;
684
+ const offset = Math.min(args.offset ?? 0, totalRowCount);
685
+ const requestedLimit = args.limit ?? totalRowCount;
686
+ const rows = [];
687
+ let narrowingRequired = false;
688
+ for (const sourceRow of payload.rows.slice(offset, offset + requestedLimit)) {
689
+ const row = {
690
+ ...sourceRow,
691
+ cells: sourceRow.cells.map(cell => ({
692
+ ...cell,
693
+ paragraphs: cell.paragraphs.map(paragraph => ({ ...paragraph, textNodes: [] })),
694
+ })),
695
+ };
696
+ const candidate = [...rows, row];
697
+ if (Buffer.byteLength(JSON.stringify(candidate)) > 6_500) {
698
+ narrowingRequired = rows.length === 0;
699
+ break;
700
+ }
701
+ rows.push(row);
702
+ }
703
+ const nextOffset = !narrowingRequired && offset + rows.length < totalRowCount
704
+ ? offset + rows.length
705
+ : null;
706
+ return {
707
+ ...retained,
708
+ schema: payload.schema,
709
+ address: payload.address,
710
+ rowCount: payload.rowCount,
711
+ columnCount: payload.columnCount,
712
+ precedingParagraph: payload.precedingParagraph,
713
+ followingParagraph: payload.followingParagraph,
714
+ receipt: {
715
+ schema: 'tiwater.docx-table-read-receipt/v1',
716
+ totalRowCount,
717
+ returnedRowCount: rows.length,
718
+ remaining: totalRowCount - offset - rows.length,
719
+ nextOffset,
720
+ inlineTextNodesOmitted: true,
721
+ narrowingRequired,
722
+ },
723
+ rows,
724
+ };
725
+ }
667
726
  throw new Error(`unsupported-docx-observation-tool:${tool}`);
668
727
  });
669
728
  }
@@ -674,12 +733,21 @@ async function docxReadObject(args) {
674
733
  const { output: _output, ...request } = args;
675
734
  return withTempJsonFile(request, async requestPath => {
676
735
  const result = await runJsonCandidateChain(docxCandidates, ['docx_read_object', requestPath]);
736
+ const observations = result.json.observations.map(compactDocxObservation);
737
+ const responseComplete = Buffer.byteLength(JSON.stringify(observations)) <= 6_500;
677
738
  return {
678
739
  tool: 'docx_read_object',
679
740
  runtime: commandRuntime(result),
680
741
  source: await fileArtifact(input),
681
742
  artifact: await writeJsonArtifact(output, result.json),
682
- observations: result.json.observations.map(compactDocxObservation),
743
+ receipt: {
744
+ schema: 'tiwater.docx-read-object-receipt/v1',
745
+ observationCount: observations.length,
746
+ returnedCount: responseComplete ? observations.length : 0,
747
+ responseComplete,
748
+ narrowingRequired: !responseComplete,
749
+ },
750
+ observations: responseComplete ? observations : [],
683
751
  };
684
752
  });
685
753
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiwater/office-mcp",
3
- "version": "0.18.10",
3
+ "version": "0.18.11",
4
4
  "description": "Published MCP server for Tiwater Office document capabilities",
5
5
  "type": "module",
6
6
  "license": "MIT",