@aaronsb/google-workspace-mcp 4.0.1 → 4.2.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 +154 -141
- package/build/factory/manifest/docs.yaml +19 -3
- package/build/index.js +13 -9
- package/build/index.js.map +1 -1
- package/build/lifecycle.d.ts +35 -0
- package/build/lifecycle.js +159 -0
- package/build/lifecycle.js.map +1 -0
- package/build/server/formatting/markdown.d.ts +2 -0
- package/build/server/formatting/markdown.js +1 -1
- package/build/server/formatting/markdown.js.map +1 -1
- package/build/server/handlers/validate.d.ts +6 -0
- package/build/server/handlers/validate.js +11 -0
- package/build/server/handlers/validate.js.map +1 -1
- package/build/server/scratchpad/adapters/import-doc.js +28 -3
- package/build/server/scratchpad/adapters/import-doc.js.map +1 -1
- package/build/server/scratchpad/docs-sync.d.ts +15 -3
- package/build/server/scratchpad/docs-sync.js +114 -45
- package/build/server/scratchpad/docs-sync.js.map +1 -1
- package/build/server/scratchpad/handler.js +5 -0
- package/build/server/scratchpad/handler.js.map +1 -1
- package/build/services/docs/patch.js +321 -16
- package/build/services/docs/patch.js.map +1 -1
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,170 +5,198 @@
|
|
|
5
5
|
[](https://nodejs.org)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
Give AI
|
|
8
|
+
**Give your AI agent real access to Google Workspace** — Gmail, Calendar, Drive, Docs, Sheets, Tasks and Meet — from one MCP server, across as many accounts as you have.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Search your mail, check your calendar, write a doc, file a task — in conversation, as yourself.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Install
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
First, you need **Google OAuth credentials** — the one prerequisite common to every path:
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
1. Go to [console.cloud.google.com/apis/credentials](https://console.cloud.google.com/apis/credentials)
|
|
17
|
+
2. Create an **OAuth 2.0 Client ID**, application type **Desktop app**
|
|
18
|
+
3. Enable the APIs you want (Gmail, Calendar, Drive, Sheets, Docs, Tasks, Meet)
|
|
19
|
+
4. Keep the **Client ID** and **Client Secret** handy — you'll paste them in below
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
Then pick the path that matches how you work. All three run the same server.
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
Node 22.12 or newer. (Node 18 and 20 are both end-of-life.)
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
---
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|------|--------------|
|
|
26
|
-
| `manage_email` | Gmail — search, read (plain or sanitized HTML), send, reply / reply-all, forward, triage, trash, labels, threads, attachments |
|
|
27
|
-
| `manage_calendar` | Calendar — list, agenda, get, create, quickAdd (natural language), update, delete, calendars, freebusy |
|
|
28
|
-
| `manage_drive` | Drive — search, get, upload, download, copy, rename / move, delete, export, permissions, comments, view images |
|
|
29
|
-
| `manage_sheets` | Sheets — read / write ranges (row-numbered output), append, clear, manage tabs, copy / duplicate / rename |
|
|
30
|
-
| `manage_docs` | Docs — get, create, append, insert text, find-and-replace |
|
|
31
|
-
| `manage_tasks` | Tasks — list / create / update / complete tasks and task lists |
|
|
32
|
-
| `manage_meet` | Meet — browse past conferences, participants, transcripts, recordings, smart notes |
|
|
33
|
-
| `manage_accounts` | Multi-account lifecycle — add accounts, manage credentials and scopes |
|
|
34
|
-
| `manage_scratchpad` | Compose / edit multi-line content (line- or JSON-path-addressed), attach files, send to any target; JSON mode live-syncs to Docs / Sheets |
|
|
35
|
-
| `manage_workspace` | File operations in the workspace sandbox (exchange point for attachments, downloads, exports) |
|
|
36
|
-
| `queue_operations` | Chain operations sequentially with `$N.field` result references |
|
|
27
|
+
### 📦 → 🤖 Claude Desktop — one-click `.mcpb` install (recommended)
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
Download **`google-workspace-mcp.mcpb`** from the [latest release](https://github.com/aaronsb/google-workspace-mcp/releases/latest), then **drag it onto the Claude Desktop window**, or double-click it.
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
Claude Desktop opens an install dialog with three fields:
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
| Field | |
|
|
34
|
+
|---|---|
|
|
35
|
+
| **Google OAuth Client ID** | required — from the step above |
|
|
36
|
+
| **Google OAuth Client Secret** | required — from the step above |
|
|
37
|
+
| **Workspace Directory** | optional — where attachments, downloads and exports land. Defaults to `~/.local/share/google-workspace-mcp/workspace/`. Give it a dedicated folder — not your home, Documents, Desktop, or a Google Drive folder. |
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
Paste, hit Save, done. No JSON to edit, no Node to install, no paths to get right — the bundle carries the server and every dependency.
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
**One bundle covers every platform** — macOS (Intel and Apple Silicon), Linux (x64 and ARM64), and Windows. There is nothing to choose: the server is pure JavaScript, so there is no platform-specific payload to pick between.
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
> *Cross-platform note:* `.mcpb` files install via Claude Desktop's bundled handler. If double-clicking doesn't trigger Claude on your system, drag the file onto the Claude Desktop window instead, or right-click → "Open with…" and pick Claude Desktop (then "always open with" if your OS offers). Behavior varies: macOS usually auto-associates, Windows may need a one-time association, Linux varies by desktop environment.
|
|
49
44
|
|
|
50
|
-
|
|
45
|
+
---
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
flowchart LR
|
|
54
|
-
disco["Google Discovery<br>documents"] --> gen["descriptor generator<br>generate-descriptor.mjs"]
|
|
55
|
-
gen --> desc[("src/google/descriptor.json<br>233 methods · committed<br>paths · verbs · params · scopes")]
|
|
56
|
-
desc --> gate{{"CI drift gate<br>regenerate and compare"}}
|
|
47
|
+
### Claude Code — one command
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class gen process
|
|
64
|
-
class desc artifact
|
|
65
|
-
class gate guard
|
|
49
|
+
```bash
|
|
50
|
+
claude mcp add google-workspace \
|
|
51
|
+
-e GOOGLE_CLIENT_ID=your-client-id \
|
|
52
|
+
-e GOOGLE_CLIENT_SECRET=your-client-secret \
|
|
53
|
+
-- npx -y @aaronsb/google-workspace-mcp
|
|
66
54
|
```
|
|
67
55
|
|
|
68
|
-
|
|
56
|
+
That's it — no file to edit. Verify with `/mcp`.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Other MCP clients
|
|
61
|
+
|
|
62
|
+
Add an entry to the client's MCP config file (for Claude Desktop by hand, that's `claude_desktop_config.json`; for Claude Code, `.mcp.json`):
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"google-workspace": {
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": ["-y", "@aaronsb/google-workspace-mcp"],
|
|
70
|
+
"env": {
|
|
71
|
+
"GOOGLE_CLIENT_ID": "your-client-id",
|
|
72
|
+
"GOOGLE_CLIENT_SECRET": "your-client-secret"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or install it globally and point at the binary directly:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm install -g @aaronsb/google-workspace-mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## How it fits together
|
|
69
86
|
|
|
70
87
|
```mermaid
|
|
71
88
|
flowchart LR
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
human["🧑 You<br>ask in plain language"]
|
|
90
|
+
agent["🤖 Your AI agent<br>Claude Desktop, Claude Code…"]
|
|
91
|
+
server["⚙️ This MCP server<br>picks the right account,<br>builds the real request"]
|
|
92
|
+
keys[("🔑 Your accounts<br>OAuth tokens, kept<br>on your own machine")]
|
|
93
|
+
google["☁️ Google<br>Gmail · Calendar · Drive<br>Docs · Sheets · Tasks · Meet"]
|
|
94
|
+
|
|
95
|
+
human -->|"“what's on my calendar?”"| agent
|
|
96
|
+
agent -->|"tool call"| server
|
|
97
|
+
server <-->|"which account?"| keys
|
|
98
|
+
server -->|"real API call, as you"| google
|
|
99
|
+
google -->|"your data"| server
|
|
100
|
+
server -->|"shaped for an agent<br>+ what to do next"| agent
|
|
101
|
+
agent -->|"an answer"| human
|
|
102
|
+
|
|
103
|
+
classDef person fill:#475569,color:#ffffff,stroke:#94a3b8
|
|
104
|
+
classDef robot fill:#2d7d9a,color:#ffffff,stroke:#4a5568
|
|
105
|
+
classDef ours fill:#7c3aed,color:#ffffff,stroke:#8b5cf6
|
|
106
|
+
classDef secrets fill:#2d8e5e,color:#ffffff,stroke:#4a5568
|
|
79
107
|
classDef external fill:#f6821f,color:#1a1a1a,stroke:#d97706
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
108
|
+
|
|
109
|
+
class human person
|
|
110
|
+
class agent robot
|
|
111
|
+
class server ours
|
|
112
|
+
class keys secrets
|
|
84
113
|
class google external
|
|
85
|
-
class desc artifact
|
|
86
|
-
class manifest config
|
|
87
|
-
class factory,patches,client core
|
|
88
|
-
class mcp inert
|
|
89
114
|
```
|
|
90
115
|
|
|
91
|
-
**The
|
|
116
|
+
**Your credentials never leave your machine.** The server holds an OAuth token per account, on your own disk, and calls Google *as you* — there is no middleman service, no account of ours, nothing to sign up for. Add as many accounts as you like (personal and work, side by side); the server routes each request to the right one.
|
|
92
117
|
|
|
93
|
-
|
|
118
|
+
## What it can do
|
|
94
119
|
|
|
95
|
-
**
|
|
120
|
+
**11 tools across 7 Google services**, plus multi-account handling, batching, content authoring, and a file sandbox.
|
|
96
121
|
|
|
97
|
-
|
|
122
|
+
| Tool | What It Does |
|
|
123
|
+
|------|--------------|
|
|
124
|
+
| `manage_email` | Gmail — search, read (plain or sanitized HTML), send, reply / reply-all, forward, triage, trash, labels, threads, attachments |
|
|
125
|
+
| `manage_calendar` | Calendar — list, agenda, get, create, quickAdd (natural language), update, delete, calendars, freebusy |
|
|
126
|
+
| `manage_drive` | Drive — search, get, upload, download, copy, rename / move, delete, export, permissions, comments, view images |
|
|
127
|
+
| `manage_sheets` | Sheets — read / write ranges (row-numbered output), append, clear, manage tabs, copy / duplicate / rename |
|
|
128
|
+
| `manage_docs` | Docs — get, create, append, insert text, find-and-replace |
|
|
129
|
+
| `manage_tasks` | Tasks — list / create / update / complete tasks and task lists |
|
|
130
|
+
| `manage_meet` | Meet — browse past conferences, participants, transcripts, recordings, smart notes |
|
|
131
|
+
| `manage_accounts` | Multi-account lifecycle — add accounts, manage credentials and scopes |
|
|
132
|
+
| `manage_scratchpad` | Compose / edit multi-line content (line- or JSON-path-addressed), attach files, send to any target; JSON mode live-syncs to Docs / Sheets |
|
|
133
|
+
| `manage_workspace` | File operations in the workspace sandbox (exchange point for attachments, downloads, exports) |
|
|
134
|
+
| `queue_operations` | Chain operations sequentially with `$N.field` result references |
|
|
98
135
|
|
|
99
|
-
|
|
136
|
+
Every response carries **next-steps** guidance, so the agent always knows what it can do next.
|
|
100
137
|
|
|
101
|
-
|
|
138
|
+
## One ask, many steps
|
|
102
139
|
|
|
103
|
-
|
|
140
|
+
The useful part isn't any single operation — it's that your agent can **string them together**.
|
|
104
141
|
|
|
105
|
-
|
|
142
|
+
You ask for one thing. The agent works out that it needs four API calls, in order, each one feeding the next:
|
|
106
143
|
|
|
107
|
-
|
|
144
|
+
```mermaid
|
|
145
|
+
sequenceDiagram
|
|
146
|
+
autonumber
|
|
147
|
+
participant H as 🧑 You
|
|
148
|
+
participant A as 🤖 Your agent
|
|
149
|
+
participant S as ⚙️ MCP server
|
|
150
|
+
participant G as ☁️ Google
|
|
151
|
+
|
|
152
|
+
H->>A: "file the invoice from Acme<br>and remind me to pay it Friday"
|
|
153
|
+
A->>S: find the email
|
|
154
|
+
S->>G: search Gmail
|
|
155
|
+
G-->>S: the message
|
|
156
|
+
S-->>A: found it — and here's what you can do next
|
|
157
|
+
A->>S: save the attachment
|
|
158
|
+
S->>G: download it
|
|
159
|
+
A->>S: put it in Drive
|
|
160
|
+
S->>G: upload
|
|
161
|
+
A->>S: create a task, due Friday
|
|
162
|
+
S->>G: Google Tasks
|
|
163
|
+
A-->>H: Done. Invoice filed, task set for Friday.
|
|
164
|
+
```
|
|
108
165
|
|
|
109
|
-
|
|
166
|
+
Two things make this work. Every response tells the agent **what it can do next**, so it isn't guessing at the next step. And `queue_operations` lets it run a whole chain in **one call**, feeding each result into the next — so "find the invoice, file it, remind me" is a single round trip rather than four.
|
|
110
167
|
|
|
111
|
-
|
|
112
|
-
npm install @aaronsb/google-workspace-mcp
|
|
113
|
-
```
|
|
168
|
+
## Ask for what's missing
|
|
114
169
|
|
|
115
|
-
|
|
170
|
+
This server exposes **80 operations**, reaching 60 of the **233 methods** Google publishes across those seven APIs. It is a curated subset on purpose: an agent has to *choose* among these, and every method it must weigh is one it can pick wrongly. A tool with 233 operations isn't more capable than one with 80 — it's harder to use correctly.
|
|
116
171
|
|
|
117
|
-
|
|
118
|
-
npx @aaronsb/google-workspace-mcp
|
|
119
|
-
```
|
|
172
|
+
But that judgement was made without you.
|
|
120
173
|
|
|
121
|
-
|
|
174
|
+
**→ [Browse every method Google publishes](docs/api-surface.md)**
|
|
122
175
|
|
|
123
|
-
|
|
124
|
-
2. **Google Cloud OAuth credentials** — create at [console.cloud.google.com/apis/credentials](https://console.cloud.google.com/apis/credentials):
|
|
125
|
-
- Create an OAuth 2.0 Client ID (Desktop application)
|
|
126
|
-
- Enable the APIs you want (Gmail, Calendar, Drive, Sheets, …)
|
|
127
|
-
3. Set environment variables:
|
|
128
|
-
```bash
|
|
129
|
-
export GOOGLE_CLIENT_ID="your-client-id"
|
|
130
|
-
export GOOGLE_CLIENT_SECRET="your-client-secret"
|
|
131
|
-
```
|
|
176
|
+
Every method is listed — what it does, whether we expose it, and a **Request** link that opens a pre-filled issue. The descriptions are Google's own, quoted verbatim, and the page is generated from the same specification the client is built from, so it can't drift from reality.
|
|
132
177
|
|
|
133
|
-
|
|
178
|
+
That page also lists **four whole APIs this server doesn't touch yet** — Chat, Contacts, Slides and Forms — for the same reason: *not targeted* is a decision, not a fact of nature.
|
|
134
179
|
|
|
135
|
-
|
|
180
|
+
A good request **names the task, not the method**:
|
|
136
181
|
|
|
137
|
-
|
|
182
|
+
> *"I want the agent to file incoming invoices into a folder automatically."*
|
|
138
183
|
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
"mcpServers": {
|
|
142
|
-
"google-workspace": {
|
|
143
|
-
"command": "npx",
|
|
144
|
-
"args": ["@aaronsb/google-workspace-mcp"],
|
|
145
|
-
"env": {
|
|
146
|
-
"GOOGLE_CLIENT_ID": "your-client-id",
|
|
147
|
-
"GOOGLE_CLIENT_SECRET": "your-client-secret"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
```
|
|
184
|
+
That can be evaluated. It might turn out an existing operation already does it, or that the right answer is a different method than the one you found. *"Expose `users.settings.filters.create`"* is a conclusion, not a case — lead with the problem and let the method follow.
|
|
153
185
|
|
|
154
|
-
|
|
186
|
+
## Why Apache 2.0, and not open core
|
|
155
187
|
|
|
156
|
-
|
|
188
|
+
**Everything is here.** There is no paid tier, no "enterprise" build, no feature held back to sell you later. What you install is what exists.
|
|
157
189
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
```
|
|
190
|
+
Open core works by keeping the good part back. The free thing is a lead magnet, and the moment your use gets serious you discover the operation you need lives behind a licence. That model would be especially rotten *here*: this is a piece of plumbing between you and **your own data**, using **your own Google credentials**, running on **your own machine**. Nothing about that arrangement should have a paywall in the middle of it, and nothing about it needs a vendor.
|
|
191
|
+
|
|
192
|
+
[Apache 2.0](LICENSE) rather than MIT for two concrete reasons:
|
|
193
|
+
|
|
194
|
+
- **An explicit patent grant.** Contributors licence their patent claims along with their code, so using this can't become a patent problem later. MIT is silent on patents, which means the question is merely unanswered rather than settled.
|
|
195
|
+
- **It's safe to adopt at work.** Apache 2.0 is on essentially every corporate allow-list. Fork it, vendor it, ship it inside a commercial product — you don't owe anyone anything, and you don't need to ask.
|
|
196
|
+
|
|
197
|
+
The one obligation is attribution: keep the notices ([`NOTICE`](NOTICE), [`LICENSE`](LICENSE)) with the code. That's it.
|
|
198
|
+
|
|
199
|
+
Through v3.0.0 this project was MIT-licensed, and that history is preserved rather than erased — MIT-era contributions keep their original notice in [`LICENSE-MIT`](LICENSE-MIT), and their authors are credited in [`NOTICE`](NOTICE). Apache 2.0 takes back nothing MIT permitted.
|
|
172
200
|
|
|
173
201
|
## Usage
|
|
174
202
|
|
|
@@ -199,20 +227,7 @@ Chain operations with result references — the output of one step feeds the nex
|
|
|
199
227
|
}
|
|
200
228
|
```
|
|
201
229
|
|
|
202
|
-
##
|
|
203
|
-
|
|
204
|
-
The coverage mapper diffs what the manifest exposes against what Google actually publishes, so the frontier is always measured rather than estimated:
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
npm run generate-descriptor # re-read Google's Discovery documents
|
|
208
|
-
make coverage # what we expose vs. what Google offers
|
|
209
|
-
make manifest-lint # validate the curated manifest
|
|
210
|
-
make check # type-check, lint, test, build, smoke
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
To expose a new operation, add it to the relevant `src/factory/manifest/*.yaml`. The descriptor already knows its path, verb, parameters, and scopes, and the factory generates the tool schema and handler. New operations get default formatting automatically — add a patch only when an agent needs a shaped response rather than a raw one.
|
|
214
|
-
|
|
215
|
-
## Data Storage
|
|
230
|
+
## Where your data lives
|
|
216
231
|
|
|
217
232
|
Follows the XDG Base Directory Specification:
|
|
218
233
|
|
|
@@ -224,19 +239,17 @@ Follows the XDG Base Directory Specification:
|
|
|
224
239
|
|
|
225
240
|
Credentials are per-account files holding standard OAuth tokens. No secrets are stored in the project directory.
|
|
226
241
|
|
|
227
|
-
##
|
|
242
|
+
## Under the hood
|
|
228
243
|
|
|
229
|
-
|
|
244
|
+
You don't need any of this to use the server. But if you're curious, or you want to add an operation:
|
|
230
245
|
|
|
231
|
-
|
|
246
|
+
The server builds its Google API client **from Google's own machine-readable API specifications**. Nothing is transcribed by hand, so the surface can't drift from reality, and adding an operation is a YAML edit rather than a code change.
|
|
232
247
|
|
|
233
|
-
|
|
248
|
+
- **[How it works](docs/how-it-works.md)** — the build-time / runtime split, the descriptor, the factory
|
|
249
|
+
- **[API coverage](docs/coverage.md)** — what's exposed, what isn't, and how to ask for more
|
|
250
|
+
- **[The full API surface](docs/api-surface.md)** — every method Google publishes, plus the four APIs we don't target yet
|
|
251
|
+
- **[Architecture decisions](docs/architecture/)** — the ADRs, including why this server owns its Google client outright
|
|
234
252
|
|
|
235
253
|
## License
|
|
236
254
|
|
|
237
|
-
[Apache License 2.0](LICENSE).
|
|
238
|
-
|
|
239
|
-
Through v3.0.0 this project was MIT-licensed. Those contributions keep their original
|
|
240
|
-
notice (`LICENSE-MIT`), and the contributors are credited in [`NOTICE`](NOTICE). Apache 2.0
|
|
241
|
-
adds an explicit patent grant and a state-your-changes requirement; it does not take back
|
|
242
|
-
anything MIT permitted.
|
|
255
|
+
[Apache License 2.0](LICENSE) — see [Why Apache 2.0](#why-apache-20-and-not-open-core) above.
|
|
@@ -4,6 +4,10 @@ requires_email: true
|
|
|
4
4
|
google_service: docs
|
|
5
5
|
operations:
|
|
6
6
|
|
|
7
|
+
# A document's text lives per-TAB, and `tabId` is the handle that addresses one — the
|
|
8
|
+
# same handle every write operation below takes. Reading without it spans the document;
|
|
9
|
+
# reading with it scopes both the text and the character indices to one tab, so an
|
|
10
|
+
# index measured here means the same thing to insertText (#157, #158).
|
|
7
11
|
get:
|
|
8
12
|
type: detail
|
|
9
13
|
description: "get document content and metadata"
|
|
@@ -13,6 +17,9 @@ operations:
|
|
|
13
17
|
type: string
|
|
14
18
|
description: "Document ID"
|
|
15
19
|
required: true
|
|
20
|
+
tabId:
|
|
21
|
+
type: string
|
|
22
|
+
description: "Tab to act on — a tabId from a previous get's tabIndex. Scopes the read on get; targets the edit on write/insertText/replaceText, which act on the FIRST tab when it is omitted (replaceText spans every tab). Character indices are per-tab."
|
|
16
23
|
|
|
17
24
|
# `title` rides in the BODY — documents.create declares no parameters at all
|
|
18
25
|
# (Discovery: `"parameters": {}`), so everything goes into the Document resource.
|
|
@@ -42,8 +49,11 @@ operations:
|
|
|
42
49
|
required: true
|
|
43
50
|
text:
|
|
44
51
|
type: string
|
|
45
|
-
description: "Text to
|
|
52
|
+
description: "Text to write (plain text) — appended to the end by write, inserted at `index` by insertText"
|
|
46
53
|
required: true
|
|
54
|
+
tabId:
|
|
55
|
+
type: string
|
|
56
|
+
description: "Tab to act on — a tabId from a previous get's tabIndex. Scopes the read on get; targets the edit on write/insertText/replaceText, which act on the FIRST tab when it is omitted (replaceText spans every tab). Character indices are per-tab."
|
|
47
57
|
|
|
48
58
|
insertText:
|
|
49
59
|
type: action
|
|
@@ -56,12 +66,15 @@ operations:
|
|
|
56
66
|
required: true
|
|
57
67
|
text:
|
|
58
68
|
type: string
|
|
59
|
-
description: "Text to
|
|
69
|
+
description: "Text to write (plain text) — appended to the end by write, inserted at `index` by insertText"
|
|
60
70
|
required: true
|
|
61
71
|
index:
|
|
62
72
|
type: number
|
|
63
|
-
description: "Character index to insert at (1 = start of
|
|
73
|
+
description: "Character index to insert at (1 = start of the tab's body)"
|
|
64
74
|
required: true
|
|
75
|
+
tabId:
|
|
76
|
+
type: string
|
|
77
|
+
description: "Tab to act on — a tabId from a previous get's tabIndex. Scopes the read on get; targets the edit on write/insertText/replaceText, which act on the FIRST tab when it is omitted (replaceText spans every tab). Character indices are per-tab."
|
|
65
78
|
|
|
66
79
|
replaceText:
|
|
67
80
|
type: action
|
|
@@ -84,3 +97,6 @@ operations:
|
|
|
84
97
|
type: boolean
|
|
85
98
|
description: "Case-sensitive match (default: true)"
|
|
86
99
|
default: true
|
|
100
|
+
tabId:
|
|
101
|
+
type: string
|
|
102
|
+
description: "Tab to act on — a tabId from a previous get's tabIndex. Scopes the read on get; targets the edit on write/insertText/replaceText, which act on the FIRST tab when it is omitted (replaceText spans every tab). Character indices are per-tab."
|
package/build/index.js
CHANGED
|
@@ -19,20 +19,24 @@
|
|
|
19
19
|
* ERR_REQUIRE_ESM ever leaks (CI job `engines-floor-reject`), and `check-node-floor.mjs`
|
|
20
20
|
* rejects a static import of the server graph outright. Those are what protect it.
|
|
21
21
|
*
|
|
22
|
-
* `./node-floor.js`
|
|
23
|
-
* this file guards against. Only the SERVER GRAPH must stay behind the
|
|
22
|
+
* `./node-floor.js` and `./lifecycle.js` import only `node:fs` (a builtin), so they cannot
|
|
23
|
+
* trigger the failure this file guards against. Only the SERVER GRAPH must stay behind the
|
|
24
|
+
* dynamic import.
|
|
24
25
|
*/
|
|
25
26
|
import { enforceNodeFloor } from './node-floor.js';
|
|
27
|
+
import { installLifecycle } from './lifecycle.js';
|
|
26
28
|
enforceNodeFloor();
|
|
29
|
+
/**
|
|
30
|
+
* Before the server starts: notice if our client dies, and exit.
|
|
31
|
+
*
|
|
32
|
+
* This also installs the uncaughtException/unhandledRejection guards, which used to live
|
|
33
|
+
* here and wrote to `process.stderr` directly. That was the busy-loop in issue #149 — once
|
|
34
|
+
* the client died, the write raised the next uncaught exception, which re-entered the
|
|
35
|
+
* handler, forever, at 100% CPU. See lifecycle.ts and ADR-104.
|
|
36
|
+
*/
|
|
37
|
+
installLifecycle();
|
|
27
38
|
// Dynamic, and only after the floor is enforced. See the file header.
|
|
28
39
|
const { startServer } = await import('./server/server.js');
|
|
29
|
-
// Prevent unhandled rejections from crashing the server
|
|
30
|
-
process.on('unhandledRejection', (reason) => {
|
|
31
|
-
process.stderr.write(`[google-workspace-mcp] unhandled rejection: ${reason}\n`);
|
|
32
|
-
});
|
|
33
|
-
process.on('uncaughtException', (err) => {
|
|
34
|
-
process.stderr.write(`[google-workspace-mcp] uncaught exception: ${err.message}\n${err.stack}\n`);
|
|
35
|
-
});
|
|
36
40
|
startServer().catch((err) => {
|
|
37
41
|
process.stderr.write(`[google-workspace-mcp] fatal: ${err.message}\n`);
|
|
38
42
|
process.exit(1);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,gBAAgB,EAAE,CAAC;AAEnB;;;;;;;GAOG;AACH,gBAAgB,EAAE,CAAC;AAEnB,sEAAsE;AACtE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE3D,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** How often to check whether our parent is still alive. */
|
|
2
|
+
export declare const WATCHDOG_INTERVAL_MS = 5000;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the process has been orphaned, given a startup ppid and what we see now.
|
|
5
|
+
*
|
|
6
|
+
* Pure so it can be tested without spawning process trees. Two signals, because neither
|
|
7
|
+
* covers every platform:
|
|
8
|
+
*
|
|
9
|
+
* `currentPpid !== originalPpid` — on Unix a dead parent means immediate reparenting to
|
|
10
|
+
* init/systemd, so a *changed* ppid is definitive. This is the reliable one, and it is
|
|
11
|
+
* immune to PID reuse.
|
|
12
|
+
*
|
|
13
|
+
* `!parentAlive` — a `kill(pid, 0)` probe, for platforms that don't reparent (Windows).
|
|
14
|
+
* Note this is checked against the ORIGINAL ppid, captured at startup.
|
|
15
|
+
*
|
|
16
|
+
* Why the original ppid matters: `process.ppid` is a LIVE GETTER, not a value fixed at
|
|
17
|
+
* startup. The fix suggested in #149 polls `process.kill(process.ppid, 0)`, which re-reads
|
|
18
|
+
* ppid every tick — after reparenting that reads as init/systemd, which is always alive,
|
|
19
|
+
* so the check never fires and the server spins on. Measured: after the parent died, ppid
|
|
20
|
+
* moved 2884591 -> 2951 (systemd), and kill(2951, 0) reports alive. Reading ppid once, at
|
|
21
|
+
* startup, is the whole trick.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isOrphaned(originalPpid: number, currentPpid: number, parentAlive: boolean): boolean;
|
|
24
|
+
export interface LifecycleHooks {
|
|
25
|
+
/** Seam for tests. Defaults to process.exit. */
|
|
26
|
+
exit?: (code: number) => void;
|
|
27
|
+
/** Seam for tests. Defaults to a real pid probe. */
|
|
28
|
+
parentAlive?: (pid: number) => boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Installs all three layers. Call once, from the entrypoint, before starting the server.
|
|
32
|
+
*
|
|
33
|
+
* Returns a `stop()` for tests; the real process never needs it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installLifecycle(hooks?: LifecycleHooks): () => void;
|