@alanse/mcp-server-google-workspace 1.0.0 → 1.0.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.
Files changed (155) hide show
  1. package/README.md +146 -17
  2. package/dist/auth.js +5 -0
  3. package/dist/lib/calendar-helpers.js +197 -0
  4. package/dist/lib/drive-helpers.js +263 -0
  5. package/dist/lib/gmail-helpers.js +204 -0
  6. package/dist/tools/calendar/acl/calendar_acl_insert.js +80 -0
  7. package/dist/tools/calendar/acl/calendar_acl_list.js +82 -0
  8. package/dist/tools/calendar/basic/calendar_create_event.js +113 -0
  9. package/dist/tools/calendar/basic/calendar_delete_event.js +52 -0
  10. package/dist/tools/calendar/basic/calendar_get_event.js +52 -0
  11. package/dist/tools/calendar/basic/calendar_list_events.js +86 -0
  12. package/dist/tools/calendar/basic/calendar_update_event.js +116 -0
  13. package/dist/tools/calendar/calendarlist/calendar_calendarlist_get.js +73 -0
  14. package/dist/tools/calendar/calendarlist/calendar_calendarlist_list.js +87 -0
  15. package/dist/tools/calendar/calendars/calendar_calendars_get.js +52 -0
  16. package/dist/tools/calendar/calendars/calendar_calendars_insert.js +66 -0
  17. package/dist/tools/calendar/calendars/calendar_calendars_update.js +85 -0
  18. package/dist/tools/calendar/colors/calendar_colors_get.js +46 -0
  19. package/dist/tools/calendar/events_advanced/calendar_events_instances.js +81 -0
  20. package/dist/tools/calendar/events_advanced/calendar_events_move.js +63 -0
  21. package/dist/tools/calendar/events_advanced/calendar_events_quickadd.js +52 -0
  22. package/dist/tools/calendar/freebusy/calendar_freebusy_query.js +69 -0
  23. package/dist/tools/calendar/settings/calendar_settings_list.js +81 -0
  24. package/dist/tools/drive/advanced/drive_empty_trash.js +56 -0
  25. package/dist/tools/drive/advanced/drive_export_file.js +158 -0
  26. package/dist/tools/drive/advanced/drive_list_revisions.js +80 -0
  27. package/dist/tools/drive/basic/drive_get_metadata.js +49 -0
  28. package/dist/tools/drive/basic/drive_list_files.js +76 -0
  29. package/dist/tools/drive/file/drive_copy_file.js +79 -0
  30. package/dist/tools/drive/file/drive_create_file.js +72 -0
  31. package/dist/tools/drive/file/drive_delete_file.js +48 -0
  32. package/dist/tools/drive/file/drive_move_file.js +79 -0
  33. package/dist/tools/drive/file/drive_rename_file.js +58 -0
  34. package/dist/tools/drive/file/drive_update_file.js +106 -0
  35. package/dist/tools/drive/file/drive_upload_file.js +80 -0
  36. package/dist/tools/drive/folder/drive_create_folder.js +67 -0
  37. package/dist/tools/drive/folder/drive_list_folder_contents.js +68 -0
  38. package/dist/tools/drive/folder/drive_move_to_folder.js +59 -0
  39. package/dist/tools/drive/permissions/drive_list_permissions.js +115 -0
  40. package/dist/tools/drive/permissions/drive_remove_permission.js +71 -0
  41. package/dist/tools/drive/permissions/drive_share_file.js +116 -0
  42. package/dist/tools/drive/permissions/drive_update_permission.js +79 -0
  43. package/dist/tools/gmail/basic/gmail_get_message.js +95 -0
  44. package/dist/tools/gmail/basic/gmail_get_thread.js +46 -0
  45. package/dist/tools/gmail/basic/gmail_list_labels.js +54 -0
  46. package/dist/tools/gmail/basic/gmail_search_messages.js +59 -0
  47. package/dist/tools/gmail/batch/gmail_batch_modify_labels.js +74 -0
  48. package/dist/tools/gmail/batch/gmail_get_messages_batch.js +120 -0
  49. package/dist/tools/gmail/batch/gmail_get_threads_batch.js +102 -0
  50. package/dist/tools/gmail/labels/gmail_manage_label.js +131 -0
  51. package/dist/tools/gmail/labels/gmail_modify_labels.js +65 -0
  52. package/dist/tools/gmail/send/gmail_draft_message.js +117 -0
  53. package/dist/tools/gmail/send/gmail_send_message.js +109 -0
  54. package/dist/tools/index.js +267 -3
  55. package/package.json +8 -3
  56. package/dist/tools/basic/gsheets_add_sheet.js +0 -65
  57. package/dist/tools/basic/gsheets_copy_sheet.js +0 -56
  58. package/dist/tools/basic/gsheets_copy_to.js +0 -113
  59. package/dist/tools/basic/gsheets_create_spreadsheet.js +0 -88
  60. package/dist/tools/basic/gsheets_delete_columns.js +0 -69
  61. package/dist/tools/basic/gsheets_delete_rows.js +0 -69
  62. package/dist/tools/basic/gsheets_delete_sheet.js +0 -56
  63. package/dist/tools/basic/gsheets_duplicate_sheet.js +0 -72
  64. package/dist/tools/basic/gsheets_insert_columns.js +0 -69
  65. package/dist/tools/basic/gsheets_insert_rows.js +0 -69
  66. package/dist/tools/basic/gsheets_list_sheets.js +0 -53
  67. package/dist/tools/basic/gsheets_read.js +0 -120
  68. package/dist/tools/basic/gsheets_rename_sheet.js +0 -64
  69. package/dist/tools/charts/gsheets_add_bubble.js +0 -176
  70. package/dist/tools/charts/gsheets_add_candlestick.js +0 -192
  71. package/dist/tools/charts/gsheets_add_chart.js +0 -162
  72. package/dist/tools/charts/gsheets_add_combo.js +0 -169
  73. package/dist/tools/charts/gsheets_add_histogram.js +0 -143
  74. package/dist/tools/charts/gsheets_add_org_chart.js +0 -160
  75. package/dist/tools/charts/gsheets_add_treemap.js +0 -177
  76. package/dist/tools/charts/gsheets_add_waterfall.js +0 -155
  77. package/dist/tools/charts/gsheets_delete_chart.js +0 -56
  78. package/dist/tools/charts/gsheets_update_chart.js +0 -118
  79. package/dist/tools/data/gsheets_append_data.js +0 -68
  80. package/dist/tools/data/gsheets_batch_clear.js +0 -53
  81. package/dist/tools/data/gsheets_batch_update.js +0 -81
  82. package/dist/tools/data/gsheets_clear_data.js +0 -53
  83. package/dist/tools/data/gsheets_create_filter.js +0 -81
  84. package/dist/tools/data/gsheets_find_replace.js +0 -124
  85. package/dist/tools/data/gsheets_set_data_validation.js +0 -153
  86. package/dist/tools/data/gsheets_sort_range.js +0 -102
  87. package/dist/tools/data/gsheets_update_cell.js +0 -44
  88. package/dist/tools/formatting/gsheets_auto_resize.js +0 -75
  89. package/dist/tools/formatting/gsheets_format_cells.js +0 -161
  90. package/dist/tools/formatting/gsheets_freeze_columns.js +0 -67
  91. package/dist/tools/formatting/gsheets_freeze_rows.js +0 -67
  92. package/dist/tools/formatting/gsheets_merge_cells.js +0 -85
  93. package/dist/tools/formatting/gsheets_set_number_format.js +0 -116
  94. package/dist/tools/formatting/gsheets_unmerge_cells.js +0 -79
  95. package/dist/tools/formatting/gsheets_update_borders.js +0 -212
  96. package/dist/tools/gdrive/gdrive_read_file.js +0 -77
  97. package/dist/tools/gdrive/gdrive_search.js +0 -71
  98. package/dist/tools/gdrive_read_file.js +0 -77
  99. package/dist/tools/gdrive_search.js +0 -71
  100. package/dist/tools/gsheets_add_bubble.js +0 -176
  101. package/dist/tools/gsheets_add_candlestick.js +0 -192
  102. package/dist/tools/gsheets_add_chart.js +0 -162
  103. package/dist/tools/gsheets_add_combo.js +0 -169
  104. package/dist/tools/gsheets_add_conditional_format.js +0 -175
  105. package/dist/tools/gsheets_add_histogram.js +0 -143
  106. package/dist/tools/gsheets_add_named_range.js +0 -87
  107. package/dist/tools/gsheets_add_org_chart.js +0 -160
  108. package/dist/tools/gsheets_add_protected_range.js +0 -127
  109. package/dist/tools/gsheets_add_sheet.js +0 -65
  110. package/dist/tools/gsheets_add_treemap.js +0 -177
  111. package/dist/tools/gsheets_add_waterfall.js +0 -155
  112. package/dist/tools/gsheets_append_data.js +0 -68
  113. package/dist/tools/gsheets_auto_resize.js +0 -75
  114. package/dist/tools/gsheets_batch_clear.js +0 -53
  115. package/dist/tools/gsheets_batch_update.js +0 -81
  116. package/dist/tools/gsheets_clear_data.js +0 -53
  117. package/dist/tools/gsheets_copy_sheet.js +0 -56
  118. package/dist/tools/gsheets_copy_to.js +0 -113
  119. package/dist/tools/gsheets_create_filter.js +0 -81
  120. package/dist/tools/gsheets_create_spreadsheet.js +0 -88
  121. package/dist/tools/gsheets_delete_chart.js +0 -56
  122. package/dist/tools/gsheets_delete_columns.js +0 -69
  123. package/dist/tools/gsheets_delete_named_range.js +0 -56
  124. package/dist/tools/gsheets_delete_protected_range.js +0 -56
  125. package/dist/tools/gsheets_delete_rows.js +0 -69
  126. package/dist/tools/gsheets_delete_sheet.js +0 -56
  127. package/dist/tools/gsheets_duplicate_sheet.js +0 -72
  128. package/dist/tools/gsheets_find_replace.js +0 -124
  129. package/dist/tools/gsheets_format_cells.js +0 -161
  130. package/dist/tools/gsheets_freeze_columns.js +0 -67
  131. package/dist/tools/gsheets_freeze_rows.js +0 -67
  132. package/dist/tools/gsheets_insert_columns.js +0 -69
  133. package/dist/tools/gsheets_insert_rows.js +0 -69
  134. package/dist/tools/gsheets_list_sheets.js +0 -53
  135. package/dist/tools/gsheets_merge_cells.js +0 -85
  136. package/dist/tools/gsheets_read.js +0 -120
  137. package/dist/tools/gsheets_rename_sheet.js +0 -64
  138. package/dist/tools/gsheets_set_data_validation.js +0 -153
  139. package/dist/tools/gsheets_set_number_format.js +0 -116
  140. package/dist/tools/gsheets_sort_range.js +0 -102
  141. package/dist/tools/gsheets_unmerge_cells.js +0 -79
  142. package/dist/tools/gsheets_update_borders.js +0 -212
  143. package/dist/tools/gsheets_update_cell.js +0 -44
  144. package/dist/tools/gsheets_update_chart.js +0 -118
  145. package/dist/tools/gsheets_update_named_range.js +0 -112
  146. package/dist/tools/gsheets_update_protected_range.js +0 -110
  147. package/dist/tools/protection/gsheets_add_conditional_format.js +0 -175
  148. package/dist/tools/protection/gsheets_add_named_range.js +0 -87
  149. package/dist/tools/protection/gsheets_add_protected_range.js +0 -127
  150. package/dist/tools/protection/gsheets_delete_named_range.js +0 -56
  151. package/dist/tools/protection/gsheets_delete_protected_range.js +0 -56
  152. package/dist/tools/protection/gsheets_update_named_range.js +0 -112
  153. package/dist/tools/protection/gsheets_update_protected_range.js +0 -110
  154. /package/dist/tools/drive/{drive_read_file.js → basic/drive_read_file.js} +0 -0
  155. /package/dist/tools/drive/{drive_search.js → basic/drive_search.js} +0 -0
