@tiwater/office-mcp 0.17.5 → 0.17.7

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.
@@ -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.17.5"
5
+ "version": "0.17.7"
6
6
  },
7
7
  "tools": [
8
8
  {
package/office/index.mjs CHANGED
@@ -173,6 +173,7 @@ function docxInspectionOutput(tool) {
173
173
  revision: docxRevision,
174
174
  summary: z.object({
175
175
  tableCount: z.number().int().nonnegative(),
176
+ openingText: z.array(z.string().min(1).max(240)).max(6),
176
177
  }).strict(),
177
178
  }).strict();
178
179
  }
@@ -186,6 +187,19 @@ const docxObjectIdentity = z.object({
186
187
  verticalMerge: z.string().nullable(),
187
188
  }).strict();
188
189
 
190
+ const docxNestedObjectIdentity = docxObjectIdentity.pick({
191
+ ref: true,
192
+ kind: true,
193
+ textPreview: true,
194
+ }).extend({
195
+ gridSpan: z.number().int().positive().optional(),
196
+ verticalMerge: z.string().optional(),
197
+ }).strict();
198
+ const docxObservationNode = z.lazy(() => z.object({
199
+ object: docxNestedObjectIdentity,
200
+ children: z.array(docxObservationNode).optional(),
201
+ }).strict());
202
+
189
203
  const docxObservationReceipt = z.object({
190
204
  schema: z.literal('tiwater.docx-observation-receipt/v1'),
191
205
  operation: z.enum(['list', 'find', 'read']),
@@ -218,14 +232,13 @@ const docxFindLiteralOutput = z.object({
218
232
 
219
233
  const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
220
234
  revision: docxRevision,
221
- object: docxObjectIdentity,
222
- objects: z.array(docxObjectIdentity).min(1),
235
+ observation: docxObservationNode,
223
236
  }).strict();
224
237
 
225
238
  const tools = [
226
239
  {
227
240
  name: 'docx_inspect',
228
- description: 'Inspect one current DOCX. The response returns its revision and table count; use paged docx_find_literal or docx_list_objects to select native objects. The complete inspection remains in the evidence artifact.',
241
+ description: 'Inspect one current DOCX. The response returns its revision, table count, and a bounded sample of its opening non-empty paragraphs for document identification; use paged docx_find_literal or docx_list_objects to select native objects. The complete inspection remains in the evidence artifact.',
229
242
  inputSchema: inputContract('docx_inspect'),
230
243
  outputSchema: docxInspectionOutput('docx_inspect'),
231
244
  annotations: { readOnlyHint: true, idempotentHint: true },
@@ -489,10 +502,17 @@ function buildServer() {
489
502
  }
490
503
 
491
504
  function compactDocxInspection(report) {
492
- if (!report?.revision || !Array.isArray(report.tables)) {
505
+ if (!report?.tables?.revision || !Array.isArray(report.tables.tables) || !Array.isArray(report.flow)) {
493
506
  throw new Error('docx-table-inspection-result-invalid');
494
507
  }
495
- return { revision: report.revision, summary: { tableCount: report.tables.length } };
508
+ const openingText = report.flow
509
+ .filter(item => item?.type === 'paragraph' && typeof item.text === 'string' && item.text.trim())
510
+ .slice(0, 6)
511
+ .map(item => item.text.trim().replace(/\s+/gu, ' ').slice(0, 240));
512
+ return {
513
+ revision: report.tables.revision,
514
+ summary: { tableCount: report.tables.tables.length, openingText },
515
+ };
496
516
  }
497
517
 
498
518
  function compactDocxObjectIdentity(object) {
@@ -506,15 +526,24 @@ function compactDocxObjectIdentity(object) {
506
526
  };
507
527
  }
508
528
 
509
- function compactDocxObservationObjects(observation) {
510
- const objects = [];
511
- function visit(node) {
512
- if (!node?.object) return;
513
- objects.push(compactDocxObjectIdentity(node.object));
514
- for (const child of node.children ?? []) visit(child);
529
+ function compactDocxObservation(observation) {
530
+ if (!observation?.object) throw new Error('docx-read-object-missing-observation');
531
+ function compactNode(node) {
532
+ const identity = compactDocxObjectIdentity(node.object);
533
+ const object = {
534
+ ref: identity.ref,
535
+ kind: identity.kind,
536
+ textPreview: identity.textPreview,
537
+ ...(identity.gridSpan === null ? {} : { gridSpan: identity.gridSpan }),
538
+ ...(identity.verticalMerge === null ? {} : { verticalMerge: identity.verticalMerge }),
539
+ };
540
+ const children = (node.children ?? []).map(compactNode);
541
+ return {
542
+ object,
543
+ ...(children.length === 0 ? {} : { children }),
544
+ };
515
545
  }
516
- visit(observation);
517
- return objects;
546
+ return compactNode(observation);
518
547
  }
519
548
 
520
549
  async function docxInspect(args) {
@@ -525,7 +554,7 @@ async function docxInspect(args) {
525
554
  runtime: commandRuntime(result),
526
555
  source: await fileArtifact(input),
527
556
  artifact: await writeJsonArtifact(requireString(args.output, 'output'), result.json),
528
- ...compactDocxInspection(result.json.tables),
557
+ ...compactDocxInspection(result.json),
529
558
  };
530
559
  }
531
560
 
@@ -561,8 +590,7 @@ async function docxReadObject(args) {
561
590
  source: await fileArtifact(input),
562
591
  artifact: await writeJsonArtifact(output, result.json),
563
592
  revision: result.json.receipt.revision,
564
- object: compactDocxObjectIdentity(result.json.observation.object),
565
- objects: compactDocxObservationObjects(result.json.observation),
593
+ observation: compactDocxObservation(result.json.observation),
566
594
  };
567
595
  });
568
596
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiwater/office-mcp",
3
- "version": "0.17.5",
3
+ "version": "0.17.7",
4
4
  "description": "Published MCP server for Tiwater Office document capabilities",
5
5
  "type": "module",
6
6
  "license": "MIT",