google-mcp-suite 0.0.0 → 1.0.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/NOTICE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Notices and Trademarks
2
2
 
3
- ## Google™, Gmail™, Google Drive™, Google Workspace™
3
+ ## Google trademarks
4
4
 
5
5
  **Google**, **Gmail**, **Google Drive**, **Google Docs**, **Google Sheets**, **Google Calendar**, and **Google Workspace** are trademarks of **Google LLC**. This project is **not affiliated with, endorsed by, sponsored by, or certified by Google LLC**.
6
6
 
package/README.md CHANGED
@@ -1,26 +1,96 @@
1
- # google-mcp-suite
1
+ <h1 align="center">google-mcp-suite</h1>
2
2
 
3
- [![CI](https://github.com/simiancraft/google-mcp-suite/actions/workflows/ci.yml/badge.svg)](https://github.com/simiancraft/google-mcp-suite/actions/workflows/ci.yml)
4
- [![codecov](https://codecov.io/gh/simiancraft/google-mcp-suite/branch/main/graph/badge.svg)](https://codecov.io/gh/simiancraft/google-mcp-suite)
5
- [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/simiancraft/google-mcp-suite/badge)](https://securityscorecards.dev/viewer/?uri=github.com/simiancraft/google-mcp-suite)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/google-mcp-suite"><img src="https://img.shields.io/npm/v/google-mcp-suite.svg" alt="npm" /></a>
5
+ &nbsp;
6
+ <a href="https://github.com/simiancraft/google-mcp-suite/actions/workflows/ci.yml"><img src="https://github.com/simiancraft/google-mcp-suite/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
7
+ &nbsp;
8
+ <a href="https://codecov.io/gh/simiancraft/google-mcp-suite"><img src="https://codecov.io/gh/simiancraft/google-mcp-suite/branch/main/graph/badge.svg" alt="codecov" /></a>
9
+ &nbsp;
10
+ <a href="https://securityscorecards.dev/viewer/?uri=github.com/simiancraft/google-mcp-suite"><img src="https://api.securityscorecards.dev/projects/github.com/simiancraft/google-mcp-suite/badge" alt="OpenSSF Scorecard" /></a>
11
+ &nbsp;
12
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-yellow.svg" alt="License: MIT" /></a>
13
+ </p>
7
14
 
8
- One [Model Context Protocol](https://modelcontextprotocol.io/) server per Google service, built to command **several Google accounts at once**. Each server is thin, authorized per account, and shares a single OAuth implementation.
15
+ <p align="center">
16
+ <strong>A Google MCP server you can read in an afternoon.</strong><br />
17
+ The curated <a href="https://modelcontextprotocol.io/">MCP</a> toolset plus the broader REST surface, in one server per account, so an agent can run several Google accounts at once and can never act on the wrong one. A folder tree that mirrors Google's API reference page-for-page, with 100% test coverage.
18
+ </p>
9
19
 
10
- > **Status:** Gmail is implemented and usable today; Drive, Sheets, Docs, and Calendar are next. Interfaces may still move before the first tagged release.
20
+ <p align="center">
21
+ <img src=".github/assets/gmail.svg" height="44" alt="Gmail" title="Gmail (shipping)" />
22
+ &nbsp;&nbsp;&nbsp;
23
+ <img src=".github/assets/drive.svg" height="44" alt="Drive (planned)" title="Drive (planned)" />
24
+ &nbsp;&nbsp;&nbsp;
25
+ <img src=".github/assets/sheets.svg" height="44" alt="Sheets (planned)" title="Sheets (planned)" />
26
+ &nbsp;&nbsp;&nbsp;
27
+ <img src=".github/assets/docs.svg" height="44" alt="Docs (planned)" title="Docs (planned)" />
28
+ &nbsp;&nbsp;&nbsp;
29
+ <img src=".github/assets/calendar.svg" height="44" alt="Calendar (planned)" title="Calendar (planned)" />
30
+ </p>
11
31
 
12
- ## Why
32
+ <p align="center">
33
+ <sub><strong>Gmail</strong> ships today with <a href="./src/gmail/CAPABILITIES.md">33 operations</a>; Drive, Sheets, Docs, and Calendar are on the way (shown dimmed).</sub>
34
+ </p>
13
35
 
14
- Commanding multiple Google accounts means running one server instance per account, and covering multiple services (Gmail, Drive, Sheets, Docs, Calendar) means one server each. Writing OAuth once and sharing it keeps every server a thin set of operations instead of a re-implemented auth client.
36
+ ## What it does
15
37
 
16
- ### MCP, and then some
38
+ Point an AI agent at your Google accounts and let it do the work: triage and send mail today, manage files and edit documents as those services land. The end goal is an agent that operates your accounts and hands you results.
39
+
40
+ The design has two internal concepts and nothing else:
41
+
42
+ 1. An **operation** is a folder of `schema.ts` + `handler.ts` + `index.ts` + `handler.test.ts`, conforming to one `operation()` shape.
43
+ 2. A **server function**, `server(...)`, wires those operations into a running MCP server.
44
+
45
+ That is the whole surface. Read one operation folder and you understand all of them.
46
+
47
+ - **REST plus MCP in one surface.** Each server exposes the curated MCP toolset *and* the broader REST method set of its Google API, so an agent gets far more than a thin slice. Gmail ships with [33 operations](./src/gmail/CAPABILITIES.md) today: 10 curated MCP tools plus 23 REST methods (the split is explained in [MCP, and then some](#mcp-and-then-some)).
48
+ - **The folder tree mirrors Google's docs.** A Google tools-list reference page becomes a `tools/` folder; a Google REST method reference page becomes a `methods/` folder. If you can find the operation in Google's docs, you can find it in this repo.
49
+
50
+ | Google's reference page | This repo's folder |
51
+ |---|---|
52
+ | A tools-list page (curated MCP toolset) | `tools/<operation>/` |
53
+ | A REST method reference page | `methods/<operation>/` |
54
+
55
+ - **Multiple accounts, in parallel.** Identity is bound to a running instance, not passed per call, so an agent can act across your accounts at once and cannot act on the wrong one.
56
+ - **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.
57
+ - **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`.
58
+
59
+ One package, one version: everything compiles into `google-mcp-suite`, which ships a bin per service (`google-mcp-gmail` today) plus the `google-mcp-doctor` setup CLI.
60
+
61
+ ## MCP, and then some
17
62
 
18
63
  This is an MCP server, and deliberately more than one. Google publishes an MCP toolset for some services, but that toolset is a small slice of what each API can do; you cannot fully instrument an account with it alone. The goal here is to **fully empower an agent across several Google accounts and services**, so each server exposes two surfaces under one wire protocol:
19
64
 
20
65
  - **`tools/`** mirrors Google's **MCP toolset** reference, verbatim.
21
66
  - **`methods/`** covers the broader **REST** reference, the operations the MCP toolset omits.
22
67
 
23
- The split is Google's own (its MCP reference and its REST reference are separate trees); we keep it on disk on purpose and unify it operationally (one `Operation` type, one merged wire surface where everything is an MCP tool). The breadth of the operation list is the evidence that MCP alone is not enough for real work. Keeping the two sourced surfaces separate makes the suite self-documenting and enables **documentation-driven updates**: point at a Google reference page and generate the matching `schema.ts`/`handler.ts`/`index.ts`, with each source page bounding the context of one unit of work.
68
+ The split is Google's own (its MCP reference and its REST reference are separate trees); we keep it on disk on purpose and unify it operationally (one `Operation` type, one merged wire surface where everything is an MCP tool). The breadth of [the operation list](./src/gmail/CAPABILITIES.md) is the evidence that MCP alone is not enough for real work. Keeping the two sourced surfaces separate also makes each new operation a bounded, documentation-driven unit of work; the recipe is in [EXTENDING.md](./EXTENDING.md).
69
+
70
+ ## Quickstart
71
+
72
+ One thing first: a Google Cloud OAuth client (roughly ten minutes of console clicks, once; the friction is Google's, not ours). [PROVISIONING.md](./PROVISIONING.md) walks every click, and `doctor` tells you which step you are on.
73
+
74
+ ```sh
75
+ npm install -g google-mcp-suite
76
+
77
+ google-mcp-doctor scopes # the exact APIs + scopes to enable in Google Cloud
78
+ google-mcp-doctor auth you@example.com # browser consent; writes the account token
79
+ google-mcp-doctor # provisioned, authorized, reachable?
80
+ ```
81
+
82
+ Then point your MCP client at a server, one instance per account:
83
+
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "gmail-personal": {
88
+ "command": "google-mcp-gmail",
89
+ "env": { "GOOGLE_MCP_ACCOUNT": "you@example.com" }
90
+ }
91
+ }
92
+ }
93
+ ```
24
94
 
25
95
  ## Layout
26
96
 
@@ -28,13 +98,15 @@ The split is Google's own (its MCP reference and its REST reference are separate
28
98
  src/
29
99
  auth/ # shared OAuth: one client secret, per-account tokens
30
100
  lib/ # the two MCP primitives: operation() + server()
101
+ doctor/ # google-mcp-doctor: provisioning + auth-health CLI
31
102
  gmail/ # the Gmail server (reference/canary); new services mirror its shape
32
103
  ```
33
104
 
34
- One package, one version. `auth`, `lib`, and each service are folders in one `src/` and compile to a single published package.
105
+ One package, one version. `auth`, `lib`, `doctor`, and each service are folders in one `src/` and compile to a single published package.
35
106
 
36
107
  - **`src/auth`** owns authentication. A service imports it and calls `authorizedClient(account)` to get an authenticated Google client.
37
108
  - **`src/lib`** owns the protocol with two primitives: `operation()` (a typed definition every operation conforms to) and `server()` (turns a service's operations into a running stdio MCP server). A service never reimplements the MCP server.
109
+ - **`src/doctor`** is the setup and health CLI; it knows the services, never the other way around. See [its README](./src/doctor/README.md).
38
110
  - **`src/<service>`** is a server: `index.ts` (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/`.
39
111
 
40
112
  ## The multi-account model
@@ -45,12 +117,16 @@ One package, one version. `auth`, `lib`, and each service are folders in one `sr
45
117
 
46
118
  ## Auth setup
47
119
 
120
+ Authorization is a one-time, per-account browser consent flow.
121
+
48
122
  1. Create a Google Cloud project, enable the APIs you need (Gmail, Drive, ...), and create an **OAuth client** (Desktop app). Download the client secret JSON.
49
- 2. Place the client secret where `src/auth` expects it (see [its README](./src/auth/README.md)), outside the repo tree.
123
+ 2. Place the client secret JSON at `~/.google-mcp/client_secret.json` (override knobs in [src/auth's README](./src/auth/README.md)).
50
124
  3. Authorize each account once; this opens a browser consent flow and stores that account's token.
51
125
  4. Run a service with `GOOGLE_MCP_ACCOUNT=<account>` to act as that account.
52
126
 
53
- Credentials never live in the repo. `.gitignore` blocks the common filenames; keep tokens and the client secret in the canonical config directory.
127
+ The [`google-mcp-doctor`](./src/doctor/README.md) CLI drives all of it except the console clicks: `doctor scopes` prints the APIs and scopes to enable, `doctor auth <email>` runs the consent flow and writes the token, and `doctor` / `doctor status` confirm every account is authorized and reachable.
128
+
129
+ Credentials never live in the repo. Tokens and the client secret live in the ignored `~/.google-mcp/` config directory, and `.gitignore` also blocks common credential filenames.
54
130
 
55
131
  For the full, step-by-step Google Cloud walkthrough (enabling APIs, declaring scopes, consent-screen and test-user setup, and what an agent can automate), see [PROVISIONING.md](./PROVISIONING.md).
56
132
 
@@ -61,11 +137,11 @@ bun install
61
137
  bun run check # lint-fix, build, typecheck, test, knip
62
138
  ```
63
139
 
64
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full task list and [AGENTS.md](./AGENTS.md) for the per-service pattern.
140
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full task list, [AGENTS.md](./AGENTS.md) for the per-service pattern, and [EXTENDING.md](./EXTENDING.md) for the add-a-service recipe.
65
141
 
66
142
  ## Services
67
143
 
68
- | Service | Status | Coverage |
144
+ | Service | Status | Operations |
69
145
  |---|---|---|
70
146
  | **Gmail** | ✅ Implemented | [33 operations](./src/gmail/CAPABILITIES.md): threads, messages, drafts, labels, filters, attachments |
71
147
  | Drive | 🔜 Planned | files, folders, sharing, revisions |
@@ -73,8 +149,16 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full task list and [AGENTS.md](
73
149
  | Docs | 🔜 Planned | documents, structured content |
74
150
  | Calendar | 🔜 Planned | events, calendars, availability |
75
151
 
76
- Gmail is the reference (canary) implementation; each new service mirrors its shape. See its [capability list](./src/gmail/CAPABILITIES.md) for the full operation set.
152
+ Gmail is the reference (canary) implementation; each new service mirrors its shape.
153
+
154
+ ---
77
155
 
78
- ## License
156
+ <p align="center">
157
+ <a href="https://github.com/simiancraft/google-mcp-suite" title="google-mcp-suite on GitHub"><img src=".github/assets/github.svg" height="18" alt="GitHub" /></a>
158
+ &nbsp;&nbsp;&nbsp;
159
+ <a href="https://x.com/5imian" title="Jesse Harlin on X"><img src=".github/assets/x.svg" height="16" alt="X" /></a>
160
+ &nbsp;&nbsp;&nbsp;
161
+ <a href="https://ko-fi.com/the_simian0604" title="Tip on Ko-fi"><img src=".github/assets/coffee.svg" height="18" alt="Ko-fi" /></a>
162
+ </p>
79
163
 
80
- [MIT](./LICENSE). Google product names are used nominatively; see [NOTICE.md](./NOTICE.md). This project is not affiliated with Google LLC.
164
+ <p align="center"><sub><a href="./LICENSE">MIT</a>. Google product names are used nominatively; see <a href="./NOTICE.md">NOTICE.md</a>; not affiliated with Google LLC. Crafted with care by <a href="https://simiancraft.com"><img src=".github/assets/simiancraft.svg" height="12" alt="" />&nbsp;Simiancraft</a>.</sub></p>
@@ -46,13 +46,13 @@ export async function diagnose(options = {}) {
46
46
  const accounts = loadAccounts();
47
47
  console.log(`\nAccounts (${accounts.length})`);
48
48
  if (accounts.length === 0) {
49
- console.log(' none yet — authorize one: google-mcp-doctor auth you@example.com');
49
+ console.log(' none yet; authorize one: google-mcp-doctor auth you@example.com');
50
50
  }
51
51
  const authorized = [];
52
52
  for (const acct of accounts) {
53
53
  const st = statusFor(acct, now);
54
54
  if (st.state === 'missing') {
55
- console.log(` ${ICON.missing} ${acct.label} no token — run: google-mcp-doctor auth ${acct.label}`);
55
+ console.log(` ${ICON.missing} ${acct.label} no token; run: google-mcp-doctor auth ${acct.label}`);
56
56
  continue;
57
57
  }
58
58
  authorized.push(acct);
@@ -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,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIhF,2EAA2E;AAC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QAAQ,CAAC,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 { loadConfig, SCOPES } from '../auth/config.js';\nimport { type Account, loadAccounts } from './accounts.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(\n ` ✗ ${svc.name} ${acct.label} → ${err instanceof Error ? err.message : String(err)}`,\n );\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"]}
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,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAgB,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIhF,2EAA2E;AAC3E,MAAM,UAAU,YAAY;IAC1B,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;QAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACnE,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,UAA2B,EAAE;IAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CA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AAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACxC,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,GAAG,CACT,OAAO,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACvF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,iBAAiB;IACjB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;IACxE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACtE,CAAC;SAAM,IAAI,QAAQ,CAAC,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 { loadConfig, SCOPES } from '../auth/config.js';\nimport { type Account, loadAccounts } from './accounts.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(\n ` ✗ ${svc.name} ${acct.label} → ${err instanceof Error ? err.message : String(err)}`,\n );\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"]}
@@ -9,7 +9,7 @@ import { runAuth } from './auth.js';
9
9
  import { diagnose, renderScopes } from './diagnose.js';
10
10
  import { renderStatus } from './status.js';
11
11
  function printHelp() {
12
- console.log(`google-mcp-doctor — provisioning & auth health for google-mcp-suite
12
+ console.log(`google-mcp-doctor: provisioning & auth health for google-mcp-suite
13
13
 
14
14
  Usage:
15
15
  google-mcp-doctor [check] full diagnostic: provisioning, accounts, services
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/doctor/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;kEAaoD,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEvD,IAAI,CAAC;IACH,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO,CAAC;QACb,KAAK,UAAU;YACb,MAAM,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YACxD,MAAM;QACR,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,YAAY,EAAE,CAAC;YACf,MAAM;QACR,KAAK,MAAM;YACT,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,QAAQ;YACX,YAAY,EAAE,CAAC;YACf,MAAM;QACR,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI;YACP,SAAS,EAAE,CAAC;YACZ,MAAM;QACR;YACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;YAC3C,SAAS,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["#!/usr/bin/env node\n/**\n * google-mcp-doctor: a micro-CLI for provisioning and auth health.\n *\n * Doctor knows the services; the services never know doctor. It imports the auth\n * layer and stable `@googleapis/*` surfaces only, never a service's internals.\n */\nimport { runAuth } from './auth.js';\nimport { diagnose, renderScopes } from './diagnose.js';\nimport { renderStatus } from './status.js';\n\nfunction printHelp(): void {\n console.log(`google-mcp-doctor — provisioning & auth health for google-mcp-suite\n\nUsage:\n google-mcp-doctor [check] full diagnostic: provisioning, accounts, services\n google-mcp-doctor status refresh-token countdown table\n google-mcp-doctor auth [<acct>…] authorize accounts\n no args → re-auth what is expired/due\n --all → every account in the roster\n <acct> → an email (no config needed) or roster label\n google-mcp-doctor scopes the APIs + scopes to enable in Google Cloud\n google-mcp-doctor help\n\nFlags:\n --no-probe skip the live service health checks (offline/fast)`);\n}\n\nconst [cmd = 'check', ...rest] = process.argv.slice(2);\n\ntry {\n switch (cmd) {\n case 'check':\n case 'diagnose':\n await diagnose({ probe: !rest.includes('--no-probe') });\n break;\n case 'status':\n case 'tokens':\n renderStatus();\n break;\n case 'auth':\n await runAuth(rest);\n break;\n case 'scopes':\n renderScopes();\n break;\n case 'help':\n case '--help':\n case '-h':\n printHelp();\n break;\n default:\n console.error(`Unknown command: ${cmd}\\n`);\n printHelp();\n process.exit(1);\n }\n} catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/doctor/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO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/**\n * google-mcp-doctor: a micro-CLI for provisioning and auth health.\n *\n * Doctor knows the services; the services never know doctor. It imports the auth\n * layer and stable `@googleapis/*` surfaces only, never a service's internals.\n */\nimport { runAuth } from './auth.js';\nimport { diagnose, renderScopes } from './diagnose.js';\nimport { renderStatus } from './status.js';\n\nfunction printHelp(): void {\n console.log(`google-mcp-doctor: provisioning & auth health for google-mcp-suite\n\nUsage:\n google-mcp-doctor [check] full diagnostic: provisioning, accounts, services\n google-mcp-doctor status refresh-token countdown table\n google-mcp-doctor auth [<acct>…] authorize accounts\n no args → re-auth what is expired/due\n --all → every account in the roster\n <acct> → an email (no config needed) or roster label\n google-mcp-doctor scopes the APIs + scopes to enable in Google Cloud\n google-mcp-doctor help\n\nFlags:\n --no-probe skip the live service health checks (offline/fast)`);\n}\n\nconst [cmd = 'check', ...rest] = process.argv.slice(2);\n\ntry {\n switch (cmd) {\n case 'check':\n case 'diagnose':\n await diagnose({ probe: !rest.includes('--no-probe') });\n break;\n case 'status':\n case 'tokens':\n renderStatus();\n break;\n case 'auth':\n await runAuth(rest);\n break;\n case 'scopes':\n renderScopes();\n break;\n case 'help':\n case '--help':\n case '-h':\n printHelp();\n break;\n default:\n console.error(`Unknown command: ${cmd}\\n`);\n printHelp();\n process.exit(1);\n }\n} catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n}\n"]}
@@ -36,8 +36,8 @@ export type AnyOperation<Client> = {
36
36
  };
37
37
  /**
38
38
  * Define an operation. A no-op at runtime (it returns its argument); its job is
39
- * type inference — `Client` from the handler's first parameter, `input`/`output`
40
- * from `schema` — and the front-door check that the handler consumes exactly what
39
+ * type inference (`Client` from the handler's first parameter, `input`/`output`
40
+ * from `schema`) and the front-door check that the handler consumes exactly what
41
41
  * the schema declares.
42
42
  */
43
43
  export declare const operation: <Client, In extends z.ZodType, Out extends z.ZodType>(def: Operation<Client, In, Out>) => Operation<Client, In, Out>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Define an operation. A no-op at runtime (it returns its argument); its job is
3
- * type inference — `Client` from the handler's first parameter, `input`/`output`
4
- * from `schema` — and the front-door check that the handler consumes exactly what
3
+ * type inference (`Client` from the handler's first parameter, `input`/`output`
4
+ * from `schema`) and the front-door check that the handler consumes exactly what
5
5
  * the schema declares.
6
6
  */
7
7
  export const operation = (def) => def;
@@ -1 +1 @@
1
- {"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/lib/operation.ts"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAA+B,EACH,EAAE,CAAC,GAAG,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAG,MAA8C;IAEjD,MAAM,MAAM,GAAyC,EAAE,CAAC;IACxD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { z } from 'zod';\n\n/**\n * A single operation: its documented I/O contract plus the work that fulfills it.\n * Every tool and method is an `Operation`; they differ only by which Google\n * reference the folder mirrors (MCP toolset vs REST), never by type.\n *\n * `schema` is the contract (zod, mirrored from the docs); `handler` receives the\n * service's authenticated client and the validated input and returns a value that\n * conforms to `schema.output`.\n */\nexport type Operation<Client, In extends z.ZodType, Out extends z.ZodType> = {\n description: string;\n schema: { input: In; output: Out };\n handler: (client: Client, args: z.infer<In>) => Promise<z.infer<Out>>;\n /** Irreversible (send, permanent delete) or a standing side effect (a forwarding filter); surfaced as MCP `destructiveHint`. */\n destructive?: boolean;\n};\n\n/**\n * An operation with its schemas erased; the shape the registry and server hold.\n * The handler's args are widened to `never` so any concrete `Operation` is\n * assignable here (a handler taking a specific input is assignable to one taking\n * `never` by contravariance; under zod 4, `z.infer<z.ZodType>` is `unknown`, which\n * would break that, so `never` restores it).\n */\nexport type AnyOperation<Client> = {\n description: string;\n schema: { input: z.ZodType; output: z.ZodType };\n handler: (client: Client, args: never) => Promise<unknown>;\n destructive?: boolean;\n};\n\n/**\n * Define an operation. A no-op at runtime (it returns its argument); its job is\n * type inference — `Client` from the handler's first parameter, `input`/`output`\n * from `schema` — and the front-door check that the handler consumes exactly what\n * the schema declares.\n */\nexport const operation = <Client, In extends z.ZodType, Out extends z.ZodType>(\n def: Operation<Client, In, Out>,\n): Operation<Client, In, Out> => def;\n\n/**\n * Merge operation groups (e.g. a service's tools and methods) into the single\n * registry the server dispatches. Throws on a duplicate wire name: two operations\n * cannot answer to the same key, and a silent `{ ...a, ...b }` spread would let\n * one shadow the other and vanish from the wire with no error.\n */\nexport function mergeOperations<Client>(\n ...groups: Record<string, AnyOperation<Client>>[]\n): Record<string, AnyOperation<Client>> {\n const merged: Record<string, AnyOperation<Client>> = {};\n for (const group of groups) {\n for (const [name, op] of Object.entries(group)) {\n if (name in merged) {\n throw new Error(`Duplicate operation name: ${name}`);\n }\n merged[name] = op;\n }\n }\n return merged;\n}\n"]}
1
+ {"version":3,"file":"operation.js","sourceRoot":"","sources":["../../src/lib/operation.ts"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAA+B,EACH,EAAE,CAAC,GAAG,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAG,MAA8C;IAEjD,MAAM,MAAM,GAAyC,EAAE,CAAC;IACxD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { z } from 'zod';\n\n/**\n * A single operation: its documented I/O contract plus the work that fulfills it.\n * Every tool and method is an `Operation`; they differ only by which Google\n * reference the folder mirrors (MCP toolset vs REST), never by type.\n *\n * `schema` is the contract (zod, mirrored from the docs); `handler` receives the\n * service's authenticated client and the validated input and returns a value that\n * conforms to `schema.output`.\n */\nexport type Operation<Client, In extends z.ZodType, Out extends z.ZodType> = {\n description: string;\n schema: { input: In; output: Out };\n handler: (client: Client, args: z.infer<In>) => Promise<z.infer<Out>>;\n /** Irreversible (send, permanent delete) or a standing side effect (a forwarding filter); surfaced as MCP `destructiveHint`. */\n destructive?: boolean;\n};\n\n/**\n * An operation with its schemas erased; the shape the registry and server hold.\n * The handler's args are widened to `never` so any concrete `Operation` is\n * assignable here (a handler taking a specific input is assignable to one taking\n * `never` by contravariance; under zod 4, `z.infer<z.ZodType>` is `unknown`, which\n * would break that, so `never` restores it).\n */\nexport type AnyOperation<Client> = {\n description: string;\n schema: { input: z.ZodType; output: z.ZodType };\n handler: (client: Client, args: never) => Promise<unknown>;\n destructive?: boolean;\n};\n\n/**\n * Define an operation. A no-op at runtime (it returns its argument); its job is\n * type inference (`Client` from the handler's first parameter, `input`/`output`\n * from `schema`) and the front-door check that the handler consumes exactly what\n * the schema declares.\n */\nexport const operation = <Client, In extends z.ZodType, Out extends z.ZodType>(\n def: Operation<Client, In, Out>,\n): Operation<Client, In, Out> => def;\n\n/**\n * Merge operation groups (e.g. a service's tools and methods) into the single\n * registry the server dispatches. Throws on a duplicate wire name: two operations\n * cannot answer to the same key, and a silent `{ ...a, ...b }` spread would let\n * one shadow the other and vanish from the wire with no error.\n */\nexport function mergeOperations<Client>(\n ...groups: Record<string, AnyOperation<Client>>[]\n): Record<string, AnyOperation<Client>> {\n const merged: Record<string, AnyOperation<Client>> = {};\n for (const group of groups) {\n for (const [name, op] of Object.entries(group)) {\n if (name in merged) {\n throw new Error(`Duplicate operation name: ${name}`);\n }\n merged[name] = op;\n }\n }\n return merged;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/lib/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI;IAClC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACjD,gFAAgF;IAChF,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,qEAAqE;IACrE,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAMF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;;;;;;iBAInB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;kBACpB,MAAM,CA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Generated by `bun run capabilities`; do not edit by hand. -->',
38
+ '',
37
39
  `${rows.length} operations across MCP tools and REST methods. ⚠️ marks irreversible operations (MCP \`destructiveHint\`).`,
38
40
  '',
39
41
  '| Operation | Source | Description |',
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/lib/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EACL,qBAAqB,EAErB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,GAAG,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAiB3D,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAS,UAAgD;IACtF,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI;QACJ,WAAW,EAAE,EAAE,CAAC,WAAW;QAC3B,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAA4B;QACxF,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAA4B;QAC3F,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,E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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAE3E,GAAG,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACzD,KAAK,EAAE,eAAe,CAAC,UAAU,CAAC;KACnC,CAAC,CAAC,CAAC;IAEJ,GAAG,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CACvD,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CACjF,CAAC;IAEF,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\nimport {\n CallToolRequestSchema,\n type CallToolResult,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\nimport pkg from '../../package.json' with { type: 'json' };\nimport type { AnyOperation } from './operation.js';\n\nexport type ServerOptions<Client> = {\n /** MCP server name (the service, e.g. 'gmail'). */\n name: string;\n version?: string;\n /** Every operation this server exposes, keyed by wire name (tools and methods merged). */\n operations: Record<string, AnyOperation<Client>>;\n /** Build the authenticated client for the account this instance is bound to. */\n client: (account: string | undefined) => Promise<Client>;\n /** Optional consent flow, invoked by the `auth` subcommand. */\n runAuth?: (account: string | undefined) => Promise<void>;\n /** Transport to connect; defaults to stdio. Injectable for tests. */\n transport?: Transport;\n};\n\nfunction errorResult(message: string): CallToolResult {\n return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };\n}\n\n/**\n * Build the MCP `tools/list` payload from the operations: each one's input and\n * output JSON Schema, plus a destructive hint for irreversible ops. On the wire,\n * every operation is a \"tool\" (MCP has no other word). Pure; exported for tests.\n */\nexport function toolDefinitions<Client>(operations: Record<string, AnyOperation<Client>>) {\n return Object.entries(operations).map(([name, op]) => ({\n name,\n description: op.description,\n inputSchema: z.toJSONSchema(op.schema.input, { io: 'input' }) as Record<string, unknown>,\n outputSchema: z.toJSONSchema(op.schema.output, { io: 'output' }) as Record<string, unknown>,\n ...(op.destructive ? { annotations: { destructiveHint: true } } : {}),\n }));\n}\n\n/** A labeled set of operations for the capability table: its provenance + the ops. */\nexport type CapabilityGroup<Client> = {\n /** Provenance shown in the Source column, e.g. 'MCP Tool' or 'REST Method'. */\n kind: string;\n operations: Record<string, AnyOperation<Client>>;\n};\n\n/**\n * Render the operations as a Markdown capability table (name, source, description,\n * and an irreversible marker), derived from the same registries the server\n * dispatches. The Source column makes the dual surface explicit: the suite is both\n * an MCP-toolset wrapper and a REST wrapper, because MCP's toolset alone cannot\n * fully drive a service. A static mirror; agents that speak MCP discover the live,\n * fully-schema'd surface via `tools/list`. Pure; a service regenerates its\n * CAPABILITIES.md from this so the doc cannot drift from the code.\n */\nexport function renderCapabilities<Client>(\n title: string,\n groups: CapabilityGroup<Client>[],\n): string {\n const rows = groups.flatMap(({ kind, operations }) =>\n Object.entries(operations).map(\n ([name, op]) => `| \\`${name}\\`${op.destructive ? ' ⚠️' : ''} | ${kind} | ${op.description} |`,\n ),\n );\n return `${[\n `# ${title}`,\n '',\n `${rows.length} operations across MCP tools and REST methods. ⚠️ marks irreversible operations (MCP \\`destructiveHint\\`).`,\n '',\n '| Operation | Source | Description |',\n '| --- | --- | --- |',\n ...rows,\n ].join('\\n')}\\n`;\n}\n\n/**\n * Run one operation by name: resolve it, validate input against its schema, run\n * the handler, validate the output, and return both a structured result and a text\n * rendering (for clients that do not yet read `structuredContent`). All failure\n * paths return an `isError` result rather than throwing. Exported for tests.\n */\nexport async function callOperation<Client>(\n operations: Record<string, AnyOperation<Client>>,\n client: Client,\n name: string,\n rawArgs: unknown,\n): Promise<CallToolResult> {\n const op = operations[name];\n if (!op) {\n return errorResult(`Unknown tool: ${name}`);\n }\n\n const parsed = op.schema.input.safeParse(rawArgs ?? {});\n if (!parsed.success) {\n return errorResult(`Invalid arguments for ${name}: ${parsed.error.message}`);\n }\n\n try {\n // `parsed.data` was just validated against this op's input schema, so it is\n // the handler's real input shape. The `AnyOperation` boundary types the\n // handler's args as `never` (so any concrete Operation stays assignable; see\n // operation.ts), and `as never` is the only call form. The validation above\n // is what makes this safe: do not call the handler before parsing.\n const result = await op.handler(client, parsed.data as never);\n const validated = op.schema.output.parse(result);\n return {\n content: [{ type: 'text', text: JSON.stringify(validated, null, 2) }],\n structuredContent: validated as Record<string, unknown>,\n };\n } catch (error) {\n return errorResult(error instanceof Error ? error.message : String(error));\n }\n}\n\n/**\n * Turn a service's operations into a running stdio MCP server. Identical for every\n * service; only the bound `Client` type and the operations differ. Owns the\n * cross-cutting concerns: the `auth` subcommand, account binding, the `tools/list`\n * payload, dispatch, validation, and error wrapping.\n */\nexport async function server<Client>(options: ServerOptions<Client>): Promise<void> {\n const { name, version = pkg.version, operations, client, runAuth } = options;\n\n if (process.argv[2] === 'auth') {\n if (!runAuth) {\n console.error(`${name}: no auth flow configured.`);\n process.exit(1);\n }\n await runAuth(process.argv[3] ?? process.env['GOOGLE_MCP_ACCOUNT']);\n process.exit(0);\n }\n\n const authed = await client(process.env['GOOGLE_MCP_ACCOUNT']);\n const mcp = new Server({ name, version }, { capabilities: { tools: {} } });\n\n mcp.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: toolDefinitions(operations),\n }));\n\n mcp.setRequestHandler(CallToolRequestSchema, (request) =>\n callOperation(operations, authed, request.params.name, request.params.arguments),\n );\n\n await mcp.connect(options.transport ?? new StdioServerTransport());\n}\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/lib/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EACL,qBAAqB,EAErB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,GAAG,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAiB3D,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAS,UAAgD;IACtF,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI;QACJ,WAAW,EAAE,EAAE,CAAC,WAAW;QAC3B,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAA4B;QACxF,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAA4B;QAC3F,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CA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CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAE3E,GAAG,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACzD,KAAK,EAAE,eAAe,CAAC,UAAU,CAAC;KACnC,CAAC,CAAC,CAAC;IAEJ,GAAG,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,OAAO,EAAE,EAAE,CACvD,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CACjF,CAAC;IAEF,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';\nimport {\n CallToolRequestSchema,\n type CallToolResult,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\nimport pkg from '../../package.json' with { type: 'json' };\nimport type { AnyOperation } from './operation.js';\n\nexport type ServerOptions<Client> = {\n /** MCP server name (the service, e.g. 'gmail'). */\n name: string;\n version?: string;\n /** Every operation this server exposes, keyed by wire name (tools and methods merged). */\n operations: Record<string, AnyOperation<Client>>;\n /** Build the authenticated client for the account this instance is bound to. */\n client: (account: string | undefined) => Promise<Client>;\n /** Optional consent flow, invoked by the `auth` subcommand. */\n runAuth?: (account: string | undefined) => Promise<void>;\n /** Transport to connect; defaults to stdio. Injectable for tests. */\n transport?: Transport;\n};\n\nfunction errorResult(message: string): CallToolResult {\n return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };\n}\n\n/**\n * Build the MCP `tools/list` payload from the operations: each one's input and\n * output JSON Schema, plus a destructive hint for irreversible ops. On the wire,\n * every operation is a \"tool\" (MCP has no other word). Pure; exported for tests.\n */\nexport function toolDefinitions<Client>(operations: Record<string, AnyOperation<Client>>) {\n return Object.entries(operations).map(([name, op]) => ({\n name,\n description: op.description,\n inputSchema: z.toJSONSchema(op.schema.input, { io: 'input' }) as Record<string, unknown>,\n outputSchema: z.toJSONSchema(op.schema.output, { io: 'output' }) as Record<string, unknown>,\n ...(op.destructive ? { annotations: { destructiveHint: true } } : {}),\n }));\n}\n\n/** A labeled set of operations for the capability table: its provenance + the ops. */\nexport type CapabilityGroup<Client> = {\n /** Provenance shown in the Source column, e.g. 'MCP Tool' or 'REST Method'. */\n kind: string;\n operations: Record<string, AnyOperation<Client>>;\n};\n\n/**\n * Render the operations as a Markdown capability table (name, source, description,\n * and an irreversible marker), derived from the same registries the server\n * dispatches. The Source column makes the dual surface explicit: the suite is both\n * an MCP-toolset wrapper and a REST wrapper, because MCP's toolset alone cannot\n * fully drive a service. A static mirror; agents that speak MCP discover the live,\n * fully-schema'd surface via `tools/list`. Pure; a service regenerates its\n * CAPABILITIES.md from this so the doc cannot drift from the code.\n */\nexport function renderCapabilities<Client>(\n title: string,\n groups: CapabilityGroup<Client>[],\n): string {\n const rows = groups.flatMap(({ kind, operations }) =>\n Object.entries(operations).map(\n ([name, op]) => `| \\`${name}\\`${op.destructive ? ' ⚠️' : ''} | ${kind} | ${op.description} |`,\n ),\n );\n return `${[\n `# ${title}`,\n '',\n '<!-- Generated by `bun run capabilities`; do not edit by hand. -->',\n '',\n `${rows.length} operations across MCP tools and REST methods. ⚠️ marks irreversible operations (MCP \\`destructiveHint\\`).`,\n '',\n '| Operation | Source | Description |',\n '| --- | --- | --- |',\n ...rows,\n ].join('\\n')}\\n`;\n}\n\n/**\n * Run one operation by name: resolve it, validate input against its schema, run\n * the handler, validate the output, and return both a structured result and a text\n * rendering (for clients that do not yet read `structuredContent`). All failure\n * paths return an `isError` result rather than throwing. Exported for tests.\n */\nexport async function callOperation<Client>(\n operations: Record<string, AnyOperation<Client>>,\n client: Client,\n name: string,\n rawArgs: unknown,\n): Promise<CallToolResult> {\n const op = operations[name];\n if (!op) {\n return errorResult(`Unknown tool: ${name}`);\n }\n\n const parsed = op.schema.input.safeParse(rawArgs ?? {});\n if (!parsed.success) {\n return errorResult(`Invalid arguments for ${name}: ${parsed.error.message}`);\n }\n\n try {\n // `parsed.data` was just validated against this op's input schema, so it is\n // the handler's real input shape. The `AnyOperation` boundary types the\n // handler's args as `never` (so any concrete Operation stays assignable; see\n // operation.ts), and `as never` is the only call form. The validation above\n // is what makes this safe: do not call the handler before parsing.\n const result = await op.handler(client, parsed.data as never);\n const validated = op.schema.output.parse(result);\n return {\n content: [{ type: 'text', text: JSON.stringify(validated, null, 2) }],\n structuredContent: validated as Record<string, unknown>,\n };\n } catch (error) {\n return errorResult(error instanceof Error ? error.message : String(error));\n }\n}\n\n/**\n * Turn a service's operations into a running stdio MCP server. Identical for every\n * service; only the bound `Client` type and the operations differ. Owns the\n * cross-cutting concerns: the `auth` subcommand, account binding, the `tools/list`\n * payload, dispatch, validation, and error wrapping.\n */\nexport async function server<Client>(options: ServerOptions<Client>): Promise<void> {\n const { name, version = pkg.version, operations, client, runAuth } = options;\n\n if (process.argv[2] === 'auth') {\n if (!runAuth) {\n console.error(`${name}: no auth flow configured.`);\n process.exit(1);\n }\n await runAuth(process.argv[3] ?? process.env['GOOGLE_MCP_ACCOUNT']);\n process.exit(0);\n }\n\n const authed = await client(process.env['GOOGLE_MCP_ACCOUNT']);\n const mcp = new Server({ name, version }, { capabilities: { tools: {} } });\n\n mcp.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: toolDefinitions(operations),\n }));\n\n mcp.setRequestHandler(CallToolRequestSchema, (request) =>\n callOperation(operations, authed, request.params.name, request.params.arguments),\n );\n\n await mcp.connect(options.transport ?? new StdioServerTransport());\n}\n"]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "google-mcp-suite",
3
- "version": "0.0.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
- "description": "Per-account MCP servers for Google services (Gmail, with more to come), sharing one OAuth implementation.",
5
+ "description": "Gmail MCP server exposing the curated MCP toolset plus the broader REST surface; one server instance per account; more Google services on the way.",
6
6
  "keywords": [
7
7
  "mcp",
8
8
  "model-context-protocol",