@mindstone/mcp-server-google-workspace 0.4.1 → 0.5.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 (42) hide show
  1. package/README.md +43 -5
  2. package/dist/modules/docs/service.d.ts +76 -6
  3. package/dist/modules/docs/service.js +791 -103
  4. package/dist/modules/docs/tabCopy.d.ts +266 -0
  5. package/dist/modules/docs/tabCopy.js +794 -0
  6. package/dist/modules/docs/tabs.d.ts +161 -0
  7. package/dist/modules/docs/tabs.js +416 -0
  8. package/dist/modules/docs/types.d.ts +141 -1
  9. package/dist/modules/drive/service.d.ts +15 -0
  10. package/dist/modules/drive/service.js +77 -2
  11. package/dist/modules/drive/types.d.ts +1 -1
  12. package/dist/modules/sheets/a1Utils.d.ts +13 -0
  13. package/dist/modules/sheets/a1Utils.js +33 -7
  14. package/dist/modules/sheets/formatters.d.ts +33 -2
  15. package/dist/modules/sheets/formatters.js +84 -5
  16. package/dist/modules/sheets/service.d.ts +26 -1
  17. package/dist/modules/sheets/service.js +264 -8
  18. package/dist/modules/sheets/types.d.ts +71 -0
  19. package/dist/modules/sheets/types.js +12 -1
  20. package/dist/modules/sheets/writeGuards.js +2 -2
  21. package/dist/tools/definitions/destructive-overrides.json +8 -0
  22. package/dist/tools/definitions/docs.js +395 -9
  23. package/dist/tools/definitions/drive.js +9 -4
  24. package/dist/tools/definitions/gmail.js +30 -3
  25. package/dist/tools/definitions/open-world-overrides.json +8 -0
  26. package/dist/tools/definitions/sheets.js +177 -1
  27. package/dist/tools/docs-handlers.d.ts +125 -0
  28. package/dist/tools/docs-handlers.js +397 -15
  29. package/dist/tools/gmail-handlers.d.ts +3 -0
  30. package/dist/tools/gmail-handlers.js +19 -5
  31. package/dist/tools/param-normalizer.js +16 -0
  32. package/dist/tools/server.js +35 -3
  33. package/dist/tools/sheets-handlers.d.ts +54 -1
  34. package/dist/tools/sheets-handlers.js +107 -13
  35. package/dist/tools/type-guards.d.ts +89 -0
  36. package/dist/tools/type-guards.js +190 -6
  37. package/dist/tools/types.d.ts +1 -1
  38. package/dist/utils/apiError.d.ts +6 -0
  39. package/dist/utils/apiError.js +12 -0
  40. package/dist/utils/tabPosition.d.ts +20 -0
  41. package/dist/utils/tabPosition.js +19 -0
  42. package/package.json +1 -1
