gogcli-mcp-calendar 4.3.0 → 4.4.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/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,154 @@ 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
+ var DEFAULT_REQUEST_KEY = "confirmation";
34558
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34559
+ 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";
34560
+ var STATE_PREFIX = "mcpu.confirm.v1.";
34561
+ function canonicalJson(value) {
34562
+ if (value === null || typeof value === "string" || typeof value === "boolean")
34563
+ return JSON.stringify(value);
34564
+ if (value === void 0)
34565
+ return "null";
34566
+ if (typeof value === "number")
34567
+ return Number.isFinite(value) ? JSON.stringify(value) : `{"$num":"${String(value)}"}`;
34568
+ if (typeof value === "bigint")
34569
+ return `{"$bigint":"${value.toString()}"}`;
34570
+ if (typeof value === "function" || typeof value === "symbol") {
34571
+ throw new TypeError(`requireConfirmation: cannot bind a ${typeof value} argument value.`);
34572
+ }
34573
+ if (Array.isArray(value))
34574
+ return `[${value.map(canonicalJson).join(",")}]`;
34575
+ if (value instanceof Date) {
34576
+ return `{"$date":${JSON.stringify(Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString())}}`;
34577
+ }
34578
+ if (ArrayBuffer.isView(value)) {
34579
+ const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
34580
+ return `{"$bytes":${JSON.stringify(bytes.toString("base64"))}}`;
34581
+ }
34582
+ if (value instanceof ArrayBuffer)
34583
+ return `{"$bytes":${JSON.stringify(Buffer.from(value).toString("base64"))}}`;
34584
+ if (value instanceof Map) {
34585
+ const entries2 = [...value.entries()].map(([k, v]) => `[${canonicalJson(k)},${canonicalJson(v)}]`).sort();
34586
+ return `{"$map":[${entries2.join(",")}]}`;
34587
+ }
34588
+ if (value instanceof Set) {
34589
+ return `{"$set":[${[...value].map(canonicalJson).sort().join(",")}]}`;
34590
+ }
34591
+ const proto = Object.getPrototypeOf(value);
34592
+ if (proto !== Object.prototype && proto !== null) {
34593
+ throw new TypeError("requireConfirmation: cannot bind a non-plain object argument value (class instance).");
34594
+ }
34595
+ const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
34596
+ return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
34597
+ }
34598
+ function escapeKey(key) {
34599
+ return key.startsWith("$") ? `$${key}` : key;
34600
+ }
34601
+ function bindingKey(binding) {
34602
+ if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
34603
+ throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
34604
+ }
34605
+ const key = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
34606
+ if (key.length < 32) {
34607
+ throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
34608
+ }
34609
+ return key;
34610
+ }
34611
+ function commitment(action, args) {
34612
+ return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
34613
+ }
34614
+ function mintState(key, action, binding) {
34615
+ const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
34616
+ const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
34617
+ const mac3 = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest("base64url");
34618
+ return `${STATE_PREFIX}${body}.${mac3}`;
34619
+ }
34620
+ function verifyState(key, action, binding, state) {
34621
+ if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
34622
+ return false;
34623
+ const rest = state.slice(STATE_PREFIX.length);
34624
+ const dot = rest.indexOf(".");
34625
+ if (dot < 0)
34626
+ return false;
34627
+ const body = rest.slice(0, dot);
34628
+ const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
34629
+ const expected = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest();
34630
+ if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
34631
+ return false;
34632
+ let payload;
34633
+ try {
34634
+ payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34635
+ } catch {
34636
+ return false;
34637
+ }
34638
+ if (typeof payload.exp !== "number" || payload.exp * 1e3 <= Date.now())
34639
+ return false;
34640
+ const want = Buffer.from(commitment(action, binding.args));
34641
+ const got = Buffer.from(typeof payload.c === "string" ? payload.c : "");
34642
+ return got.length === want.length && timingSafeEqual(got, want);
34643
+ }
34644
+ function echoedState(ctx) {
34645
+ const accessor = ctx.mcpReq.requestState;
34646
+ return typeof accessor === "function" ? accessor() : void 0;
34647
+ }
34648
+ function requireConfirmation(ctx, options) {
34649
+ const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
34650
+ const key = options.binding ? bindingKey(options.binding) : void 0;
34651
+ const confirmationSchema = external_exports.object({
34652
+ confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
34653
+ });
34654
+ const ask = () => {
34655
+ const preview = {
34656
+ action: options.action,
34657
+ ...options.details === void 0 ? {} : { details: options.details }
34658
+ };
34659
+ return inputRequired({
34660
+ inputRequests: {
34661
+ [requestKey]: inputRequired.elicit({
34662
+ message: `${options.message}
34663
+ ${JSON.stringify(preview, null, 2)}`,
34664
+ requestedSchema: confirmationSchema
34665
+ })
34666
+ },
34667
+ ...key && options.binding ? { requestState: mintState(key, options.action, options.binding) } : {}
34668
+ });
34669
+ };
34670
+ const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
34671
+ const accepted = acceptedContent(ctx.mcpReq.inputResponses, requestKey, confirmationSchema);
34672
+ if (response.kind === "missing") {
34673
+ if (callerAcceptsFormElicitation(ctx) === false) {
34674
+ return textResult({
34675
+ confirmed: false,
34676
+ dispatched: false,
34677
+ action: options.action,
34678
+ reason: "confirmation-unsupported",
34679
+ note: options.unsupportedNote ? `${UNSUPPORTED_NOTE}. ${options.unsupportedNote}` : `${UNSUPPORTED_NOTE}.`
34680
+ });
34681
+ }
34682
+ return ask();
34683
+ }
34684
+ if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
34685
+ if (key && options.binding) {
34686
+ const state = echoedState(ctx);
34687
+ if (state === void 0 || state === null) {
34688
+ 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.`);
34689
+ }
34690
+ if (!verifyState(key, options.action, options.binding, state))
34691
+ return ask();
34692
+ }
34693
+ return void 0;
34694
+ }
34695
+ return textResult({
34696
+ confirmed: false,
34697
+ cancelled: true,
34698
+ action: options.action,
34699
+ note: "Nothing was changed because the confirmation was declined, cancelled, or left unchecked."
34700
+ });
34701
+ }
34702
+
34492
34703
  // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
34493
34704
  var SERVER_PROTOCOL_VERSIONS = Object.freeze([
34494
34705
  "2026-07-28",
@@ -34784,9 +34995,9 @@ function offsetAt(instant, tz) {
34784
34995
  const w = wallPartsIn(instant, tz);
34785
34996
  const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
34786
34997
  const minutes = Math.round((asUTC - instant.getTime()) / 6e4);
34787
- const sign = minutes < 0 ? "-" : "+";
34998
+ const sign2 = minutes < 0 ? "-" : "+";
34788
34999
  const abs = Math.abs(minutes);
34789
- return `${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
35000
+ return `${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
34790
35001
  }
34791
35002
  function wallPartsIn(instant, tz) {
34792
35003
  const parts = new Intl.DateTimeFormat("en-US", {
@@ -35600,6 +35811,174 @@ function formatAuthHealth(raw, now) {
35600
35811
  return accounts.map((a) => formatOneAccountHealth(a, now)).join("\n\n");
35601
35812
  }
35602
35813
 
35814
+ // ../gogcli-mcp/src/send-confirm-token.ts
35815
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
35816
+ var CONFIRM_TOKEN_TTL_DEFAULT_SECONDS = 600;
35817
+ var PREFIX = "gct1";
35818
+ var secret;
35819
+ var spent = /* @__PURE__ */ new Map();
35820
+ function sendConfirmFallbackEnabled() {
35821
+ return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
35822
+ }
35823
+ function confirmTokenTtlSeconds() {
35824
+ const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
35825
+ if (raw && /^\d+$/.test(raw)) {
35826
+ const n = Number(raw);
35827
+ if (n > 0) return n;
35828
+ }
35829
+ return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
35830
+ }
35831
+ function hmacKey() {
35832
+ if (!secret) {
35833
+ const configured = readEnvVar("GOG_CONFIRM_SECRET");
35834
+ secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
35835
+ }
35836
+ return secret;
35837
+ }
35838
+ function canonicalize(value) {
35839
+ if (Array.isArray(value)) return value.map(canonicalize);
35840
+ if (value && typeof value === "object") {
35841
+ const out = {};
35842
+ for (const key of Object.keys(value).sort()) {
35843
+ const v = value[key];
35844
+ if (v !== void 0) out[key] = canonicalize(v);
35845
+ }
35846
+ return out;
35847
+ }
35848
+ return value;
35849
+ }
35850
+ function hashSendPayload(payload) {
35851
+ return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
35852
+ }
35853
+ function sign(body) {
35854
+ return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
35855
+ }
35856
+ function issueConfirmToken(binding, now = Date.now()) {
35857
+ const exp = now + confirmTokenTtlSeconds() * 1e3;
35858
+ const claims = {
35859
+ t: binding.tool,
35860
+ a: binding.account,
35861
+ g: binding.target,
35862
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
35863
+ h: binding.payloadHash,
35864
+ iat: now,
35865
+ exp,
35866
+ n: randomBytes(16).toString("base64url")
35867
+ };
35868
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
35869
+ return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
35870
+ }
35871
+ function signatureMatches(body, sig) {
35872
+ const expected = Buffer.from(sign(body), "utf8");
35873
+ const actual = Buffer.from(sig, "utf8");
35874
+ return expected.length === actual.length && timingSafeEqual2(expected, actual);
35875
+ }
35876
+ function parseClaims(body) {
35877
+ try {
35878
+ return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
35879
+ } catch {
35880
+ return void 0;
35881
+ }
35882
+ }
35883
+ function verifyConfirmToken(token, binding, now = Date.now()) {
35884
+ for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
35885
+ const parts = token.split(".");
35886
+ if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
35887
+ const [, body, sig] = parts;
35888
+ if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
35889
+ const claims = parseClaims(body);
35890
+ if (!claims) return { ok: false, error: "TOKEN_INVALID" };
35891
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
35892
+ return { ok: false, error: "TOKEN_INVALID" };
35893
+ }
35894
+ if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
35895
+ if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
35896
+ if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
35897
+ if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
35898
+ spent.set(claims.n, claims.exp);
35899
+ return { ok: true };
35900
+ }
35901
+
35902
+ // ../gogcli-mcp/src/dispatch-confirmation.ts
35903
+ var CONFIRM_ACTION_INSTRUCTION = "Show this preview to the user verbatim and proceed only after they explicitly approve in chat. Then call again with confirmToken.";
35904
+ var FALLBACK_HINT = "Or set GOG_SEND_CONFIRM_FALLBACK=token to enable two-step confirmation.";
35905
+ var CONFIRM_FALLBACK_DESCRIPTION = ' If the client cannot show that prompt (no MCP elicitation, e.g. claude.ai) and the server sets GOG_SEND_CONFIRM_FALLBACK=token, 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. Show that preview to the user verbatim; 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.';
35906
+ var confirmTokenParam = external_exports.string().optional().describe(
35907
+ `ONLY for the two-step fallback (client without MCP elicitation, server with GOG_SEND_CONFIRM_FALLBACK=token). 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.`
35908
+ );
35909
+ var TOKEN_ERROR_NOTE = {
35910
+ 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.",
35911
+ 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.",
35912
+ 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."
35913
+ };
35914
+ var DRAFT_CHANGED_NOTE = {
35915
+ "message-id-rotated": "Nothing was sent or changed: the target was edited since the user approved it (a draft's messageId or an event's version rotated), so what would happen is not what they saw.",
35916
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
35917
+ };
35918
+ function isToolResult(value) {
35919
+ return Array.isArray(value.content);
35920
+ }
35921
+ function rejection2(data) {
35922
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
35923
+ }
35924
+ async function tokenConfirmation(op, fallback) {
35925
+ const subject = await fallback.subject();
35926
+ if (isToolResult(subject)) return subject;
35927
+ const binding = {
35928
+ tool: fallback.tool,
35929
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
35930
+ target: subject.target,
35931
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
35932
+ payloadHash: hashSendPayload(subject.payload)
35933
+ };
35934
+ const phaseOne = () => {
35935
+ const { token, expiresAt } = issueConfirmToken(binding);
35936
+ return {
35937
+ action: op,
35938
+ preview: subject.preview,
35939
+ confirmToken: token,
35940
+ expiresAt,
35941
+ ttlSeconds: confirmTokenTtlSeconds(),
35942
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
35943
+ };
35944
+ };
35945
+ if (!fallback.confirmToken) {
35946
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
35947
+ }
35948
+ const verdict = verifyConfirmToken(fallback.confirmToken, binding);
35949
+ if (verdict.ok) return void 0;
35950
+ if (verdict.error === "DRAFT_CHANGED") {
35951
+ return rejection2({
35952
+ error: "DRAFT_CHANGED",
35953
+ reason: verdict.reason,
35954
+ note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
35955
+ ...phaseOne()
35956
+ });
35957
+ }
35958
+ return rejection2({ error: verdict.error, action: op, note: TOKEN_ERROR_NOTE[verdict.error] });
35959
+ }
35960
+ function gatedElsewhere(what, via, does, tool) {
35961
+ return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
35962
+ }
35963
+ async function requireDispatchConfirmation(ctx, options) {
35964
+ const { action, fallback } = options;
35965
+ if (fallback && callerAcceptsFormElicitation(ctx) === false && sendConfirmFallbackEnabled()) {
35966
+ return tokenConfirmation(action, fallback);
35967
+ }
35968
+ const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
35969
+ return requireConfirmation(ctx, {
35970
+ action,
35971
+ message: options.message,
35972
+ details: options.details,
35973
+ confirmationLabel: options.confirmationLabel,
35974
+ ...note ? { unsupportedNote: note } : {}
35975
+ });
35976
+ }
35977
+ function resultText(result) {
35978
+ const first = result.content[0];
35979
+ return first && first.type === "text" && typeof first.text === "string" ? first.text : "{}";
35980
+ }
35981
+
35603
35982
  // ../gogcli-mcp/src/tools/auth.ts
35604
35983
  var AUTH_RUN_SUBCOMMANDS = ["list", "status", "services", "remove", "alias"];
35605
35984
  function registerAuthToolsWith(server, defaultServices) {
@@ -35735,6 +36114,54 @@ function authToolsFor(defaultServices) {
35735
36114
  }
35736
36115
 
35737
36116
  // ../gogcli-mcp/src/tools/calendar.ts
36117
+ var CALENDAR_GATED = {
36118
+ create: "gog_calendar_create",
36119
+ add: "gog_calendar_create",
36120
+ new: "gog_calendar_create",
36121
+ update: "gog_calendar_update",
36122
+ edit: "gog_calendar_update",
36123
+ set: "gog_calendar_update",
36124
+ respond: "gog_calendar_respond",
36125
+ rsvp: "gog_calendar_respond",
36126
+ reply: "gog_calendar_respond"
36127
+ };
36128
+ function vetCalendarRun(subcommand, _args) {
36129
+ const sub = subcommand.toLowerCase();
36130
+ const tool = Object.hasOwn(CALENDAR_GATED, sub) ? CALENDAR_GATED[sub] : void 0;
36131
+ return tool ? gatedElsewhere(`gog calendar ${sub}`, "gog_calendar_run", "can change what guests see", tool) : void 0;
36132
+ }
36133
+ function parseAttendees(value) {
36134
+ if (!value) return [];
36135
+ return value.split(",").map((entry) => entry.split(";")).filter((parts) => !parts.slice(1).some((m) => m.trim().toLowerCase() === "resource")).map((parts) => parts[0].trim()).filter(Boolean);
36136
+ }
36137
+ function timeOf(t) {
36138
+ const v = t?.dateTime ?? t?.date;
36139
+ return typeof v === "string" ? v : void 0;
36140
+ }
36141
+ function eventSnapshot(raw) {
36142
+ let event;
36143
+ try {
36144
+ event = JSON.parse(raw)?.event;
36145
+ } catch {
36146
+ event = void 0;
36147
+ }
36148
+ const str = (v) => typeof v === "string" ? v : void 0;
36149
+ return {
36150
+ summary: str(event?.summary),
36151
+ start: timeOf(event?.start),
36152
+ end: timeOf(event?.end),
36153
+ organizer: str(event?.organizer?.email),
36154
+ // Guests are the OTHER people: not this account's own attendee row, not rooms.
36155
+ guests: (Array.isArray(event?.attendees) ? event.attendees : []).filter((a) => a.self !== true && a.resource !== true && typeof a.email === "string").map((a) => a.email),
36156
+ etag: str(event?.etag)
36157
+ };
36158
+ }
36159
+ async function readEvent(calendarId, eventId, account) {
36160
+ const got = await runOrDiagnose(["calendar", "event", pos(calendarId), pos(eventId)], { account });
36161
+ if (got.isError) return { error: got };
36162
+ return { event: eventSnapshot(resultText(got)) };
36163
+ }
36164
+ var CALENDAR_CONFIRM_LABEL = "Confirm that this change, which other people will see, should be made now.";
35738
36165
  var reminderParams = {
35739
36166
  reminders: external_exports.array(external_exports.string()).max(5).optional().describe(
35740
36167
  `Reminders as method:duration, e.g. ["popup:30m", "email:1d"]. Method is popup or email; duration accepts m/h/d (max 40320 minutes = 4 weeks). Google allows at most 5. These REPLACE the event's reminders \u2014 on update, pass an EMPTY array to drop custom reminders and go back to the calendar's defaults. Cannot be combined with noReminders.`
@@ -35822,7 +36249,7 @@ function registerCalendarTools(server) {
35822
36249
  return runOrDiagnose(args, { account });
35823
36250
  });
35824
36251
  server.registerTool("gog_calendar_create", {
35825
- description: "Create a calendar event. Set withZoom=true to attach a Zoom meeting (requires Zoom S2S OAuth setup via gog_zoom_auth_setup; the join URL + meeting ID + passcode are appended to the event description \u2014 Google rejects native conference card writes from non-Workspace-Marketplace OAuth clients).",
36252
+ description: "Create a calendar event. Set withZoom=true to attach a Zoom meeting (requires Zoom S2S OAuth setup via gog_zoom_auth_setup; the join URL + meeting ID + passcode are appended to the event description \u2014 Google rejects native conference card writes from non-Workspace-Marketplace OAuth clients). With attendees, the event lands on other people's calendars (no invitation email is sent), so the MCP host is asked to show the user a confirmation prompt with the guests, time and details first; a guest-free event is created without asking." + CONFIRM_FALLBACK_DESCRIPTION,
35826
36253
  annotations: { destructiveHint: false },
35827
36254
  inputSchema: external_exports.object({
35828
36255
  calendarId: external_exports.string().describe('Calendar ID (use "primary" for the default calendar)'),
@@ -35836,9 +36263,10 @@ function registerCalendarTools(server) {
35836
36263
  timezone: external_exports.string().optional().describe("IANA timezone metadata applied to from/to (e.g. America/New_York). Sets both start and end timezone unless start/end timezone are overridden."),
35837
36264
  withZoom: external_exports.boolean().optional().describe("Create a Zoom video conference for this event (requires Zoom S2S OAuth setup)"),
35838
36265
  ...reminderParams,
35839
- account: accountParam
36266
+ account: accountParam,
36267
+ confirmToken: confirmTokenParam
35840
36268
  })
35841
- }, async ({ calendarId, summary, from, to, description, location, attendees, allDay, timezone, withZoom, reminders, noReminders, account }) => {
36269
+ }, async ({ calendarId, summary, from, to, description, location, attendees, allDay, timezone, withZoom, reminders, noReminders, account, confirmToken }, ctx) => {
35842
36270
  const args = ["calendar", "create", pos(calendarId), `--summary=${summary}`, `--from=${from}`, `--to=${to}`];
35843
36271
  if (description) args.push(`--description=${description}`);
35844
36272
  if (location) args.push(`--location=${location}`);
@@ -35847,10 +36275,28 @@ function registerCalendarTools(server) {
35847
36275
  if (timezone) args.push(`--timezone=${timezone}`);
35848
36276
  if (withZoom) args.push("--with-zoom");
35849
36277
  pushReminderFlags(args, { reminders, noReminders });
36278
+ const guests = parseAttendees(attendees);
36279
+ if (guests.length > 0) {
36280
+ const event = { calendarId, summary, from, to, allDay: Boolean(allDay), timezone, location, description, guests, attendees, withZoom: Boolean(withZoom) };
36281
+ const confirmation = await requireDispatchConfirmation(ctx, {
36282
+ action: "calendar.create",
36283
+ message: "Review and confirm this event, which will appear on the guests' calendars:",
36284
+ confirmationLabel: CALENDAR_CONFIRM_LABEL,
36285
+ details: event,
36286
+ unsupportedNote: "Create it without attendees instead; the user can add the guests in Google Calendar.",
36287
+ fallback: {
36288
+ tool: "gog_calendar_create",
36289
+ account,
36290
+ confirmToken,
36291
+ subject: () => ({ target: calendarId, payload: event, preview: event })
36292
+ }
36293
+ });
36294
+ if (confirmation) return confirmation;
36295
+ }
35850
36296
  return runOrDiagnose(args, { account });
35851
36297
  });
35852
36298
  server.registerTool("gog_calendar_update", {
35853
- description: "Update an existing calendar event. Zoom: withZoom adds a Zoom meeting, regenerateZoom replaces the existing one, removeZoom strips it. removeMeet clears the event's Google Meet conference data (e.g. before attaching another provider). Conference flags are independent \u2014 use one per call.",
36299
+ description: "Update an existing calendar event. Zoom: withZoom adds a Zoom meeting, regenerateZoom replaces the existing one, removeZoom strips it. removeMeet clears the event's Google Meet conference data (e.g. before attaching another provider). Conference flags are independent \u2014 use one per call. A change guests can see (time, title, place, description, attendees, attachments, conferencing) on an event that has guests \u2014 or gains them \u2014 reads the event and asks the MCP host to show the user a confirmation prompt with the event as it stands and the change; no invitation email is sent. Reminder-only changes and guest-free events are updated without asking." + CONFIRM_FALLBACK_DESCRIPTION,
35854
36300
  annotations: { destructiveHint: false },
35855
36301
  inputSchema: external_exports.object({
35856
36302
  calendarId: external_exports.string().describe("Calendar ID"),
@@ -35868,9 +36314,10 @@ function registerCalendarTools(server) {
35868
36314
  removeZoom: external_exports.boolean().optional().describe("Remove the event's Zoom video conference"),
35869
36315
  removeMeet: external_exports.boolean().optional().describe("Remove the event's Google Meet video conference (clears conference data only)"),
35870
36316
  ...reminderParams,
35871
- account: accountParam
36317
+ account: accountParam,
36318
+ confirmToken: confirmTokenParam
35872
36319
  })
35873
- }, async ({ calendarId, eventId, summary, from, to, description, location, attendees, addAttendees, attachments, withZoom, regenerateZoom, removeZoom, removeMeet, reminders, noReminders, account }) => {
36320
+ }, async ({ calendarId, eventId, summary, from, to, description, location, attendees, addAttendees, attachments, withZoom, regenerateZoom, removeZoom, removeMeet, reminders, noReminders, account, confirmToken }, ctx) => {
35874
36321
  const args = ["calendar", "update", pos(calendarId), pos(eventId)];
35875
36322
  if (summary !== void 0) args.push(`--summary=${summary}`);
35876
36323
  if (from !== void 0) args.push(`--from=${from}`);
@@ -35885,6 +36332,45 @@ function registerCalendarTools(server) {
35885
36332
  if (removeZoom) args.push("--remove-zoom");
35886
36333
  if (removeMeet) args.push("--remove-meet");
35887
36334
  pushReminderFlags(args, { reminders, noReminders });
36335
+ const changes = Object.fromEntries(Object.entries({
36336
+ summary,
36337
+ from,
36338
+ to,
36339
+ description,
36340
+ location,
36341
+ attendees,
36342
+ addAttendees,
36343
+ attachments,
36344
+ withZoom,
36345
+ regenerateZoom,
36346
+ removeZoom,
36347
+ removeMeet
36348
+ }).filter(([, v]) => v !== void 0 && v !== false));
36349
+ if (Object.keys(changes).length > 0) {
36350
+ const read = await readEvent(calendarId, eventId, account);
36351
+ if (read.error) return read.error;
36352
+ const { etag, ...current } = read.event;
36353
+ const added = [...parseAttendees(attendees), ...parseAttendees(addAttendees)];
36354
+ if (current.guests.length > 0 || added.length > 0) {
36355
+ const view = { calendarId, eventId, current, changes };
36356
+ const confirmation = await requireDispatchConfirmation(ctx, {
36357
+ action: "calendar.update",
36358
+ message: "Review and confirm this change to an event other people are on:",
36359
+ confirmationLabel: CALENDAR_CONFIRM_LABEL,
36360
+ details: view,
36361
+ unsupportedNote: "Ask the user to make this change in Google Calendar.",
36362
+ fallback: {
36363
+ tool: "gog_calendar_update",
36364
+ account,
36365
+ confirmToken,
36366
+ // The etag rotates on any edit, so an event changed elsewhere between
36367
+ // the two phases is DRAFT_CHANGED rather than edited over.
36368
+ subject: () => ({ target: `${calendarId}/${eventId}`, revision: etag, payload: view, preview: view })
36369
+ }
36370
+ });
36371
+ if (confirmation) return confirmation;
36372
+ }
36373
+ }
35888
36374
  return runOrDiagnose(args, { account });
35889
36375
  });
35890
36376
  server.registerTool("gog_calendar_delete", {
@@ -35899,21 +36385,40 @@ function registerCalendarTools(server) {
35899
36385
  return runOrDiagnose(["calendar", "delete", pos(calendarId), pos(eventId), "--force"], { account });
35900
36386
  });
35901
36387
  server.registerTool("gog_calendar_respond", {
35902
- description: "Respond to a calendar event invitation.",
36388
+ description: "Respond to a calendar event invitation. The organizer sees the response, so this reads the event and asks the MCP host to show the user a confirmation prompt with the event, organizer, response and comment; nothing is recorded unless they accept." + CONFIRM_FALLBACK_DESCRIPTION,
35903
36389
  annotations: { destructiveHint: true },
35904
36390
  inputSchema: external_exports.object({
35905
36391
  calendarId: external_exports.string().describe("Calendar ID"),
35906
36392
  eventId: external_exports.string().describe("Event ID"),
35907
36393
  status: external_exports.enum(["accepted", "declined", "tentative"]).describe("Response status"),
35908
36394
  comment: external_exports.string().optional().describe("Optional comment to include with response"),
35909
- account: accountParam
36395
+ account: accountParam,
36396
+ confirmToken: confirmTokenParam
35910
36397
  })
35911
- }, async ({ calendarId, eventId, status, comment, account }) => {
36398
+ }, async ({ calendarId, eventId, status, comment, account, confirmToken }, ctx) => {
35912
36399
  const args = ["calendar", "respond", pos(calendarId), pos(eventId), `--status=${status}`];
35913
36400
  if (comment) args.push(`--comment=${comment}`);
36401
+ const read = await readEvent(calendarId, eventId, account);
36402
+ if (read.error) return read.error;
36403
+ const { etag, ...event } = read.event;
36404
+ const view = { calendarId, eventId, event, response: status, ...comment ? { comment } : {} };
36405
+ const confirmation = await requireDispatchConfirmation(ctx, {
36406
+ action: "calendar.respond",
36407
+ message: "Review and confirm this response, which the organizer will see:",
36408
+ confirmationLabel: "Confirm that this response should be recorded now.",
36409
+ details: view,
36410
+ unsupportedNote: "Ask the user to respond from Google Calendar.",
36411
+ fallback: {
36412
+ tool: "gog_calendar_respond",
36413
+ account,
36414
+ confirmToken,
36415
+ subject: () => ({ target: `${calendarId}/${eventId}`, revision: etag, payload: view, preview: view })
36416
+ }
36417
+ });
36418
+ if (confirmation) return confirmation;
35914
36419
  return runOrDiagnose(args, { account });
35915
36420
  });
35916
- registerRunTool(server, { service: "calendar", examples: '"calendars", "freebusy"' });
36421
+ registerRunTool(server, { service: "calendar", examples: '"calendars", "freebusy"', vet: vetCalendarRun });
35917
36422
  }
35918
36423
 
35919
36424
  // ../gogcli-mcp/src/attachments.ts
@@ -35957,7 +36462,7 @@ var replySchema = {
35957
36462
  signatureFile: external_exports.string().optional().describe("Append a local signature file (plain text or HTML), read on the gog server"),
35958
36463
  account: accountParam
35959
36464
  };
35960
- var sendReplySchema = external_exports.object(replySchema);
36465
+ var sendReplySchema = external_exports.object({ ...replySchema, confirmToken: confirmTokenParam });
35961
36466
 
35962
36467
  // ../gogcli-mcp/src/tools/sheets.ts
35963
36468
  var cellValueParam = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]);
@@ -35969,7 +36474,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
35969
36474
  );
35970
36475
 
35971
36476
  // ../gogcli-mcp/src/server.ts
35972
- var VERSION = true ? "4.3.0" : "0.0.0";
36477
+ var VERSION = true ? "4.4.0" : "0.0.0";
35973
36478
 
35974
36479
  // ../gogcli-mcp/src/bootstrap-auth.ts
35975
36480
  import { join as join5 } from "node:path";
@@ -36006,12 +36511,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
36006
36511
  const [clientId, clientSecret, refreshToken, account] = values;
36007
36512
  const { spawner } = options;
36008
36513
  try {
36009
- const { createHash } = await import("node:crypto");
36514
+ const { createHash: createHash3 } = await import("node:crypto");
36010
36515
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
36011
36516
  const home = options.home ?? (await import("node:os")).homedir();
36012
36517
  const dir = join5(home, ".gogcli-mcp");
36013
36518
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
36014
- const fingerprint = createHash("sha256").update(values.join("\0")).digest("hex");
36519
+ const fingerprint = createHash3("sha256").update(values.join("\0")).digest("hex");
36015
36520
  const previous = await readFile(marker, "utf8").catch(() => void 0);
36016
36521
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
36017
36522
  await run(
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp-calendar",
5
5
  "display_name": "gogcli (Calendar)",
6
- "version": "4.3.0",
6
+ "version": "4.4.0",
7
7
  "description": "Extended Google Calendar for Claude via gogcli — auth + Calendar events + Meet space management",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp-calendar",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp-calendar",
5
5
  "description": "Extended Google Calendar + Meet MCP server via gogcli — auth + Calendar events + Meet space management",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",