google-mcp-suite 1.20.0 → 1.21.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/ADOPTING.md +91 -2
- package/README.md +36 -5
- package/dist/auth/accounts.d.ts.map +1 -0
- package/dist/{doctor → auth}/accounts.js +2 -1
- package/dist/auth/accounts.js.map +1 -0
- package/dist/calendar/index.js +4 -21
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/service.d.ts +4 -0
- package/dist/calendar/service.d.ts.map +1 -0
- package/dist/calendar/service.js +22 -0
- package/dist/calendar/service.js.map +1 -0
- package/dist/docs/index.js +4 -24
- package/dist/docs/index.js.map +1 -1
- package/dist/docs/service.d.ts +4 -0
- package/dist/docs/service.d.ts.map +1 -0
- package/dist/docs/service.js +25 -0
- package/dist/docs/service.js.map +1 -0
- package/dist/doctor/auth.d.ts +1 -1
- package/dist/doctor/auth.d.ts.map +1 -1
- package/dist/doctor/auth.js +1 -1
- package/dist/doctor/auth.js.map +1 -1
- package/dist/doctor/diagnose.js +1 -1
- package/dist/doctor/diagnose.js.map +1 -1
- package/dist/doctor/status.d.ts +1 -1
- package/dist/doctor/status.d.ts.map +1 -1
- package/dist/doctor/status.js +1 -1
- package/dist/doctor/status.js.map +1 -1
- package/dist/drive/index.js +4 -21
- package/dist/drive/index.js.map +1 -1
- package/dist/drive/service.d.ts +4 -0
- package/dist/drive/service.d.ts.map +1 -0
- package/dist/drive/service.js +22 -0
- package/dist/drive/service.js.map +1 -0
- package/dist/gmail/index.js +4 -21
- package/dist/gmail/index.js.map +1 -1
- package/dist/gmail/service.d.ts +4 -0
- package/dist/gmail/service.d.ts.map +1 -0
- package/dist/gmail/service.js +22 -0
- package/dist/gmail/service.js.map +1 -0
- package/dist/host/cli.d.ts +16 -0
- package/dist/host/cli.d.ts.map +1 -0
- package/dist/host/cli.js +56 -0
- package/dist/host/cli.js.map +1 -0
- package/dist/host/host.d.ts +64 -0
- package/dist/host/host.d.ts.map +1 -0
- package/dist/host/host.js +217 -0
- package/dist/host/host.js.map +1 -0
- package/dist/host/index.d.ts +3 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +52 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/services.d.ts +15 -0
- package/dist/host/services.d.ts.map +1 -0
- package/dist/host/services.js +27 -0
- package/dist/host/services.js.map +1 -0
- package/dist/lib/server.d.ts +25 -6
- package/dist/lib/server.d.ts.map +1 -1
- package/dist/lib/server.js +32 -18
- package/dist/lib/server.js.map +1 -1
- package/dist/sheets/index.js +4 -24
- package/dist/sheets/index.js.map +1 -1
- package/dist/sheets/service.d.ts +4 -0
- package/dist/sheets/service.d.ts.map +1 -0
- package/dist/sheets/service.js +25 -0
- package/dist/sheets/service.js.map +1 -0
- package/dist/suite/dispatch.d.ts +2 -0
- package/dist/suite/dispatch.d.ts.map +1 -1
- package/dist/suite/dispatch.js +8 -7
- package/dist/suite/dispatch.js.map +1 -1
- package/llms-install.md +10 -1
- package/package.json +8 -7
- package/dist/doctor/accounts.d.ts.map +0 -1
- package/dist/doctor/accounts.js.map +0 -1
- /package/dist/{doctor → auth}/accounts.d.ts +0 -0
package/ADOPTING.md
CHANGED
|
@@ -57,7 +57,8 @@ Adoption changes an enumerable set of things. Decommissioning removes that set.
|
|
|
57
57
|
[Removing credentials](#removing-credentials-optional-destructive)).
|
|
58
58
|
3. **MCP server entries**, named `<service>-<account>` (`gmail-personal`,
|
|
59
59
|
`calendar-work`), one per service per account, registered at the client's
|
|
60
|
-
user/global scope
|
|
60
|
+
user/global scope; either a stdio command per entry, or (with the shared
|
|
61
|
+
host) a `url` per entry pointing at `http://127.0.0.1:8765/<account>/<service>`.
|
|
61
62
|
4. **Client-specific supersession settings** that stop the client preferring
|
|
62
63
|
its own first-party Google surface (Claude Code: three `permissions.deny`
|
|
63
64
|
strings; Codex CLI: `enabled = false` lines for any installed
|
|
@@ -217,6 +218,91 @@ requirement is satisfied by default; there is no scope flag to hunt for.
|
|
|
217
218
|
**Gemini CLI**: the `mcpServers` JSON shape above, inside
|
|
218
219
|
`~/.gemini/settings.json` (`gemini mcp add` also works).
|
|
219
220
|
|
|
221
|
+
**Shared host (optional; one process for everything):** stdio is fine for
|
|
222
|
+
one client. Choose the host when more than one agent or session runs on the
|
|
223
|
+
box, or when the client spawns MCP servers per thread and never closes them
|
|
224
|
+
(Codex `app-server` does). Process count and memory otherwise multiply by
|
|
225
|
+
services, accounts, and sessions. Run `google-mcp-host` once under a supervisor
|
|
226
|
+
and register the same `<service>-<account>` names by URL. The host serves every
|
|
227
|
+
roster account at `http://127.0.0.1:8765/<account>/<service>`.
|
|
228
|
+
|
|
229
|
+
Moving to HTTP is **one name, one transport**: remove the stdio entry first,
|
|
230
|
+
then register the URL under that same name. For Claude Code, run
|
|
231
|
+
`claude mcp remove --scope user <name>`. In Codex TOML, delete the entry's
|
|
232
|
+
`command`, `args`, and `env` lines or tables. In `mcpServers` JSON, delete the
|
|
233
|
+
old command entry before replacing it with the URL entry. Otherwise the
|
|
234
|
+
client spawns the stdio copy AND connects to the host. Restart existing
|
|
235
|
+
client sessions after replacement so their stdio processes can shut down.
|
|
236
|
+
|
|
237
|
+
For persistent sharing, use the [systemd user unit or launchd user agent
|
|
238
|
+
template](./src/host/README.md#run-as-a-user-service). Install the package
|
|
239
|
+
globally and give the template the absolute directory holding `node` and the
|
|
240
|
+
`google-mcp-host` shim; a supervisor does not see your shell's PATH, so a
|
|
241
|
+
version-managed Node (nvm, fnm, volta) is invisible to it otherwise.
|
|
242
|
+
Both templates read `$HOME/.google-mcp/host.env` (mode 0600) containing
|
|
243
|
+
`GOOGLE_MCP_HOST_TOKEN=<secret>`. On Linux, enable the unit with
|
|
244
|
+
`systemctl --user enable --now google-mcp-host`; use `loginctl enable-linger`
|
|
245
|
+
for headless operation. WSL2 requires `[boot]` with `systemd=true` in
|
|
246
|
+
`/etc/wsl.conf`. On macOS, bootstrap the user agent as shown in the template.
|
|
247
|
+
|
|
248
|
+
Before launching, probe a served route without a session id:
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
curl -i --header "Authorization: Bearer <secret>" 'http://127.0.0.1:8765/<account>/gmail'
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
HTTP 400 with `No session; send an initialize request first` confirms liveness;
|
|
255
|
+
404 means the route is not served, 401 means the token is missing or wrong,
|
|
256
|
+
and connection refused means no host is listening there. The startup message
|
|
257
|
+
`port 8765 is in use; a google-mcp-host is probably already running; point clients at it`
|
|
258
|
+
(the selected port replaces 8765) is another signal; probe and reuse that
|
|
259
|
+
listener instead of launching a duplicate.
|
|
260
|
+
|
|
261
|
+
Use `<url>` = `http://127.0.0.1:8765/<account>/<service>`. Register each
|
|
262
|
+
replacement with the token from `host.env`:
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
# Claude Code
|
|
266
|
+
claude mcp add --scope user --transport http <name> <url> --header "Authorization: Bearer <secret>"
|
|
267
|
+
# Codex CLI
|
|
268
|
+
codex mcp add <name> --url <url> --bearer-token-env-var GOOGLE_MCP_HOST_TOKEN
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Codex writes `bearer_token_env_var = "GOOGLE_MCP_HOST_TOKEN"` beside the URL
|
|
272
|
+
in its TOML entry. Export the variable from `$HOME/.google-mcp/host.env`
|
|
273
|
+
(mode 0600) before starting Codex: `set -a; . "$HOME/.google-mcp/host.env"; set +a`.
|
|
274
|
+
The supervisor reads the same file; a GUI client must inherit the variable
|
|
275
|
+
from its launch environment too.
|
|
276
|
+
|
|
277
|
+
For JSON clients that support HTTP headers:
|
|
278
|
+
|
|
279
|
+
```json
|
|
280
|
+
{
|
|
281
|
+
"mcpServers": {
|
|
282
|
+
"<name>": {
|
|
283
|
+
"url": "http://127.0.0.1:8765/<account>/<service>",
|
|
284
|
+
"headers": { "Authorization": "Bearer <secret>" }
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Claude and JSON header entries hold the literal secret from `host.env`;
|
|
291
|
+
update them when it changes.
|
|
292
|
+
|
|
293
|
+
Identity is unchanged (one account per session, chosen by the path), the
|
|
294
|
+
operations and instructions are the stdio bins', and step 7 verifies it the
|
|
295
|
+
same way. On a shared machine set `--token` (or `GOOGLE_MCP_HOST_TOKEN`) and
|
|
296
|
+
pass it as an `Authorization: Bearer` header from each client; see
|
|
297
|
+
[src/host/README.md](./src/host/README.md).
|
|
298
|
+
|
|
299
|
+
Each logical client connection has its own session. Idle time runs from the
|
|
300
|
+
last request; an open SSE stream does not keep it alive. After `--idle`
|
|
301
|
+
minutes (default 720), the host reaps the session, and its old id receives
|
|
302
|
+
404. The client must initialize again without that id, as required by the
|
|
303
|
+
[MCP session specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#session-management).
|
|
304
|
+
Recovery is spec-mandated and unverified per client.
|
|
305
|
+
|
|
220
306
|
**Cloud-sandboxed agents (Google Jules and similar):** out of scope. Jules
|
|
221
307
|
connects only to an allowlist of hosted MCP servers, with no way to run an
|
|
222
308
|
arbitrary stdio server, and its tasks execute in a fresh VM that does not have
|
|
@@ -377,7 +463,10 @@ only what adoption added.
|
|
|
377
463
|
```
|
|
378
464
|
|
|
379
465
|
Other clients: delete the corresponding `mcpServers` / `[mcp_servers.*]`
|
|
380
|
-
entries.
|
|
466
|
+
entries. If adoption ran the shared host, stop its process (and remove the
|
|
467
|
+
supervisor unit that started it) once the `url` entries are gone.
|
|
468
|
+
Also remove any leftover stdio registrations for those names; moving to
|
|
469
|
+
the host must replace the old transport, not leave both configured.
|
|
381
470
|
4. **Uninstall the package** (optional):
|
|
382
471
|
|
|
383
472
|
```sh
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ That is the whole surface. Read one operation folder and you understand all of t
|
|
|
58
58
|
- **Siloed by design.** Each service runs as its own independent server in its own lane; the orchestrating agent is the single thing that coordinates them.
|
|
59
59
|
- **Strict by construction.** Input and output schemas are validated on every call, vocabulary is sourced from Google's own docs, types are strict (NodeNext ESM, `verbatimModuleSyntax`, `noUncheckedIndexedAccess`), and coverage is pinned at 100% in `bunfig.toml`.
|
|
60
60
|
|
|
61
|
-
One package, one version: everything compiles into `google-mcp-suite`, which ships a bin per service (`google-mcp-gmail`, `google-mcp-calendar`, `google-mcp-sheets`, `google-mcp-docs`, and `google-mcp-drive` today) plus the `google-mcp-doctor` setup CLI. A `google-mcp-suite` front-door bin dispatches to any of them (`npx google-mcp-suite gmail`), which is also what lets MCP registries launch the suite from its package name alone.
|
|
61
|
+
One package, one version: everything compiles into `google-mcp-suite`, which ships a bin per service (`google-mcp-gmail`, `google-mcp-calendar`, `google-mcp-sheets`, `google-mcp-docs`, and `google-mcp-drive` today) plus the `google-mcp-doctor` setup CLI and `google-mcp-host`, which serves every service for every account from one Streamable HTTP process. A `google-mcp-suite` front-door bin dispatches to any of them (`npx google-mcp-suite gmail`, `npx google-mcp-suite host`), which is also what lets MCP registries launch the suite from its package name alone.
|
|
62
62
|
|
|
63
63
|
## MCP, and then some
|
|
64
64
|
|
|
@@ -125,6 +125,35 @@ The `GOOGLE_MCP_ACCOUNT` value must be the same string `doctor auth` was given;
|
|
|
125
125
|
a bare email is its own account label. For short aliases (`personal`, `work`)
|
|
126
126
|
write the optional roster first, as [ADOPTING.md](./ADOPTING.md) step 3 does.
|
|
127
127
|
|
|
128
|
+
### Or one shared host
|
|
129
|
+
|
|
130
|
+
Stdio is fine for one client. Each stdio entry above is a process per client
|
|
131
|
+
session, so on a machine running several agents at once (or a client that
|
|
132
|
+
spawns MCP servers per thread and never closes them), that multiplies into
|
|
133
|
+
hundreds of idle Node processes.
|
|
134
|
+
`google-mcp-host` serves every service for every roster account from one
|
|
135
|
+
process over MCP's Streamable HTTP transport; each client connection is its
|
|
136
|
+
own session, bound to the account in the path:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
google-mcp-host # http://127.0.0.1:8765/<account>/<service>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"mcpServers": {
|
|
145
|
+
"gmail-personal": { "url": "http://127.0.0.1:8765/personal/gmail" },
|
|
146
|
+
"calendar-work": { "url": "http://127.0.0.1:8765/work/calendar" }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Remove each old stdio entry before registering its URL: one name, one transport.
|
|
152
|
+
Same operations, same instructions, same instance names; only the process
|
|
153
|
+
count changes. Loopback-only by default, with an optional bearer token and idle
|
|
154
|
+
session reaping; supervisor templates, the liveness probe, per-client tokens,
|
|
155
|
+
and session semantics are in [src/host/README.md](./src/host/README.md).
|
|
156
|
+
|
|
128
157
|
Then ask your agent for something no single-account tool can do:
|
|
129
158
|
|
|
130
159
|
> Find a free 30-minute window next week that works across my work and personal calendars, book it on the work calendar with a Meet link, email the invite summary to my personal address, and log the booking in my scheduling spreadsheet.
|
|
@@ -135,7 +164,8 @@ Then ask your agent for something no single-account tool can do:
|
|
|
135
164
|
src/
|
|
136
165
|
auth/ # shared OAuth: one client secret, per-account tokens
|
|
137
166
|
lib/ # the two MCP primitives: operation() + server()
|
|
138
|
-
suite/ # google-mcp-suite: the front-door bin; dispatches to a service or
|
|
167
|
+
suite/ # google-mcp-suite: the front-door bin; dispatches to a service, doctor, or host
|
|
168
|
+
host/ # google-mcp-host: every service, every account, one Streamable HTTP process
|
|
139
169
|
doctor/ # google-mcp-doctor: provisioning + auth-health CLI
|
|
140
170
|
gmail/ # the Gmail server (reference/canary); new services mirror its shape
|
|
141
171
|
calendar/ # the Calendar server; same shape
|
|
@@ -147,15 +177,16 @@ src/
|
|
|
147
177
|
One package, one version. `auth`, `lib`, `doctor`, and each service are folders in one `src/` and compile to a single published package.
|
|
148
178
|
|
|
149
179
|
- **`src/auth`** owns authentication. A service imports it and calls `authorizedClient(account)` to get an authenticated Google client.
|
|
150
|
-
- **`src/lib`** owns the protocol with two primitives: `operation()` (a typed definition every operation conforms to) and `server()` (turns a service's
|
|
180
|
+
- **`src/lib`** owns the protocol with two primitives: `operation()` (a typed definition every operation conforms to) and `server()` (turns a service's definition into a running stdio MCP server; `createServer()` underneath it is what the host builds per session). A service never reimplements the MCP server.
|
|
151
181
|
- **`src/doctor`** is the setup and health CLI; it knows the services, never the other way around. See [its README](./src/doctor/README.md).
|
|
152
|
-
- **`src
|
|
182
|
+
- **`src/host`** is the shared Streamable HTTP host: one process, every service, every account, one session per client. It knows the services the same way doctor does. See [its README](./src/host/README.md).
|
|
183
|
+
- **`src/<service>`** is a server: `service.ts` (the definition) and `index.ts` (the stdio bootstrap) plus a folder per operation under `tools/` (MCP-sourced verbs) and `methods/` (REST-sourced verbs), each holding `schema.ts` + `handler.ts` + `index.ts` + `handler.test.ts`; shared zod nouns live in `entities/` and projections in `lib/`.
|
|
153
184
|
|
|
154
185
|
## The multi-account model
|
|
155
186
|
|
|
156
187
|
- **One OAuth app.** A single Google Cloud OAuth client (`client_secret`) is shared across every service.
|
|
157
188
|
- **One token per account.** Each account is authorized once, granted the full scope union for all services. Tokens are stored per account, outside the repo. The account name is a label you choose at `doctor auth` time; an email address or a short alias (`work`, `personal`) both work, and the alias form keeps your MCP config readable.
|
|
158
|
-
- **Identity by instance.** A running server is bound to one account via the `GOOGLE_MCP_ACCOUNT` environment variable. To command three accounts, you run three instances of a service, each with a different `GOOGLE_MCP_ACCOUNT`. There is no per-call account argument, so a server cannot act on the wrong account.
|
|
189
|
+
- **Identity by instance.** A running server is bound to one account via the `GOOGLE_MCP_ACCOUNT` environment variable. To command three accounts, you run three instances of a service, each with a different `GOOGLE_MCP_ACCOUNT`. There is no per-call account argument, so a server cannot act on the wrong account. The shared host keeps the same rule per session: the account is the first segment of the session's URL path.
|
|
159
190
|
|
|
160
191
|
## Auth setup
|
|
161
192
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/auth/accounts.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,YAAY;;;kBAAyE,CAAC;AAE5F,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,YAAY,IAAI,OAAO,EAAE,CAUxC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAIjE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Account roster the doctor drives the OAuth flow across
|
|
2
|
+
* Account roster: the doctor drives the OAuth flow across it, and the shared
|
|
3
|
+
* HTTP host (src/host) serves every account on it.
|
|
3
4
|
*
|
|
4
5
|
* The roster lives outside the repo at `<GOOGLE_MCP_DIR>/accounts.json`, so real
|
|
5
6
|
* email addresses never land in version control. Shape:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/auth/accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAI5F,MAAM,UAAU,Y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C,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["/**\n * Account roster: the doctor drives the OAuth flow across it, and the shared\n * HTTP host (src/host) serves every account on it.\n *\n * The roster lives outside the repo at `<GOOGLE_MCP_DIR>/accounts.json`, so real\n * email addresses never land in version control. Shape:\n *\n * [\n * { \"label\": \"personal\", \"email\": \"you@gmail.com\" },\n * { \"label\": \"simiancraft\", \"email\": \"you@your-domain.com\" }\n * ]\n *\n * `label` is the GOOGLE_MCP_ACCOUNT value and the token filename\n * (`tokens/<label>.json`); `email` is optional and used as the consent\n * `login_hint` so the right Google account is preselected.\n *\n * The roster is optional. Single-account auth works with no file at all (the\n * email is its own label); the roster only powers `--all`, status, and prefill.\n * When absent, it is inferred from the token files already in `tokens/`.\n */\nimport { readdirSync } from 'node:fs';\nimport path from 'node:path';\nimport { z } from 'zod';\nimport { loadConfig } from '../auth/config.js';\nimport { readJsonFile } from '../lib/utils/json.js';\n\nconst AccountsFile = z.array(z.object({ label: z.string(), email: z.string().optional() }));\n\nexport type Account = z.infer<typeof AccountsFile>[number];\n\nexport function accountsFile(): string {\n return path.join(loadConfig().dir, 'accounts.json');\n}\n\nexport function loadAccounts(): Account[] {\n try {\n return readJsonFile(accountsFile(), AccountsFile);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return inferFromTokens();\n if (err instanceof z.ZodError) {\n throw new Error('accounts.json must be an array of { label, email? }.');\n }\n throw err;\n }\n}\n\n/**\n * Turn a CLI argument into an account, even with no roster: a bare email is its\n * own label and its own login hint, so `doctor auth you@gmail.com` works from a\n * cold start. A known label resolves to its roster entry (with email prefill).\n */\nexport function toAccount(arg: string, roster: Account[]): Account {\n const known = roster.find((a) => a.label === arg || a.email === arg);\n if (known) return known;\n return arg.includes('@') ? { label: arg, email: arg } : { label: arg };\n}\n\nfunction inferFromTokens(): Account[] {\n try {\n return readdirSync(loadConfig().tokensDir)\n .filter((f) => f.endsWith('.json'))\n .map((f) => ({ label: f.replace(/\\.json$/, '') }));\n } catch {\n return [];\n }\n}\n"]}
|
package/dist/calendar/index.js
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { calendar } from '@googleapis/calendar';
|
|
3
|
-
import { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';
|
|
4
|
-
import { mergeOperations } from '../lib/operation.js';
|
|
5
2
|
import { server } from '../lib/server.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// src/auth/config.ts BEFORE the first auth. The scope union is front-loaded so each
|
|
11
|
-
// account consents once, and Google only re-issues a refresh token on a fresh grant;
|
|
12
|
-
// adding a scope later forces re-consent of every account. Nothing in this file
|
|
13
|
-
// references scopes, which is exactly why it is easy to miss.
|
|
14
|
-
await server({
|
|
15
|
-
name: 'calendar',
|
|
16
|
-
title: 'Google Calendar (google-mcp-suite)',
|
|
17
|
-
description: 'Per-account Google Calendar MCP server: events, calendars, sharing, free/busy, and meeting-time suggestions.',
|
|
18
|
-
instructions,
|
|
19
|
-
operations: mergeOperations(tools, methods),
|
|
20
|
-
client: async (account) => calendar({ version: 'v3', auth: await authorizedClient(account) }),
|
|
21
|
-
runAuth: runAuthFlow,
|
|
22
|
-
staleCredentials: isInvalidGrant,
|
|
23
|
-
});
|
|
3
|
+
import { service } from './service.js';
|
|
4
|
+
// The stdio bin: one process bound to GOOGLE_MCP_ACCOUNT. The definition lives
|
|
5
|
+
// in service.ts so the shared HTTP host (src/host) can serve the same surface.
|
|
6
|
+
await server(service);
|
|
24
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/calendar/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/calendar/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,+EAA+E;AAC/E,+EAA+E;AAC/E,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { server } from '../lib/server.js';\nimport { service } from './service.js';\n\n// The stdio bin: one process bound to GOOGLE_MCP_ACCOUNT. The definition lives\n// in service.ts so the shared HTTP host (src/host) can serve the same surface.\nawait server(service);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/calendar/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAU1D,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAU3D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { calendar } from '@googleapis/calendar';
|
|
2
|
+
import { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';
|
|
3
|
+
import { mergeOperations } from '../lib/operation.js';
|
|
4
|
+
import { instructions } from './instructions.js';
|
|
5
|
+
import { methods } from './methods/registry.js';
|
|
6
|
+
import { tools } from './tools/registry.js';
|
|
7
|
+
// Cloning this for a new service? Add that service's OAuth scopes to `SCOPES` in
|
|
8
|
+
// src/auth/config.ts BEFORE the first auth. The scope union is front-loaded so each
|
|
9
|
+
// account consents once, and Google only re-issues a refresh token on a fresh grant;
|
|
10
|
+
// adding a scope later forces re-consent of every account. Nothing in this file
|
|
11
|
+
// references scopes, which is exactly why it is easy to miss.
|
|
12
|
+
export const service = {
|
|
13
|
+
name: 'calendar',
|
|
14
|
+
title: 'Google Calendar (google-mcp-suite)',
|
|
15
|
+
description: 'Per-account Google Calendar MCP server: events, calendars, sharing, free/busy, and meeting-time suggestions.',
|
|
16
|
+
instructions,
|
|
17
|
+
operations: mergeOperations(tools, methods),
|
|
18
|
+
client: async (account) => calendar({ version: 'v3', auth: await authorizedClient(account) }),
|
|
19
|
+
runAuth: runAuthFlow,
|
|
20
|
+
staleCredentials: isInvalidGrant,
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/calendar/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,iFAAiF;AACjF,oFAAoF;AACpF,qFAAqF;AACrF,gFAAgF;AAChF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAA4C;IAC9D,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,oCAAoC;IAC3C,WAAW,EACT,8GAA8G;IAChH,YAAY;IACZ,UAAU,EAAE,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC;IAC3C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7F,OAAO,EAAE,WAAW;IACpB,gBAAgB,EAAE,cAAc;CACjC,CAAC","sourcesContent":["import { calendar, type calendar_v3 } from '@googleapis/calendar';\nimport { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';\nimport { mergeOperations } from '../lib/operation.js';\nimport type { ServiceDefinition } from '../lib/server.js';\nimport { instructions } from './instructions.js';\nimport { methods } from './methods/registry.js';\nimport { tools } from './tools/registry.js';\n\n// Cloning this for a new service? Add that service's OAuth scopes to `SCOPES` in\n// src/auth/config.ts BEFORE the first auth. The scope union is front-loaded so each\n// account consents once, and Google only re-issues a refresh token on a fresh grant;\n// adding a scope later forces re-consent of every account. Nothing in this file\n// references scopes, which is exactly why it is easy to miss.\nexport const service: ServiceDefinition<calendar_v3.Calendar> = {\n name: 'calendar',\n title: 'Google Calendar (google-mcp-suite)',\n description:\n 'Per-account Google Calendar MCP server: events, calendars, sharing, free/busy, and meeting-time suggestions.',\n instructions,\n operations: mergeOperations(tools, methods),\n client: async (account) => calendar({ version: 'v3', auth: await authorizedClient(account) }),\n runAuth: runAuthFlow,\n staleCredentials: isInvalidGrant,\n};\n"]}
|
package/dist/docs/index.js
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { docs } from '@googleapis/docs';
|
|
3
|
-
import { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';
|
|
4
|
-
import { mergeOperations } from '../lib/operation.js';
|
|
5
2
|
import { server } from '../lib/server.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
// account consents once, and Google only re-issues a refresh token on a fresh grant;
|
|
11
|
-
// adding a scope later forces re-consent of every account. Nothing in this file
|
|
12
|
-
// references scopes, which is exactly why it is easy to miss.
|
|
13
|
-
//
|
|
14
|
-
// Docs is methods-only: Google publishes no MCP toolset for Docs (its
|
|
15
|
-
// MCP-supported products are Gmail, Drive, Calendar, Chat, and People), so there
|
|
16
|
-
// is no tools/ folder and the REST-sourced methods are the whole surface.
|
|
17
|
-
await server({
|
|
18
|
-
name: 'docs',
|
|
19
|
-
title: 'Google Docs (google-mcp-suite)',
|
|
20
|
-
description: 'Per-account Google Docs MCP server: document reads and creation plus curated text editing and styling.',
|
|
21
|
-
instructions,
|
|
22
|
-
operations: mergeOperations(methods),
|
|
23
|
-
client: async (account) => docs({ version: 'v1', auth: await authorizedClient(account) }),
|
|
24
|
-
runAuth: runAuthFlow,
|
|
25
|
-
staleCredentials: isInvalidGrant,
|
|
26
|
-
});
|
|
3
|
+
import { service } from './service.js';
|
|
4
|
+
// The stdio bin: one process bound to GOOGLE_MCP_ACCOUNT. The definition lives
|
|
5
|
+
// in service.ts so the shared HTTP host (src/host) can serve the same surface.
|
|
6
|
+
await server(service);
|
|
27
7
|
//# sourceMappingURL=index.js.map
|
package/dist/docs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,+EAA+E;AAC/E,+EAA+E;AAC/E,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { server } from '../lib/server.js';\nimport { service } from './service.js';\n\n// The stdio bin: one process bound to GOOGLE_MCP_ACCOUNT. The definition lives\n// in service.ts so the shared HTTP host (src/host) can serve the same surface.\nawait server(service);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/docs/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAa1D,eAAO,MAAM,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAUnD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { docs } from '@googleapis/docs';
|
|
2
|
+
import { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';
|
|
3
|
+
import { mergeOperations } from '../lib/operation.js';
|
|
4
|
+
import { instructions } from './instructions.js';
|
|
5
|
+
import { methods } from './methods/registry.js';
|
|
6
|
+
// Cloning this for a new service? Add that service's OAuth scopes to `SCOPES` in
|
|
7
|
+
// src/auth/config.ts BEFORE the first auth. The scope union is front-loaded so each
|
|
8
|
+
// account consents once, and Google only re-issues a refresh token on a fresh grant;
|
|
9
|
+
// adding a scope later forces re-consent of every account. Nothing in this file
|
|
10
|
+
// references scopes, which is exactly why it is easy to miss.
|
|
11
|
+
//
|
|
12
|
+
// Docs is methods-only: Google publishes no MCP toolset for Docs (its
|
|
13
|
+
// MCP-supported products are Gmail, Drive, Calendar, Chat, and People), so there
|
|
14
|
+
// is no tools/ folder and the REST-sourced methods are the whole surface.
|
|
15
|
+
export const service = {
|
|
16
|
+
name: 'docs',
|
|
17
|
+
title: 'Google Docs (google-mcp-suite)',
|
|
18
|
+
description: 'Per-account Google Docs MCP server: document reads and creation plus curated text editing and styling.',
|
|
19
|
+
instructions,
|
|
20
|
+
operations: mergeOperations(methods),
|
|
21
|
+
client: async (account) => docs({ version: 'v1', auth: await authorizedClient(account) }),
|
|
22
|
+
runAuth: runAuthFlow,
|
|
23
|
+
staleCredentials: isInvalidGrant,
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/docs/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgB,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,iFAAiF;AACjF,oFAAoF;AACpF,qFAAqF;AACrF,gFAAgF;AAChF,8DAA8D;AAC9D,EAAE;AACF,sEAAsE;AACtE,iFAAiF;AACjF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,OAAO,GAAoC;IACtD,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,gCAAgC;IACvC,WAAW,EACT,wGAAwG;IAC1G,YAAY;IACZ,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;IACzF,OAAO,EAAE,WAAW;IACpB,gBAAgB,EAAE,cAAc;CACjC,CAAC","sourcesContent":["import { docs, type docs_v1 } from '@googleapis/docs';\nimport { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';\nimport { mergeOperations } from '../lib/operation.js';\nimport type { ServiceDefinition } from '../lib/server.js';\nimport { instructions } from './instructions.js';\nimport { methods } from './methods/registry.js';\n\n// Cloning this for a new service? Add that service's OAuth scopes to `SCOPES` in\n// src/auth/config.ts BEFORE the first auth. The scope union is front-loaded so each\n// account consents once, and Google only re-issues a refresh token on a fresh grant;\n// adding a scope later forces re-consent of every account. Nothing in this file\n// references scopes, which is exactly why it is easy to miss.\n//\n// Docs is methods-only: Google publishes no MCP toolset for Docs (its\n// MCP-supported products are Gmail, Drive, Calendar, Chat, and People), so there\n// is no tools/ folder and the REST-sourced methods are the whole surface.\nexport const service: ServiceDefinition<docs_v1.Docs> = {\n name: 'docs',\n title: 'Google Docs (google-mcp-suite)',\n description:\n 'Per-account Google Docs MCP server: document reads and creation plus curated text editing and styling.',\n instructions,\n operations: mergeOperations(methods),\n client: async (account) => docs({ version: 'v1', auth: await authorizedClient(account) }),\n runAuth: runAuthFlow,\n staleCredentials: isInvalidGrant,\n};\n"]}
|
package/dist/doctor/auth.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* google-mcp-doctor auth --all # every account in the roster
|
|
6
6
|
* google-mcp-doctor auth # re-auth only what is expired/due
|
|
7
7
|
*/
|
|
8
|
+
import { type Account } from '../auth/accounts.js';
|
|
8
9
|
import { runAuthFlow } from '../auth/oauth.js';
|
|
9
|
-
import { type Account } from './accounts.js';
|
|
10
10
|
export declare function selectTargets(args: string[], roster?: Account[], now?: number): Account[];
|
|
11
11
|
export type RunAuthDeps = {
|
|
12
12
|
authorize?: typeof runAuthFlow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/doctor/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/doctor/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,OAAO,EAA2B,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,GAAE,OAAO,EAAmB,EAClC,GAAG,GAAE,MAAmB,GACvB,OAAO,EAAE,CAaX;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,OAAO,WAAW,CAAC;IAC/B,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBnF"}
|
package/dist/doctor/auth.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* google-mcp-doctor auth --all # every account in the roster
|
|
6
6
|
* google-mcp-doctor auth # re-auth only what is expired/due
|
|
7
7
|
*/
|
|
8
|
+
import { loadAccounts, toAccount } from '../auth/accounts.js';
|
|
8
9
|
import { runAuthFlow } from '../auth/oauth.js';
|
|
9
|
-
import { loadAccounts, toAccount } from './accounts.js';
|
|
10
10
|
import { openInBrowser } from './browser.js';
|
|
11
11
|
import { statusFor } from './status.js';
|
|
12
12
|
export function selectTargets(args, roster = loadAccounts(), now = Date.now()) {
|
package/dist/doctor/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/doctor/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/doctor/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgB,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,UAAU,aAAa,CAC3B,IAAc,EACd,MAAM,GAAc,YAAY,EAAE,EAClC,GAAG,GAAW,IAAI,CAAC,GAAG,EAAE;IAExB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,I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AAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtE,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE;YAC1B,WAAW;YACX,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjD,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * Authorize accounts through the browser consent flow, one at a time.\n *\n * google-mcp-doctor auth you@example.com # one account, works with no roster\n * google-mcp-doctor auth --all # every account in the roster\n * google-mcp-doctor auth # re-auth only what is expired/due\n */\n\nimport { type Account, loadAccounts, toAccount } from '../auth/accounts.js';\nimport { runAuthFlow } from '../auth/oauth.js';\nimport { openInBrowser } from './browser.js';\nimport { statusFor } from './status.js';\n\nexport function selectTargets(\n args: string[],\n roster: Account[] = loadAccounts(),\n now: number = Date.now(),\n): Account[] {\n const flags = new Set(args.filter((a) => a.startsWith('--')));\n const names = args.filter((a) => !a.startsWith('--'));\n if (names.length > 0) return names.map((n) => toAccount(n, roster));\n if (flags.has('--all')) {\n if (roster.length === 0) {\n throw new Error(\n 'No accounts configured. Pass an email: google-mcp-doctor auth you@example.com',\n );\n }\n return roster;\n }\n return roster.filter((a) => statusFor(a, now).state !== 'fresh');\n}\n\nexport type RunAuthDeps = {\n authorize?: typeof runAuthFlow;\n openBrowser?: (url: string) => void;\n};\n\nexport async function runAuth(args: string[], deps: RunAuthDeps = {}): Promise<void> {\n const authorize = deps.authorize ?? runAuthFlow;\n const openBrowser = deps.openBrowser ?? openInBrowser;\n const targets = selectTargets(args);\n if (targets.length === 0) {\n console.log('Nothing due; all tokens are fresh. Pass an email/label, or --all to force.');\n return;\n }\n console.log(`Authorizing: ${targets.map((t) => t.label).join(', ')}\\n`);\n for (const acct of targets) {\n console.log(`→ ${acct.label}${acct.email ? ` (${acct.email})` : ''}`);\n await authorize(acct.label, {\n openBrowser,\n ...(acct.email ? { loginHint: acct.email } : {}),\n });\n console.log(' done.\\n');\n }\n console.log('Done. Confirm with: google-mcp-doctor status');\n}\n"]}
|
package/dist/doctor/diagnose.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* next action: provisioning, accounts, services.
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
|
+
import { loadAccounts } from '../auth/accounts.js';
|
|
7
8
|
import { loadConfig, SCOPES } from '../auth/config.js';
|
|
8
9
|
import { errorMessage } from '../lib/utils/error.js';
|
|
9
|
-
import { loadAccounts } from './accounts.js';
|
|
10
10
|
import { requiredApis, SERVICES, scopeRegistryDrift } from './services.js';
|
|
11
11
|
import { grantedScopes, humanizeRemaining, ICON, statusFor } from './status.js';
|
|
12
12
|
/** `doctor scopes`: the provisioning quick reference, version-accurate. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../src/doctor/diagnose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../src/doctor/diagnose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAgB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,IAAI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AAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC;IACrF,CAAC;SAAM,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,CAAC,MAAM,sCAAsC,CAAC,CAAC;IACnF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC;IACrF,CAAC;AACH,CAAC","sourcesContent":["/**\n * The doctor's diagnostic: a state-aware, version-accurate health check that an\n * agent (or human) reads to know what to do next. Three subjects, then a single\n * next action: provisioning, accounts, services.\n */\nimport { existsSync } from 'node:fs';\nimport { type Account, loadAccounts } from '../auth/accounts.js';\nimport { loadConfig, SCOPES } from '../auth/config.js';\nimport { errorMessage } from '../lib/utils/error.js';\nimport { requiredApis, SERVICES, type ServiceInfo, scopeRegistryDrift } from './services.js';\nimport { grantedScopes, humanizeRemaining, ICON, statusFor } from './status.js';\n\nexport type DiagnoseOptions = { probe?: boolean; services?: ServiceInfo[]; now?: number };\n\n/** `doctor scopes`: the provisioning quick reference, version-accurate. */\nexport function renderScopes(): void {\n console.log('Enable these Google Cloud APIs:');\n for (const a of requiredApis()) console.log(` ${a}`);\n console.log('\\nDeclare these OAuth scopes on the consent screen:');\n for (const s of SCOPES) console.log(` ${s}`);\n}\n\nexport async function diagnose(options: DiagnoseOptions = {}): Promise<void> {\n const probe = options.probe ?? true;\n const services = options.services ?? SERVICES;\n const now = options.now ?? Date.now();\n console.log('google-mcp doctor\\n');\n\n // 1. Provisioning\n console.log('Provisioning');\n const secret = loadConfig().clientSecretPath;\n const hasSecret = existsSync(secret);\n console.log(` [${hasSecret ? '✓' : '✗'}] OAuth client secret ${secret}`);\n if (!hasSecret) {\n console.log(' → Create an OAuth Desktop client in Google Cloud and save it here.');\n console.log(` → Enable APIs: ${requiredApis().join(', ')}`);\n console.log(\n ' → Declare these scopes on the consent screen, add yourself as a test user:',\n );\n for (const s of SCOPES) console.log(` ${s}`);\n console.log(' → Full walkthrough: PROVISIONING.md');\n }\n const drift = scopeRegistryDrift(\n [...SCOPES],\n services.flatMap((s) => s.scopes),\n );\n const driftClean = drift.missing.length === 0 && drift.extra.length === 0;\n console.log(\n ` [${driftClean ? '✓' : '✗'}] Scope registry ${SCOPES.length} scopes across ${services.length} services`,\n );\n if (drift.missing.length)\n console.log(` unattributed in services.ts: ${drift.missing.join(', ')}`);\n if (drift.extra.length) console.log(` not in auth SCOPES: ${drift.extra.join(', ')}`);\n\n // 2. Accounts\n const accounts = loadAccounts();\n console.log(`\\nAccounts (${accounts.length})`);\n if (accounts.length === 0) {\n console.log(' none yet; authorize one: google-mcp-doctor auth you@example.com');\n }\n const authorized: Account[] = [];\n for (const acct of accounts) {\n const st = statusFor(acct, now);\n if (st.state === 'missing') {\n console.log(\n ` ${ICON.missing} ${acct.label} no token; run: google-mcp-doctor auth ${acct.label}`,\n );\n continue;\n }\n authorized.push(acct);\n const granted = new Set(grantedScopes(acct.label) ?? []);\n const missing = SCOPES.filter((s) => !granted.has(s));\n const note =\n missing.length === 0\n ? `${SCOPES.length}/${SCOPES.length} scopes`\n : `MISSING ${missing.length} scope(s)`;\n console.log(\n ` ${ICON[st.state]} ${acct.label} ${note} ${humanizeRemaining(st.remainingMs)} left`,\n );\n for (const s of missing) console.log(` missing: ${s}`);\n if (missing.length)\n console.log(` → re-auth to pick them up: google-mcp-doctor auth ${acct.label}`);\n }\n\n // 3. Services (live probe per authorized account)\n console.log('\\nServices');\n for (const svc of services) {\n if (!svc.implemented) {\n console.log(` · ${svc.name} planned`);\n continue;\n }\n if (!probe || authorized.length === 0 || !svc.probe) {\n console.log(\n ` ${svc.name} implemented${probe && authorized.length === 0 ? ' (no account to probe)' : ''}`,\n );\n continue;\n }\n for (const acct of authorized) {\n try {\n const who = await svc.probe(acct.label);\n console.log(` ✓ ${svc.name} ${acct.label} → ${who}`);\n } catch (err) {\n console.log(` ✗ ${svc.name} ${acct.label} → ${errorMessage(err)}`);\n }\n }\n }\n\n // 4. Next action\n console.log('');\n const due = accounts.filter((a) => statusFor(a, now).state !== 'fresh');\n if (!hasSecret) {\n console.log('Next: finish provisioning above, then re-run doctor.');\n } else if (accounts.length === 0) {\n console.log('Next: authorize an account → google-mcp-doctor auth you@example.com');\n } else if (due.length) {\n console.log(`Next: authorize ${due.length} account(s) → google-mcp-doctor auth`);\n } else {\n console.log('All set: client secret present, accounts fresh, services reachable.');\n }\n}\n"]}
|
package/dist/doctor/status.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/doctor/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/doctor/status.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,OAAO,EAAgB,MAAM,qBAAqB,CAAC;AAajE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAK3C,CAAC;AAEF,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAsBpE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAEtD;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAO5D;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMhE;AAMD,wDAAwD;AACxD,wBAAgB,YAAY,IAAI,IAAI,CAsBnC"}
|
package/dist/doctor/status.js
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { statSync } from 'node:fs';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
+
import { loadAccounts } from '../auth/accounts.js';
|
|
12
13
|
import { tokenPath } from '../auth/config.js';
|
|
13
14
|
import { readJsonFile } from '../lib/utils/json.js';
|
|
14
|
-
import { loadAccounts } from './accounts.js';
|
|
15
15
|
// The two token-file fields the doctor reads; tolerant of every other key.
|
|
16
16
|
const TokenFile = z.object({
|
|
17
17
|
refresh_token_expires_in: z.number().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/doctor/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/doctor/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,2EAA2E;AAC3E,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,wBAAwB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,E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AC7C,CAAC;AACH,CAAC","sourcesContent":["/**\n * Refresh-token countdown for every known account.\n *\n * In an External + Testing OAuth app, refresh tokens expire 7 days after they\n * are issued. Google does not return an issuance timestamp, so the token file's\n * modification time (written at the end of the consent flow) is the reliable\n * \"authorized at\" signal. Consumer tokens also carry `refresh_token_expires_in`;\n * when present it is preferred over the flat 7-day assumption.\n */\nimport { statSync } from 'node:fs';\nimport { z } from 'zod';\nimport { type Account, loadAccounts } from '../auth/accounts.js';\nimport { tokenPath } from '../auth/config.js';\nimport { readJsonFile } from '../lib/utils/json.js';\n\n// The two token-file fields the doctor reads; tolerant of every other key.\nconst TokenFile = z.object({\n refresh_token_expires_in: z.number().optional(),\n scope: z.string().optional(),\n});\n\nconst SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;\nconst DUE_SOON_MS = 48 * 60 * 60 * 1000;\n\nexport type TokenState = 'fresh' | 'due-soon' | 'expired' | 'missing';\n\nexport type TokenStatus = {\n account: Account;\n authorizedAt?: Date;\n expiresAt?: Date;\n remainingMs?: number;\n state: TokenState;\n};\n\nexport const ICON: Record<TokenState, string> = {\n fresh: '✓',\n 'due-soon': '⚠',\n expired: '✗',\n missing: '·',\n};\n\nexport function statusFor(account: Account, now: number): TokenStatus {\n let stat: ReturnType<typeof statSync>;\n try {\n stat = statSync(tokenPath(account.label));\n } catch {\n return { account, state: 'missing' };\n }\n const authorizedAt = stat.mtime;\n let lifetimeMs = SEVEN_DAYS_MS;\n try {\n const raw = readJsonFile(tokenPath(account.label), TokenFile);\n if (raw.refresh_token_expires_in !== undefined) {\n lifetimeMs = raw.refresh_token_expires_in * 1000;\n }\n } catch {\n // keep the 7-day default\n }\n const expiresAt = new Date(authorizedAt.getTime() + lifetimeMs);\n const remainingMs = expiresAt.getTime() - now;\n const state: TokenState =\n remainingMs <= 0 ? 'expired' : remainingMs <= DUE_SOON_MS ? 'due-soon' : 'fresh';\n return { account, authorizedAt, expiresAt, remainingMs, state };\n}\n\nexport function allStatuses(now: number): TokenStatus[] {\n return loadAccounts().map((a) => statusFor(a, now));\n}\n\n/** Scopes Google actually granted this account, or null if no token exists. */\nexport function grantedScopes(label: string): string[] | null {\n try {\n const raw = readJsonFile(tokenPath(label), TokenFile);\n return raw.scope ? raw.scope.split(' ').filter(Boolean) : [];\n } catch {\n return null;\n }\n}\n\nexport function humanizeRemaining(ms: number | undefined): string {\n if (ms === undefined) return '-';\n if (ms <= 0) return 'expired';\n const hours = Math.floor(ms / 3_600_000);\n const days = Math.floor(hours / 24);\n return days >= 1 ? `${days}d ${hours % 24}h` : `${hours}h`;\n}\n\nfunction stamp(d: Date | undefined): string {\n return d ? d.toISOString().slice(0, 16).replace('T', ' ') : '-';\n}\n\n/** `doctor status`: the at-a-glance countdown table. */\nexport function renderStatus(): void {\n const statuses = allStatuses(Date.now());\n if (statuses.length === 0) {\n console.log('No accounts found. Authorize one: google-mcp-doctor auth you@example.com');\n return;\n }\n console.table(\n statuses.map((s) => ({\n account: s.account.label,\n authorized: stamp(s.authorizedAt),\n expires: stamp(s.expiresAt),\n 'time left': humanizeRemaining(s.remainingMs),\n state: `${ICON[s.state]} ${s.state}`,\n })),\n );\n const due = statuses.filter((s) => s.state !== 'fresh');\n if (due.length > 0) {\n console.log(\n `\\n${due.length} account(s) need re-auth: ${due.map((d) => d.account.label).join(', ')}`,\n );\n console.log('Run: google-mcp-doctor auth');\n }\n}\n"]}
|
package/dist/drive/index.js
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { drive } from '@googleapis/drive';
|
|
3
|
-
import { authorizedClient, isInvalidGrant, runAuthFlow } from '../auth/oauth.js';
|
|
4
|
-
import { mergeOperations } from '../lib/operation.js';
|
|
5
2
|
import { server } from '../lib/server.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// src/auth/config.ts BEFORE the first auth. The scope union is front-loaded so each
|
|
11
|
-
// account consents once, and Google only re-issues a refresh token on a fresh grant;
|
|
12
|
-
// adding a scope later forces re-consent of every account. Nothing in this file
|
|
13
|
-
// references scopes, which is exactly why it is easy to miss.
|
|
14
|
-
await server({
|
|
15
|
-
name: 'drive',
|
|
16
|
-
title: 'Google Drive (google-mcp-suite)',
|
|
17
|
-
description: 'Per-account Google Drive MCP server: files, comments, revisions, and shared drives.',
|
|
18
|
-
instructions,
|
|
19
|
-
operations: mergeOperations(tools, methods),
|
|
20
|
-
client: async (account) => drive({ version: 'v3', auth: await authorizedClient(account) }),
|
|
21
|
-
runAuth: runAuthFlow,
|
|
22
|
-
staleCredentials: isInvalidGrant,
|
|
23
|
-
});
|
|
3
|
+
import { service } from './service.js';
|
|
4
|
+
// The stdio bin: one process bound to GOOGLE_MCP_ACCOUNT. The definition lives
|
|
5
|
+
// in service.ts so the shared HTTP host (src/host) can serve the same surface.
|
|
6
|
+
await server(service);
|
|
24
7
|
//# sourceMappingURL=index.js.map
|