@@ -8,6 +8,7 @@ export const sheetsTools = [
8
8
  Returns human-readable text by default. Use return_json: true for the raw Google Sheets API response.
9
9
  If you intend to write back to this range, call with value_view: 'shaped' first to see formulas — overwriting formulas with computed values is silently destructive.
10
10
  For large or unbounded reads, returns an anchor envelope (first 50 + last 10 rows + summary). Pass anchor_mode: 'never' for legacy first-N truncation. Use continuation_token to page through the middle.
11
+ Rows in the text output are numbered with their sheet row numbers. Merged cells show their value only in the first cell of the merge and the other cells read as empty, so when finding a row by its labels, carry a merged label down to the rows below it.
11
12
 
12
13
  Usage examples:
13
14
 
@@ -83,6 +84,7 @@ export const sheetsTools = [
83
84
  Use this for focused data extraction. For spreadsheet metadata, use read_workspace_spreadsheet.
84
85
  If you intend to write back to this range, call with value_view: 'shaped' first to see formulas — overwriting formulas with computed values is silently destructive.
85
86
  For large or unbounded reads, returns an anchor envelope (first 50 + last 10 rows + summary). Pass anchor_mode: 'never' for legacy first-N truncation. Use continuation_token to page through the middle.
87
+ Rows in the text output are numbered with their sheet row numbers. Merged cells show their value only in the first cell of the merge and the other cells read as empty, so when finding a row by its labels, carry a merged label down to the rows below it.
86
88
 
87
89
  Usage examples:
88
90
 
@@ -255,6 +257,7 @@ export const sheetsTools = [
255
257
 
256
258
  Overwrites existing data in the specified range. Use append_to_workspace_spreadsheet to add data without overwriting.
257
259
  Prefer formulas over computed values. By default this tool refuses to overwrite cells that currently contain formulas; pass overwrite_formulas: true to force, or write to non-formula cells. Best-effort: protects against formula overwrite absent concurrent edits to the same range during the call. Sheets has no transactional write API; under concurrent edits the guard cannot guarantee zero overwrites. value_input_option defaults to USER_ENTERED so '=SUM(...)' is parsed as a formula; use RAW only when literally storing '=' as text.
260
+ To add a new column or row formatted like its neighbours (for example a new date column in a tracker), insert it first with insert_workspace_spreadsheet_dimension, then write to it. Write numbers as plain numbers (1234.56), not locale-formatted text such as "€1.234,56": the cell's own format displays them, and formatted text can be stored as text that totals ignore.
258
261
 
259
262
  Usage examples:
260
263
 
@@ -357,7 +360,8 @@ export const sheetsTools = [
357
360
  Usage example:
358
361
  { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz" }
359
362
 
360
- Use the returned sheetId (numeric) when calling delete_workspace_spreadsheet_sheet with the snake_case parameter sheet_id.`,
363
+ Sheets are numbered from 1 in this list; the position parameters of duplicate_workspace_spreadsheet_sheet and update_workspace_spreadsheet_sheet count from 0.
364
+ Use the returned sheetId (numeric) as sheet_id when calling duplicate_workspace_spreadsheet_sheet (copy a tab), update_workspace_spreadsheet_sheet (rename or reorder a tab), insert_workspace_spreadsheet_dimension or delete_workspace_spreadsheet_sheet.`,
361
365
  aliases: ['list_sheets', 'get_sheets', 'show_sheets'],
362
366
  annotations: { readOnlyHint: true },
363
367
  inputSchema: {
@@ -449,6 +453,177 @@ export const sheetsTools = [
449
453
  required: ['spreadsheet_id', 'sheet_id']
450
454
  }
451
455
  },
456
+ {
457
+ name: 'duplicate_workspace_spreadsheet_sheet',
458
+ category: 'Sheets/Spreadsheets',
459
+ description: `Duplicate a sheet (tab) inside the same Google Sheets spreadsheet, for example to start a new
460
+ campaign or month from a template tab.
461
+
462
+ Google copies the values, formulas, formatting, merged cells and data validation, and gives the copy
463
+ a new numeric sheetId (returned in the result). Without title Google names it "Copy of <name>";
464
+ titles must be unique in the spreadsheet. Without position the copy goes right after the source.
465
+ To reuse the copy, write the new values over the old ones instead of clearing the range first — clearing also deletes any formulas in it.
466
+
467
+ Usage examples:
468
+
469
+ 1. Copy a template tab under a new name (placed right after it):
470
+ { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz", "sheet_id": 123456789, "title": "Acme Launch – Week 1" }
471
+
472
+ 2. Copy a tab found by its name to the front:
473
+ { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz", "sheet_title": "Acme Launch – Template", "title": "Acme Launch – Week 1", "position": 0 }
474
+
475
+ Name the sheet to copy by sheet_id (from list_workspace_spreadsheet_sheets) or by its exact name in sheet_title.`,
476
+ aliases: ['duplicate_sheet', 'copy_sheet_tab'],
477
+ annotations: { readOnlyHint: false, destructiveHint: true },
478
+ inputSchema: {
479
+ type: 'object',
480
+ properties: {
481
+ email: {
482
+ type: 'string',
483
+ description: 'Email address of the Google account'
484
+ },
485
+ spreadsheet_id: {
486
+ type: 'string',
487
+ description: 'Google Sheets spreadsheet ID'
488
+ },
489
+ sheet_id: {
490
+ type: 'number',
491
+ description: 'Numeric sheetId of the sheet to copy (from list_workspace_spreadsheet_sheets). Pass this or sheet_title, not both.'
492
+ },
493
+ sheet_title: {
494
+ type: 'string',
495
+ description: 'Exact name of the sheet to copy. Pass this or sheet_id, not both.'
496
+ },
497
+ title: {
498
+ type: 'string',
499
+ description: 'Name for the copy (unique in the spreadsheet). new_title is also accepted.'
500
+ },
501
+ position: {
502
+ type: 'number',
503
+ description: 'Position of the copy: 0 = first; list_workspace_spreadsheet_sheets numbers sheets from 1. Default: right after the source.'
504
+ }
505
+ },
506
+ required: ['spreadsheet_id']
507
+ }
508
+ },
509
+ {
510
+ name: 'update_workspace_spreadsheet_sheet',
511
+ category: 'Sheets/Spreadsheets',
512
+ description: `Rename a sheet (tab) and/or move it to another position in a Google Sheets spreadsheet.
513
+
514
+ position is where the sheet should end up (0 = first). Titles must be unique in the spreadsheet.
515
+ If the sheet already has that title and position, nothing is written. The result reports the sheet's actual position after the change.
516
+
517
+ Usage examples:
518
+
519
+ 1. Rename:
520
+ { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz", "sheet_id": 123456789, "title": "Acme Launch – Archive" }
521
+
522
+ 2. Move a tab found by its name to the front:
523
+ { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz", "sheet_title": "Acme Launch – Archive", "position": 0 }
524
+
525
+ Name the sheet by sheet_id (from list_workspace_spreadsheet_sheets) or by its current exact name in sheet_title; title is the new name.`,
526
+ aliases: ['rename_sheet', 'move_sheet', 'reorder_sheet'],
527
+ annotations: { readOnlyHint: false, destructiveHint: true },
528
+ inputSchema: {
529
+ type: 'object',
530
+ properties: {
531
+ email: {
532
+ type: 'string',
533
+ description: 'Email address of the Google account'
534
+ },
535
+ spreadsheet_id: {
536
+ type: 'string',
537
+ description: 'Google Sheets spreadsheet ID'
538
+ },
539
+ sheet_id: {
540
+ type: 'number',
541
+ description: 'Numeric sheetId (from list_workspace_spreadsheet_sheets). Pass this or sheet_title, not both.'
542
+ },
543
+ sheet_title: {
544
+ type: 'string',
545
+ description: 'Current exact name of the sheet. Pass this or sheet_id, not both. Put a new name in title.'
546
+ },
547
+ title: {
548
+ type: 'string',
549
+ description: 'New name (unique in the spreadsheet). new_title is also accepted.'
550
+ },
551
+ position: {
552
+ type: 'number',
553
+ description: 'Final position of the sheet: 0 = first; list_workspace_spreadsheet_sheets numbers sheets from 1.'
554
+ }
555
+ },
556
+ required: ['spreadsheet_id']
557
+ }
558
+ },
559
+ {
560
+ name: 'insert_workspace_spreadsheet_dimension',
561
+ category: 'Sheets/Spreadsheets',
562
+ description: `Insert empty rows or columns into a sheet, formatted like their neighbours — for example a new
563
+ date column at the end of a tracker that keeps the currency format and bold header of the column before it.
564
+
565
+ This shifts cells: everything at and after start_index moves down (rows) or right (columns), and
566
+ Google adjusts formulas that refer to the moved cells. Cell addresses noted before the insert point
567
+ to different cells afterwards, so re-read before writing values. Nothing is deleted.
568
+ Merged cells and other range-based formatting extend to the new rows/columns only when the insert
569
+ lands inside them; inserted at their edge, the new rows/columns stay outside them.
570
+
571
+ start_index is 0-based (row 1 = 0, column A = 0) and is the index the first new row/column gets:
572
+ to add a column after column E (index 4), use start_index 5. count is 1 to 100 (default 1).
573
+ inherit_from "before" (default) copies the formatting of the row/column before the insert; "after"
574
+ copies the one after it (the default at start_index 0, where there is nothing before).
575
+ The result names the inserted range in A1 notation.
576
+
577
+ Usage examples:
578
+
579
+ 1. Add one column after column E, formatted like column E:
580
+ { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz", "sheet_id": 123456789, "dimension": "COLUMNS", "start_index": 5 }
581
+
582
+ 2. Insert 3 rows above row 10 of a sheet found by its name, formatted like row 10:
583
+ { "email": "user@example.com", "spreadsheet_id": "1ABC123xyz", "sheet_title": "Acme Launch – Week 1", "dimension": "ROWS", "start_index": 9, "count": 3, "inherit_from": "after" }`,
584
+ aliases: ['insert_sheet_rows', 'insert_sheet_columns', 'insert_rows_or_columns'],
585
+ annotations: { readOnlyHint: false, destructiveHint: true },
586
+ inputSchema: {
587
+ type: 'object',
588
+ properties: {
589
+ email: {
590
+ type: 'string',
591
+ description: 'Email address of the Google account'
592
+ },
593
+ spreadsheet_id: {
594
+ type: 'string',
595
+ description: 'Google Sheets spreadsheet ID'
596
+ },
597
+ sheet_id: {
598
+ type: 'number',
599
+ description: 'Numeric sheetId (from list_workspace_spreadsheet_sheets). Pass this or sheet_title, not both.'
600
+ },
601
+ sheet_title: {
602
+ type: 'string',
603
+ description: 'Exact sheet name. Pass this or sheet_id, not both.'
604
+ },
605
+ dimension: {
606
+ type: 'string',
607
+ enum: ['ROWS', 'COLUMNS'],
608
+ description: 'Insert rows or columns'
609
+ },
610
+ start_index: {
611
+ type: 'number',
612
+ description: '0-based index the first new row/column gets (row 1 = 0, column A = 0); existing cells from here on move down or right'
613
+ },
614
+ count: {
615
+ type: 'number',
616
+ description: 'How many rows/columns to insert, 1 to 100 (default 1)'
617
+ },
618
+ inherit_from: {
619
+ type: 'string',
620
+ enum: ['before', 'after'],
621
+ description: 'Copy formatting from the row/column before the insert (default) or after it'
622
+ }
623
+ },
624
+ required: ['spreadsheet_id', 'dimension', 'start_index']
625
+ }
626
+ },
452
627
  {
453
628
  name: 'extract_workspace_spreadsheet_id',
454
629
  category: 'Sheets/Utility',
@@ -493,6 +668,7 @@ export const sheetsTools = [
493
668
  Ideal for reading from multiple sheets or non-contiguous ranges.
494
669
  If you intend to write back to these ranges, call with value_view: 'shaped' first to see formulas — overwriting formulas with computed values is silently destructive.
495
670
  For large or unbounded reads, returns an anchor envelope (first 50 + last 10 rows + summary). Pass anchor_mode: 'never' for legacy first-N truncation. Use continuation_token to page through the middle.
671
+ Rows in the text output are numbered with their sheet row numbers. Merged cells show their value only in the first cell of the merge and the other cells read as empty, so when finding a row by its labels, carry a merged label down to the rows below it.
496
672
 
497
673
  Usage examples:
498
674
 
@@ -1,3 +1,4 @@
1
+ import { DocumentResponse, TabListResponse, TabWriteResponse, TabDeleteResponse, InsertTextResponse, TabCopyResponse } from '../modules/docs/types.js';
1
2
  import { McpToolResponse } from './types.js';
2
3
  interface ReadDocumentArgs {
3
4
  email?: string;
@@ -7,6 +8,10 @@ interface ReadDocumentArgs {
7
8
  maxChars?: number;
8
9
  return_json?: boolean;
9
10
  returnJson?: boolean;
11
+ tab_id?: string;
12
+ tabId?: string;
13
+ all_tabs?: boolean;
14
+ allTabs?: boolean;
10
15
  }
11
16
  interface CreateDocumentArgs {
12
17
  email?: string;
@@ -18,12 +23,16 @@ interface AppendDocumentArgs {
18
23
  document_id?: string;
19
24
  documentId?: string;
20
25
  text: string;
26
+ tab_id?: string;
27
+ tabId?: string;
21
28
  }
22
29
  interface ReplaceDocumentArgs {
23
30
  email?: string;
24
31
  document_id?: string;
25
32
  documentId?: string;
26
33
  content: string;
34
+ tab_id?: string;
35
+ tabId?: string;
27
36
  }
28
37
  interface FindReplaceArgs {
29
38
  email?: string;
@@ -35,6 +44,8 @@ interface FindReplaceArgs {
35
44
  replaceText?: string;
36
45
  match_case?: boolean;
37
46
  matchCase?: boolean;
47
+ tab_id?: string;
48
+ tabId?: string;
38
49
  }
39
50
  interface ExtractIdArgs {
40
51
  input: string;
@@ -45,6 +56,8 @@ interface ListTabsArgs {
45
56
  documentId?: string;
46
57
  include_word_count?: boolean;
47
58
  includeWordCount?: boolean;
59
+ return_json?: boolean;
60
+ returnJson?: boolean;
48
61
  }
49
62
  interface BatchUpdateDocumentArgs {
50
63
  email?: string;
@@ -60,6 +73,76 @@ interface BatchUpdateDocumentArgs {
60
73
  return_json?: boolean;
61
74
  returnJson?: boolean;
62
75
  }
76
+ interface AddDocumentTabArgs {
77
+ email?: string;
78
+ document_id?: string;
79
+ documentId?: string;
80
+ title: string;
81
+ parent_tab_id?: string;
82
+ parentTabId?: string;
83
+ position?: number;
84
+ }
85
+ interface UpdateDocumentTabArgs {
86
+ email?: string;
87
+ document_id?: string;
88
+ documentId?: string;
89
+ tab_id?: string;
90
+ tabId?: string;
91
+ title?: string;
92
+ parent_tab_id?: string;
93
+ parentTabId?: string;
94
+ position?: number;
95
+ }
96
+ interface DeleteDocumentTabArgs {
97
+ email?: string;
98
+ document_id?: string;
99
+ documentId?: string;
100
+ tab_id?: string;
101
+ tabId?: string;
102
+ delete_sub_tabs?: boolean;
103
+ deleteSubTabs?: boolean;
104
+ }
105
+ interface InsertDocumentTextArgs {
106
+ email?: string;
107
+ document_id?: string;
108
+ documentId?: string;
109
+ tab_id?: string;
110
+ tabId?: string;
111
+ anchor_text?: string;
112
+ anchorText?: string;
113
+ position?: string;
114
+ text: string;
115
+ match_case?: boolean;
116
+ matchCase?: boolean;
117
+ expect_empty_paragraph?: boolean;
118
+ expectEmptyParagraph?: boolean;
119
+ }
120
+ interface CopyDocumentTabArgs {
121
+ email?: string;
122
+ document_id?: string;
123
+ documentId?: string;
124
+ source_tab_id?: string;
125
+ sourceTabId?: string;
126
+ target_tab_id?: string;
127
+ targetTabId?: string;
128
+ overwrite_existing?: boolean;
129
+ overwriteExisting?: boolean;
130
+ new_tab_title?: string;
131
+ newTabTitle?: string;
132
+ new_tab_parent_id?: string;
133
+ newTabParentId?: string;
134
+ new_tab_position?: number;
135
+ newTabPosition?: number;
136
+ }
137
+ /**
138
+ * Format DocumentResponse as human-readable text
139
+ */
140
+ export declare function formatDocumentResponseAsText(doc: DocumentResponse): string;
141
+ /**
142
+ * Format a document's tab tree as human-readable text: one line per tab,
143
+ * indented by nesting level and numbered by path (1., 1.1., 1.1.1.).
144
+ */
145
+ export declare function formatTabsAsText(result: TabListResponse): string;
63
146
  /**
64
147
  * Read a Google Docs document
65
148
  */
@@ -92,5 +175,47 @@ export declare function handleListDocumentTabs(args: ListTabsArgs): Promise<McpT
92
175
  * Batch update a Google Docs document with multiple operations
93
176
  */
94
177
  export declare function handleBatchUpdateDocument(args: BatchUpdateDocumentArgs): Promise<McpToolResponse | string | object>;
178
+ /**
179
+ * Result of add_workspace_document_tab (titles enveloped).
180
+ */
181
+ export declare function formatTabAddedAsText(data: TabWriteResponse): string;
182
+ /**
183
+ * Result of update_workspace_document_tab (titles enveloped).
184
+ */
185
+ export declare function formatTabUpdatedAsText(data: TabWriteResponse): string;
186
+ /**
187
+ * Result of delete_workspace_document_tab: the tab and every sub-tab deleted with it.
188
+ */
189
+ export declare function formatTabDeletedAsText(data: TabDeleteResponse): string;
190
+ /**
191
+ * Result of insert_workspace_document_text (tab title enveloped).
192
+ */
193
+ export declare function formatInsertTextAsText(data: InsertTextResponse): string;
194
+ /**
195
+ * Add a tab to a Google Docs document
196
+ */
197
+ export declare function handleAddDocumentTab(args: AddDocumentTabArgs): Promise<McpToolResponse | string | object>;
198
+ /**
199
+ * Rename and/or move a tab in a Google Docs document
200
+ */
201
+ export declare function handleUpdateDocumentTab(args: UpdateDocumentTabArgs): Promise<McpToolResponse | string | object>;
202
+ /**
203
+ * Delete a tab (and all its sub-tabs) from a Google Docs document
204
+ */
205
+ export declare function handleDeleteDocumentTab(args: DeleteDocumentTabArgs): Promise<McpToolResponse | string | object>;
206
+ /**
207
+ * Insert plain text into one tab next to a unique anchor
208
+ */
209
+ export declare function handleInsertDocumentText(args: InsertDocumentTextArgs): Promise<McpToolResponse | string | object>;
210
+ /**
211
+ * Result of copy_workspace_document_tab: what was copied, the verification
212
+ * outcome, what fell back or was left out, and the cost. Titles, paths and
213
+ * chip titles are document content, so the whole result is enveloped.
214
+ */
215
+ export declare function formatTabCopyAsText(data: TabCopyResponse): string;
216
+ /**
217
+ * Copy one tab's content into a new tab or into an existing tab (cleared first)
218
+ */
219
+ export declare function handleCopyDocumentTab(args: CopyDocumentTabArgs): Promise<McpToolResponse | string | object>;
95
220
  export {};
96
221
  //# sourceMappingURL=docs-handlers.d.ts.map