gogcli-mcp 4.4.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.
package/dist/lib.js CHANGED
@@ -33017,10 +33017,8 @@ function errorResult(message) {
33017
33017
 
33018
33018
  // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
33019
33019
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
33020
- var DEFAULT_REQUEST_KEY = "confirmation";
33021
- var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
33022
- 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";
33023
- var STATE_PREFIX = "mcpu.confirm.v1.";
33020
+
33021
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
33024
33022
  function canonicalJson(value) {
33025
33023
  if (value === null || typeof value === "string" || typeof value === "boolean")
33026
33024
  return JSON.stringify(value);
@@ -33031,7 +33029,7 @@ function canonicalJson(value) {
33031
33029
  if (typeof value === "bigint")
33032
33030
  return `{"$bigint":"${value.toString()}"}`;
33033
33031
  if (typeof value === "function" || typeof value === "symbol") {
33034
- throw new TypeError(`requireConfirmation: cannot bind a ${typeof value} argument value.`);
33032
+ throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
33035
33033
  }
33036
33034
  if (Array.isArray(value))
33037
33035
  return `[${value.map(canonicalJson).join(",")}]`;
@@ -33053,7 +33051,7 @@ function canonicalJson(value) {
33053
33051
  }
33054
33052
  const proto = Object.getPrototypeOf(value);
33055
33053
  if (proto !== Object.prototype && proto !== null) {
33056
- throw new TypeError("requireConfirmation: cannot bind a non-plain object argument value (class instance).");
33054
+ throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
33057
33055
  }
33058
33056
  const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
33059
33057
  return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
@@ -33061,6 +33059,12 @@ function canonicalJson(value) {
33061
33059
  function escapeKey(key) {
33062
33060
  return key.startsWith("$") ? `$${key}` : key;
33063
33061
  }
33062
+
33063
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
33064
+ var DEFAULT_REQUEST_KEY = "confirmation";
33065
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
33066
+ 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";
33067
+ var STATE_PREFIX = "mcpu.confirm.v1.";
33064
33068
  function bindingKey(binding) {
33065
33069
  if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
33066
33070
  throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
@@ -33163,11 +33167,169 @@ ${JSON.stringify(preview, null, 2)}`,
33163
33167
  });
33164
33168
  }
33165
33169
 
33166
- // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
33167
- var SERVER_PROTOCOL_VERSIONS = Object.freeze([
33168
- "2026-07-28",
33169
- ...SUPPORTED_PROTOCOL_VERSIONS
33170
- ]);
33170
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
33171
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
33172
+ function createSpentTokenStore() {
33173
+ const spent2 = /* @__PURE__ */ new Map();
33174
+ return {
33175
+ has: (nonce) => spent2.has(nonce),
33176
+ add: (nonce, exp) => {
33177
+ spent2.set(nonce, exp);
33178
+ },
33179
+ prune: (now) => {
33180
+ for (const [nonce, exp] of spent2)
33181
+ if (exp < now)
33182
+ spent2.delete(nonce);
33183
+ },
33184
+ clear: () => spent2.clear(),
33185
+ get size() {
33186
+ return spent2.size;
33187
+ }
33188
+ };
33189
+ }
33190
+ var PROCESS_SPENT = createSpentTokenStore();
33191
+ var PREFIX = "mcpu.token.v1.";
33192
+ var DEFAULT_TTL_SECONDS = 600;
33193
+ function tokenKey(key) {
33194
+ const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
33195
+ if (bytes.length < 32)
33196
+ throw new RangeError("confirm token: key must be at least 32 bytes.");
33197
+ return bytes;
33198
+ }
33199
+ function ttlOf(ttlSeconds) {
33200
+ if (ttlSeconds === void 0)
33201
+ return DEFAULT_TTL_SECONDS;
33202
+ if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
33203
+ throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
33204
+ }
33205
+ return ttlSeconds;
33206
+ }
33207
+ function sign(key, body) {
33208
+ return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
33209
+ }
33210
+ function hashConfirmPayload(payload) {
33211
+ return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
33212
+ }
33213
+ function issueConfirmToken(key, binding, options = {}) {
33214
+ const k = tokenKey(key);
33215
+ const now = options.now ?? Date.now();
33216
+ const exp = now + ttlOf(options.ttlSeconds) * 1e3;
33217
+ const claims = {
33218
+ t: binding.tool,
33219
+ ...binding.account === void 0 ? {} : { a: binding.account },
33220
+ g: binding.target,
33221
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
33222
+ h: binding.payloadHash,
33223
+ exp,
33224
+ n: randomBytes(16).toString("base64url")
33225
+ };
33226
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
33227
+ return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
33228
+ }
33229
+ function parseClaims(body) {
33230
+ try {
33231
+ const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
33232
+ return claims && typeof claims === "object" ? claims : void 0;
33233
+ } catch {
33234
+ return void 0;
33235
+ }
33236
+ }
33237
+ function verifyConfirmToken(key, token, binding, options = {}) {
33238
+ const k = tokenKey(key);
33239
+ const now = options.now ?? Date.now();
33240
+ const spent2 = options.spent ?? PROCESS_SPENT;
33241
+ spent2.prune(now);
33242
+ if (!token.startsWith(PREFIX))
33243
+ return { ok: false, error: "TOKEN_INVALID" };
33244
+ const rest = token.slice(PREFIX.length);
33245
+ const dot = rest.indexOf(".");
33246
+ const body = dot < 0 ? "" : rest.slice(0, dot);
33247
+ const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
33248
+ const expected = sign(k, body);
33249
+ if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
33250
+ return { ok: false, error: "TOKEN_INVALID" };
33251
+ const claims = parseClaims(body);
33252
+ if (!claims)
33253
+ return { ok: false, error: "TOKEN_INVALID" };
33254
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
33255
+ return { ok: false, error: "TOKEN_INVALID" };
33256
+ }
33257
+ if (spent2.has(claims.n))
33258
+ return { ok: false, error: "TOKEN_REUSED" };
33259
+ if (now > claims.exp)
33260
+ return { ok: false, error: "TOKEN_EXPIRED" };
33261
+ if (claims.r !== binding.revision)
33262
+ return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
33263
+ if (claims.h !== binding.payloadHash)
33264
+ return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
33265
+ spent2.add(claims.n, claims.exp);
33266
+ return { ok: true };
33267
+ }
33268
+ 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.";
33269
+ 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.`);
33270
+ var TOKEN_ERROR_NOTE = {
33271
+ 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.",
33272
+ 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.",
33273
+ 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."
33274
+ };
33275
+ var CHANGED_NOTE = {
33276
+ "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.",
33277
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
33278
+ };
33279
+ function isToolResult(value) {
33280
+ return Array.isArray(value.content);
33281
+ }
33282
+ function rejection(data) {
33283
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
33284
+ }
33285
+ async function tokenConfirmation(action, fb) {
33286
+ const subject = await fb.subject();
33287
+ if (isToolResult(subject))
33288
+ return subject;
33289
+ const binding = {
33290
+ tool: fb.tool,
33291
+ ...fb.account === void 0 ? {} : { account: fb.account },
33292
+ target: subject.target,
33293
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
33294
+ payloadHash: hashConfirmPayload(subject.payload)
33295
+ };
33296
+ const phaseOne = () => {
33297
+ const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
33298
+ return {
33299
+ action,
33300
+ preview: subject.preview,
33301
+ confirmToken: token,
33302
+ expiresAt,
33303
+ ttlSeconds: ttlOf(fb.ttlSeconds),
33304
+ instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
33305
+ };
33306
+ };
33307
+ if (!fb.confirmToken) {
33308
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
33309
+ }
33310
+ const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
33311
+ if (verdict.ok)
33312
+ return void 0;
33313
+ if (verdict.error === "DRAFT_CHANGED") {
33314
+ return rejection({
33315
+ error: "DRAFT_CHANGED",
33316
+ reason: verdict.reason,
33317
+ note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
33318
+ ...phaseOne()
33319
+ });
33320
+ }
33321
+ return rejection({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
33322
+ }
33323
+ async function requireConfirmationWithFallback(ctx, options) {
33324
+ const { tokenFallback, ...confirmation } = options;
33325
+ if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
33326
+ return tokenConfirmation(options.action, tokenFallback);
33327
+ }
33328
+ return requireConfirmation(ctx, confirmation);
33329
+ }
33330
+
33331
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
33332
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
33171
33333
 
33172
33334
  // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
33173
33335
  import { homedir } from "node:os";
@@ -33208,6 +33370,67 @@ function expandPath(p) {
33208
33370
  return isAbsolute(expanded) ? expanded : resolve(expanded);
33209
33371
  }
33210
33372
 
33373
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
33374
+ var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
33375
+ var DEFAULT_TTL_SECONDS2 = 600;
33376
+ var warned = /* @__PURE__ */ new Set();
33377
+ function readConfirmMode(env = process.env) {
33378
+ const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
33379
+ if (!raw)
33380
+ return "ask-user";
33381
+ if (MODES.has(raw))
33382
+ return raw;
33383
+ if (!warned.has(raw)) {
33384
+ warned.add(raw);
33385
+ process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
33386
+ `);
33387
+ }
33388
+ return "refuse";
33389
+ }
33390
+ function confirmTtlFromEnv(env = process.env) {
33391
+ const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
33392
+ return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
33393
+ }
33394
+ var processKey;
33395
+ function confirmKeyFromEnv(env = process.env) {
33396
+ const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
33397
+ if (secret)
33398
+ return createHash3("sha256").update(secret, "utf8").digest();
33399
+ processKey ??= randomBytes2(32);
33400
+ return processKey;
33401
+ }
33402
+ 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.)";
33403
+ var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
33404
+ function confirmationFromEnv(options) {
33405
+ const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
33406
+ const mode = readConfirmMode(env);
33407
+ if (mode === "refuse") {
33408
+ return {
33409
+ ...confirmation,
33410
+ unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
33411
+ };
33412
+ }
33413
+ return {
33414
+ ...confirmation,
33415
+ tokenFallback: {
33416
+ key: confirmKeyFromEnv(env),
33417
+ tool,
33418
+ ...account === void 0 ? {} : { account },
33419
+ ...confirmToken === void 0 ? {} : { confirmToken },
33420
+ subject,
33421
+ ttlSeconds: confirmTtlFromEnv(env),
33422
+ instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
33423
+ ...spent2 === void 0 ? {} : { spent: spent2 }
33424
+ }
33425
+ };
33426
+ }
33427
+
33428
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
33429
+ var SERVER_PROTOCOL_VERSIONS = Object.freeze([
33430
+ "2026-07-28",
33431
+ ...SUPPORTED_PROTOCOL_VERSIONS
33432
+ ]);
33433
+
33211
33434
  // ../../node_modules/@chrischall/mcp-utils/dist/fs/confine.js
33212
33435
  import { existsSync, realpathSync } from "node:fs";
33213
33436
  import { dirname, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "node:path";
@@ -34200,95 +34423,13 @@ function assertNotBoth(inlineParam, fileParam, inlineValue, fileValue) {
34200
34423
  }
34201
34424
 
34202
34425
  // src/dispatch-confirmation.ts
34203
- import { createHash as createHash3 } from "node:crypto";
34426
+ import { createHash as createHash4 } from "node:crypto";
34204
34427
  import { readFileSync } from "node:fs";
34205
34428
 
34206
34429
  // src/send-confirm-token.ts
34207
- import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
34208
- var CONFIRM_TOKEN_TTL_DEFAULT_SECONDS = 600;
34209
- var PREFIX = "gct1";
34210
- var secret;
34211
- var spent = /* @__PURE__ */ new Map();
34212
- function sendConfirmFallbackEnabled() {
34213
- return readEnvVar("GOG_SEND_CONFIRM_FALLBACK")?.trim().toLowerCase() === "token";
34214
- }
34215
- function confirmTokenTtlSeconds() {
34216
- const raw = readEnvVar("GOG_CONFIRM_TTL_SECONDS")?.trim();
34217
- if (raw && /^\d+$/.test(raw)) {
34218
- const n = Number(raw);
34219
- if (n > 0) return n;
34220
- }
34221
- return CONFIRM_TOKEN_TTL_DEFAULT_SECONDS;
34222
- }
34223
- function hmacKey() {
34224
- if (!secret) {
34225
- const configured = readEnvVar("GOG_CONFIRM_SECRET");
34226
- secret = configured ? Buffer.from(configured, "utf8") : randomBytes(32);
34227
- }
34228
- return secret;
34229
- }
34230
- function canonicalize(value) {
34231
- if (Array.isArray(value)) return value.map(canonicalize);
34232
- if (value && typeof value === "object") {
34233
- const out = {};
34234
- for (const key of Object.keys(value).sort()) {
34235
- const v = value[key];
34236
- if (v !== void 0) out[key] = canonicalize(v);
34237
- }
34238
- return out;
34239
- }
34240
- return value;
34241
- }
34242
- function hashSendPayload(payload) {
34243
- return createHash2("sha256").update(JSON.stringify(canonicalize(payload))).digest("hex");
34244
- }
34245
- function sign(body) {
34246
- return createHmac2("sha256", hmacKey()).update(`${PREFIX}.${body}`).digest("base64url");
34247
- }
34248
- function issueConfirmToken(binding, now = Date.now()) {
34249
- const exp = now + confirmTokenTtlSeconds() * 1e3;
34250
- const claims = {
34251
- t: binding.tool,
34252
- a: binding.account,
34253
- g: binding.target,
34254
- ...binding.revision === void 0 ? {} : { r: binding.revision },
34255
- h: binding.payloadHash,
34256
- iat: now,
34257
- exp,
34258
- n: randomBytes(16).toString("base64url")
34259
- };
34260
- const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
34261
- return { token: `${PREFIX}.${body}.${sign(body)}`, expiresAt: new Date(exp).toISOString() };
34262
- }
34263
- function signatureMatches(body, sig) {
34264
- const expected = Buffer.from(sign(body), "utf8");
34265
- const actual = Buffer.from(sig, "utf8");
34266
- return expected.length === actual.length && timingSafeEqual2(expected, actual);
34267
- }
34268
- function parseClaims(body) {
34269
- try {
34270
- return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34271
- } catch {
34272
- return void 0;
34273
- }
34274
- }
34275
- function verifyConfirmToken(token, binding, now = Date.now()) {
34276
- for (const [nonce, exp] of spent) if (exp < now) spent.delete(nonce);
34277
- const parts = token.split(".");
34278
- if (parts.length !== 3 || parts[0] !== PREFIX || !parts[1] || !parts[2]) return { ok: false, error: "TOKEN_INVALID" };
34279
- const [, body, sig] = parts;
34280
- if (!signatureMatches(body, sig)) return { ok: false, error: "TOKEN_INVALID" };
34281
- const claims = parseClaims(body);
34282
- if (!claims) return { ok: false, error: "TOKEN_INVALID" };
34283
- if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
34284
- return { ok: false, error: "TOKEN_INVALID" };
34285
- }
34286
- if (spent.has(claims.n)) return { ok: false, error: "TOKEN_REUSED" };
34287
- if (now > claims.exp) return { ok: false, error: "TOKEN_EXPIRED" };
34288
- if (claims.r !== binding.revision) return { ok: false, error: "DRAFT_CHANGED", reason: "message-id-rotated" };
34289
- if (claims.h !== binding.payloadHash) return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
34290
- spent.set(claims.n, claims.exp);
34291
- return { ok: true };
34430
+ var spent = createSpentTokenStore();
34431
+ function confirmSpentStore() {
34432
+ return spent;
34292
34433
  }
34293
34434
 
34294
34435
  // src/dispatch-confirmation.ts
@@ -34310,13 +34451,13 @@ function attachmentDetails(paths, inline) {
34310
34451
  } catch {
34311
34452
  bytes = void 0;
34312
34453
  }
34313
- out.push(bytes ? { name: path, size: bytes.length, sha256: createHash3("sha256").update(bytes).digest("hex") } : { name: path, size: null });
34454
+ out.push(bytes ? { name: path, size: bytes.length, sha256: createHash4("sha256").update(bytes).digest("hex") } : { name: path, size: null });
34314
34455
  }
34315
34456
  for (const a of inline ?? []) {
34316
34457
  out.push({
34317
34458
  name: a.filename,
34318
34459
  size: Buffer.from(a.contentBase64, "base64").length,
34319
- sha256: createHash3("sha256").update(a.contentBase64).digest("hex")
34460
+ sha256: createHash4("sha256").update(a.contentBase64).digest("hex")
34320
34461
  });
34321
34462
  }
34322
34463
  return out;
@@ -34328,63 +34469,8 @@ function attachmentPreview(details) {
34328
34469
  return details.map(({ name, size }) => ({ name, size }));
34329
34470
  }
34330
34471
  var CONFIRM_SEND_INSTRUCTION = "Show this preview to the user verbatim and send only after they explicitly approve in chat. Then call again with confirmToken.";
34331
- 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.";
34332
- var FALLBACK_HINT = "Or set GOG_SEND_CONFIRM_FALLBACK=token to enable two-step confirmation.";
34333
- 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.';
34334
- var confirmTokenParam = external_exports.string().optional().describe(
34335
- `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.`
34336
- );
34337
- var TOKEN_ERROR_NOTE = {
34338
- 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.",
34339
- 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.",
34340
- 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."
34341
- };
34342
- var DRAFT_CHANGED_NOTE = {
34343
- "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.",
34344
- "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
34345
- };
34346
- function isToolResult(value) {
34347
- return Array.isArray(value.content);
34348
- }
34349
- function rejection(data) {
34350
- return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
34351
- }
34352
- async function tokenConfirmation(op, fallback) {
34353
- const subject = await fallback.subject();
34354
- if (isToolResult(subject)) return subject;
34355
- const binding = {
34356
- tool: fallback.tool,
34357
- account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
34358
- target: subject.target,
34359
- ...subject.revision === void 0 ? {} : { revision: subject.revision },
34360
- payloadHash: hashSendPayload(subject.payload)
34361
- };
34362
- const phaseOne = () => {
34363
- const { token, expiresAt } = issueConfirmToken(binding);
34364
- return {
34365
- action: op,
34366
- preview: subject.preview,
34367
- confirmToken: token,
34368
- expiresAt,
34369
- ttlSeconds: confirmTokenTtlSeconds(),
34370
- instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION
34371
- };
34372
- };
34373
- if (!fallback.confirmToken) {
34374
- return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
34375
- }
34376
- const verdict = verifyConfirmToken(fallback.confirmToken, binding);
34377
- if (verdict.ok) return void 0;
34378
- if (verdict.error === "DRAFT_CHANGED") {
34379
- return rejection({
34380
- error: "DRAFT_CHANGED",
34381
- reason: verdict.reason,
34382
- note: `${DRAFT_CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
34383
- ...phaseOne()
34384
- });
34385
- }
34386
- return rejection({ error: verdict.error, action: op, note: TOKEN_ERROR_NOTE[verdict.error] });
34387
- }
34472
+ var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
34473
+ 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.';
34388
34474
  function gatedElsewhere(what, via, does, tool) {
34389
34475
  return `${what} ${does} and is not available through ${via}. Use ${tool}, which asks the user to confirm.`;
34390
34476
  }
@@ -34393,17 +34479,23 @@ function hasCommandWord(args, words) {
34393
34479
  }
34394
34480
  async function requireDispatchConfirmation(ctx, options) {
34395
34481
  const { action, fallback } = options;
34396
- if (fallback && callerAcceptsFormElicitation(ctx) === false && sendConfirmFallbackEnabled()) {
34397
- return tokenConfirmation(action, fallback);
34398
- }
34399
- const note = fallback ? [options.unsupportedNote, FALLBACK_HINT].filter(Boolean).join(" ") : options.unsupportedNote;
34400
- return requireConfirmation(ctx, {
34482
+ const confirmation = {
34401
34483
  action,
34402
34484
  message: options.message,
34403
34485
  details: options.details,
34404
34486
  confirmationLabel: options.confirmationLabel,
34405
- ...note ? { unsupportedNote: note } : {}
34406
- });
34487
+ ...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
34488
+ };
34489
+ if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
34490
+ return requireConfirmationWithFallback(ctx, confirmationFromEnv({
34491
+ ...confirmation,
34492
+ tool: fallback.tool,
34493
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
34494
+ confirmToken: fallback.confirmToken,
34495
+ subject: fallback.subject,
34496
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
34497
+ spent: confirmSpentStore()
34498
+ }));
34407
34499
  }
34408
34500
  function resultText(result) {
34409
34501
  const first = result.content[0];
@@ -37121,7 +37213,7 @@ function registerTasksTools(server) {
37121
37213
  }
37122
37214
 
37123
37215
  // src/server.ts
37124
- var VERSION = true ? "4.4.0" : "0.0.0";
37216
+ var VERSION = true ? "4.5.0" : "0.0.0";
37125
37217
  var BASE_TOOL_REGISTRARS = [
37126
37218
  registerApiTools,
37127
37219
  registerAppScriptTools,
@@ -37173,12 +37265,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
37173
37265
  const [clientId, clientSecret, refreshToken, account] = values;
37174
37266
  const { spawner } = options;
37175
37267
  try {
37176
- const { createHash: createHash4 } = await import("node:crypto");
37268
+ const { createHash: createHash5 } = await import("node:crypto");
37177
37269
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
37178
37270
  const home = options.home ?? (await import("node:os")).homedir();
37179
37271
  const dir = join5(home, ".gogcli-mcp");
37180
37272
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
37181
- const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
37273
+ const fingerprint = createHash5("sha256").update(values.join("\0")).digest("hex");
37182
37274
  const previous = await readFile(marker, "utf8").catch(() => void 0);
37183
37275
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
37184
37276
  await run(
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp",
5
5
  "display_name": "gogcli",
6
- "version": "4.4.0",
6
+ "version": "4.5.0",
7
7
  "description": "Google Sheets (and more) for Claude via gogcli — read, write, and manage spreadsheets",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp",
5
5
  "description": "MCP server wrapping gogcli for Google service access",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
@@ -41,7 +41,7 @@
41
41
  "test:coverage": "vitest run --coverage"
42
42
  },
43
43
  "dependencies": {
44
- "@chrischall/mcp-utils": "^2.4.0",
44
+ "@chrischall/mcp-utils": "^2.6.0",
45
45
  "@modelcontextprotocol/server": "^2.0.0",
46
46
  "zod": "^4.6.1"
47
47
  },
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "source": "github",
8
8
  "subfolder": "packages/gogcli-mcp"
9
9
  },
10
- "version": "4.4.0",
10
+ "version": "4.5.0",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "gogcli-mcp",
15
- "version": "4.4.0",
15
+ "version": "4.5.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },