gogcli-mcp-drive 4.3.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "metadata": {
9
9
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
10
- "version": "4.3.0"
10
+ "version": "4.5.0"
11
11
  },
12
12
  "plugins": [
13
13
  {
@@ -15,7 +15,7 @@
15
15
  "displayName": "gogcli (Drive)",
16
16
  "source": "./",
17
17
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
18
- "version": "4.3.0",
18
+ "version": "4.5.0",
19
19
  "author": {
20
20
  "name": "Chris Hall"
21
21
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gogcli-mcp-drive",
3
3
  "displayName": "gogcli (Drive)",
4
- "version": "4.3.0",
4
+ "version": "4.5.0",
5
5
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
6
6
  "author": {
7
7
  "name": "Chris Hall",
package/dist/index.js CHANGED
@@ -37,6 +37,33 @@ var storage2 = new AsyncLocalStorage2();
37
37
  function withCallerCapabilities(capabilities, fn) {
38
38
  return capabilities ? storage2.run(capabilities, fn) : fn();
39
39
  }
40
+ function currentCallerCapabilities() {
41
+ return storage2.getStore();
42
+ }
43
+ var ENVELOPE_CAPABILITIES_KEY = "io.modelcontextprotocol/clientCapabilities";
44
+ var ELICITATION_MODES = ["form", "url"];
45
+ function isRecord(value) {
46
+ return typeof value === "object" && value !== null && !Array.isArray(value);
47
+ }
48
+ function callerCapabilities(ctx) {
49
+ const envelope = isRecord(ctx) && isRecord(ctx.mcpReq) ? ctx.mcpReq.envelope : void 0;
50
+ if (isRecord(envelope)) {
51
+ const declared = envelope[ENVELOPE_CAPABILITIES_KEY];
52
+ if (isRecord(declared))
53
+ return declared;
54
+ }
55
+ return currentCallerCapabilities();
56
+ }
57
+ function callerAcceptsFormElicitation(ctx) {
58
+ const capabilities = callerCapabilities(ctx);
59
+ if (!capabilities)
60
+ return void 0;
61
+ const elicitation = capabilities.elicitation;
62
+ if (!isRecord(elicitation))
63
+ return false;
64
+ const namedModes = ELICITATION_MODES.filter((mode) => mode in elicitation);
65
+ return namedModes.length === 0 || namedModes.includes("form");
66
+ }
40
67
 
41
68
  // ../../node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
42
69
  var __create = Object.create;
@@ -24101,6 +24128,37 @@ var inputRequired = Object.assign(buildInputRequired, {
24101
24128
  return { method: "roots/list" };
24102
24129
  }
24103
24130
  });
24131
+ function acceptedContent(responses, key, schema) {
24132
+ const view = inputResponse(responses, key);
24133
+ if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
24134
+ if (schema === void 0) return view.content;
24135
+ const outcome = schema["~standard"].validate(view.content);
24136
+ if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
24137
+ return outcome.issues === void 0 ? outcome.value : void 0;
24138
+ }
24139
+ function inputResponse(responses, key) {
24140
+ if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
24141
+ const entry = responses[key];
24142
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
24143
+ const candidate = entry;
24144
+ if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
24145
+ const content = candidate["content"];
24146
+ return {
24147
+ kind: "elicit",
24148
+ action: candidate["action"],
24149
+ ...content !== null && typeof content === "object" && !Array.isArray(content) && { content }
24150
+ };
24151
+ }
24152
+ if (Array.isArray(candidate["roots"])) return {
24153
+ kind: "roots",
24154
+ roots: candidate["roots"]
24155
+ };
24156
+ if (typeof candidate["role"] === "string" && candidate["content"] !== void 0) return {
24157
+ kind: "sampling",
24158
+ result: candidate
24159
+ };
24160
+ return { kind: "missing" };
24161
+ }
24104
24162
  var REQUEST_STATE_ONLY_LEG_PACING_MS = 250;
24105
24163
  function inputRequiredRoundsExceededMessage(method, maxRounds) {
24106
24164
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
@@ -34148,14 +34206,14 @@ function serveStdio(factory, options = {}) {
34148
34206
  return false;
34149
34207
  };
34150
34208
  const answerLegacyRejection = (request, reason, requestedVersion) => {
34151
- const rejection2 = modernOnlyStrictRejection({
34209
+ const rejection3 = modernOnlyStrictRejection({
34152
34210
  kind: "legacy",
34153
34211
  reason,
34154
34212
  ...requestedVersion !== void 0 && { requestedVersion }
34155
34213
  }, SUPPORTED_MODERN_PROTOCOL_VERSIONS);
34156
- if (rejection2 === void 0) return Promise.resolve();
34157
- reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${rejection2.cell}): ${rejection2.message}`));
34158
- return writeErrorResponse(request.id, rejection2.code, rejection2.message, rejection2.data);
34214
+ if (rejection3 === void 0) return Promise.resolve();
34215
+ reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${rejection3.cell}): ${rejection3.message}`));
34216
+ return writeErrorResponse(request.id, rejection3.code, rejection3.message, rejection3.data);
34159
34217
  };
34160
34218
  const onInstanceClosed = (channel) => {
34161
34219
  if (closing || channel === discarding) return;
@@ -34479,6 +34537,11 @@ function walk(value, keep, drop) {
34479
34537
  }
34480
34538
 
34481
34539
  // ../../node_modules/@chrischall/mcp-utils/dist/response/index.js
34540
+ function textResult(data) {
34541
+ return {
34542
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
34543
+ };
34544
+ }
34482
34545
  function rawTextResult(text) {
34483
34546
  return { content: [{ type: "text", text }] };
34484
34547
  }
@@ -34489,6 +34552,416 @@ function errorResult(message) {
34489
34552
  };
34490
34553
  }
34491
34554
 
34555
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34556
+ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
34557
+
34558
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
34559
+ function canonicalJson(value) {
34560
+ if (value === null || typeof value === "string" || typeof value === "boolean")
34561
+ return JSON.stringify(value);
34562
+ if (value === void 0)
34563
+ return "null";
34564
+ if (typeof value === "number")
34565
+ return Number.isFinite(value) ? JSON.stringify(value) : `{"$num":"${String(value)}"}`;
34566
+ if (typeof value === "bigint")
34567
+ return `{"$bigint":"${value.toString()}"}`;
34568
+ if (typeof value === "function" || typeof value === "symbol") {
34569
+ throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
34570
+ }
34571
+ if (Array.isArray(value))
34572
+ return `[${value.map(canonicalJson).join(",")}]`;
34573
+ if (value instanceof Date) {
34574
+ return `{"$date":${JSON.stringify(Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString())}}`;
34575
+ }
34576
+ if (ArrayBuffer.isView(value)) {
34577
+ const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
34578
+ return `{"$bytes":${JSON.stringify(bytes.toString("base64"))}}`;
34579
+ }
34580
+ if (value instanceof ArrayBuffer)
34581
+ return `{"$bytes":${JSON.stringify(Buffer.from(value).toString("base64"))}}`;
34582
+ if (value instanceof Map) {
34583
+ const entries2 = [...value.entries()].map(([k, v]) => `[${canonicalJson(k)},${canonicalJson(v)}]`).sort();
34584
+ return `{"$map":[${entries2.join(",")}]}`;
34585
+ }
34586
+ if (value instanceof Set) {
34587
+ return `{"$set":[${[...value].map(canonicalJson).sort().join(",")}]}`;
34588
+ }
34589
+ const proto = Object.getPrototypeOf(value);
34590
+ if (proto !== Object.prototype && proto !== null) {
34591
+ throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
34592
+ }
34593
+ const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
34594
+ return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
34595
+ }
34596
+ function escapeKey(key) {
34597
+ return key.startsWith("$") ? `$${key}` : key;
34598
+ }
34599
+
34600
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34601
+ var DEFAULT_REQUEST_KEY = "confirmation";
34602
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34603
+ var UNSUPPORTED_NOTE = "Nothing was done because this client cannot show a confirmation prompt (it declares no MCP elicitation capability), and this action is never taken without one";
34604
+ var STATE_PREFIX = "mcpu.confirm.v1.";
34605
+ function bindingKey(binding) {
34606
+ if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
34607
+ throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
34608
+ }
34609
+ const key = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
34610
+ if (key.length < 32) {
34611
+ throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
34612
+ }
34613
+ return key;
34614
+ }
34615
+ function commitment(action, args) {
34616
+ return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
34617
+ }
34618
+ function mintState(key, action, binding) {
34619
+ const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
34620
+ const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
34621
+ const mac3 = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest("base64url");
34622
+ return `${STATE_PREFIX}${body}.${mac3}`;
34623
+ }
34624
+ function verifyState(key, action, binding, state) {
34625
+ if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
34626
+ return false;
34627
+ const rest = state.slice(STATE_PREFIX.length);
34628
+ const dot = rest.indexOf(".");
34629
+ if (dot < 0)
34630
+ return false;
34631
+ const body = rest.slice(0, dot);
34632
+ const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
34633
+ const expected = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest();
34634
+ if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
34635
+ return false;
34636
+ let payload;
34637
+ try {
34638
+ payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34639
+ } catch {
34640
+ return false;
34641
+ }
34642
+ if (typeof payload.exp !== "number" || payload.exp * 1e3 <= Date.now())
34643
+ return false;
34644
+ const want = Buffer.from(commitment(action, binding.args));
34645
+ const got = Buffer.from(typeof payload.c === "string" ? payload.c : "");
34646
+ return got.length === want.length && timingSafeEqual(got, want);
34647
+ }
34648
+ function echoedState(ctx) {
34649
+ const accessor = ctx.mcpReq.requestState;
34650
+ return typeof accessor === "function" ? accessor() : void 0;
34651
+ }
34652
+ function requireConfirmation(ctx, options) {
34653
+ const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
34654
+ const key = options.binding ? bindingKey(options.binding) : void 0;
34655
+ const confirmationSchema = external_exports.object({
34656
+ confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
34657
+ });
34658
+ const ask = () => {
34659
+ const preview = {
34660
+ action: options.action,
34661
+ ...options.details === void 0 ? {} : { details: options.details }
34662
+ };
34663
+ return inputRequired({
34664
+ inputRequests: {
34665
+ [requestKey]: inputRequired.elicit({
34666
+ message: `${options.message}
34667
+ ${JSON.stringify(preview, null, 2)}`,
34668
+ requestedSchema: confirmationSchema
34669
+ })
34670
+ },
34671
+ ...key && options.binding ? { requestState: mintState(key, options.action, options.binding) } : {}
34672
+ });
34673
+ };
34674
+ const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
34675
+ const accepted = acceptedContent(ctx.mcpReq.inputResponses, requestKey, confirmationSchema);
34676
+ if (response.kind === "missing") {
34677
+ if (callerAcceptsFormElicitation(ctx) === false) {
34678
+ return textResult({
34679
+ confirmed: false,
34680
+ dispatched: false,
34681
+ action: options.action,
34682
+ reason: "confirmation-unsupported",
34683
+ note: options.unsupportedNote ? `${UNSUPPORTED_NOTE}. ${options.unsupportedNote}` : `${UNSUPPORTED_NOTE}.`
34684
+ });
34685
+ }
34686
+ return ask();
34687
+ }
34688
+ if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
34689
+ if (key && options.binding) {
34690
+ const state = echoedState(ctx);
34691
+ if (state === void 0 || state === null) {
34692
+ return errorResult(`Confirmation for ${options.action} was accepted, but the retry carried no requestState, so it cannot be checked against the prompt that was shown. Nothing was done. The likely cause is that the MCP client or host does not round-trip requestState (it must echo the requestState from the input_required result back on the retry); asking again would loop.`);
34693
+ }
34694
+ if (!verifyState(key, options.action, options.binding, state))
34695
+ return ask();
34696
+ }
34697
+ return void 0;
34698
+ }
34699
+ return textResult({
34700
+ confirmed: false,
34701
+ cancelled: true,
34702
+ action: options.action,
34703
+ note: "Nothing was changed because the confirmation was declined, cancelled, or left unchecked."
34704
+ });
34705
+ }
34706
+
34707
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
34708
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
34709
+ function createSpentTokenStore() {
34710
+ const spent2 = /* @__PURE__ */ new Map();
34711
+ return {
34712
+ has: (nonce) => spent2.has(nonce),
34713
+ add: (nonce, exp) => {
34714
+ spent2.set(nonce, exp);
34715
+ },
34716
+ prune: (now) => {
34717
+ for (const [nonce, exp] of spent2)
34718
+ if (exp < now)
34719
+ spent2.delete(nonce);
34720
+ },
34721
+ clear: () => spent2.clear(),
34722
+ get size() {
34723
+ return spent2.size;
34724
+ }
34725
+ };
34726
+ }
34727
+ var PROCESS_SPENT = createSpentTokenStore();
34728
+ var PREFIX = "mcpu.token.v1.";
34729
+ var DEFAULT_TTL_SECONDS = 600;
34730
+ function tokenKey(key) {
34731
+ const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
34732
+ if (bytes.length < 32)
34733
+ throw new RangeError("confirm token: key must be at least 32 bytes.");
34734
+ return bytes;
34735
+ }
34736
+ function ttlOf(ttlSeconds) {
34737
+ if (ttlSeconds === void 0)
34738
+ return DEFAULT_TTL_SECONDS;
34739
+ if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
34740
+ throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
34741
+ }
34742
+ return ttlSeconds;
34743
+ }
34744
+ function sign(key, body) {
34745
+ return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
34746
+ }
34747
+ function hashConfirmPayload(payload) {
34748
+ return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
34749
+ }
34750
+ function issueConfirmToken(key, binding, options = {}) {
34751
+ const k = tokenKey(key);
34752
+ const now = options.now ?? Date.now();
34753
+ const exp = now + ttlOf(options.ttlSeconds) * 1e3;
34754
+ const claims = {
34755
+ t: binding.tool,
34756
+ ...binding.account === void 0 ? {} : { a: binding.account },
34757
+ g: binding.target,
34758
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
34759
+ h: binding.payloadHash,
34760
+ exp,
34761
+ n: randomBytes(16).toString("base64url")
34762
+ };
34763
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
34764
+ return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
34765
+ }
34766
+ function parseClaims(body) {
34767
+ try {
34768
+ const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34769
+ return claims && typeof claims === "object" ? claims : void 0;
34770
+ } catch {
34771
+ return void 0;
34772
+ }
34773
+ }
34774
+ function verifyConfirmToken(key, token, binding, options = {}) {
34775
+ const k = tokenKey(key);
34776
+ const now = options.now ?? Date.now();
34777
+ const spent2 = options.spent ?? PROCESS_SPENT;
34778
+ spent2.prune(now);
34779
+ if (!token.startsWith(PREFIX))
34780
+ return { ok: false, error: "TOKEN_INVALID" };
34781
+ const rest = token.slice(PREFIX.length);
34782
+ const dot = rest.indexOf(".");
34783
+ const body = dot < 0 ? "" : rest.slice(0, dot);
34784
+ const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
34785
+ const expected = sign(k, body);
34786
+ if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
34787
+ return { ok: false, error: "TOKEN_INVALID" };
34788
+ const claims = parseClaims(body);
34789
+ if (!claims)
34790
+ return { ok: false, error: "TOKEN_INVALID" };
34791
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
34792
+ return { ok: false, error: "TOKEN_INVALID" };
34793
+ }
34794
+ if (spent2.has(claims.n))
34795
+ return { ok: false, error: "TOKEN_REUSED" };
34796
+ if (now > claims.exp)
34797
+ return { ok: false, error: "TOKEN_EXPIRED" };
34798
+ if (claims.r !== binding.revision)
34799
+ return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
34800
+ if (claims.h !== binding.payloadHash)
34801
+ return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
34802
+ spent2.add(claims.n, claims.exp);
34803
+ return { ok: true };
34804
+ }
34805
+ var CONFIRM_TOKEN_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
34806
+ var confirmTokenParam = external_exports.string().optional().describe(`ONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat \u2014 never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.`);
34807
+ var TOKEN_ERROR_NOTE = {
34808
+ TOKEN_EXPIRED: "Nothing was sent or changed: the confirmToken expired. Call again WITHOUT confirmToken for a fresh preview, and ask the user to approve it again.",
34809
+ TOKEN_REUSED: "Nothing was sent or changed by this call: this confirmToken was already used, and one approval acts once. If doing it again is really intended, call again WITHOUT confirmToken and get a new approval.",
34810
+ TOKEN_INVALID: "Nothing was sent or changed: this confirmToken was not issued by this server for this tool, account and target (or the server has restarted since). Call again WITHOUT confirmToken for a fresh preview and approval."
34811
+ };
34812
+ var CHANGED_NOTE = {
34813
+ "revision-changed": "Nothing was sent or changed: the target was edited since the user approved it (its version rotated), so what would happen is not what they saw.",
34814
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
34815
+ };
34816
+ function isToolResult(value) {
34817
+ return Array.isArray(value.content);
34818
+ }
34819
+ function rejection2(data) {
34820
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
34821
+ }
34822
+ async function tokenConfirmation(action, fb) {
34823
+ const subject = await fb.subject();
34824
+ if (isToolResult(subject))
34825
+ return subject;
34826
+ const binding = {
34827
+ tool: fb.tool,
34828
+ ...fb.account === void 0 ? {} : { account: fb.account },
34829
+ target: subject.target,
34830
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
34831
+ payloadHash: hashConfirmPayload(subject.payload)
34832
+ };
34833
+ const phaseOne = () => {
34834
+ const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
34835
+ return {
34836
+ action,
34837
+ preview: subject.preview,
34838
+ confirmToken: token,
34839
+ expiresAt,
34840
+ ttlSeconds: ttlOf(fb.ttlSeconds),
34841
+ instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
34842
+ };
34843
+ };
34844
+ if (!fb.confirmToken) {
34845
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
34846
+ }
34847
+ const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
34848
+ if (verdict.ok)
34849
+ return void 0;
34850
+ if (verdict.error === "DRAFT_CHANGED") {
34851
+ return rejection2({
34852
+ error: "DRAFT_CHANGED",
34853
+ reason: verdict.reason,
34854
+ note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
34855
+ ...phaseOne()
34856
+ });
34857
+ }
34858
+ return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
34859
+ }
34860
+ async function requireConfirmationWithFallback(ctx, options) {
34861
+ const { tokenFallback, ...confirmation } = options;
34862
+ if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
34863
+ return tokenConfirmation(options.action, tokenFallback);
34864
+ }
34865
+ return requireConfirmation(ctx, confirmation);
34866
+ }
34867
+
34868
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34869
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
34870
+
34871
+ // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34872
+ import { homedir } from "node:os";
34873
+ import { isAbsolute, join, resolve } from "node:path";
34874
+ var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34875
+ function readEnvVar(key, opts = {}) {
34876
+ const env = opts.env ?? process.env;
34877
+ const raw = env[key];
34878
+ if (typeof raw === "string") {
34879
+ const trimmed = raw.trim();
34880
+ if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34881
+ return trimmed;
34882
+ }
34883
+ }
34884
+ return opts.default;
34885
+ }
34886
+ var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34887
+ var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34888
+ function parseBoolEnv(key, opts = {}) {
34889
+ const fallback = opts.default ?? false;
34890
+ const raw = readEnvVar(key, { env: opts.env });
34891
+ if (raw === void 0)
34892
+ return fallback;
34893
+ const token = raw.toLowerCase();
34894
+ if (TRUE_TOKENS.has(token))
34895
+ return true;
34896
+ if (FALSE_TOKENS.has(token))
34897
+ return false;
34898
+ return fallback;
34899
+ }
34900
+ function expandPath(p) {
34901
+ let expanded = p;
34902
+ if (p === "~") {
34903
+ expanded = homedir();
34904
+ } else if (p.startsWith("~/")) {
34905
+ expanded = join(homedir(), p.slice(2));
34906
+ }
34907
+ return isAbsolute(expanded) ? expanded : resolve(expanded);
34908
+ }
34909
+
34910
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34911
+ var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
34912
+ var DEFAULT_TTL_SECONDS2 = 600;
34913
+ var warned = /* @__PURE__ */ new Set();
34914
+ function readConfirmMode(env = process.env) {
34915
+ const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
34916
+ if (!raw)
34917
+ return "ask-user";
34918
+ if (MODES.has(raw))
34919
+ return raw;
34920
+ if (!warned.has(raw)) {
34921
+ warned.add(raw);
34922
+ process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
34923
+ `);
34924
+ }
34925
+ return "refuse";
34926
+ }
34927
+ function confirmTtlFromEnv(env = process.env) {
34928
+ const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
34929
+ return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
34930
+ }
34931
+ var processKey;
34932
+ function confirmKeyFromEnv(env = process.env) {
34933
+ const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
34934
+ if (secret)
34935
+ return createHash3("sha256").update(secret, "utf8").digest();
34936
+ processKey ??= randomBytes2(32);
34937
+ return processKey;
34938
+ }
34939
+ var CONFIRM_TOKEN_AUTO_INSTRUCTION = "Nothing has been done yet. Review this preview; if it is what was intended, call again with the same arguments plus confirmToken. (This server runs with MCP_CONFIRM_MODE=auto, so the user's approval in chat is not required.)";
34940
+ var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
34941
+ function confirmationFromEnv(options) {
34942
+ const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
34943
+ const mode = readConfirmMode(env);
34944
+ if (mode === "refuse") {
34945
+ return {
34946
+ ...confirmation,
34947
+ unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
34948
+ };
34949
+ }
34950
+ return {
34951
+ ...confirmation,
34952
+ tokenFallback: {
34953
+ key: confirmKeyFromEnv(env),
34954
+ tool,
34955
+ ...account === void 0 ? {} : { account },
34956
+ ...confirmToken === void 0 ? {} : { confirmToken },
34957
+ subject,
34958
+ ttlSeconds: confirmTtlFromEnv(env),
34959
+ instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
34960
+ ...spent2 === void 0 ? {} : { spent: spent2 }
34961
+ }
34962
+ };
34963
+ }
34964
+
34492
34965
  // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
34493
34966
  var SERVER_PROTOCOL_VERSIONS = Object.freeze([
34494
34967
  "2026-07-28",
@@ -34664,45 +35137,6 @@ function runMcp(opts) {
34664
35137
  return handle;
34665
35138
  }
34666
35139
 
34667
- // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34668
- import { homedir } from "node:os";
34669
- import { isAbsolute, join, resolve } from "node:path";
34670
- var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
34671
- function readEnvVar(key, opts = {}) {
34672
- const env = opts.env ?? process.env;
34673
- const raw = env[key];
34674
- if (typeof raw === "string") {
34675
- const trimmed = raw.trim();
34676
- if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
34677
- return trimmed;
34678
- }
34679
- }
34680
- return opts.default;
34681
- }
34682
- var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
34683
- var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
34684
- function parseBoolEnv(key, opts = {}) {
34685
- const fallback = opts.default ?? false;
34686
- const raw = readEnvVar(key, { env: opts.env });
34687
- if (raw === void 0)
34688
- return fallback;
34689
- const token = raw.toLowerCase();
34690
- if (TRUE_TOKENS.has(token))
34691
- return true;
34692
- if (FALSE_TOKENS.has(token))
34693
- return false;
34694
- return fallback;
34695
- }
34696
- function expandPath(p) {
34697
- let expanded = p;
34698
- if (p === "~") {
34699
- expanded = homedir();
34700
- } else if (p.startsWith("~/")) {
34701
- expanded = join(homedir(), p.slice(2));
34702
- }
34703
- return isAbsolute(expanded) ? expanded : resolve(expanded);
34704
- }
34705
-
34706
35140
  // ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
34707
35141
  import { existsSync, realpathSync } from "node:fs";
34708
35142
  import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
@@ -34784,9 +35218,9 @@ function offsetAt(instant, tz) {
34784
35218
  const w = wallPartsIn(instant, tz);
34785
35219
  const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
34786
35220
  const minutes = Math.round((asUTC - instant.getTime()) / 6e4);
34787
- const sign = minutes < 0 ? "-" : "+";
35221
+ const sign2 = minutes < 0 ? "-" : "+";
34788
35222
  const abs = Math.abs(minutes);
34789
- return `${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
35223
+ return `${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
34790
35224
  }
34791
35225
  function wallPartsIn(instant, tz) {
34792
35226
  const parts = new Intl.DateTimeFormat("en-US", {
@@ -35582,6 +36016,43 @@ function formatAuthHealth(raw, now) {
35582
36016
  return accounts.map((a) => formatOneAccountHealth(a, now)).join("\n\n");
35583
36017
  }
35584
36018
 
36019
+ // ../gogcli-mcp/src/send-confirm-token.ts
36020
+ var spent = createSpentTokenStore();
36021
+ function confirmSpentStore() {
36022
+ return spent;
36023
+ }
36024
+
36025
+ // ../gogcli-mcp/src/dispatch-confirmation.ts
36026
+ var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
36027
+ var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai), a two-step flow applies instead: call WITHOUT confirmToken and nothing is sent or changed \u2014 the result has status "confirmation-required", the full preview and a confirmToken. Follow its instruction (by default: show the preview to the user verbatim and only after they explicitly approve it in chat, call again with the SAME arguments plus confirmToken). The tool re-reads what it would act on and refuses (DRAFT_CHANGED, with a fresh preview and token) if it changed; TOKEN_EXPIRED / TOKEN_REUSED / TOKEN_INVALID also do nothing. A server set to MCP_CONFIRM_MODE=refuse refuses instead.';
36028
+ function gatedElsewhere(what, via, does, tool) {
36029
+ return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
36030
+ }
36031
+ async function requireDispatchConfirmation(ctx, options) {
36032
+ const { action, fallback } = options;
36033
+ const confirmation = {
36034
+ action,
36035
+ message: options.message,
36036
+ details: options.details,
36037
+ confirmationLabel: options.confirmationLabel,
36038
+ ...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
36039
+ };
36040
+ if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
36041
+ return requireConfirmationWithFallback(ctx, confirmationFromEnv({
36042
+ ...confirmation,
36043
+ tool: fallback.tool,
36044
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
36045
+ confirmToken: fallback.confirmToken,
36046
+ subject: fallback.subject,
36047
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
36048
+ spent: confirmSpentStore()
36049
+ }));
36050
+ }
36051
+ function resultText(result) {
36052
+ const first = result.content[0];
36053
+ return first && first.type === "text" && typeof first.text === "string" ? first.text : "{}";
36054
+ }
36055
+
35585
36056
  // ../gogcli-mcp/src/tools/auth.ts
35586
36057
  var AUTH_RUN_SUBCOMMANDS = ["list", "status", "services", "remove", "alias"];
35587
36058
  function registerAuthToolsWith(server, defaultServices) {
@@ -35782,7 +36253,18 @@ function inlineFileArg(flag, attachment, opts = {}) {
35782
36253
  }
35783
36254
 
35784
36255
  // ../gogcli-mcp/src/tools/drive.ts
36256
+ function vetDriveRun(subcommand, _args) {
36257
+ return subcommand.toLowerCase() === "share" ? gatedElsewhere("gog drive share", "gog_drive_run", "grants access to a file", "gog_drive_share") : void 0;
36258
+ }
35785
36259
  var GOOGLE_DOC_MIME = "application/vnd.google-apps.document";
36260
+ function shareTargetMeta(raw) {
36261
+ try {
36262
+ const { name, mimeType } = fileMeta(raw);
36263
+ return { name, mimeType };
36264
+ } catch {
36265
+ return {};
36266
+ }
36267
+ }
35786
36268
  function fileMeta(raw) {
35787
36269
  const parsed = JSON.parse(raw);
35788
36270
  const f = parsed.file ?? parsed;
@@ -35905,7 +36387,7 @@ function registerDriveTools(server) {
35905
36387
  return runOrDiagnose(args, { account });
35906
36388
  });
35907
36389
  server.registerTool("gog_drive_share", {
35908
- description: "Share a Google Drive file or folder.",
36390
+ description: "Share a Google Drive file or folder. Granting access is the risk even though no email is sent (gog does not notify by default), so this reads the file and asks the MCP host to show the user a confirmation prompt naming it, who gets access and with what role; nothing is shared unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
35909
36391
  annotations: { destructiveHint: true },
35910
36392
  inputSchema: external_exports.object({
35911
36393
  fileId: external_exports.string().describe("File or folder ID"),
@@ -35913,9 +36395,35 @@ function registerDriveTools(server) {
35913
36395
  email: external_exports.string().optional().describe("User email (required when to=user)"),
35914
36396
  domain: external_exports.string().optional().describe("Domain (required when to=domain)"),
35915
36397
  role: external_exports.enum(["reader", "writer"]).optional().describe("Permission role (default: reader)"),
35916
- account: accountParam
36398
+ account: accountParam,
36399
+ confirmToken: confirmTokenParam
35917
36400
  })
35918
- }, async ({ fileId, to, email: email3, domain: domain2, role, account }) => {
36401
+ }, async ({ fileId, to, email: email3, domain: domain2, role, account, confirmToken }, ctx) => {
36402
+ const got = await runOrDiagnose(["drive", "get", pos(fileId)], { account });
36403
+ if (got.isError) return got;
36404
+ const file2 = { id: fileId, ...shareTargetMeta(resultText(got)) };
36405
+ const grant = {
36406
+ file: file2,
36407
+ to,
36408
+ ...email3 ? { email: email3 } : {},
36409
+ ...domain2 ? { domain: domain2 } : {},
36410
+ role: role ?? "reader",
36411
+ publicLink: to === "anyone"
36412
+ };
36413
+ const confirmation = await requireDispatchConfirmation(ctx, {
36414
+ action: "drive.share",
36415
+ message: to === "anyone" ? "Review and confirm making this file available to ANYONE with the link:" : "Review and confirm this Drive share:",
36416
+ confirmationLabel: "Confirm that this access should be granted now.",
36417
+ details: grant,
36418
+ unsupportedNote: "Ask the user to share it themselves from Google Drive.",
36419
+ fallback: {
36420
+ tool: "gog_drive_share",
36421
+ account,
36422
+ confirmToken,
36423
+ subject: () => ({ target: fileId, payload: grant, preview: grant })
36424
+ }
36425
+ });
36426
+ if (confirmation) return confirmation;
35919
36427
  const args = ["drive", "share", pos(fileId), `--to=${to}`];
35920
36428
  if (email3) args.push(`--email=${email3}`);
35921
36429
  if (domain2) args.push(`--domain=${domain2}`);
@@ -36028,7 +36536,7 @@ function registerDriveTools(server) {
36028
36536
  return diagnose(err);
36029
36537
  }
36030
36538
  });
36031
- registerRunTool(server, { service: "drive", examples: '"copy", "download", "permissions"' });
36539
+ registerRunTool(server, { service: "drive", examples: '"copy", "download", "permissions"', vet: vetDriveRun });
36032
36540
  }
36033
36541
 
36034
36542
  // ../gogcli-mcp/src/tools/gmail.ts
@@ -36052,7 +36560,7 @@ var replySchema = {
36052
36560
  signatureFile: external_exports.string().optional().describe("Append a local signature file (plain text or HTML), read on the gog server"),
36053
36561
  account: accountParam
36054
36562
  };
36055
- var sendReplySchema = external_exports.object(replySchema);
36563
+ var sendReplySchema = external_exports.object({ ...replySchema, confirmToken: confirmTokenParam });
36056
36564
 
36057
36565
  // ../gogcli-mcp/src/tools/sheets.ts
36058
36566
  var cellValueParam = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]);
@@ -36064,7 +36572,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
36064
36572
  );
36065
36573
 
36066
36574
  // ../gogcli-mcp/src/server.ts
36067
- var VERSION = true ? "4.3.0" : "0.0.0";
36575
+ var VERSION = true ? "4.5.0" : "0.0.0";
36068
36576
 
36069
36577
  // ../gogcli-mcp/src/bootstrap-auth.ts
36070
36578
  import { join as join5 } from "node:path";
@@ -36101,12 +36609,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
36101
36609
  const [clientId, clientSecret, refreshToken, account] = values;
36102
36610
  const { spawner } = options;
36103
36611
  try {
36104
- const { createHash } = await import("node:crypto");
36612
+ const { createHash: createHash4 } = await import("node:crypto");
36105
36613
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
36106
36614
  const home = options.home ?? (await import("node:os")).homedir();
36107
36615
  const dir = join5(home, ".gogcli-mcp");
36108
36616
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
36109
- const fingerprint = createHash("sha256").update(values.join("\0")).digest("hex");
36617
+ const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
36110
36618
  const previous = await readFile(marker, "utf8").catch(() => void 0);
36111
36619
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
36112
36620
  await run(
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp-drive",
5
5
  "display_name": "gogcli (Drive)",
6
- "version": "4.3.0",
6
+ "version": "4.5.0",
7
7
  "description": "Extended Google Drive for Claude via gogcli — auth + full Drive support (upload, download, permissions, comments, shared drives)",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp-drive",
3
- "version": "4.3.0",
3
+ "version": "4.5.0",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp-drive",
5
5
  "description": "Extended Google Drive MCP server via gogcli — auth + full Drive support (upload/download/permissions/comments/shared drives)",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
@@ -24,7 +24,7 @@
24
24
  "test:coverage": "vitest run --coverage"
25
25
  },
26
26
  "dependencies": {
27
- "@chrischall/mcp-utils": "^2.4.0",
27
+ "@chrischall/mcp-utils": "^2.6.0",
28
28
  "@modelcontextprotocol/server": "^2.0.0",
29
29
  "zod": "^4.6.1"
30
30
  },
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "source": "github",
8
8
  "subfolder": "packages/gogcli-mcp-drive"
9
9
  },
10
- "version": "4.3.0",
10
+ "version": "4.5.0",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "gogcli-mcp-drive",
15
- "version": "4.3.0",
15
+ "version": "4.5.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },