@tiwater/office-mcp 0.21.1 → 0.21.2

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.
@@ -0,0 +1,15 @@
1
+ import path from 'node:path';
2
+
3
+ const pendingWrites = new Map();
4
+
5
+ export async function withOutputWriteLock(output, write) {
6
+ const target = path.resolve(output);
7
+ const previous = pendingWrites.get(target) ?? Promise.resolve();
8
+ const current = previous.catch(() => undefined).then(write);
9
+ pendingWrites.set(target, current);
10
+ try {
11
+ return await current;
12
+ } finally {
13
+ if (pendingWrites.get(target) === current) pendingWrites.delete(target);
14
+ }
15
+ }
@@ -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.1"
5
+ "version": "0.21.2"
6
6
  },
7
7
  "tools": [
8
8
  {
package/office/index.mjs CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  returnedContentBudgetBytes,
22
22
  writeJsonArtifact,
23
23
  } from '../_shared/large-json-result.mjs';
24
+ import { withOutputWriteLock } from '../_shared/output-write-lock.mjs';
24
25
 
25
26
  const packageMetadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
26
27
  const inputContractManifest = JSON.parse(await readFile(
@@ -644,7 +645,9 @@ function buildServer() {
644
645
  ...(tool.annotations ? { annotations: tool.annotations } : {}),
645
646
  },
646
647
  async args => {
647
- const payload = await tool.handler(args);
648
+ const payload = typeof args.output === 'string'
649
+ ? await withOutputWriteLock(args.output, () => tool.handler(args))
650
+ : await tool.handler(args);
648
651
  return createToolResult(payload, { isError: payload?.summary?.pass === false });
649
652
  },
650
653
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiwater/office-mcp",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "Published MCP server for Tiwater Office document capabilities",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -18,6 +18,7 @@
18
18
  "files": [
19
19
  "_shared/tool-runtime.mjs",
20
20
  "_shared/large-json-result.mjs",
21
+ "_shared/output-write-lock.mjs",
21
22
  "office/index.mjs",
22
23
  "office/README.md",
23
24
  "office/contracts/tiwater-office-provider-contract-manifest-v1.json",