@usejunior/docx-mcp 0.3.1 → 0.6.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 (167) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cli/commands/grep.d.ts +15 -0
  3. package/dist/cli/commands/grep.d.ts.map +1 -0
  4. package/dist/cli/commands/grep.js +128 -0
  5. package/dist/cli/commands/grep.js.map +1 -0
  6. package/dist/cli/flag_parser.js +1 -1
  7. package/dist/cli/flag_parser.js.map +1 -1
  8. package/dist/cli/help.d.ts.map +1 -1
  9. package/dist/cli/help.js +1 -0
  10. package/dist/cli/help.js.map +1 -1
  11. package/dist/cli/index.d.ts.map +1 -1
  12. package/dist/cli/index.js +7 -0
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/conformance/harness.d.ts.map +1 -1
  15. package/dist/conformance/harness.js +10 -11
  16. package/dist/conformance/harness.js.map +1 -1
  17. package/dist/gdocs_loader.d.ts +2 -0
  18. package/dist/gdocs_loader.d.ts.map +1 -0
  19. package/dist/gdocs_loader.js +14 -0
  20. package/dist/gdocs_loader.js.map +1 -0
  21. package/dist/server.d.ts +2 -2
  22. package/dist/server.d.ts.map +1 -1
  23. package/dist/server.js +68 -7
  24. package/dist/server.js.map +1 -1
  25. package/dist/session/manager.d.ts +52 -16
  26. package/dist/session/manager.d.ts.map +1 -1
  27. package/dist/session/manager.js +140 -56
  28. package/dist/session/manager.js.map +1 -1
  29. package/dist/tool_catalog.d.ts +44 -55
  30. package/dist/tool_catalog.d.ts.map +1 -1
  31. package/dist/tool_catalog.js +56 -41
  32. package/dist/tool_catalog.js.map +1 -1
  33. package/dist/tools/accept_changes.d.ts +0 -1
  34. package/dist/tools/accept_changes.d.ts.map +1 -1
  35. package/dist/tools/accept_changes.js +1 -1
  36. package/dist/tools/accept_changes.js.map +1 -1
  37. package/dist/tools/add_comment.d.ts +0 -1
  38. package/dist/tools/add_comment.d.ts.map +1 -1
  39. package/dist/tools/add_comment.js +2 -2
  40. package/dist/tools/add_comment.js.map +1 -1
  41. package/dist/tools/add_footnote.d.ts +0 -1
  42. package/dist/tools/add_footnote.d.ts.map +1 -1
  43. package/dist/tools/add_footnote.js +1 -1
  44. package/dist/tools/add_footnote.js.map +1 -1
  45. package/dist/tools/apply_plan.d.ts +0 -1
  46. package/dist/tools/apply_plan.d.ts.map +1 -1
  47. package/dist/tools/apply_plan.js +6 -6
  48. package/dist/tools/apply_plan.js.map +1 -1
  49. package/dist/tools/clear_formatting.d.ts +0 -1
  50. package/dist/tools/clear_formatting.d.ts.map +1 -1
  51. package/dist/tools/clear_formatting.js +1 -1
  52. package/dist/tools/clear_formatting.js.map +1 -1
  53. package/dist/tools/{clear_session.d.ts → close_file.d.ts} +2 -3
  54. package/dist/tools/close_file.d.ts.map +1 -0
  55. package/dist/tools/close_file.js +46 -0
  56. package/dist/tools/close_file.js.map +1 -0
  57. package/dist/tools/compare_documents.d.ts +0 -1
  58. package/dist/tools/compare_documents.d.ts.map +1 -1
  59. package/dist/tools/compare_documents.js +4 -5
  60. package/dist/tools/compare_documents.js.map +1 -1
  61. package/dist/tools/delete_comment.d.ts +0 -1
  62. package/dist/tools/delete_comment.d.ts.map +1 -1
  63. package/dist/tools/delete_comment.js +1 -1
  64. package/dist/tools/delete_comment.js.map +1 -1
  65. package/dist/tools/delete_footnote.d.ts +0 -1
  66. package/dist/tools/delete_footnote.d.ts.map +1 -1
  67. package/dist/tools/delete_footnote.js +1 -1
  68. package/dist/tools/delete_footnote.js.map +1 -1
  69. package/dist/tools/extract_revisions.d.ts +0 -1
  70. package/dist/tools/extract_revisions.d.ts.map +1 -1
  71. package/dist/tools/extract_revisions.js +1 -1
  72. package/dist/tools/extract_revisions.js.map +1 -1
  73. package/dist/tools/format_layout.d.ts +0 -1
  74. package/dist/tools/format_layout.d.ts.map +1 -1
  75. package/dist/tools/format_layout.js +1 -1
  76. package/dist/tools/format_layout.js.map +1 -1
  77. package/dist/tools/gdocs/close_file.d.ts +4 -0
  78. package/dist/tools/gdocs/close_file.d.ts.map +1 -0
  79. package/dist/tools/gdocs/close_file.js +15 -0
  80. package/dist/tools/gdocs/close_file.js.map +1 -0
  81. package/dist/tools/gdocs/format_layout.d.ts +14 -0
  82. package/dist/tools/gdocs/format_layout.d.ts.map +1 -0
  83. package/dist/tools/gdocs/format_layout.js +88 -0
  84. package/dist/tools/gdocs/format_layout.js.map +1 -0
  85. package/dist/tools/gdocs/get_file_status.d.ts +4 -0
  86. package/dist/tools/gdocs/get_file_status.d.ts.map +1 -0
  87. package/dist/tools/gdocs/get_file_status.js +22 -0
  88. package/dist/tools/gdocs/get_file_status.js.map +1 -0
  89. package/dist/tools/gdocs/grep.d.ts +13 -0
  90. package/dist/tools/gdocs/grep.d.ts.map +1 -0
  91. package/dist/tools/gdocs/grep.js +113 -0
  92. package/dist/tools/gdocs/grep.js.map +1 -0
  93. package/dist/tools/gdocs/insert_paragraph.d.ts +9 -0
  94. package/dist/tools/gdocs/insert_paragraph.d.ts.map +1 -0
  95. package/dist/tools/gdocs/insert_paragraph.js +35 -0
  96. package/dist/tools/gdocs/insert_paragraph.js.map +1 -0
  97. package/dist/tools/gdocs/read_file.d.ts +9 -0
  98. package/dist/tools/gdocs/read_file.d.ts.map +1 -0
  99. package/dist/tools/gdocs/read_file.js +116 -0
  100. package/dist/tools/gdocs/read_file.js.map +1 -0
  101. package/dist/tools/gdocs/replace_text.d.ts +9 -0
  102. package/dist/tools/gdocs/replace_text.d.ts.map +1 -0
  103. package/dist/tools/gdocs/replace_text.js +35 -0
  104. package/dist/tools/gdocs/replace_text.js.map +1 -0
  105. package/dist/tools/gdocs/save.d.ts +7 -0
  106. package/dist/tools/gdocs/save.d.ts.map +1 -0
  107. package/dist/tools/gdocs/save.js +46 -0
  108. package/dist/tools/gdocs/save.js.map +1 -0
  109. package/dist/tools/get_comments.d.ts +0 -1
  110. package/dist/tools/get_comments.d.ts.map +1 -1
  111. package/dist/tools/get_comments.js +1 -1
  112. package/dist/tools/get_comments.js.map +1 -1
  113. package/dist/tools/get_file_status.d.ts +6 -0
  114. package/dist/tools/get_file_status.d.ts.map +1 -0
  115. package/dist/tools/get_file_status.js +40 -0
  116. package/dist/tools/get_file_status.js.map +1 -0
  117. package/dist/tools/get_footnotes.d.ts +0 -1
  118. package/dist/tools/get_footnotes.d.ts.map +1 -1
  119. package/dist/tools/get_footnotes.js +1 -1
  120. package/dist/tools/get_footnotes.js.map +1 -1
  121. package/dist/tools/grep.d.ts +5 -2
  122. package/dist/tools/grep.d.ts.map +1 -1
  123. package/dist/tools/grep.js +236 -90
  124. package/dist/tools/grep.js.map +1 -1
  125. package/dist/tools/has_tracked_changes.d.ts +0 -1
  126. package/dist/tools/has_tracked_changes.d.ts.map +1 -1
  127. package/dist/tools/has_tracked_changes.js +1 -1
  128. package/dist/tools/has_tracked_changes.js.map +1 -1
  129. package/dist/tools/init_plan.d.ts +0 -1
  130. package/dist/tools/init_plan.d.ts.map +1 -1
  131. package/dist/tools/init_plan.js +2 -1
  132. package/dist/tools/init_plan.js.map +1 -1
  133. package/dist/tools/insert_paragraph.d.ts +0 -1
  134. package/dist/tools/insert_paragraph.d.ts.map +1 -1
  135. package/dist/tools/insert_paragraph.js +1 -1
  136. package/dist/tools/insert_paragraph.js.map +1 -1
  137. package/dist/tools/open_document.d.ts.map +1 -1
  138. package/dist/tools/open_document.js +1 -2
  139. package/dist/tools/open_document.js.map +1 -1
  140. package/dist/tools/provider_guard.d.ts +3 -0
  141. package/dist/tools/provider_guard.d.ts.map +1 -0
  142. package/dist/tools/provider_guard.js +12 -0
  143. package/dist/tools/provider_guard.js.map +1 -0
  144. package/dist/tools/read_file.d.ts +0 -1
  145. package/dist/tools/read_file.d.ts.map +1 -1
  146. package/dist/tools/read_file.js +89 -17
  147. package/dist/tools/read_file.js.map +1 -1
  148. package/dist/tools/replace_text.d.ts +0 -1
  149. package/dist/tools/replace_text.d.ts.map +1 -1
  150. package/dist/tools/replace_text.js +1 -1
  151. package/dist/tools/replace_text.js.map +1 -1
  152. package/dist/tools/save.d.ts +0 -1
  153. package/dist/tools/save.d.ts.map +1 -1
  154. package/dist/tools/save.js +3 -4
  155. package/dist/tools/save.js.map +1 -1
  156. package/dist/tools/session_resolution.d.ts +16 -4
  157. package/dist/tools/session_resolution.d.ts.map +1 -1
  158. package/dist/tools/session_resolution.js +132 -67
  159. package/dist/tools/session_resolution.js.map +1 -1
  160. package/dist/tools/update_footnote.d.ts +0 -1
  161. package/dist/tools/update_footnote.d.ts.map +1 -1
  162. package/dist/tools/update_footnote.js +1 -1
  163. package/dist/tools/update_footnote.js.map +1 -1
  164. package/package.json +11 -3
  165. package/dist/tools/clear_session.d.ts.map +0 -1
  166. package/dist/tools/clear_session.js +0 -66
  167. package/dist/tools/clear_session.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
