@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.
- package/README.md +43 -5
- package/dist/modules/docs/service.d.ts +76 -6
- package/dist/modules/docs/service.js +791 -103
- package/dist/modules/docs/tabCopy.d.ts +266 -0
- package/dist/modules/docs/tabCopy.js +794 -0
- package/dist/modules/docs/tabs.d.ts +161 -0
- package/dist/modules/docs/tabs.js +416 -0
- package/dist/modules/docs/types.d.ts +141 -1
- package/dist/modules/drive/service.d.ts +15 -0
- package/dist/modules/drive/service.js +77 -2
- package/dist/modules/drive/types.d.ts +1 -1
- package/dist/modules/sheets/a1Utils.d.ts +13 -0
- package/dist/modules/sheets/a1Utils.js +33 -7
- package/dist/modules/sheets/formatters.d.ts +33 -2
- package/dist/modules/sheets/formatters.js +84 -5
- package/dist/modules/sheets/service.d.ts +26 -1
- package/dist/modules/sheets/service.js +264 -8
- package/dist/modules/sheets/types.d.ts +71 -0
- package/dist/modules/sheets/types.js +12 -1
- package/dist/modules/sheets/writeGuards.js +2 -2
- package/dist/tools/definitions/destructive-overrides.json +8 -0
- package/dist/tools/definitions/docs.js +395 -9
- package/dist/tools/definitions/drive.js +9 -4
- package/dist/tools/definitions/gmail.js +30 -3
- package/dist/tools/definitions/open-world-overrides.json +8 -0
- package/dist/tools/definitions/sheets.js +177 -1
- package/dist/tools/docs-handlers.d.ts +125 -0
- package/dist/tools/docs-handlers.js +397 -15
- package/dist/tools/gmail-handlers.d.ts +3 -0
- package/dist/tools/gmail-handlers.js +19 -5
- package/dist/tools/param-normalizer.js +16 -0
- package/dist/tools/server.js +35 -3
- package/dist/tools/sheets-handlers.d.ts +54 -1
- package/dist/tools/sheets-handlers.js +107 -13
- package/dist/tools/type-guards.d.ts +89 -0
- package/dist/tools/type-guards.js +190 -6
- package/dist/tools/types.d.ts +1 -1
- package/dist/utils/apiError.d.ts +6 -0
- package/dist/utils/apiError.js +12 -0
- package/dist/utils/tabPosition.d.ts +20 -0
- package/dist/utils/tabPosition.js +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@ Google Workspace MCP server — Gmail, Calendar, Drive, Docs, Sheets, Slides, Co
|
|
|
8
8
|
|
|
9
9
|
## Status
|
|
10
10
|
|
|
11
|
-
- **Version:** [0.
|
|
11
|
+
- **Version:** [0.5.0](./CHANGELOG.md) · npm: not yet published
|
|
12
12
|
- **Auth:** OAuth (host-orchestrated) ([`GOOGLE_CLIENT_SECRET`](./server.json))
|
|
13
|
-
- **Tools:** [
|
|
13
|
+
- **Tools:** [124](./src/tools/definitions/) (Gmail, Calendar, Drive, Docs, Sheets, Slides, Contacts, Chat, Meet, Tasks, Forms, Comments, Account)
|
|
14
14
|
- **Surface:** cloud-api
|
|
15
15
|
- **Machine-readable:** [`STATUS.json`](./STATUS.json)
|
|
16
16
|
|
|
@@ -152,7 +152,7 @@ Until the host has written `${ACCOUNTS_PATH}` and the matching per-account token
|
|
|
152
152
|
}
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
## Tools (
|
|
155
|
+
## Tools (124)
|
|
156
156
|
|
|
157
157
|
The full list lives under [`src/tools/definitions/`](./src/tools/definitions/) and is also surfaced in [`tools-inventory.json`](./tools-inventory.json). Grouped by domain:
|
|
158
158
|
|
|
@@ -161,8 +161,8 @@ The full list lives under [`src/tools/definitions/`](./src/tools/definitions/) a
|
|
|
161
161
|
| Gmail | 23 | Email search/thread/send/compose, drafts, labels, label filters, attachments, archive/trash/read-state helpers, settings, vacation responder, and send-as aliases/signatures. |
|
|
162
162
|
| Calendar | 9 | Current time, free-slot lookup, calendar/event listing, event creation, updates, responses, and deletion. |
|
|
163
163
|
| Drive | 15 | List/search/upload/download/copy/move/trash/untrash files, folders, permissions, revisions, shared-drive discovery, and activity queries (what changed, when, by whom). |
|
|
164
|
-
| Docs |
|
|
165
|
-
| Sheets |
|
|
164
|
+
| Docs | 13 | Read, create, append, replace, find/replace (whole doc or one tab), insert text at an anchor, tab tree, add/rename/move/delete tabs, copy a tab's content into another tab, and batch updates. Read, append, replace and find/replace can target one tab (`tab_id`); reads can also cover every tab (`all_tabs`). |
|
|
165
|
+
| Sheets | 17 | Read/write ranges, create spreadsheets, sheet management (add, duplicate, rename, reorder, delete), insert rows or columns formatted like their neighbours, batch operations, find/replace, and formatting. |
|
|
166
166
|
| Slides | 7 | Read, create, list/get slides, batch update, thumbnails, and ID extraction. |
|
|
167
167
|
| Labels | 12 | Gmail label CRUD and filter rules. |
|
|
168
168
|
| Contacts | 4 | List, search, create, and update contacts. |
|
|
@@ -186,6 +186,44 @@ Known Drive API limitations for shared-drive files (not fixable in this connecto
|
|
|
186
186
|
- Files native to a shared drive have no `owners[]` — ownership belongs to the drive itself. Use `lastModifyingUser` and `createdTime` as proxies when attributing files.
|
|
187
187
|
- The Revisions API does not support shared-drive files, so `list_file_revisions` / `download_file_revision` only work for My Drive files.
|
|
188
188
|
|
|
189
|
+
### Docs tabs
|
|
190
|
+
|
|
191
|
+
A Google Doc can hold many tabs, nested up to a few levels deep. Every tab has a tab id such as `t.abc123`; `list_workspace_document_tabs` shows the whole tree with each tab's id, parent and position. A Docs link containing `?tab=t.xxxx` points at one tab, and `t.xxxx` is its tab id.
|
|
192
|
+
|
|
193
|
+
**Without `tab_id`:**
|
|
194
|
+
|
|
195
|
+
- `read_workspace_document` returns the first tab and, on a document with several tabs, adds a line saying how many there are. Pass `tab_id` to read one tab, or `all_tabs: true` to read every tab under `## Tab:` headings with one shared `max_chars` budget (tabs that don't fit are listed by id).
|
|
196
|
+
- `append_to_workspace_document`, `replace_workspace_document` and `insert_workspace_document_text` act on the first tab. A tool call never inherits the tab an earlier call used, so pass `tab_id` on every call that should act on another tab.
|
|
197
|
+
- `find_and_replace_workspace_document` replaces in **every** tab. Pass `tab_id` to limit it to one tab (its sub-tabs are separate tabs and are not included).
|
|
198
|
+
|
|
199
|
+
`tab_id: "default"` means the first top-level tab for reads, edits, the anchored insert, `parent_tab_id` when adding a tab, and the copy source. Tools that delete, rename, move or overwrite a tab need a real tab id and refuse `"default"`.
|
|
200
|
+
|
|
201
|
+
**Managing tabs:** `add_workspace_document_tab`, `update_workspace_document_tab` (rename, reorder, or nest under another tab; the API can't move a sub-tab back to the top level) and `delete_workspace_document_tab`.
|
|
202
|
+
|
|
203
|
+
- Tab titles must be unique across the whole document, sub-tabs included; a clash is refused before anything changes.
|
|
204
|
+
- `position` is 0-based among the tab's siblings (0 = first) and means where the tab ends up after the move. The numbers in list outputs start at 1. Results report the position the document actually shows.
|
|
205
|
+
- Deleting a tab deletes all its sub-tabs with it. A tab that has sub-tabs is refused unless `delete_sub_tabs: true` is passed.
|
|
206
|
+
|
|
207
|
+
**Inserting text at an anchor:** `insert_workspace_document_text` adds plain text to one tab without rewriting it. `anchor_text` must appear exactly once in the tab, inside one paragraph. `position` is `after` (default) or `before` the anchor, or `next_paragraph_start`: the start of the paragraph after the anchor's, which is how to fill an empty bullet under a heading. Anchor on the line directly above that slot; the paragraph there must be empty unless `expect_empty_paragraph: false` is passed. Newlines start new paragraphs that keep the paragraph's heading or bullet formatting; the inserted text itself is plain (no bold or links picked up from its neighbours).
|
|
208
|
+
|
|
209
|
+
**Copying a tab:** `copy_workspace_document_tab` copies one tab's content into another tab of the same document.
|
|
210
|
+
|
|
211
|
+
- Copied: text, heading and paragraph styles, character styles and links, bullets and numbering (mapped to Google Docs' preset list styles), tables (cell text, column widths, cell styles), page breaks and smart chips. A smart chip linking to a file you can't open becomes a titled link; people and date chips become their text. The result lists both.
|
|
212
|
+
- Not copied: headers and footers, sub-tabs, images and other special elements (listed under "Not copied"; inline ones also leave a visible `[placeholder]`), and table cell merges (cells are copied unmerged; a table whose merged cells can't be copied is refused before anything is written).
|
|
213
|
+
- Not copied faithfully: links to headings inside the copied tab still point at the original tab's headings, so after a reset they no longer resolve.
|
|
214
|
+
- Which target: to archive or duplicate a tab, use `new_tab_title`. To reset a tab in place from a template tab (keeping its id, position and sub-tabs), use `target_tab_id` with `overwrite_existing: true`, which clears that tab first. Never delete a tab in order to replace it: deleting also deletes its sub-tabs.
|
|
215
|
+
- The result starts with a `Verification:` line comparing text, heading types, paragraph formatting, bullets, list grouping and table shapes with the source. Before deleting or resetting the source, check both that it says `passed` and that the `Not copied` line lists nothing you can't lose: verification can pass while, say, a floating image was left out. A failed verification comes back as an error result.
|
|
216
|
+
- The copy is not atomic. If it stops part-way, the connector tries to delete a new tab again and the result says whether that worked (if not, it names the tab to delete); an existing target may be left cleared or partly written (the document's version history can restore it). If it completes but verification finds differences, the tab is kept so it can be checked, and the result lists the first few places it differs. Long tabs can take 10-60 seconds.
|
|
217
|
+
|
|
218
|
+
**Example: a weekly archive-and-reset** of a fictional "Acme weekly sync" doc that has a live tab and a Template tab. The business rules (the next meeting date, which lines to keep) are the caller's:
|
|
219
|
+
|
|
220
|
+
1. `list_workspace_document_tabs` to get the live and Template tab ids, then read the live tab with `tab_id: <live tab id>`. Note the date line and the out-of-office lines to keep **before** anything changes.
|
|
221
|
+
2. `copy_workspace_document_tab` with `source_tab_id: <live tab id>`, `new_tab_title: "2031-10-13"`, `new_tab_parent_id: <live tab id>` and `new_tab_position: 0`, archiving it as its first sub-tab.
|
|
222
|
+
3. Stop unless the result says `Verification: passed` and its `Not copied` line lists nothing the archive can't do without.
|
|
223
|
+
4. `copy_workspace_document_tab` with `source_tab_id: <Template tab id>`, `target_tab_id: <live tab id>` and `overwrite_existing: true`, resetting the live tab in place.
|
|
224
|
+
5. `find_and_replace_workspace_document` the date placeholder **with `tab_id: <live tab id>`** (without it the Template's placeholder changes too), and check the result says `Replaced 1`.
|
|
225
|
+
6. `insert_workspace_document_text` the kept out-of-office lines **with `tab_id: <live tab id>`** (without it the text goes into the first tab, which may be the Template) and `position: "next_paragraph_start"`, anchored on the line directly above the empty bullet.
|
|
226
|
+
|
|
189
227
|
### Vacation responder
|
|
190
228
|
|
|
191
229
|
`update_workspace_vacation_responder` merges with the existing settings (the Gmail API otherwise replaces the whole resource): omitted subject/body are kept, an existing HTML body stays HTML, and a pending scheduled end is preserved when `end_time` is omitted. To remove a scheduled end and make the auto-reply open-ended, pass `clear_end_time: true` (mutually exclusive with `end_time`). An already-past end is never carried into a re-enable.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { docs_v1 } from 'googleapis';
|
|
2
2
|
import { BaseGoogleService } from '../../services/base/BaseGoogleService.js';
|
|
3
|
-
import { DocsOperationResult, ReadDocumentOptions, CreateDocumentOptions, AppendDocumentOptions, ReplaceDocumentOptions, FindReplaceOptions, ListTabsOptions, BatchUpdateDocumentOptions } from './types.js';
|
|
3
|
+
import { DocsOperationResult, ReadDocumentOptions, CreateDocumentOptions, AppendDocumentOptions, ReplaceDocumentOptions, FindReplaceOptions, ListTabsOptions, BatchUpdateDocumentOptions, AddTabOptions, UpdateTabOptions, DeleteTabOptions, InsertTextOptions, CopyTabOptions } from './types.js';
|
|
4
|
+
/** Cap on `read_workspace_document` with `tab_id` + `return_json` (enveloped size). */
|
|
5
|
+
export declare const MAX_TAB_JSON_CHARS = 100000;
|
|
4
6
|
export declare class DocsService extends BaseGoogleService<docs_v1.Docs> {
|
|
5
7
|
private initialized;
|
|
6
8
|
constructor();
|
|
@@ -19,24 +21,43 @@ export declare class DocsService extends BaseGoogleService<docs_v1.Docs> {
|
|
|
19
21
|
* Get the end index of the document body for insert operations
|
|
20
22
|
*/
|
|
21
23
|
private getDocumentEndIndex;
|
|
24
|
+
/**
|
|
25
|
+
* Full read of every tab's content, flattened in tree order.
|
|
26
|
+
*/
|
|
27
|
+
private readAllTabs;
|
|
28
|
+
/**
|
|
29
|
+
* Tree-only read (tab properties, no content).
|
|
30
|
+
*/
|
|
31
|
+
private readTabTree;
|
|
32
|
+
private toTabInfo;
|
|
22
33
|
/**
|
|
23
34
|
* Read a document and return its content
|
|
24
35
|
*/
|
|
25
36
|
getDocument(email: string, documentId: string, options?: ReadDocumentOptions): Promise<DocsOperationResult>;
|
|
37
|
+
/**
|
|
38
|
+
* `tab_id` / `all_tabs` reads: one full `includeTabsContent` read, then the
|
|
39
|
+
* requested tab (text or bounded JSON) or every tab under one text budget.
|
|
40
|
+
*/
|
|
41
|
+
private getDocumentTabs;
|
|
26
42
|
/**
|
|
27
43
|
* Create a new document with optional initial content
|
|
28
44
|
*/
|
|
29
45
|
createDocument(email: string, options: CreateDocumentOptions): Promise<DocsOperationResult>;
|
|
30
46
|
/**
|
|
31
|
-
* Append text to the end of a document
|
|
47
|
+
* Append text to the end of a document (the first tab, or `tabId`'s tab)
|
|
32
48
|
*/
|
|
33
49
|
appendToDocument(email: string, options: AppendDocumentOptions): Promise<DocsOperationResult>;
|
|
34
50
|
/**
|
|
35
|
-
*
|
|
51
|
+
* Delete-then-insert requests that replace a body's content.
|
|
52
|
+
*/
|
|
53
|
+
private buildReplaceRequests;
|
|
54
|
+
/**
|
|
55
|
+
* Replace the content of the first tab, or of `tabId`'s tab
|
|
36
56
|
*/
|
|
37
57
|
replaceDocument(email: string, options: ReplaceDocumentOptions): Promise<DocsOperationResult>;
|
|
38
58
|
/**
|
|
39
|
-
* Find and replace text
|
|
59
|
+
* Find and replace text in every tab, or only in `tabId`'s tab
|
|
60
|
+
* (sub-tabs are separate tabs and are not included).
|
|
40
61
|
*/
|
|
41
62
|
findAndReplace(email: string, options: FindReplaceOptions): Promise<DocsOperationResult>;
|
|
42
63
|
/**
|
|
@@ -50,9 +71,58 @@ export declare class DocsService extends BaseGoogleService<docs_v1.Docs> {
|
|
|
50
71
|
*/
|
|
51
72
|
batchUpdate(email: string, documentId: string, options: BatchUpdateDocumentOptions): Promise<DocsOperationResult>;
|
|
52
73
|
/**
|
|
53
|
-
* List
|
|
54
|
-
*
|
|
74
|
+
* List every tab in a document (all nesting levels, tree order).
|
|
75
|
+
* Without word counts this is a tree-only read (no tab content fetched).
|
|
55
76
|
*/
|
|
56
77
|
listTabs(email: string, options: ListTabsOptions): Promise<DocsOperationResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Initialised, scope-checked Docs client for a write.
|
|
80
|
+
*/
|
|
81
|
+
private getWriteClient;
|
|
82
|
+
/**
|
|
83
|
+
* Shared catch for the tab-management and insert methods: auth handoffs and
|
|
84
|
+
* input errors propagate; API failures become `{ success: false }`.
|
|
85
|
+
*/
|
|
86
|
+
private toFailure;
|
|
87
|
+
private toTabRef;
|
|
88
|
+
private parentRef;
|
|
89
|
+
/**
|
|
90
|
+
* Add a tab (optionally under a parent, at a 0-based position among its new
|
|
91
|
+
* siblings). Reports the tab as the document shows it after the write.
|
|
92
|
+
*/
|
|
93
|
+
addTab(email: string, options: AddTabOptions): Promise<DocsOperationResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Rename and/or move a tab. `position` is the 0-based position the tab should
|
|
96
|
+
* end up at among its destination siblings; the API's before-removal index is
|
|
97
|
+
* computed here. Reports the actual title, parent and position after the write.
|
|
98
|
+
*/
|
|
99
|
+
updateTab(email: string, options: UpdateTabOptions): Promise<DocsOperationResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Delete a tab and, with it, every sub-tab below it. A tab that has sub-tabs
|
|
102
|
+
* is refused before any write unless the caller passes `deleteSubTabs`.
|
|
103
|
+
*/
|
|
104
|
+
deleteTab(email: string, options: DeleteTabOptions): Promise<DocsOperationResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Insert plain text into one tab next to a unique anchor: right after it,
|
|
107
|
+
* right before it, or at the start of the paragraph that follows it (in the
|
|
108
|
+
* same container). The inserted text takes the paragraph formatting of where
|
|
109
|
+
* it lands (heading, bullet) but its character style is cleared. The text is
|
|
110
|
+
* first normalised to what Docs stores, so the style-clear range never
|
|
111
|
+
* reaches past it into existing text.
|
|
112
|
+
*/
|
|
113
|
+
insertText(email: string, options: InsertTextOptions): Promise<DocsOperationResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Copy one tab's content into another tab of the same document: into a new
|
|
116
|
+
* tab (`newTabTitle`) or into an existing tab, which is cleared first
|
|
117
|
+
* (`targetTabId` + `overwriteExisting`). Every input check, the source read
|
|
118
|
+
* and the per-chip access checks happen before the first write. On a failure
|
|
119
|
+
* after that, a tab this call created is deleted again (best effort); an
|
|
120
|
+
* existing target is left as it is and the error says so. A copy that
|
|
121
|
+
* completes but fails verification is kept, in either mode, and returned
|
|
122
|
+
* with its report (the handler marks it as an error).
|
|
123
|
+
*/
|
|
124
|
+
copyTab(email: string, options: CopyTabOptions, checkChip: (uri: string) => Promise<boolean>): Promise<DocsOperationResult>;
|
|
125
|
+
/** Best-effort removal of a tab a failed copy created. True when it is gone. */
|
|
126
|
+
private deleteHalfWrittenTab;
|
|
57
127
|
}
|
|
58
128
|
//# sourceMappingURL=service.d.ts.map
|