google-workspace-admin-mcp 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +148 -2
- package/dist/auth/config.d.ts +14 -0
- package/dist/auth/config.d.ts.map +1 -0
- package/dist/auth/config.js +49 -0
- package/dist/auth/config.js.map +1 -0
- package/dist/auth/edition.d.ts +26 -0
- package/dist/auth/edition.d.ts.map +1 -0
- package/dist/auth/edition.js +64 -0
- package/dist/auth/edition.js.map +1 -0
- package/dist/auth/oauth.d.ts +10 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +84 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/token-store.d.ts +14 -0
- package/dist/auth/token-store.d.ts.map +1 -0
- package/dist/auth/token-store.js +37 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/catalog.d.ts +33 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +7 -0
- package/dist/catalog.js.map +1 -0
- package/dist/docs/scopes.d.ts +8 -0
- package/dist/docs/scopes.d.ts.map +1 -0
- package/dist/docs/scopes.js +23 -0
- package/dist/docs/scopes.js.map +1 -0
- package/dist/docs/tools.d.ts +18 -0
- package/dist/docs/tools.d.ts.map +1 -0
- package/dist/docs/tools.js +68 -0
- package/dist/docs/tools.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +75 -0
- package/dist/main.js.map +1 -0
- package/dist/passthrough/allowlist.d.ts +14 -0
- package/dist/passthrough/allowlist.d.ts.map +1 -0
- package/dist/passthrough/allowlist.js +28 -0
- package/dist/passthrough/allowlist.js.map +1 -0
- package/dist/passthrough/dispatch.d.ts +20 -0
- package/dist/passthrough/dispatch.d.ts.map +1 -0
- package/dist/passthrough/dispatch.js +116 -0
- package/dist/passthrough/dispatch.js.map +1 -0
- package/dist/safety/audit.d.ts +18 -0
- package/dist/safety/audit.d.ts.map +1 -0
- package/dist/safety/audit.js +26 -0
- package/dist/safety/audit.js.map +1 -0
- package/dist/safety/policy.d.ts +14 -0
- package/dist/safety/policy.d.ts.map +1 -0
- package/dist/safety/policy.js +29 -0
- package/dist/safety/policy.js.map +1 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +78 -0
- package/dist/server.js.map +1 -0
- package/dist/services/cloud-search.d.ts +42 -0
- package/dist/services/cloud-search.d.ts.map +1 -0
- package/dist/services/cloud-search.js +113 -0
- package/dist/services/cloud-search.js.map +1 -0
- package/dist/services/devices.d.ts +50 -0
- package/dist/services/devices.d.ts.map +1 -0
- package/dist/services/devices.js +136 -0
- package/dist/services/devices.js.map +1 -0
- package/dist/services/directory-groups.d.ts +65 -0
- package/dist/services/directory-groups.d.ts.map +1 -0
- package/dist/services/directory-groups.js +150 -0
- package/dist/services/directory-groups.js.map +1 -0
- package/dist/services/directory.d.ts +67 -0
- package/dist/services/directory.d.ts.map +1 -0
- package/dist/services/directory.js +179 -0
- package/dist/services/directory.js.map +1 -0
- package/dist/services/domains.d.ts +27 -0
- package/dist/services/domains.d.ts.map +1 -0
- package/dist/services/domains.js +78 -0
- package/dist/services/domains.js.map +1 -0
- package/dist/services/group-settings-catalog.d.ts +27 -0
- package/dist/services/group-settings-catalog.d.ts.map +1 -0
- package/dist/services/group-settings-catalog.js +100 -0
- package/dist/services/group-settings-catalog.js.map +1 -0
- package/dist/services/group-settings.d.ts +26 -0
- package/dist/services/group-settings.d.ts.map +1 -0
- package/dist/services/group-settings.js +59 -0
- package/dist/services/group-settings.js.map +1 -0
- package/dist/services/licensing.d.ts +40 -0
- package/dist/services/licensing.d.ts.map +1 -0
- package/dist/services/licensing.js +96 -0
- package/dist/services/licensing.js.map +1 -0
- package/dist/services/orgunits.d.ts +40 -0
- package/dist/services/orgunits.d.ts.map +1 -0
- package/dist/services/orgunits.js +97 -0
- package/dist/services/orgunits.js.map +1 -0
- package/dist/services/reports.d.ts +98 -0
- package/dist/services/reports.d.ts.map +1 -0
- package/dist/services/reports.js +240 -0
- package/dist/services/reports.js.map +1 -0
- package/dist/services/resources.d.ts +96 -0
- package/dist/services/resources.d.ts.map +1 -0
- package/dist/services/resources.js +275 -0
- package/dist/services/resources.js.map +1 -0
- package/dist/services/roles.d.ts +62 -0
- package/dist/services/roles.d.ts.map +1 -0
- package/dist/services/roles.js +142 -0
- package/dist/services/roles.js.map +1 -0
- package/dist/services/transfer.d.ts +43 -0
- package/dist/services/transfer.d.ts.map +1 -0
- package/dist/services/transfer.js +98 -0
- package/dist/services/transfer.js.map +1 -0
- package/dist/services/user-security.d.ts +37 -0
- package/dist/services/user-security.d.ts.map +1 -0
- package/dist/services/user-security.js +90 -0
- package/dist/services/user-security.js.map +1 -0
- package/dist/services/vault-query.d.ts +60 -0
- package/dist/services/vault-query.d.ts.map +1 -0
- package/dist/services/vault-query.js +216 -0
- package/dist/services/vault-query.js.map +1 -0
- package/dist/services/vault.d.ts +219 -0
- package/dist/services/vault.d.ts.map +1 -0
- package/dist/services/vault.js +624 -0
- package/dist/services/vault.js.map +1 -0
- package/dist/smoke/checks.d.ts +26 -0
- package/dist/smoke/checks.d.ts.map +1 -0
- package/dist/smoke/checks.js +102 -0
- package/dist/smoke/checks.js.map +1 -0
- package/dist/smoke/guards.d.ts +36 -0
- package/dist/smoke/guards.d.ts.map +1 -0
- package/dist/smoke/guards.js +111 -0
- package/dist/smoke/guards.js.map +1 -0
- package/dist/smoke/redact.d.ts +17 -0
- package/dist/smoke/redact.d.ts.map +1 -0
- package/dist/smoke/redact.js +103 -0
- package/dist/smoke/redact.js.map +1 -0
- package/dist/smoke/report.d.ts +38 -0
- package/dist/smoke/report.d.ts.map +1 -0
- package/dist/smoke/report.js +93 -0
- package/dist/smoke/report.js.map +1 -0
- package/dist/smoke/shape.d.ts +26 -0
- package/dist/smoke/shape.d.ts.map +1 -0
- package/dist/smoke/shape.js +96 -0
- package/dist/smoke/shape.js.map +1 -0
- package/dist/tools/cloud-search.d.ts +4 -0
- package/dist/tools/cloud-search.d.ts.map +1 -0
- package/dist/tools/cloud-search.js +82 -0
- package/dist/tools/cloud-search.js.map +1 -0
- package/dist/tools/directory/devices.d.ts +4 -0
- package/dist/tools/directory/devices.d.ts.map +1 -0
- package/dist/tools/directory/devices.js +133 -0
- package/dist/tools/directory/devices.js.map +1 -0
- package/dist/tools/directory/domains.d.ts +4 -0
- package/dist/tools/directory/domains.d.ts.map +1 -0
- package/dist/tools/directory/domains.js +79 -0
- package/dist/tools/directory/domains.js.map +1 -0
- package/dist/tools/directory/groups.d.ts +4 -0
- package/dist/tools/directory/groups.d.ts.map +1 -0
- package/dist/tools/directory/groups.js +192 -0
- package/dist/tools/directory/groups.js.map +1 -0
- package/dist/tools/directory/orgunits.d.ts +4 -0
- package/dist/tools/directory/orgunits.d.ts.map +1 -0
- package/dist/tools/directory/orgunits.js +117 -0
- package/dist/tools/directory/orgunits.js.map +1 -0
- package/dist/tools/directory/roles.d.ts +4 -0
- package/dist/tools/directory/roles.d.ts.map +1 -0
- package/dist/tools/directory/roles.js +155 -0
- package/dist/tools/directory/roles.js.map +1 -0
- package/dist/tools/directory/user-security.d.ts +4 -0
- package/dist/tools/directory/user-security.d.ts.map +1 -0
- package/dist/tools/directory/user-security.js +115 -0
- package/dist/tools/directory/user-security.js.map +1 -0
- package/dist/tools/directory/users.d.ts +4 -0
- package/dist/tools/directory/users.d.ts.map +1 -0
- package/dist/tools/directory/users.js +261 -0
- package/dist/tools/directory/users.js.map +1 -0
- package/dist/tools/directory.d.ts +23 -0
- package/dist/tools/directory.d.ts.map +1 -0
- package/dist/tools/directory.js +23 -0
- package/dist/tools/directory.js.map +1 -0
- package/dist/tools/group-settings.d.ts +4 -0
- package/dist/tools/group-settings.d.ts.map +1 -0
- package/dist/tools/group-settings.js +47 -0
- package/dist/tools/group-settings.js.map +1 -0
- package/dist/tools/licensing.d.ts +4 -0
- package/dist/tools/licensing.d.ts.map +1 -0
- package/dist/tools/licensing.js +99 -0
- package/dist/tools/licensing.js.map +1 -0
- package/dist/tools/reports.d.ts +4 -0
- package/dist/tools/reports.d.ts.map +1 -0
- package/dist/tools/reports.js +120 -0
- package/dist/tools/reports.js.map +1 -0
- package/dist/tools/resources.d.ts +4 -0
- package/dist/tools/resources.d.ts.map +1 -0
- package/dist/tools/resources.js +309 -0
- package/dist/tools/resources.js.map +1 -0
- package/dist/tools/system.d.ts +16 -0
- package/dist/tools/system.d.ts.map +1 -0
- package/dist/tools/system.js +73 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/tools/transfer.d.ts +4 -0
- package/dist/tools/transfer.d.ts.map +1 -0
- package/dist/tools/transfer.js +96 -0
- package/dist/tools/transfer.js.map +1 -0
- package/dist/tools/vault.d.ts +4 -0
- package/dist/tools/vault.d.ts.map +1 -0
- package/dist/tools/vault.js +656 -0
- package/dist/tools/vault.js.map +1 -0
- package/dist/util/errors.d.ts +18 -0
- package/dist/util/errors.d.ts.map +1 -0
- package/dist/util/errors.js +97 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/redact.d.ts +12 -0
- package/dist/util/redact.d.ts.map +1 -0
- package/dist/util/redact.js +37 -0
- package/dist/util/redact.js.map +1 -0
- package/docs/SETUP.md +229 -0
- package/docs/SMOKE-TESTING.md +171 -0
- package/docs/TOOLS.md +130 -0
- package/docs/api/scopes.json +59 -0
- package/package.json +79 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/docs/tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAcjD,gFAAgF;AAChF,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAkB5E;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAQ5D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAqB5E"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
/**
|
|
5
|
+
* A stand-in for any service. Tool factories only close over their dependency;
|
|
6
|
+
* they do not call it while building specs, so a proxy is enough to enumerate
|
|
7
|
+
* the registry without a tenant.
|
|
8
|
+
*/
|
|
9
|
+
// biome-ignore lint/suspicious/noExplicitAny: a universal stand-in has no shape.
|
|
10
|
+
const anything = new Proxy(() => { }, {
|
|
11
|
+
get: (_target, property) => (property === Symbol.toPrimitive ? () => "" : anything),
|
|
12
|
+
apply: () => anything,
|
|
13
|
+
construct: () => anything,
|
|
14
|
+
});
|
|
15
|
+
/** Every tool module in the tools directory, built without a network client. */
|
|
16
|
+
export async function loadToolSpecs(toolsDir) {
|
|
17
|
+
const files = readdirSync(toolsDir)
|
|
18
|
+
.filter((file) => file.endsWith(".ts"))
|
|
19
|
+
.sort();
|
|
20
|
+
const specs = [];
|
|
21
|
+
for (const file of files) {
|
|
22
|
+
const module = (await import(pathToFileURL(join(toolsDir, file)).href));
|
|
23
|
+
for (const [name, exported] of Object.entries(module)) {
|
|
24
|
+
if (name.endsWith("Tools") && typeof exported === "function") {
|
|
25
|
+
specs.push(...exported(anything));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return specs;
|
|
30
|
+
}
|
|
31
|
+
/** Reads the markdown tool table. Notes are ignored on purpose. */
|
|
32
|
+
export function parseToolsTable(markdown) {
|
|
33
|
+
const rows = [];
|
|
34
|
+
for (const line of markdown.split("\n")) {
|
|
35
|
+
const match = /^\| `([a-z0-9_]+)` \| ([a-z-]+) \| (yes|no) \|/.exec(line);
|
|
36
|
+
if (!match)
|
|
37
|
+
continue;
|
|
38
|
+
rows.push({ name: match[1], surface: match[2], mutating: match[3] === "yes" });
|
|
39
|
+
}
|
|
40
|
+
return rows;
|
|
41
|
+
}
|
|
42
|
+
export function readToolsTable(path) {
|
|
43
|
+
return parseToolsTable(readFileSync(path, "utf8"));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A registered tool with no row is the failure the table exists to catch. A row
|
|
47
|
+
* with no tool is allowed: passthrough tools are registered only when enabled,
|
|
48
|
+
* and a surface can be documented before its branch merges.
|
|
49
|
+
*/
|
|
50
|
+
export function missingRows(specs, rows) {
|
|
51
|
+
const byName = new Map(rows.map((row) => [row.name, row]));
|
|
52
|
+
const problems = [];
|
|
53
|
+
for (const spec of specs) {
|
|
54
|
+
const row = byName.get(spec.name);
|
|
55
|
+
if (!row) {
|
|
56
|
+
problems.push(`${spec.name} is registered but has no row in docs/TOOLS.md`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (row.surface !== spec.surface) {
|
|
60
|
+
problems.push(`${spec.name} says surface ${spec.surface}, the table says ${row.surface}`);
|
|
61
|
+
}
|
|
62
|
+
if (row.mutating !== (spec.access !== "read")) {
|
|
63
|
+
problems.push(`${spec.name} is ${spec.access}, the table says mutating: ${row.mutating ? "yes" : "no"}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return problems;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/docs/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE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CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,iBAAiB,IAAI,CAAC,OAAO,oBAAoB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,CAAC;YAC9C,QAAQ,CAAC,IAAI,CACX,GAAG,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,8BAA8B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAC1F,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { loadConfig } from "./auth/config.js";
|
|
4
|
+
import { EditionProbe } from "./auth/edition.js";
|
|
5
|
+
import { authorize, createOAuthClient } from "./auth/oauth.js";
|
|
6
|
+
import { FileTokenStore } from "./auth/token-store.js";
|
|
7
|
+
import { passthroughTools } from "./passthrough/dispatch.js";
|
|
8
|
+
import { buildServer } from "./server.js";
|
|
9
|
+
import { CloudSearchService } from "./services/cloud-search.js";
|
|
10
|
+
import { DevicesService } from "./services/devices.js";
|
|
11
|
+
import { DirectoryService } from "./services/directory.js";
|
|
12
|
+
import { GroupsService } from "./services/directory-groups.js";
|
|
13
|
+
import { DomainsService } from "./services/domains.js";
|
|
14
|
+
import { GroupSettingsService } from "./services/group-settings.js";
|
|
15
|
+
import { LicensingService } from "./services/licensing.js";
|
|
16
|
+
import { OrgUnitsService } from "./services/orgunits.js";
|
|
17
|
+
import { ReportsService } from "./services/reports.js";
|
|
18
|
+
import { ResourcesService } from "./services/resources.js";
|
|
19
|
+
import { RolesService } from "./services/roles.js";
|
|
20
|
+
import { TransferService } from "./services/transfer.js";
|
|
21
|
+
import { UserSecurityService } from "./services/user-security.js";
|
|
22
|
+
import { VaultService } from "./services/vault.js";
|
|
23
|
+
const VERSION = "0.1.0";
|
|
24
|
+
async function main() {
|
|
25
|
+
const command = process.argv[2];
|
|
26
|
+
if (command === "--version" || command === "-v") {
|
|
27
|
+
process.stdout.write(`google-workspace-admin-mcp ${VERSION}\n`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const config = loadConfig();
|
|
31
|
+
const store = new FileTokenStore(config.tokenPath);
|
|
32
|
+
if (command === "auth") {
|
|
33
|
+
const token = await authorize(config, store);
|
|
34
|
+
process.stdout.write(`Authorized. Token stored at ${config.tokenPath}\n`);
|
|
35
|
+
void token;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const token = await store.load();
|
|
39
|
+
const auth = token ? authorizedClient(config, token) : undefined;
|
|
40
|
+
const { server } = buildServer({
|
|
41
|
+
config,
|
|
42
|
+
token,
|
|
43
|
+
vault: auth ? new VaultService(auth) : undefined,
|
|
44
|
+
cloudSearch: auth ? new CloudSearchService(auth) : undefined,
|
|
45
|
+
transfer: auth ? new TransferService(auth) : undefined,
|
|
46
|
+
resources: auth ? new ResourcesService(auth) : undefined,
|
|
47
|
+
groupSettings: auth ? new GroupSettingsService(auth) : undefined,
|
|
48
|
+
licensing: auth ? new LicensingService(auth) : undefined,
|
|
49
|
+
passthrough: auth && config.passthrough ? passthroughTools({ auth, mode: config.mode }) : undefined,
|
|
50
|
+
directory: auth
|
|
51
|
+
? {
|
|
52
|
+
users: new DirectoryService(auth),
|
|
53
|
+
domains: new DomainsService(auth),
|
|
54
|
+
groups: new GroupsService(auth),
|
|
55
|
+
orgUnits: new OrgUnitsService(auth),
|
|
56
|
+
roles: new RolesService(auth),
|
|
57
|
+
devices: new DevicesService(auth),
|
|
58
|
+
userSecurity: new UserSecurityService(auth),
|
|
59
|
+
}
|
|
60
|
+
: undefined,
|
|
61
|
+
edition: auth ? new EditionProbe(auth) : undefined,
|
|
62
|
+
reports: auth ? new ReportsService(auth) : undefined,
|
|
63
|
+
});
|
|
64
|
+
await server.connect(new StdioServerTransport());
|
|
65
|
+
}
|
|
66
|
+
function authorizedClient(config, token) {
|
|
67
|
+
const client = createOAuthClient(config);
|
|
68
|
+
client.setCredentials(token);
|
|
69
|
+
return client;
|
|
70
|
+
}
|
|
71
|
+
main().catch((error) => {
|
|
72
|
+
process.stderr.write(`${error.message}\n`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,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AI,CAAC;gBAC7B,OAAO,EAAE,IAAI,cAAc,CAAC,IAAI,CAAC;gBACjC,YAAY,EAAE,IAAI,mBAAmB,CAAC,IAAI,CAAC;aAC5C;YACH,CAAC,CAAC,SAAS;QACb,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QAClD,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAqC,EACrC,KAA8E;IAE9E,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,IAAI,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AllowlistedMethod {
|
|
2
|
+
api: string;
|
|
3
|
+
method: string;
|
|
4
|
+
access: "read" | "write";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Every method reachable through the passthrough tool. Adding a method means
|
|
8
|
+
* classifying it; there is no wildcard and no inference.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ALLOWLIST: AllowlistedMethod[];
|
|
11
|
+
export declare function findMethod(api: string, method: string): AllowlistedMethod | undefined;
|
|
12
|
+
export declare function permittedMethods(api: string): string[];
|
|
13
|
+
export declare function assertAllowlistClassified(entries?: AllowlistedMethod[]): void;
|
|
14
|
+
//# sourceMappingURL=allowlist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.d.ts","sourceRoot":"","sources":["../../src/passthrough/allowlist.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,iBAAiB,EAQxC,CAAC;AAEF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAErF;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtD;AAED,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,iBAAiB,EAAc,GAAG,IAAI,CAWxF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every method reachable through the passthrough tool. Adding a method means
|
|
3
|
+
* classifying it; there is no wildcard and no inference.
|
|
4
|
+
*/
|
|
5
|
+
export const ALLOWLIST = [
|
|
6
|
+
{ api: "directory", method: "users.list", access: "read" },
|
|
7
|
+
{ api: "directory", method: "users.get", access: "read" },
|
|
8
|
+
{ api: "directory", method: "groups.list", access: "read" },
|
|
9
|
+
{ api: "directory", method: "orgunits.list", access: "read" },
|
|
10
|
+
{ api: "reports", method: "activities.list", access: "read" },
|
|
11
|
+
{ api: "vault", method: "matters.list", access: "read" },
|
|
12
|
+
{ api: "transfer", method: "transfers.list", access: "read" },
|
|
13
|
+
];
|
|
14
|
+
export function findMethod(api, method) {
|
|
15
|
+
return ALLOWLIST.find((entry) => entry.api === api && entry.method === method);
|
|
16
|
+
}
|
|
17
|
+
export function permittedMethods(api) {
|
|
18
|
+
return ALLOWLIST.filter((entry) => entry.api === api).map((entry) => entry.method);
|
|
19
|
+
}
|
|
20
|
+
export function assertAllowlistClassified(entries = ALLOWLIST) {
|
|
21
|
+
const unclassified = entries.filter((entry) => entry.access !== "read" && entry.access !== "write");
|
|
22
|
+
if (unclassified.length > 0) {
|
|
23
|
+
throw new Error(`Passthrough entries without a read/write classification: ${unclassified
|
|
24
|
+
.map((e) => `${e.api}.${e.method}`)
|
|
25
|
+
.join(", ")}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=allowlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../src/passthrough/allowlist.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE;IAC1D,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE;IACzD,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE;IAC3D,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE;IAC7D,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE;IAC7D,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE;IACxD,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE;CAC9D,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,MAAc;IACpD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,OAAO,GAAwB,SAAS;IAChF,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CACjC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,CAC/D,CAAC;IACF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,4DAA4D,YAAY;aACrE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;aAClC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OAuth2Client } from "google-auth-library";
|
|
2
|
+
import type { AnyToolSpec } from "../catalog.js";
|
|
3
|
+
import type { Mode } from "../safety/policy.js";
|
|
4
|
+
import { type AllowlistedMethod, findMethod, permittedMethods } from "./allowlist.js";
|
|
5
|
+
export interface PassthroughDeps {
|
|
6
|
+
auth: OAuth2Client;
|
|
7
|
+
mode: Mode;
|
|
8
|
+
allowlist?: AllowlistedMethod[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One raw-call tool per API that appears in the allowlist.
|
|
12
|
+
*
|
|
13
|
+
* The tool is registered as a read tool on purpose: it carries both read and
|
|
14
|
+
* write methods, so dropping it in read-only mode would remove the safe half
|
|
15
|
+
* too. Write methods are refused inside the call instead, and the result tells
|
|
16
|
+
* the audit log which access was actually exercised.
|
|
17
|
+
*/
|
|
18
|
+
export declare function passthroughTools(deps: PassthroughDeps): AnyToolSpec[];
|
|
19
|
+
export { findMethod, permittedMethods };
|
|
20
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/passthrough/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EAAU,WAAW,EAAW,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAEL,KAAK,iBAAiB,EAEtB,UAAU,EACV,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAsBxB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,EAAE,CA0ErE;AAiDD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { google } from "googleapis";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { mapGoogleError, ToolError } from "../util/errors.js";
|
|
4
|
+
import { ALLOWLIST, assertAllowlistClassified, findMethod, permittedMethods, } from "./allowlist.js";
|
|
5
|
+
const SURFACE = {
|
|
6
|
+
directory: "directory",
|
|
7
|
+
reports: "reports",
|
|
8
|
+
vault: "vault",
|
|
9
|
+
transfer: "transfer",
|
|
10
|
+
};
|
|
11
|
+
const EDITION = {
|
|
12
|
+
vault: "enterprise",
|
|
13
|
+
};
|
|
14
|
+
const shape = {
|
|
15
|
+
method: z.string().min(1).describe('Allowlisted method, for example "users.get"'),
|
|
16
|
+
params: z
|
|
17
|
+
.record(z.string(), z.unknown())
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("JSON payload passed to the method unchanged"),
|
|
20
|
+
confirm: z.boolean().optional().describe("Required for write methods"),
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* One raw-call tool per API that appears in the allowlist.
|
|
24
|
+
*
|
|
25
|
+
* The tool is registered as a read tool on purpose: it carries both read and
|
|
26
|
+
* write methods, so dropping it in read-only mode would remove the safe half
|
|
27
|
+
* too. Write methods are refused inside the call instead, and the result tells
|
|
28
|
+
* the audit log which access was actually exercised.
|
|
29
|
+
*/
|
|
30
|
+
export function passthroughTools(deps) {
|
|
31
|
+
const allowlist = deps.allowlist ?? ALLOWLIST;
|
|
32
|
+
assertAllowlistClassified(allowlist);
|
|
33
|
+
const apis = [...new Set(allowlist.map((entry) => entry.api))];
|
|
34
|
+
const clients = buildClients(deps.auth);
|
|
35
|
+
return apis
|
|
36
|
+
.filter((api) => clients[api])
|
|
37
|
+
.map((api) => {
|
|
38
|
+
const surface = SURFACE[api] ?? "system";
|
|
39
|
+
const methods = allowlist.filter((entry) => entry.api === api);
|
|
40
|
+
return {
|
|
41
|
+
name: `gws_passthrough_${api}`,
|
|
42
|
+
surface,
|
|
43
|
+
access: "read",
|
|
44
|
+
edition: EDITION[api] ?? "all",
|
|
45
|
+
description: `Call an allowlisted ${api} API method with a raw JSON payload, for cases the curated tools do not cover. ` +
|
|
46
|
+
`Permitted methods: ${methods.map((entry) => entry.method).join(", ")}. ` +
|
|
47
|
+
`Write methods require confirm: true and are refused while the server is read-only.`,
|
|
48
|
+
inputShape: shape,
|
|
49
|
+
run: async (input) => {
|
|
50
|
+
const args = z.object(shape).parse(input);
|
|
51
|
+
const entry = findMethodIn(allowlist, api, args.method);
|
|
52
|
+
if (!entry) {
|
|
53
|
+
throw new ToolError("invalid_request", `${api}.${args.method} is not allowlisted.`, `Permitted methods: ${permittedMethodsFor(allowlist, api).join(", ")}.`);
|
|
54
|
+
}
|
|
55
|
+
if (entry.access === "write") {
|
|
56
|
+
if (deps.mode !== "write") {
|
|
57
|
+
throw new ToolError("invalid_request", `Passthrough write methods are unavailable: write mode is disabled (GWS_MODE is read-only).`, "Set GWS_MODE=write and restart the server to enable writes.");
|
|
58
|
+
}
|
|
59
|
+
if (args.confirm !== true) {
|
|
60
|
+
throw new ToolError("invalid_request", `${api}.${args.method} changes tenant state.`, "Call again with confirm: true after checking the payload.");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const call = resolveMethod(clients[api], args.method);
|
|
64
|
+
if (!call) {
|
|
65
|
+
throw new ToolError("invalid_request", `${api}.${args.method} is allowlisted but not callable in this googleapis version.`, "Remove it from the allowlist or update the dependency.");
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const response = await call({ ...(args.params ?? {}) });
|
|
69
|
+
return {
|
|
70
|
+
summary: `${api}.${args.method} succeeded`,
|
|
71
|
+
data: response.data,
|
|
72
|
+
access: entry.access,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw mapGoogleError(error, surface);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function buildClients(auth) {
|
|
83
|
+
return {
|
|
84
|
+
directory: google.admin({ version: "directory_v1", auth }),
|
|
85
|
+
reports: google.admin({ version: "reports_v1", auth }),
|
|
86
|
+
vault: google.vault({ version: "v1", auth }),
|
|
87
|
+
transfer: google.admin({ version: "datatransfer_v1", auth }),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Walks the allowlisted dotted path on the resource object. Only names that
|
|
92
|
+
* already passed the allowlist reach this function, and the method keeps its
|
|
93
|
+
* resource as `this` because googleapis methods use it.
|
|
94
|
+
*/
|
|
95
|
+
function resolveMethod(root, path) {
|
|
96
|
+
const segments = path.split(".");
|
|
97
|
+
let parent = root;
|
|
98
|
+
let current = root;
|
|
99
|
+
for (const segment of segments) {
|
|
100
|
+
if (!current || typeof current !== "object")
|
|
101
|
+
return undefined;
|
|
102
|
+
parent = current;
|
|
103
|
+
current = current[segment];
|
|
104
|
+
}
|
|
105
|
+
if (typeof current !== "function")
|
|
106
|
+
return undefined;
|
|
107
|
+
return (params) => current.call(parent, params);
|
|
108
|
+
}
|
|
109
|
+
function findMethodIn(allowlist, api, method) {
|
|
110
|
+
return allowlist.find((entry) => entry.api === api && entry.method === method);
|
|
111
|
+
}
|
|
112
|
+
function permittedMethodsFor(allowlist, api) {
|
|
113
|
+
return allowlist.filter((entry) => entry.api === api).map((entry) => entry.method);
|
|
114
|
+
}
|
|
115
|
+
export { findMethod, permittedMethods };
|
|
116
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/passthrough/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,SAAS,EAET,yBAAyB,EACzB,UAAU,EACV,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,GAA4B;IACvC,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,OAAO,GAAyC;IACpD,KAAK,EAAE,YAAY;CACpB,CAAC;AAEF,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC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O,OAAO,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC9D,MAAM,GAAG,OAAO,CAAC;QACjB,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,CAAC,MAAe,EAAE,EAAE,CACxB,OAAgE,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,YAAY,CACnB,SAA8B,EAC9B,GAAW,EACX,MAAc;IAEd,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,mBAAmB,CAAC,SAA8B,EAAE,GAAW;IACtE,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACrF,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AuditEntry {
|
|
2
|
+
timestamp: string;
|
|
3
|
+
tool: string;
|
|
4
|
+
access: string;
|
|
5
|
+
outcome: "ok" | "error";
|
|
6
|
+
durationMs: number;
|
|
7
|
+
args?: unknown;
|
|
8
|
+
error?: {
|
|
9
|
+
category: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class AuditLog {
|
|
14
|
+
private readonly path;
|
|
15
|
+
constructor(path: string);
|
|
16
|
+
append(entry: Omit<AuditEntry, "timestamp">): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/safety/audit.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,MAAM,EAAI;IAEvC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBhE;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { appendFile, chmod, mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { ToolError } from "../util/errors.js";
|
|
4
|
+
import { redact } from "../util/redact.js";
|
|
5
|
+
export class AuditLog {
|
|
6
|
+
path;
|
|
7
|
+
constructor(path) {
|
|
8
|
+
this.path = path;
|
|
9
|
+
}
|
|
10
|
+
async append(entry) {
|
|
11
|
+
const line = JSON.stringify({
|
|
12
|
+
timestamp: new Date().toISOString(),
|
|
13
|
+
...entry,
|
|
14
|
+
args: entry.args === undefined ? undefined : redact(entry.args),
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
await mkdir(dirname(this.path), { recursive: true });
|
|
18
|
+
await appendFile(this.path, `${line}\n`, { mode: 0o600 });
|
|
19
|
+
await chmod(this.path, 0o600);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw new ToolError("unknown", `Could not write the audit log at ${this.path}: ${error.message}`, "Fix the path or permissions; the call is refused rather than run unaudited.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/safety/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAY3C,MAAM,OAAO,QAAQ;IACU,IAAI;IAAjC,YAA6B,IAAY;oBAAZ,IAAI;IAAW,CAAC;IAE7C,KAAK,CAAC,MAAM,CAAC,KAAoC;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YAC1B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,GAAG,KAAK;YACR,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;SAChE,CAAC,CAAC;QAEH,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACrD,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1D,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,SAAS,CACjB,SAAS,EACT,oCAAoC,IAAI,CAAC,IAAI,KAAM,KAAe,CAAC,OAAO,EAAE,EAC5E,6EAA6E,CAC9E,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AnyToolSpec } from "../catalog.js";
|
|
2
|
+
export type Mode = "readonly" | "write";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only mode omits mutating tools at registration time. A tool that is not
|
|
5
|
+
* registered cannot be called, so a model cannot argue its way into it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toolsForMode(specs: AnyToolSpec[], mode: Mode): AnyToolSpec[];
|
|
8
|
+
/**
|
|
9
|
+
* Destructive tools need an explicit confirm argument. Without it, no API call
|
|
10
|
+
* happens and the caller learns exactly what confirming would do.
|
|
11
|
+
*/
|
|
12
|
+
export declare function requireConfirm(spec: AnyToolSpec, input: Record<string, unknown>): void;
|
|
13
|
+
export declare function parseMode(value: string | undefined): Mode;
|
|
14
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/safety/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIjD,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC;AAExC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,WAAW,EAAE,CAE5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAWtF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAQzD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isMutating } from "../catalog.js";
|
|
2
|
+
import { ToolError } from "../util/errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Read-only mode omits mutating tools at registration time. A tool that is not
|
|
5
|
+
* registered cannot be called, so a model cannot argue its way into it.
|
|
6
|
+
*/
|
|
7
|
+
export function toolsForMode(specs, mode) {
|
|
8
|
+
return mode === "write" ? specs : specs.filter((spec) => !isMutating(spec));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Destructive tools need an explicit confirm argument. Without it, no API call
|
|
12
|
+
* happens and the caller learns exactly what confirming would do.
|
|
13
|
+
*/
|
|
14
|
+
export function requireConfirm(spec, input) {
|
|
15
|
+
if (spec.access !== "destructive")
|
|
16
|
+
return;
|
|
17
|
+
if (input.confirm === true)
|
|
18
|
+
return;
|
|
19
|
+
const note = "confirmNote" in spec ? spec.confirmNote : "This operation cannot be undone.";
|
|
20
|
+
throw new ToolError("invalid_request", `${spec.name} is irreversible: ${note}`, "Call again with confirm: true after checking the target.");
|
|
21
|
+
}
|
|
22
|
+
export function parseMode(value) {
|
|
23
|
+
if (!value || value === "readonly" || value === "read-only")
|
|
24
|
+
return "readonly";
|
|
25
|
+
if (value === "write")
|
|
26
|
+
return "write";
|
|
27
|
+
throw new ToolError("invalid_request", `GWS_MODE must be "readonly" or "write", got "${value}".`, "Unset it to keep the default read-only mode.");
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/safety/policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAoB,EAAE,IAAU;IAC3D,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAiB,EAAE,KAA8B;IAC9E,IAAI,IAAI,CAAC,MAAM,KAAK,aAAa;QAAE,OAAO;IAE1C,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;QAAE,OAAO;IAEnC,MAAM,IAAI,GAAG,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,kCAAkC,CAAC;IAC3F,MAAM,IAAI,SAAS,CACjB,iBAAiB,EACjB,GAAG,IAAI,CAAC,IAAI,qBAAqB,IAAI,EAAE,EACvC,0DAA0D,CAC3D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAyB;IACjD,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,WAAW;QAAE,OAAO,UAAU,CAAC;IAC/E,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACtC,MAAM,IAAI,SAAS,CACjB,iBAAiB,EACjB,gDAAgD,KAAK,IAAI,EACzD,8CAA8C,CAC/C,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { AppConfig } from "./auth/config.js";
|
|
3
|
+
import type { EditionProbe } from "./auth/edition.js";
|
|
4
|
+
import type { StoredToken } from "./auth/token-store.js";
|
|
5
|
+
import type { AnyToolSpec } from "./catalog.js";
|
|
6
|
+
import type { CloudSearchService } from "./services/cloud-search.js";
|
|
7
|
+
import type { GroupSettingsService } from "./services/group-settings.js";
|
|
8
|
+
import type { LicensingService } from "./services/licensing.js";
|
|
9
|
+
import type { ReportsService } from "./services/reports.js";
|
|
10
|
+
import type { ResourcesService } from "./services/resources.js";
|
|
11
|
+
import type { TransferService } from "./services/transfer.js";
|
|
12
|
+
import type { VaultService } from "./services/vault.js";
|
|
13
|
+
import type { DirectoryServices } from "./tools/directory.js";
|
|
14
|
+
import { ToolError } from "./util/errors.js";
|
|
15
|
+
export interface ServerDeps {
|
|
16
|
+
config: AppConfig;
|
|
17
|
+
token?: StoredToken;
|
|
18
|
+
vault?: VaultService;
|
|
19
|
+
cloudSearch?: CloudSearchService;
|
|
20
|
+
transfer?: TransferService;
|
|
21
|
+
resources?: ResourcesService;
|
|
22
|
+
groupSettings?: GroupSettingsService;
|
|
23
|
+
licensing?: LicensingService;
|
|
24
|
+
/** Built by main when GWS_PASSTHROUGH is on; absent means no passthrough tool. */
|
|
25
|
+
passthrough?: AnyToolSpec[];
|
|
26
|
+
directory?: DirectoryServices;
|
|
27
|
+
edition?: EditionProbe;
|
|
28
|
+
reports?: ReportsService;
|
|
29
|
+
}
|
|
30
|
+
export declare function buildServer(deps: ServerDeps): {
|
|
31
|
+
server: McpServer;
|
|
32
|
+
tools: string[];
|
|
33
|
+
};
|
|
34
|
+
export { ToolError };
|
|
35
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAS9D,OAAO,EAAkB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,kFAAkF;IAClF,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAmEpF;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { AuditLog } from "./safety/audit.js";
|
|
4
|
+
import { requireConfirm, toolsForMode } from "./safety/policy.js";
|
|
5
|
+
import { cloudSearchTools } from "./tools/cloud-search.js";
|
|
6
|
+
import { directoryTools } from "./tools/directory.js";
|
|
7
|
+
import { groupSettingsTools } from "./tools/group-settings.js";
|
|
8
|
+
import { licensingTools } from "./tools/licensing.js";
|
|
9
|
+
import { reportsTools } from "./tools/reports.js";
|
|
10
|
+
import { resourceTools } from "./tools/resources.js";
|
|
11
|
+
import { systemTools } from "./tools/system.js";
|
|
12
|
+
import { transferTools } from "./tools/transfer.js";
|
|
13
|
+
import { vaultTools } from "./tools/vault.js";
|
|
14
|
+
import { mapGoogleError, ToolError } from "./util/errors.js";
|
|
15
|
+
export function buildServer(deps) {
|
|
16
|
+
const { config, token } = deps;
|
|
17
|
+
const audit = new AuditLog(config.auditPath);
|
|
18
|
+
const specs = [
|
|
19
|
+
...systemTools({ config, token, edition: deps.edition }),
|
|
20
|
+
...(deps.directory ? directoryTools(deps.directory) : []),
|
|
21
|
+
...(deps.vault ? vaultTools(deps.vault) : []),
|
|
22
|
+
...(deps.cloudSearch ? cloudSearchTools(deps.cloudSearch) : []),
|
|
23
|
+
...(deps.transfer ? transferTools(deps.transfer) : []),
|
|
24
|
+
...(deps.resources ? resourceTools(deps.resources) : []),
|
|
25
|
+
...(deps.groupSettings ? groupSettingsTools(deps.groupSettings) : []),
|
|
26
|
+
...(deps.licensing ? licensingTools(deps.licensing) : []),
|
|
27
|
+
...(deps.passthrough ?? []),
|
|
28
|
+
...(deps.reports ? reportsTools(deps.reports) : []),
|
|
29
|
+
];
|
|
30
|
+
const registered = toolsForMode(specs, config.mode);
|
|
31
|
+
const server = new McpServer({ name: "google-workspace-admin-mcp", version: "0.1.0" });
|
|
32
|
+
for (const spec of registered) {
|
|
33
|
+
server.registerTool(spec.name, { description: spec.description, inputSchema: spec.inputShape }, async (input) => {
|
|
34
|
+
const started = Date.now();
|
|
35
|
+
let parsed = {};
|
|
36
|
+
try {
|
|
37
|
+
parsed = z.object(spec.inputShape).parse(input ?? {});
|
|
38
|
+
requireConfirm(spec, parsed);
|
|
39
|
+
const result = await spec.run(parsed, { dryRun: false });
|
|
40
|
+
await audit.append({
|
|
41
|
+
tool: spec.name,
|
|
42
|
+
access: result.access ?? spec.access,
|
|
43
|
+
outcome: "ok",
|
|
44
|
+
durationMs: Date.now() - started,
|
|
45
|
+
args: parsed,
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: JSON.stringify({ summary: result.summary, data: result.data }),
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const toolError = mapGoogleError(error, spec.surface);
|
|
58
|
+
await audit
|
|
59
|
+
.append({
|
|
60
|
+
tool: spec.name,
|
|
61
|
+
access: spec.access,
|
|
62
|
+
outcome: "error",
|
|
63
|
+
durationMs: Date.now() - started,
|
|
64
|
+
args: parsed,
|
|
65
|
+
error: { category: toolError.category, message: toolError.message },
|
|
66
|
+
})
|
|
67
|
+
.catch(() => undefined);
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: "text", text: JSON.stringify(toolError.toJSON()) }],
|
|
70
|
+
isError: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return { server, tools: registered.map((spec) => spec.name) };
|
|
76
|
+
}
|
|
77
|
+
export { ToolError };
|
|
78
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,cAAc,EA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