3
3
  readonly name: "read_file";
4
- readonly description: "Read document content. Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate. Accepts session_id or file_path.";
4
+ readonly description: "Read document content (DOCX or Google Doc). Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate.";
5
5
  readonly input: z.ZodObject<{
6
6
  offset: z.ZodOptional<z.ZodNumber>;
7
7
  limit: z.ZodOptional<z.ZodNumber>;
@@ -12,7 +12,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
12
12
  simple: "simple";
13
13
  }>>;
14
14
  show_formatting: z.ZodOptional<z.ZodBoolean>;
15
- session_id: z.ZodOptional<z.ZodString>;
15
+ google_doc_id: z.ZodOptional<z.ZodString>;
16
16
  file_path: z.ZodOptional<z.ZodString>;
17
17
  }, z.core.$strip>;
18
18
  readonly annotations: {
@@ -21,8 +21,9 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
21
21
  };
22
22
  }, {
23
23
  readonly name: "grep";
24
- readonly description: "Search paragraphs with regex. Accepts session_id or file_path.";
24
+ readonly description: "Search paragraphs with regex. Use file_path for session-based search, file_paths for stateless multi-file search, or google_doc_id for Google Docs.";
25
25
  readonly input: z.ZodObject<{
26
+ file_paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
27
  patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
28
  pattern: z.ZodOptional<z.ZodString>;
28
29
  case_sensitive: z.ZodOptional<z.ZodBoolean>;
@@ -30,7 +31,9 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
30
31
  max_results: z.ZodOptional<z.ZodNumber>;
31
32
  context_chars: z.ZodOptional<z.ZodNumber>;
32
33
  dedupe_by_paragraph: z.ZodOptional<z.ZodBoolean>;
33
- session_id: z.ZodOptional<z.ZodString>;
34
+ search_xml: z.ZodOptional<z.ZodBoolean>;
35
+ include_context: z.ZodOptional<z.ZodBoolean>;
36
+ google_doc_id: z.ZodOptional<z.ZodString>;
34
37
  file_path: z.ZodOptional<z.ZodString>;
35
38
  }, z.core.$strip>;
36
39
  readonly annotations: {
@@ -39,12 +42,11 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
39
42
  };
40
43
  }, {
41
44
  readonly name: "init_plan";
42
- readonly description: "Initialize revision-bound context metadata for coordinated multi-agent planning. Accepts session_id or file_path.";
45
+ readonly description: "Initialize revision-bound context metadata for coordinated multi-agent planning.";
43
46
  readonly input: z.ZodObject<{
44
47
  plan_name: z.ZodOptional<z.ZodString>;
45
48
  orchestrator_id: z.ZodOptional<z.ZodString>;
46
- session_id: z.ZodOptional<z.ZodString>;
47
- file_path: z.ZodOptional<z.ZodString>;
49
+ file_path: z.ZodString;
48
50
  }, z.core.$strip>;
49
51
  readonly annotations: {
50
52
  readonly readOnlyHint: true;
@@ -64,12 +66,11 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
64
66
  };
65
67
  }, {
66
68
  readonly name: "apply_plan";
67
- readonly description: "Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a session document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output.";
69
+ readonly description: "Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output.";
68
70
  readonly input: z.ZodObject<{
69
71
  steps: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$catchall<z.ZodUnknown>>>>;
70
72
  plan_file_path: z.ZodOptional<z.ZodString>;
71
- session_id: z.ZodOptional<z.ZodString>;
72
- file_path: z.ZodOptional<z.ZodString>;
73
+ file_path: z.ZodString;
73
74
  }, z.core.$strip>;
74
75
  readonly annotations: {
75
76
  readonly readOnlyHint: false;
@@ -77,14 +78,14 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
77
78
  };
78
79
  }, {
79
80
  readonly name: "replace_text";
80
- readonly description: "Replace text in a paragraph by _bk_* id, preserving formatting. Accepts session_id or file_path.";
81
+ readonly description: "Replace text in a paragraph by _bk_* id, preserving formatting. Supports DOCX and Google Docs.";
81
82
  readonly input: z.ZodObject<{
82
83
  target_paragraph_id: z.ZodString;
83
84
  old_string: z.ZodString;
84
85
  new_string: z.ZodString;
85
86
  instruction: z.ZodString;
86
87
  normalize_first: z.ZodOptional<z.ZodBoolean>;
87
- session_id: z.ZodOptional<z.ZodString>;
88
+ google_doc_id: z.ZodOptional<z.ZodString>;
88
89
  file_path: z.ZodOptional<z.ZodString>;
89
90
  }, z.core.$strip>;
90
91
  readonly annotations: {
@@ -93,7 +94,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
93
94
  };
94
95
  }, {
95
96
  readonly name: "insert_paragraph";
96
- readonly description: "Insert a paragraph before/after an anchor paragraph by _bk_* id. Accepts session_id or file_path.";
97
+ readonly description: "Insert a paragraph before/after an anchor paragraph by _bk_* id. Supports DOCX and Google Docs.";
97
98
  readonly input: z.ZodObject<{
98
99
  positional_anchor_node_id: z.ZodString;
99
100
  new_string: z.ZodString;
@@ -103,7 +104,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
103
104
  AFTER: "AFTER";
104
105
  }>>;
105
106
  style_source_id: z.ZodOptional<z.ZodString>;
106
- session_id: z.ZodOptional<z.ZodString>;
107
+ google_doc_id: z.ZodOptional<z.ZodString>;
107
108
  file_path: z.ZodOptional<z.ZodString>;
108
109
  }, z.core.$strip>;