@@ -1,124 +0,0 @@
1
- import { google } from "googleapis";
2
- export const schema = {
3
- name: "gsheets_find_replace",
4
- description: "Find and replace text in a range or entire sheet",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- spreadsheetId: {
9
- type: "string",
10
- description: "The ID of the spreadsheet",
11
- },
12
- sheetId: {
13
- type: "number",
14
- description: "The ID of the sheet (optional, searches all sheets if omitted)",
15
- },
16
- find: {
17
- type: "string",
18
- description: "Text to find",
19
- },
20
- replacement: {
21
- type: "string",
22
- description: "Replacement text",
23
- },
24
- matchCase: {
25
- type: "boolean",
26
- description: "Case-sensitive matching (default: false)",
27
- },
28
- matchEntireCell: {
29
- type: "boolean",
30
- description: "Match entire cell content (default: false)",
31
- },
32
- searchByRegex: {
33
- type: "boolean",
34
- description: "Use regex pattern (default: false)",
35
- },
36
- startRow: {
37
- type: "number",
38
- description: "Starting row index (0-based, optional)",
39
- },
40
- endRow: {
41
- type: "number",
42
- description: "Ending row index (exclusive, 0-based, optional)",
43
- },
44
- startColumn: {
45
- type: "number",
46
- description: "Starting column index (0-based, optional)",
47
- },
48
- endColumn: {
49
- type: "number",
50
- description: "Ending column index (exclusive, 0-based, optional)",
51
- },
52
- },
53
- required: ["spreadsheetId", "find", "replacement"],
54
- },
55
- };
56
- export async function findReplace(args) {
57
- try {
58
- const sheets = google.sheets("v4");
59
- const findReplaceSpec = {
60
- find: args.find,
61
- replacement: args.replacement,
62
- matchCase: args.matchCase || false,
63
- matchEntireCell: args.matchEntireCell || false,
64
- searchByRegex: args.searchByRegex || false,
65
- };
66
- // Add range if specified
67
- if (args.sheetId !== undefined ||
68
- args.startRow !== undefined ||
69
- args.endRow !== undefined ||
70
- args.startColumn !== undefined ||
71
- args.endColumn !== undefined) {
72
- findReplaceSpec.range = {};
73
- if (args.sheetId !== undefined) {
74
- findReplaceSpec.range.sheetId = args.sheetId;
75
- }
76
- if (args.startRow !== undefined) {
77
- findReplaceSpec.range.startRowIndex = args.startRow;
78
- }
79
- if (args.endRow !== undefined) {
80
- findReplaceSpec.range.endRowIndex = args.endRow;
81
- }
82
- if (args.startColumn !== undefined) {
83
- findReplaceSpec.range.startColumnIndex = args.startColumn;
84
- }
85
- if (args.endColumn !== undefined) {
86
- findReplaceSpec.range.endColumnIndex = args.endColumn;
87
- }
88
- }
89
- const response = await sheets.spreadsheets.batchUpdate({
90
- spreadsheetId: args.spreadsheetId,
91
- requestBody: {
92
- requests: [
93
- {
94
- findReplace: findReplaceSpec,
95
- },
96
- ],
97
- },
98
- });
99
- const occurrencesChanged = response.data.replies?.[0]?.findReplace?.occurrencesChanged || 0;
100
- const rowsChanged = response.data.replies?.[0]?.findReplace?.rowsChanged || 0;
101
- const sheetsChanged = response.data.replies?.[0]?.findReplace?.sheetsChanged || 0;
102
- const valuesChanged = response.data.replies?.[0]?.findReplace?.valuesChanged || 0;
103
- return {
104
- content: [
105
- {
106
- type: "text",
107
- text: `Successfully replaced "${args.find}" with "${args.replacement}". Changed: ${occurrencesChanged} occurrences, ${rowsChanged} rows, ${sheetsChanged} sheets, ${valuesChanged} values.`,
108
- },
109
- ],
110
- isError: false,
111
- };
112
- }
113
- catch (error) {
114
- return {
115
- content: [
116
- {
117
- type: "text",
118
- text: `Error finding and replacing: ${error.message}`,
119
- },
120
- ],
121
- isError: true,
122
- };
123
- }
124
- }
@@ -1,153 +0,0 @@
1
- import { google } from "googleapis";
2
- export const schema = {
3
- name: "gsheets_set_data_validation",
4
- description: "Set data validation rules for cells (dropdowns, number ranges, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- spreadsheetId: {
9
- type: "string",
10
- description: "The ID of the spreadsheet",
11
- },
12
- sheetId: {
13
- type: "number",
14
- description: "The ID of the sheet",
15
- },
16
- startRow: {
17
- type: "number",
18
- description: "Starting row index (0-based)",
19
- },
20
- endRow: {
21
- type: "number",
22
- description: "Ending row index (exclusive, 0-based)",
23
- },
24
- startColumn: {
25
- type: "number",
26
- description: "Starting column index (0-based)",
27
- },
28
- endColumn: {
29
- type: "number",
30
- description: "Ending column index (exclusive, 0-based)",
31
- },
32
- validation: {
33
- type: "object",
34
- properties: {
35
- type: {
36
- type: "string",
37
- enum: ["ONE_OF_LIST", "ONE_OF_RANGE", "NUMBER_GREATER", "NUMBER_LESS", "NUMBER_BETWEEN", "DATE_AFTER", "DATE_BEFORE", "CUSTOM_FORMULA"],
38
- description: "The type of data validation",
39
- },
40
- values: {
41
- type: "array",
42
- items: { type: "string" },
43
- description: "List of valid values (for ONE_OF_LIST)",
44
- },
45
- minValue: {
46
- type: "string",
47
- description: "Minimum value (for NUMBER_BETWEEN, NUMBER_GREATER)",
48
- },
49
- maxValue: {
50
- type: "string",
51
- description: "Maximum value (for NUMBER_BETWEEN, NUMBER_LESS)",
52
- },
53
- formula: {
54
- type: "string",
55
- description: "Custom formula (for CUSTOM_FORMULA)",
56
- },
57
- strict: {
58
- type: "boolean",
59
- description: "Whether to reject input when validation fails (default: true)",
60
- },
61
- showCustomUi: {
62
- type: "boolean",
63
- description: "Show dropdown for list validation (default: true)",
64
- },
65
- },
66
- required: ["type"],
67
- description: "Data validation settings",
68
- },
69
- },
70
- required: ["spreadsheetId", "sheetId", "startRow", "endRow", "startColumn", "endColumn", "validation"],
71
- },
72
- };
73
- export async function setDataValidation(args) {
74
- try {
75
- const sheets = google.sheets("v4");
76
- const condition = {};
77
- switch (args.validation.type) {
78
- case "ONE_OF_LIST":
79
- if (!args.validation.values || args.validation.values.length === 0) {
80
- throw new Error("values array is required for ONE_OF_LIST validation");
81
- }
82
- condition.type = "ONE_OF_LIST";
83
- condition.values = args.validation.values.map(v => ({ userEnteredValue: v }));
84
- break;
85
- case "NUMBER_GREATER":
86
- condition.type = "NUMBER_GREATER";
87
- condition.values = [{ userEnteredValue: args.validation.minValue }];
88
- break;
89
- case "NUMBER_LESS":
90
- condition.type = "NUMBER_LESS";
91
- condition.values = [{ userEnteredValue: args.validation.maxValue }];
92
- break;
93
- case "NUMBER_BETWEEN":
94
- condition.type = "NUMBER_BETWEEN";
95
- condition.values = [
96
- { userEnteredValue: args.validation.minValue },
97
- { userEnteredValue: args.validation.maxValue },
98
- ];
99
- break;
100
- case "CUSTOM_FORMULA":
101
- condition.type = "CUSTOM_FORMULA";
102
- condition.values = [{ userEnteredValue: args.validation.formula }];
103
- break;
104
- default:
105
- condition.type = args.validation.type;
106
- }
107
- const rule = {
108
- condition,
109
- strict: args.validation.strict !== false,
110
- showCustomUi: args.validation.showCustomUi !== false,
111
- };
112
- await sheets.spreadsheets.batchUpdate({
113
- spreadsheetId: args.spreadsheetId,
114
- requestBody: {
115
- requests: [
116
- {
117
- setDataValidation: {
118
- range: {
119
- sheetId: args.sheetId,
120
- startRowIndex: args.startRow,
121
- endRowIndex: args.endRow,
122
- startColumnIndex: args.startColumn,
123
- endColumnIndex: args.endColumn,
124
- },
125
- rule,
126
- },
127
- },
128
- ],
129
- },
130
- });
131
- const rangeStr = `R${args.startRow}C${args.startColumn}:R${args.endRow - 1}C${args.endColumn - 1}`;
132
- return {
133
- content: [
134
- {
135
- type: "text",
136
- text: `Successfully set data validation (${args.validation.type}) for range ${rangeStr}`,
137
- },
138
- ],
139
- isError: false,
140
- };
141
- }
142
- catch (error) {
143
- return {
144
- content: [
145
- {
146
- type: "text",
147
- text: `Error setting data validation: ${error.message}`,
148
- },
149
- ],
150
- isError: true,
151
- };
152
- }
153
- }
@@ -1,102 +0,0 @@
1
- import { google } from "googleapis";
2
- export const schema = {
3
- name: "gsheets_sort_range",
4
- description: "Sort a range of data in a Google Spreadsheet",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- spreadsheetId: {
9
- type: "string",
10
- description: "The ID of the spreadsheet",
11
- },
12
- sheetId: {
13
- type: "number",
14
- description: "The ID of the sheet",
15
- },
16
- startRow: {
17
- type: "number",
18
- description: "Starting row index (0-based)",
19
- },
20
- endRow: {
21
- type: "number",
22
- description: "Ending row index (exclusive, 0-based)",
23
- },
24
- startColumn: {
25
- type: "number",
26
- description: "Starting column index (0-based)",
27
- },
28
- endColumn: {
29
- type: "number",
30
- description: "Ending column index (exclusive, 0-based)",
31
- },
32
- sortSpecs: {
33
- type: "array",
34
- items: {
35
- type: "object",
36
- properties: {
37
- dimensionIndex: {
38
- type: "number",
39
- description: "Column index to sort by (0-based)",
40
- },
41
- sortOrder: {
42
- type: "string",
43
- enum: ["ASCENDING", "DESCENDING"],
44
- description: "Sort order",
45
- },
46
- },
47
- required: ["dimensionIndex", "sortOrder"],
48
- },
49
- description: "Sort specifications (multiple for multi-level sorting)",
50
- },
51
- },
52
- required: ["spreadsheetId", "sheetId", "startRow", "endRow", "startColumn", "endColumn", "sortSpecs"],
53
- },
54
- };
55
- export async function sortRange(args) {
56
- try {
57
- const sheets = google.sheets("v4");
58
- await sheets.spreadsheets.batchUpdate({
59
- spreadsheetId: args.spreadsheetId,
60
- requestBody: {
61
- requests: [
62
- {
63
- sortRange: {
64
- range: {
65
- sheetId: args.sheetId,
66
- startRowIndex: args.startRow,
67
- endRowIndex: args.endRow,
68
- startColumnIndex: args.startColumn,
69
- endColumnIndex: args.endColumn,
70
- },
71
- sortSpecs: args.sortSpecs,
72
- },
73
- },
74
- ],
75
- },
76
- });
77
- const rangeStr = `R${args.startRow}C${args.startColumn}:R${args.endRow - 1}C${args.endColumn - 1}`;
78
- const sortDesc = args.sortSpecs
79
- .map((spec) => `column ${spec.dimensionIndex} (${spec.sortOrder})`)
80
- .join(", ");
81
- return {
82
- content: [
83
- {
84
- type: "text",
85
- text: `Successfully sorted range ${rangeStr} by ${sortDesc}`,
86
- },
87
- ],
88
- isError: false,
89
- };
90
- }
91
- catch (error) {
92
- return {
93
- content: [
94
- {
95
- type: "text",
96
- text: `Error sorting range: ${error.message}`,
97
- },
98
- ],
99
- isError: true,
100
- };
101
- }
102
- }
@@ -1,44 +0,0 @@
1
- import { google } from "googleapis";
2
- export const schema = {
3
- name: "gsheets_update_cell",
4
- description: "Update a cell value in a Google Spreadsheet",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- fileId: {
9
- type: "string",
10
- description: "ID of the spreadsheet",
11
- },
12
- range: {
13
- type: "string",
14
- description: "Cell range in A1 notation (e.g. 'Sheet1!A1')",
15
- },
16
- value: {
17
- type: "string",
18
- description: "New cell value",
19
- },
20
- },
21
- required: ["fileId", "range", "value"],
22
- },
23
- };
24
- export async function updateCell(args) {
25
- const { fileId, range, value } = args;
26
- const sheets = google.sheets({ version: "v4" });
27
- await sheets.spreadsheets.values.update({
28
- spreadsheetId: fileId,
29
- range: range,
30
- valueInputOption: "RAW",
31
- requestBody: {
32
- values: [[value]],
33
- },
34
- });
35
- return {
36
- content: [
37
- {
38
- type: "text",
39
- text: `Updated cell ${range} to value: ${value}`,
40
- },
41
- ],
42
- isError: false,
43
- };
44
- }
@@ -1,75 +0,0 @@
1
- import { google } from "googleapis";
2
- export const schema = {
3
- name: "gsheets_auto_resize",
4
- description: "Automatically resize rows or columns to fit content",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- spreadsheetId: {
9
- type: "string",
10
- description: "The ID of the spreadsheet",
11
- },
12
- sheetId: {
13
- type: "number",
14
- description: "The ID of the sheet",
15
- },
16
- dimension: {
17
- type: "string",
18
- enum: ["ROWS", "COLUMNS"],
19
- description: "Whether to resize rows or columns",
20
- },
21
- startIndex: {
22
- type: "number",
23
- description: "The starting index (0-based) of rows/columns to resize",
24
- },
25
- endIndex: {
26
- type: "number",
27
- description: "The ending index (exclusive, 0-based) of rows/columns to resize",
28
- },
29
- },
30
- required: ["spreadsheetId", "sheetId", "dimension", "startIndex", "endIndex"],
31
- },
32
- };
33
- export async function autoResize(args) {
34
- try {
35
- const sheets = google.sheets("v4");
36
- await sheets.spreadsheets.batchUpdate({
37
- spreadsheetId: args.spreadsheetId,
38
- requestBody: {
39
- requests: [
40
- {
41
- autoResizeDimensions: {
42
- dimensions: {
43
- sheetId: args.sheetId,
44
- dimension: args.dimension,
45
- startIndex: args.startIndex,
46
- endIndex: args.endIndex,
47
- },
48
- },
49
- },
50
- ],
51
- },
52
- });
53
- const count = args.endIndex - args.startIndex;
54
- return {
55
- content: [
56
- {
57
- type: "text",
58
- text: `Successfully auto-resized ${count} ${args.dimension.toLowerCase()} (indices ${args.startIndex}-${args.endIndex - 1})`,
59
- },
60
- ],
61
- isError: false,
62
- };
63
- }
64
- catch (error) {
65
- return {
66
- content: [
67
- {
68
- type: "text",
69
- text: `Error auto-resizing: ${error.message}`,
70
- },
71
- ],
72
- isError: true,
73
- };
74
- }
75
- }
@@ -1,161 +0,0 @@
1
- import { google } from "googleapis";
2
- export const schema = {
3
- name: "gsheets_format_cells",
4
- description: "Format cells in a Google Spreadsheet (font, colors, alignment, etc.)",
5
- inputSchema: {
6
- type: "object",
7
- properties: {
8
- spreadsheetId: {
9
- type: "string",
10
- description: "The ID of the spreadsheet",
11
- },
12
- sheetId: {
13
- type: "number",
14
- description: "The ID of the sheet",
15
- },
16
- startRow: {
17
- type: "number",
18
- description: "Starting row index (0-based)",
19
- },
20
- endRow: {
21
- type: "number",
22
- description: "Ending row index (exclusive, 0-based)",
23
- },
24
- startColumn: {
25
- type: "number",
26
- description: "Starting column index (0-based)",
27
- },
28
- endColumn: {
29
- type: "number",
30
- description: "Ending column index (exclusive, 0-based)",
31
- },
32
- format: {
33
- type: "object",
34
- properties: {
35
- bold: { type: "boolean", description: "Make text bold" },
36
- italic: { type: "boolean", description: "Make text italic" },
37
- fontSize: { type: "number", description: "Font size in points" },
38
- fontFamily: { type: "string", description: "Font family name" },
39
- textColor: {
40
- type: "object",
41
- properties: {
42
- red: { type: "number", minimum: 0, maximum: 1 },
43
- green: { type: "number", minimum: 0, maximum: 1 },
44
- blue: { type: "number", minimum: 0, maximum: 1 },
45
- },
46
- description: "Text color (RGB values 0-1)",
47
- },
48
- backgroundColor: {
49
- type: "object",
50
- properties: {
51
- red: { type: "number", minimum: 0, maximum: 1 },
52
- green: { type: "number", minimum: 0, maximum: 1 },
53
- blue: { type: "number", minimum: 0, maximum: 1 },
54
- },
55
- description: "Background color (RGB values 0-1)",
56
- },
57
- horizontalAlignment: {
58
- type: "string",
59
- enum: ["LEFT", "CENTER", "RIGHT"],
60
- description: "Horizontal text alignment",
61
- },
62
- verticalAlignment: {
63
- type: "string",
64
- enum: ["TOP", "MIDDLE", "BOTTOM"],
65
- description: "Vertical text alignment",
66
- },
67
- },
68
- description: "Format options to apply",
69
- },
70
- },
71
- required: ["spreadsheetId", "sheetId", "startRow", "endRow", "startColumn", "endColumn", "format"],
72
- },
73
- };
74
- export async function formatCells(args) {
75
- try {
76
- const sheets = google.sheets("v4");
77
- const cellFormat = {};
78
- const fields = [];
79
- if (args.format.bold !== undefined || args.format.italic !== undefined ||
80
- args.format.fontSize !== undefined || args.format.fontFamily !== undefined ||
81
- args.format.textColor !== undefined) {
82
- cellFormat.textFormat = {};
83
- if (args.format.bold !== undefined) {
84
- cellFormat.textFormat.bold = args.format.bold;
85
- fields.push("userEnteredFormat.textFormat.bold");
86
- }
87
- if (args.format.italic !== undefined) {
88
- cellFormat.textFormat.italic = args.format.italic;
89
- fields.push("userEnteredFormat.textFormat.italic");
90
- }
91
- if (args.format.fontSize !== undefined) {
92
- cellFormat.textFormat.fontSize = args.format.fontSize;
93
- fields.push("userEnteredFormat.textFormat.fontSize");
94
- }
95
- if (args.format.fontFamily !== undefined) {
96
- cellFormat.textFormat.fontFamily = args.format.fontFamily;
97
- fields.push("userEnteredFormat.textFormat.fontFamily");
98
- }
99
- if (args.format.textColor !== undefined) {
100
- cellFormat.textFormat.foregroundColor = args.format.textColor;
101
- fields.push("userEnteredFormat.textFormat.foregroundColor");
102
- }
103
- }
104
- if (args.format.backgroundColor !== undefined) {
105
- cellFormat.backgroundColor = args.format.backgroundColor;
106
- fields.push("userEnteredFormat.backgroundColor");
107
- }
108
- if (args.format.horizontalAlignment !== undefined) {
109
- cellFormat.horizontalAlignment = args.format.horizontalAlignment;
110
- fields.push("userEnteredFormat.horizontalAlignment");
111
- }
112
- if (args.format.verticalAlignment !== undefined) {
113
- cellFormat.verticalAlignment = args.format.verticalAlignment;
114
- fields.push("userEnteredFormat.verticalAlignment");
115
- }
116
- await sheets.spreadsheets.batchUpdate({
117
- spreadsheetId: args.spreadsheetId,
118
- requestBody: {
119
- requests: [
120
- {
121
- repeatCell: {
122
- range: {
123
- sheetId: args.sheetId,
124
- startRowIndex: args.startRow,
125
- endRowIndex: args.endRow,
126
- startColumnIndex: args.startColumn,
127
- endColumnIndex: args.endColumn,
128
- },
129
- cell: {
130
- userEnteredFormat: cellFormat,
131
- },
132
- fields: fields.join(","),
133
- },
134
- },
135
- ],
136
- },
137
- });
138
- const rangeStr = `R${args.startRow}C${args.startColumn}:R${args.endRow - 1}C${args.endColumn - 1}`;
139
- const appliedFormats = Object.keys(args.format).join(", ");
140
- return {
141
- content: [
142
- {
143
- type: "text",
144
- text: `Successfully formatted cells in range ${rangeStr}. Applied formats: ${appliedFormats}`,
145
- },
146
- ],
147
- isError: false,
148
- };
149
- }
150
- catch (error) {
151
- return {
152
- content: [
153
- {
154
- type: "text",
155
- text: `Error formatting cells: ${error.message}`,
156
- },
157
- ],
158
- isError: true,
159
- };
160
- }
161
- }