109
110
  readonly annotations: {
@@ -112,7 +113,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
112
113
  };
113
114
  }, {
114
115
  readonly name: "save";
115
- readonly description: "Save clean and/or tracked changes output back to the local filesystem. Defaults to both clean and tracked outputs when no format override is provided. Accepts session_id or file_path.";
116
+ readonly description: "Save document. For DOCX: saves clean and/or tracked changes output. For Google Docs: checkpoint (default) returns revisionId, or snapshot exports as DOCX.";
116
117
  readonly input: z.ZodObject<{
117
118
  save_to_local_path: z.ZodString;
118
119
  clean_bookmarks: z.ZodOptional<z.ZodBoolean>;
@@ -129,7 +130,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
129
130
  atomizer: "atomizer";
130
131
  }>>;
131
132
  fail_on_rebuild_fallback: z.ZodOptional<z.ZodBoolean>;
132
- session_id: z.ZodOptional<z.ZodString>;
133
+ google_doc_id: z.ZodOptional<z.ZodString>;
133
134
  file_path: z.ZodOptional<z.ZodString>;
134
135
  }, z.core.$strip>;
135
136
  readonly annotations: {
@@ -138,7 +139,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
138
139
  };
139
140
  }, {
140
141
  readonly name: "format_layout";
141
- readonly description: "Apply deterministic OOXML layout controls (paragraph spacing, table row height, cell padding). Accepts session_id or file_path.";
142
+ readonly description: "Apply layout controls (paragraph spacing, table row height, cell padding). Google Docs supports paragraph spacing only.";
142
143
  readonly input: z.ZodObject<{
143
144
  strict: z.ZodOptional<z.ZodBoolean>;
144
145
  paragraph_spacing: z.ZodOptional<z.ZodObject<{
@@ -171,7 +172,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
171
172
  left_dxa: z.ZodOptional<z.ZodNumber>;
172
173
  right_dxa: z.ZodOptional<z.ZodNumber>;
173
174
  }, z.core.$strip>>;
174
- session_id: z.ZodOptional<z.ZodString>;
175
+ google_doc_id: z.ZodOptional<z.ZodString>;
175
176
  file_path: z.ZodOptional<z.ZodString>;
176
177
  }, z.core.$strip>;
177
178
  readonly annotations: {
@@ -182,8 +183,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
182
183
  readonly name: "accept_changes";
183
184
  readonly description: "Accept all tracked changes in the document body, producing a clean document with no revision markup. Returns acceptance stats.";
184
185
  readonly input: z.ZodObject<{
185
- session_id: z.ZodOptional<z.ZodString>;
186
- file_path: z.ZodOptional<z.ZodString>;
186
+ file_path: z.ZodString;
187
187
  }, z.core.$strip>;
188
188
  readonly annotations: {
189
189
  readonly readOnlyHint: false;
@@ -193,18 +193,17 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
193
193
  readonly name: "has_tracked_changes";
194
194
  readonly description: "Check whether the document body contains tracked-change markers (insertions, deletions, moves, and property-change records). Read-only.";
195
195
  readonly input: z.ZodObject<{
196
- session_id: z.ZodOptional<z.ZodString>;
197
- file_path: z.ZodOptional<z.ZodString>;
196
+ file_path: z.ZodString;
198
197
  }, z.core.$strip>;
199
198
  readonly annotations: {
200
199
  readonly readOnlyHint: true;
201
200
  readonly destructiveHint: false;
202
201
  };
203
202
  }, {
204
- readonly name: "get_session_status";
205
- readonly description: "Get session metadata. Accepts session_id or file_path.";
203
+ readonly name: "get_file_status";
204
+ readonly description: "Get file/session metadata including edit count, normalization stats, and cache info. Supports DOCX and Google Docs.";
206
205
  readonly input: z.ZodObject<{
207
- session_id: z.ZodOptional<z.ZodString>;
206
+ google_doc_id: z.ZodOptional<z.ZodString>;
208
207
  file_path: z.ZodOptional<z.ZodString>;
209
208
  }, z.core.$strip>;
210
209
  readonly annotations: {
@@ -212,13 +211,13 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
212
211
  readonly destructiveHint: false;
213
212
  };
214
213
  }, {
215
- readonly name: "clear_session";
216
- readonly description: "Clear one session, all sessions for a file path, or all sessions with explicit confirmation.";
214
+ readonly name: "close_file";
215
+ readonly description: "Close an open file session, or close all sessions with explicit confirmation. Supports DOCX and Google Docs.";
217
216
  readonly input: z.ZodObject<{
218
- session_id: z.ZodOptional<z.ZodString>;
219
- file_path: z.ZodOptional<z.ZodString>;
220
217
  clear_all: z.ZodOptional<z.ZodBoolean>;
221
218
  confirm: z.ZodOptional<z.ZodBoolean>;
219
+ google_doc_id: z.ZodOptional<z.ZodString>;
220
+ file_path: z.ZodOptional<z.ZodString>;
222
221
  }, z.core.$strip>;
223
222
  readonly annotations: {
224
223
  readonly readOnlyHint: false;
@@ -234,8 +233,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
234
233
  author: z.ZodString;
235
234
  text: z.ZodString;
236
235
  initials: z.ZodOptional<z.ZodString>;
237
- session_id: z.ZodOptional<z.ZodString>;
238
- file_path: z.ZodOptional<z.ZodString>;
236
+ file_path: z.ZodString;
239
237
  }, z.core.$strip>;
240
238
  readonly annotations: {
241
239
  readonly readOnlyHint: false;
@@ -245,8 +243,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
245
243
  readonly name: "get_comments";
246
244
  readonly description: "Get all comments from the document with IDs, authors, dates, text, and anchored paragraph IDs. Includes threaded replies. Read-only.";
247
245
  readonly input: z.ZodObject<{
248
- session_id: z.ZodOptional<z.ZodString>;
249
- file_path: z.ZodOptional<z.ZodString>;
246
+ file_path: z.ZodString;
250
247
  }, z.core.$strip>;
251
248
  readonly annotations: {
252
249
  readonly readOnlyHint: true;
@@ -257,8 +254,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
257
254
  readonly description: "Delete a comment and all its threaded replies from the document. Cascade-deletes all descendants.";
258
255
  readonly input: z.ZodObject<{
259
256
  comment_id: z.ZodNumber;
260
- session_id: z.ZodOptional<z.ZodString>;
261
- file_path: z.ZodOptional<z.ZodString>;
257
+ file_path: z.ZodString;
262
258
  }, z.core.$strip>;
263
259
  readonly annotations: {
264
260
  readonly readOnlyHint: false;
@@ -266,18 +262,17 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
266
262
  };
267
263
  }, {
268
264
  readonly name: "compare_documents";
269
- readonly description: "Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or session_id/file_path to compare session edits against the original.";
265
+ readonly description: "Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or file_path to compare session edits against the original.";
270
266
  readonly input: z.ZodObject<{
271
- original_file_path: z.ZodOptional<z.ZodString>;
272
- revised_file_path: z.ZodOptional<z.ZodString>;
273
- session_id: z.ZodOptional<z.ZodString>;
274
- file_path: z.ZodOptional<z.ZodString>;
275
267
  save_to_local_path: z.ZodString;
276
268
  author: z.ZodOptional<z.ZodString>;
277
269
  engine: z.ZodOptional<z.ZodEnum<{
278
270
  auto: "auto";
279
271
  atomizer: "atomizer";
280
272
  }>>;
273
+ file_path: z.ZodOptional<z.ZodString>;
274
+ original_file_path: z.ZodOptional<z.ZodString>;
275
+ revised_file_path: z.ZodOptional<z.ZodString>;
281
276
  }, z.core.$strip>;
282
277
  readonly annotations: {
283
278
  readonly readOnlyHint: true;
@@ -287,8 +282,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
287
282
  readonly name: "get_footnotes";
288
283
  readonly description: "Get all footnotes from the document with IDs, display numbers, text, and anchored paragraph IDs. Read-only.";
289
284
  readonly input: z.ZodObject<{
290
- session_id: z.ZodOptional<z.ZodString>;
291
- file_path: z.ZodOptional<z.ZodString>;
285
+ file_path: z.ZodString;
292
286
  }, z.core.$strip>;
293
287
  readonly annotations: {
294
288
  readonly readOnlyHint: true;
@@ -301,8 +295,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
301
295
  target_paragraph_id: z.ZodString;
302
296
  after_text: z.ZodOptional<z.ZodString>;
303
297
  text: z.ZodString;
304
- session_id: z.ZodOptional<z.ZodString>;
305
- file_path: z.ZodOptional<z.ZodString>;
298
+ file_path: z.ZodString;
306
299
  }, z.core.$strip>;
307
300
  readonly annotations: {
308
301
  readonly readOnlyHint: false;
@@ -314,8 +307,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
314
307
  readonly input: z.ZodObject<{
315
308
  note_id: z.ZodNumber;
316
309
  new_text: z.ZodString;
317
- session_id: z.ZodOptional<z.ZodString>;
318
- file_path: z.ZodOptional<z.ZodString>;
310
+ file_path: z.ZodString;
319
311
  }, z.core.$strip>;
320
312
  readonly annotations: {
321
313
  readonly readOnlyHint: false;
@@ -326,8 +318,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
326
318
  readonly description: "Delete a footnote and its reference from the document.";
327
319
  readonly input: z.ZodObject<{
328
320
  note_id: z.ZodNumber;
329
- session_id: z.ZodOptional<z.ZodString>;
330
- file_path: z.ZodOptional<z.ZodString>;
321
+ file_path: z.ZodString;
331
322
  }, z.core.$strip>;
332
323
  readonly annotations: {
333
324
  readonly readOnlyHint: false;
@@ -335,7 +326,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
335
326
  };
336
327
  }, {
337
328
  readonly name: "clear_formatting";
338
- readonly description: "Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs. Accepts session_id or file_path.";
329
+ readonly description: "Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs.";
339
330
  readonly input: z.ZodObject<{
340
331
  paragraph_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
341
332
  clear_highlight: z.ZodOptional<z.ZodBoolean>;
@@ -344,8 +335,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
344
335
  clear_underline: z.ZodOptional<z.ZodBoolean>;
345
336
  clear_color: z.ZodOptional<z.ZodBoolean>;
346
337
  clear_font: z.ZodOptional<z.ZodBoolean>;
347
- session_id: z.ZodOptional<z.ZodString>;
348
- file_path: z.ZodOptional<z.ZodString>;
338
+ file_path: z.ZodString;
349
339
  }, z.core.$strip>;
350
340
  readonly annotations: {
351
341
  readonly readOnlyHint: false;
@@ -357,8 +347,7 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
357
347
  readonly input: z.ZodObject<{
358
348
  offset: z.ZodOptional<z.ZodNumber>;
359
349
  limit: z.ZodOptional<z.ZodNumber>;
360
- session_id: z.ZodOptional<z.ZodString>;
361
- file_path: z.ZodOptional<z.ZodString>;
350
+ file_path: z.ZodString;
362
351
  }, z.core.$strip>;
363
352
  readonly annotations: {
364
353
  readonly readOnlyHint: true;
@@ -366,8 +355,8 @@ export declare const SAFE_DOCX_TOOL_CATALOG: readonly [{
366
355
  };
367
356
  }];
368
357
  export declare const SAFE_DOCX_MCP_TOOLS: {
369
- name: "read_file" | "grep" | "init_plan" | "merge_plans" | "apply_plan" | "replace_text" | "insert_paragraph" | "save" | "format_layout" | "accept_changes" | "has_tracked_changes" | "get_session_status" | "clear_session" | "add_comment" | "get_comments" | "delete_comment" | "compare_documents" | "get_footnotes" | "add_footnote" | "update_footnote" | "delete_footnote" | "clear_formatting" | "extract_revisions";
370
- description: "Read document content. Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate. Accepts session_id or file_path." | "Search paragraphs with regex. Accepts session_id or file_path." | "Initialize revision-bound context metadata for coordinated multi-agent planning. Accepts session_id or file_path." | "Deterministically merge multiple sub-agent plans and detect hard conflicts before apply." | "Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a session document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output." | "Replace text in a paragraph by _bk_* id, preserving formatting. Accepts session_id or file_path." | "Insert a paragraph before/after an anchor paragraph by _bk_* id. Accepts session_id or file_path." | "Save clean and/or tracked changes output back to the local filesystem. Defaults to both clean and tracked outputs when no format override is provided. Accepts session_id or file_path." | "Apply deterministic OOXML layout controls (paragraph spacing, table row height, cell padding). Accepts session_id or file_path." | "Accept all tracked changes in the document body, producing a clean document with no revision markup. Returns acceptance stats." | "Check whether the document body contains tracked-change markers (insertions, deletions, moves, and property-change records). Read-only." | "Get session metadata. Accepts session_id or file_path." | "Clear one session, all sessions for a file path, or all sessions with explicit confirmation." | "Add a comment or threaded reply to a document. Provide target_paragraph_id + anchor_text for root comments, or parent_comment_id for replies." | "Get all comments from the document with IDs, authors, dates, text, and anchored paragraph IDs. Includes threaded replies. Read-only." | "Delete a comment and all its threaded replies from the document. Cascade-deletes all descendants." | "Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or session_id/file_path to compare session edits against the original." | "Get all footnotes from the document with IDs, display numbers, text, and anchored paragraph IDs. Read-only." | "Add a footnote anchored to a paragraph. Optionally position the reference after specific text using after_text. Note: [^N] markers in read_file output are display-only and not part of the editable text used by replace_text." | "Update the text content of an existing footnote." | "Delete a footnote and its reference from the document." | "Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs. Accepts session_id or file_path." | "Extract tracked changes as structured JSON with before/after text per paragraph, revision details, and comments. Supports pagination via offset and limit. Read-only - does not modify the document.";
358
+ name: "read_file" | "grep" | "init_plan" | "merge_plans" | "apply_plan" | "replace_text" | "insert_paragraph" | "save" | "format_layout" | "accept_changes" | "has_tracked_changes" | "get_file_status" | "close_file" | "add_comment" | "get_comments" | "delete_comment" | "compare_documents" | "get_footnotes" | "add_footnote" | "update_footnote" | "delete_footnote" | "clear_formatting" | "extract_revisions";
359
+ description: "Read document content (DOCX or Google Doc). Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate." | "Search paragraphs with regex. Use file_path for session-based search, file_paths for stateless multi-file search, or google_doc_id for Google Docs." | "Initialize revision-bound context metadata for coordinated multi-agent planning." | "Deterministically merge multiple sub-agent plans and detect hard conflicts before apply." | "Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output." | "Replace text in a paragraph by _bk_* id, preserving formatting. Supports DOCX and Google Docs." | "Insert a paragraph before/after an anchor paragraph by _bk_* id. Supports DOCX and Google Docs." | "Save document. For DOCX: saves clean and/or tracked changes output. For Google Docs: checkpoint (default) returns revisionId, or snapshot exports as DOCX." | "Apply layout controls (paragraph spacing, table row height, cell padding). Google Docs supports paragraph spacing only." | "Accept all tracked changes in the document body, producing a clean document with no revision markup. Returns acceptance stats." | "Check whether the document body contains tracked-change markers (insertions, deletions, moves, and property-change records). Read-only." | "Get file/session metadata including edit count, normalization stats, and cache info. Supports DOCX and Google Docs." | "Close an open file session, or close all sessions with explicit confirmation. Supports DOCX and Google Docs." | "Add a comment or threaded reply to a document. Provide target_paragraph_id + anchor_text for root comments, or parent_comment_id for replies." | "Get all comments from the document with IDs, authors, dates, text, and anchored paragraph IDs. Includes threaded replies. Read-only." | "Delete a comment and all its threaded replies from the document. Cascade-deletes all descendants." | "Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or file_path to compare session edits against the original." | "Get all footnotes from the document with IDs, display numbers, text, and anchored paragraph IDs. Read-only." | "Add a footnote anchored to a paragraph. Optionally position the reference after specific text using after_text. Note: [^N] markers in read_file output are display-only and not part of the editable text used by replace_text." | "Update the text content of an existing footnote." | "Delete a footnote and its reference from the document." | "Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs." | "Extract tracked changes as structured JSON with before/after text per paragraph, revision details, and comments. Supports pagination via offset and limit. Read-only - does not modify the document.";
371
360
  inputSchema: Record<string, unknown>;
372
361
  annotations: {
373
362
  readonly readOnlyHint: true;
@@ -1 +1 @@
1
- {"version":3,"file":"tool_catalog.d.ts","sourceRoot":"","sources":["../src/tool_catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Ta,CAAC;AAUjD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK7B,CAAC;AAEJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"tool_catalog.d.ts","sourceRoot":"","sources":["../src/tool_catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmUa,CAAC;AAUjD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK7B,CAAC;AAEJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -1,15 +1,22 @@
1
1
  import { z } from 'zod';
2
- const SESSION_OR_FILE_FIELDS = {
3
- session_id: z.string().optional(),
4
- file_path: z.string().optional(),
2
+ const FILE_FIELD = {
3
+ file_path: z.string().describe('Path to the DOCX file.'),
4
+ };
5
+ const FILE_FIELD_OPTIONAL = {
6
+ file_path: z.string().optional().describe('Path to the DOCX file.'),
7
+ };
8
+ const GOOGLE_DOC_ID_FIELD = {
9
+ google_doc_id: z.string().optional().describe('Google Doc ID or URL (alternative to file_path). ' +
10
+ 'Extract from URL: docs.google.com/document/d/{ID}/edit'),
5
11
  };
6
12
  const PLAN_OBJECT_SCHEMA = z.object({}).catchall(z.unknown());
7
13
  export const SAFE_DOCX_TOOL_CATALOG = [
8
14
  {
9
15
  name: 'read_file',
10
- description: 'Read document content. Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate. Accepts session_id or file_path.',
16
+ description: 'Read document content (DOCX or Google Doc). Output is token-limited (~14k tokens) by default with pagination metadata (has_more, next_offset). Use offset/limit to paginate.',
11
17
  input: z.object({
12
- ...SESSION_OR_FILE_FIELDS,
18
+ ...FILE_FIELD_OPTIONAL,
19
+ ...GOOGLE_DOC_ID_FIELD,
13
20
  offset: z.number().optional().describe('1-based paragraph offset for pagination. Negative values count from end.'),
14
21
  limit: z.number().optional().describe('Max paragraphs to return. When omitted, output is token-limited to ~14k tokens with pagination.'),
15
22
  node_ids: z.array(z.string()).optional(),
@@ -23,9 +30,11 @@ export const SAFE_DOCX_TOOL_CATALOG = [
23
30
  },
24
31
  {
25
32
  name: 'grep',
26
- description: 'Search paragraphs with regex. Accepts session_id or file_path.',
33
+ description: 'Search paragraphs with regex. Use file_path for session-based search, file_paths for stateless multi-file search, or google_doc_id for Google Docs.',
27
34
  input: z.object({
28
- ...SESSION_OR_FILE_FIELDS,
35
+ ...FILE_FIELD_OPTIONAL,
36
+ ...GOOGLE_DOC_ID_FIELD,
37
+ file_paths: z.array(z.string()).optional().describe('Multiple file paths for stateless multi-file search. No session created.'),
29
38
  patterns: z.array(z.string()).optional(),
30
39
  pattern: z.string().optional(),
31
40
  case_sensitive: z.boolean().optional(),
@@ -33,14 +42,16 @@ export const SAFE_DOCX_TOOL_CATALOG = [
33
42
  max_results: z.number().optional(),
34
43
  context_chars: z.number().optional(),
35
44
  dedupe_by_paragraph: z.boolean().optional(),
45
+ search_xml: z.boolean().optional().describe('When true, search raw XML (word/document.xml) instead of paragraph text.'),
46
+ include_context: z.boolean().optional().describe('When false, skip document view context (list labels, headers) for faster results. Default: true.'),
36
47
  }),
37
48
  annotations: { readOnlyHint: true, destructiveHint: false },
38
49
  },
39
50
  {
40
51
  name: 'init_plan',
41
- description: 'Initialize revision-bound context metadata for coordinated multi-agent planning. Accepts session_id or file_path.',
52
+ description: 'Initialize revision-bound context metadata for coordinated multi-agent planning.',
42
53
  input: z.object({
43
- ...SESSION_OR_FILE_FIELDS,
54
+ ...FILE_FIELD,
44
55
  plan_name: z.string().optional(),
45
56
  orchestrator_id: z.string().optional(),
46
57
  }),
@@ -58,9 +69,9 @@ export const SAFE_DOCX_TOOL_CATALOG = [
58
69
  },
59
70
  {
60
71
  name: 'apply_plan',
61
- description: 'Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a session document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output.',
72
+ description: 'Validate and apply a batch of edit steps (replace_text, insert_paragraph) to a document in one call. Validates all steps first; applies only if all pass. Accepts inline steps or a plan_file_path. Compatible with merge_plans output.',
62
73
  input: z.object({
63
- ...SESSION_OR_FILE_FIELDS,
74
+ ...FILE_FIELD,
64
75
  steps: z
65
76
  .array(z.object({}).catchall(z.unknown()))
66
77
  .optional()
@@ -74,9 +85,10 @@ export const SAFE_DOCX_TOOL_CATALOG = [
74
85
  },
75
86
  {
76
87
  name: 'replace_text',
77
- description: 'Replace text in a paragraph by _bk_* id, preserving formatting. Accepts session_id or file_path.',
88
+ description: 'Replace text in a paragraph by _bk_* id, preserving formatting. Supports DOCX and Google Docs.',
78
89
  input: z.object({
79
- ...SESSION_OR_FILE_FIELDS,
90
+ ...FILE_FIELD_OPTIONAL,
91
+ ...GOOGLE_DOC_ID_FIELD,
80
92
  target_paragraph_id: z.string(),
81
93
  old_string: z.string(),
82
94
  new_string: z.string(),
@@ -90,9 +102,10 @@ export const SAFE_DOCX_TOOL_CATALOG = [
90
102
  },
91
103
  {
92
104
  name: 'insert_paragraph',
93
- description: 'Insert a paragraph before/after an anchor paragraph by _bk_* id. Accepts session_id or file_path.',
105
+ description: 'Insert a paragraph before/after an anchor paragraph by _bk_* id. Supports DOCX and Google Docs.',
94
106
  input: z.object({
95
- ...SESSION_OR_FILE_FIELDS,
107
+ ...FILE_FIELD_OPTIONAL,
108
+ ...GOOGLE_DOC_ID_FIELD,
96
109
  positional_anchor_node_id: z.string(),
97
110
  new_string: z.string(),
98
111
  instruction: z.string(),
@@ -106,9 +119,10 @@ export const SAFE_DOCX_TOOL_CATALOG = [
106
119
  },
107
120
  {
108
121
  name: 'save',
109
- description: 'Save clean and/or tracked changes output back to the local filesystem. Defaults to both clean and tracked outputs when no format override is provided. Accepts session_id or file_path.',
122
+ description: 'Save document. For DOCX: saves clean and/or tracked changes output. For Google Docs: checkpoint (default) returns revisionId, or snapshot exports as DOCX.',
110
123
  input: z.object({
111
- ...SESSION_OR_FILE_FIELDS,
124
+ ...FILE_FIELD_OPTIONAL,
125
+ ...GOOGLE_DOC_ID_FIELD,
112
126
  save_to_local_path: z.string(),
113
127
  clean_bookmarks: z.boolean().optional(),
114
128
  save_format: z.enum(['clean', 'tracked', 'both']).optional(),
@@ -125,9 +139,10 @@ export const SAFE_DOCX_TOOL_CATALOG = [
125
139
  },
126
140
  {
127
141
  name: 'format_layout',
128
- description: 'Apply deterministic OOXML layout controls (paragraph spacing, table row height, cell padding). Accepts session_id or file_path.',
142
+ description: 'Apply layout controls (paragraph spacing, table row height, cell padding). Google Docs supports paragraph spacing only.',
129
143
  input: z.object({
130
- ...SESSION_OR_FILE_FIELDS,
144
+ ...FILE_FIELD_OPTIONAL,
145
+ ...GOOGLE_DOC_ID_FIELD,
131
146
  strict: z.boolean().optional(),
132
147
  paragraph_spacing: z
133
148
  .object({
@@ -164,7 +179,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
164
179
  name: 'accept_changes',
165
180
  description: 'Accept all tracked changes in the document body, producing a clean document with no revision markup. Returns acceptance stats.',
166
181
  input: z.object({
167
- ...SESSION_OR_FILE_FIELDS,
182
+ ...FILE_FIELD,
168
183
  }),
169
184
  annotations: { readOnlyHint: false, destructiveHint: true },
170
185
  },
@@ -172,24 +187,25 @@ export const SAFE_DOCX_TOOL_CATALOG = [
172
187
  name: 'has_tracked_changes',
173
188
  description: 'Check whether the document body contains tracked-change markers (insertions, deletions, moves, and property-change records). Read-only.',
174
189
  input: z.object({
175
- ...SESSION_OR_FILE_FIELDS,
190
+ ...FILE_FIELD,
176
191
  }),
177
192
  annotations: { readOnlyHint: true, destructiveHint: false },
178
193
  },
179
194
  {
180
- name: 'get_session_status',
181
- description: 'Get session metadata. Accepts session_id or file_path.',
195
+ name: 'get_file_status',
196
+ description: 'Get file/session metadata including edit count, normalization stats, and cache info. Supports DOCX and Google Docs.',
182
197
  input: z.object({
183
- ...SESSION_OR_FILE_FIELDS,
198
+ ...FILE_FIELD_OPTIONAL,
199
+ ...GOOGLE_DOC_ID_FIELD,
184
200
  }),
185
201
  annotations: { readOnlyHint: true, destructiveHint: false },
186
202
  },
187
203
  {
188
- name: 'clear_session',
189
- description: 'Clear one session, all sessions for a file path, or all sessions with explicit confirmation.',
204
+ name: 'close_file',
205
+ description: 'Close an open file session, or close all sessions with explicit confirmation. Supports DOCX and Google Docs.',
190
206
  input: z.object({
191
- session_id: z.string().optional(),
192
- file_path: z.string().optional(),
207
+ ...FILE_FIELD_OPTIONAL,
208
+ ...GOOGLE_DOC_ID_FIELD,
193
209
  clear_all: z.boolean().optional(),
194
210
  confirm: z.boolean().optional(),
195
211
  }),
@@ -199,7 +215,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
199
215
  name: 'add_comment',
200
216
  description: 'Add a comment or threaded reply to a document. Provide target_paragraph_id + anchor_text for root comments, or parent_comment_id for replies.',
201
217
  input: z.object({
202
- ...SESSION_OR_FILE_FIELDS,
218
+ ...FILE_FIELD,
203
219
  target_paragraph_id: z.string().optional().describe('Paragraph ID to anchor the comment to (for root comments).'),
204
220
  anchor_text: z.string().optional().describe('Text within the paragraph to anchor the comment to. If omitted, anchors to entire paragraph.'),
205
221
  parent_comment_id: z.number().optional().describe('Parent comment ID for threaded replies.'),
@@ -213,7 +229,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
213
229
  name: 'get_comments',
214
230
  description: 'Get all comments from the document with IDs, authors, dates, text, and anchored paragraph IDs. Includes threaded replies. Read-only.',
215
231
  input: z.object({
216
- ...SESSION_OR_FILE_FIELDS,
232
+ ...FILE_FIELD,
217
233
  }),
218
234
  annotations: { readOnlyHint: true, destructiveHint: false },
219
235
  },
@@ -221,19 +237,18 @@ export const SAFE_DOCX_TOOL_CATALOG = [
221
237
  name: 'delete_comment',
222
238
  description: 'Delete a comment and all its threaded replies from the document. Cascade-deletes all descendants.',
223
239
  input: z.object({
224
- ...SESSION_OR_FILE_FIELDS,
240
+ ...FILE_FIELD,
225
241
  comment_id: z.number().describe('Comment ID to delete.'),
226
242
  }),
227
243
  annotations: { readOnlyHint: false, destructiveHint: true },
228
244
  },
229
245
  {
230
246
  name: 'compare_documents',
231
- description: 'Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or session_id/file_path to compare session edits against the original.',
247
+ description: 'Compare two DOCX documents and produce a tracked-changes output document. Provide original_file_path + revised_file_path for standalone comparison, or file_path to compare session edits against the original.',
232
248
  input: z.object({
233
249
  original_file_path: z.string().optional().describe('Path to the original DOCX file.'),
234
250
  revised_file_path: z.string().optional().describe('Path to the revised DOCX file.'),
235
- session_id: z.string().optional(),
236
- file_path: z.string().optional(),
251
+ ...FILE_FIELD_OPTIONAL,
237
252
  save_to_local_path: z.string().describe('Path to save the tracked-changes DOCX output.'),
238
253
  author: z.string().optional().describe("Author name for track changes. Default: 'Comparison'."),
239
254
  engine: z.enum(['auto', 'atomizer']).optional().describe("Comparison engine. Default: 'auto'."),
@@ -244,7 +259,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
244
259
  name: 'get_footnotes',
245
260
  description: 'Get all footnotes from the document with IDs, display numbers, text, and anchored paragraph IDs. Read-only.',
246
261
  input: z.object({
247
- ...SESSION_OR_FILE_FIELDS,
262
+ ...FILE_FIELD,
248
263
  }),
249
264
  annotations: { readOnlyHint: true, destructiveHint: false },
250
265
  },
@@ -252,7 +267,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
252
267
  name: 'add_footnote',
253
268
  description: 'Add a footnote anchored to a paragraph. Optionally position the reference after specific text using after_text. Note: [^N] markers in read_file output are display-only and not part of the editable text used by replace_text.',
254
269
  input: z.object({
255
- ...SESSION_OR_FILE_FIELDS,
270
+ ...FILE_FIELD,
256
271
  target_paragraph_id: z.string().describe('Paragraph ID to anchor the footnote to.'),
257
272
  after_text: z.string().optional().describe('Text after which to insert the footnote reference. If omitted, appends at end of paragraph.'),
258
273
  text: z.string().describe('Footnote body text.'),
@@ -263,7 +278,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
263
278
  name: 'update_footnote',
264
279
  description: 'Update the text content of an existing footnote.',
265
280
  input: z.object({
266
- ...SESSION_OR_FILE_FIELDS,
281
+ ...FILE_FIELD,
267
282
  note_id: z.number().describe('Footnote ID to update.'),
268
283
  new_text: z.string().describe('New footnote body text.'),
269
284
  }),
@@ -273,16 +288,16 @@ export const SAFE_DOCX_TOOL_CATALOG = [
273
288
  name: 'delete_footnote',
274
289
  description: 'Delete a footnote and its reference from the document.',
275
290
  input: z.object({
276
- ...SESSION_OR_FILE_FIELDS,
291
+ ...FILE_FIELD,
277
292
  note_id: z.number().describe('Footnote ID to delete.'),
278
293
  }),
279
294
  annotations: { readOnlyHint: false, destructiveHint: true },
280
295
  },
281
296
  {
282
297
  name: 'clear_formatting',
283
- description: 'Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs. Accepts session_id or file_path.',
298
+ description: 'Clear specific run-level formatting (bold, italic, underline, highlight, color, font) from paragraphs.',
284
299
  input: z.object({
285
- ...SESSION_OR_FILE_FIELDS,
300
+ ...FILE_FIELD,
286
301
  paragraph_ids: z.array(z.string()).optional().describe('Paragraph IDs to clear formatting from. If omitted, clears from all paragraphs.'),
287
302
  clear_highlight: z.boolean().optional().describe('Remove highlight formatting.'),
288
303
  clear_bold: z.boolean().optional().describe('Remove bold formatting.'),
@@ -297,7 +312,7 @@ export const SAFE_DOCX_TOOL_CATALOG = [
297
312
  name: 'extract_revisions',
298
313
  description: 'Extract tracked changes as structured JSON with before/after text per paragraph, revision details, and comments. Supports pagination via offset and limit. Read-only - does not modify the document.',
299
314
  input: z.object({
300
- ...SESSION_OR_FILE_FIELDS,
315
+ ...FILE_FIELD,
301
316
  offset: z.number().optional().describe('0-based offset for pagination. Default: 0.'),
302
317
  limit: z.number().optional().describe('Max entries per page (1-500). Default: 50.'),
303
318
  }),