gogcli-mcp-sheets 4.5.0 → 4.5.2

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;
@@ -19763,7 +19790,7 @@ function date4(params) {
19763
19790
  return _coercedDate(ZodDate, params);
19764
19791
  }
19765
19792
 
19766
- // ../../node_modules/@modelcontextprotocol/core/dist/auth-CUe6YdwF.mjs
19793
+ // ../../node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/dist/auth-CGP0BDVq.mjs
19767
19794
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
19768
19795
  var SUPPORTED_PROTOCOL_VERSIONS = [
19769
19796
  LATEST_PROTOCOL_VERSION,
@@ -20600,7 +20627,8 @@ var OAuthMetadataSchema = looseObject({
20600
20627
  introspection_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
20601
20628
  code_challenge_methods_supported: array(string2()).optional(),
20602
20629
  client_id_metadata_document_supported: boolean2().optional(),
20603
- authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0)
20630
+ authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0),
20631
+ dpop_signing_alg_values_supported: array(string2()).optional()
20604
20632
  });
20605
20633
  var OpenIdProviderMetadataSchema = looseObject({
20606
20634
  issuer: string2(),
@@ -20701,7 +20729,7 @@ var OAuthTokenRevocationRequestSchema = object({
20701
20729
  token_type_hint: string2().optional()
20702
20730
  }).strip();
20703
20731
 
20704
- // ../../node_modules/@modelcontextprotocol/server/dist/src-CX2iR2pK.mjs
20732
+ // ../../node_modules/@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs
20705
20733
  var BRANDS = /* @__PURE__ */ Symbol.for("mcp.sdk.errorBrands");
20706
20734
  function stampErrorBrands(instance, ctor) {
20707
20735
  const brands = /* @__PURE__ */ new Set();
@@ -20815,8 +20843,18 @@ var SdkError = class extends Error {
20815
20843
  if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
20816
20844
  return brandedHasInstance(this, value);
20817
20845
  }
20818
- constructor(code, message, data) {
20819
- super(message);
20846
+ /**
20847
+ * @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
20848
+ * @param message - Human-readable description.
20849
+ * @param data - Optional structured payload (for example the HTTP status carried by
20850
+ * {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
20851
+ * promoted to `Error.cause`.
20852
+ * @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
20853
+ * failure as `{ cause }` so it is reachable through the `Error.cause` chain that
20854
+ * loggers and error trackers walk.
20855
+ */
20856
+ constructor(code, message, data, options) {
20857
+ super(message, options);
20820
20858
  this.code = code;
20821
20859
  this.data = data;
20822
20860
  this.name = "SdkError";
@@ -20827,8 +20865,11 @@ var SdkHttpError = class extends SdkError {
20827
20865
  static {
20828
20866
  Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
20829
20867
  }
20830
- constructor(code, message, data) {
20831
- super(code, message, data);
20868
+ /**
20869
+ * @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
20870
+ */
20871
+ constructor(code, message, data, options) {
20872
+ super(code, message, data, options);
20832
20873
  this.name = "SdkHttpError";
20833
20874
  }
20834
20875
  get status() {
@@ -23779,7 +23820,7 @@ var INBOUND_VALIDATION_LADDER = [
23779
23820
  evaluatedAt: "pre-dispatch",
23780
23821
  codes: [HEADER_MISMATCH_ERROR_CODE],
23781
23822
  conformance: ["http-header-validation"],
23782
- rationale: "SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
23823
+ rationale: "SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
23783
23824
  },
23784
23825
  {
23785
23826
  rung: "client-capabilities",
@@ -24101,6 +24142,37 @@ var inputRequired = Object.assign(buildInputRequired, {
24101
24142
  return { method: "roots/list" };
24102
24143
  }
24103
24144
  });
24145
+ function acceptedContent(responses, key, schema) {
24146
+ const view = inputResponse(responses, key);
24147
+ if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
24148
+ if (schema === void 0) return view.content;
24149
+ const outcome = schema["~standard"].validate(view.content);
24150
+ if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
24151
+ return outcome.issues === void 0 ? outcome.value : void 0;
24152
+ }
24153
+ function inputResponse(responses, key) {
24154
+ if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
24155
+ const entry = responses[key];
24156
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
24157
+ const candidate = entry;
24158
+ if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
24159
+ const content = candidate["content"];
24160
+ return {
24161
+ kind: "elicit",
24162
+ action: candidate["action"],
24163
+ ...content !== null && typeof content === "object" && !Array.isArray(content) && { content }
24164
+ };
24165
+ }
24166
+ if (Array.isArray(candidate["roots"])) return {
24167
+ kind: "roots",
24168
+ roots: candidate["roots"]
24169
+ };
24170
+ if (typeof candidate["role"] === "string" && candidate["content"] !== void 0) return {
24171
+ kind: "sampling",
24172
+ result: candidate
24173
+ };
24174
+ return { kind: "missing" };
24175
+ }
24104
24176
  var REQUEST_STATE_ONLY_LEG_PACING_MS = 250;
24105
24177
  function inputRequiredRoundsExceededMessage(method, maxRounds) {
24106
24178
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
@@ -24549,7 +24621,7 @@ var Protocol = class {
24549
24621
  return this._requestHandlers.get(method);
24550
24622
  }
24551
24623
  async _oncancel(notification) {
24552
- if (!notification.params.requestId) return;
24624
+ if (notification.params.requestId === void 0) return;
24553
24625
  this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
24554
24626
  }
24555
24627
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
@@ -24948,19 +25020,20 @@ var Protocol = class {
24948
25020
  const cancel = (reason) => {
24949
25021
  if (responseReceived) return;
24950
25022
  this._progressHandlers.delete(messageId);
24951
- if (requestAbort === void 0) this._transport?.send(this._envelopeOutbound({
24952
- jsonrpc: "2.0",
24953
- method: "notifications/cancelled",
24954
- params: {
24955
- requestId: messageId,
24956
- reason: String(reason)
24957
- }
24958
- }), {
24959
- relatedRequestId,
24960
- resumptionToken,
24961
- onresumptiontoken
24962
- }).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error62}`)));
24963
- else requestAbort.abort();
25023
+ if (requestAbort === void 0) {
25024
+ if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
25025
+ jsonrpc: "2.0",
25026
+ method: "notifications/cancelled",
25027
+ params: {
25028
+ requestId: messageId,
25029
+ reason: String(reason)
25030
+ }
25031
+ }), {
25032
+ relatedRequestId,
25033
+ resumptionToken,
25034
+ onresumptiontoken
25035
+ }).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error62}`)));
25036
+ } else requestAbort.abort();
24964
25037
  reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
24965
25038
  };
24966
25039
  this._responseHandlers.set(messageId, (response) => {
@@ -25040,7 +25113,7 @@ var Protocol = class {
25040
25113
  jsonrpc: "2.0",
25041
25114
  ...notification
25042
25115
  });
25043
- if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && !options?.relatedRequestId) {
25116
+ if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
25044
25117
  if (this._pendingDebouncedNotifications.has(notification.method)) return;
25045
25118
  this._pendingDebouncedNotifications.add(notification.method);
25046
25119
  Promise.resolve().then(() => {
@@ -32343,7 +32416,7 @@ var Ajv = import_ajv.Ajv;
32343
32416
  // ../../node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
32344
32417
  import process2 from "node:process";
32345
32418
 
32346
- // ../../node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs
32419
+ // ../../node_modules/@modelcontextprotocol/server/dist/mcp-Dw2OlZ1f.mjs
32347
32420
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
32348
32421
  function isCompletable(schema) {
32349
32422
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -32536,6 +32609,9 @@ function notificationToServerEvent(method, uri) {
32536
32609
  };
32537
32610
  }
32538
32611
  }
32612
+ function supportsScopeChallengeResolver(transport) {
32613
+ return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
32614
+ }
32539
32615
  var DEFAULT_LEGACY_SHIM_MAX_ROUNDS = 8;
32540
32616
  var DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS = 6e5;
32541
32617
  function resolveLegacyShimOptions(options) {
@@ -33346,6 +33422,7 @@ var McpServer = class {
33346
33422
  * ```
33347
33423
  */
33348
33424
  async connect(transport) {
33425
+ if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
33349
33426
  return await this.server.connect(transport);
33350
33427
  }
33351
33428
  /**
@@ -33354,6 +33431,41 @@ var McpServer = class {
33354
33431
  async close() {
33355
33432
  await this.server.close();
33356
33433
  }
33434
+ /** @internal */
33435
+ resolveScopeChallenge = (context) => {
33436
+ switch (context.request.method) {
33437
+ case "tools/call": {
33438
+ const toolName = context.request.params?.name;
33439
+ if (typeof toolName !== "string") return;
33440
+ const tool = this._registeredTools[toolName];
33441
+ if (tool === void 0 || !tool.enabled) return;
33442
+ return tool.scopeChallenge?.(context);
33443
+ }
33444
+ case "resources/read": {
33445
+ const resourceUri = context.request.params?.uri;
33446
+ if (typeof resourceUri !== "string") return;
33447
+ let uri;
33448
+ try {
33449
+ uri = new URL(resourceUri);
33450
+ } catch {
33451
+ return;
33452
+ }
33453
+ const resource = this._registeredResources[uri.toString()];
33454
+ if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
33455
+ for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
33456
+ return;
33457
+ }
33458
+ case "prompts/get": {
33459
+ const promptName = context.request.params?.name;
33460
+ if (typeof promptName !== "string") return;
33461
+ const prompt = this._registeredPrompts[promptName];
33462
+ if (prompt === void 0 || !prompt.enabled) return;
33463
+ return prompt.scopeChallenge?.(context);
33464
+ }
33465
+ default:
33466
+ return;
33467
+ }
33468
+ };
33357
33469
  _toolHandlersInitialized = false;
33358
33470
  setToolRequestHandlers() {
33359
33471
  if (this._toolHandlersInitialized) return;
@@ -33520,7 +33632,10 @@ var McpServer = class {
33520
33632
  }
33521
33633
  for (const template of Object.values(this._registeredResourceTemplates)) {
33522
33634
  const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
33523
- if (variables) return attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
33635
+ if (variables) {
33636
+ if (!template.enabled) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
33637
+ return attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
33638
+ }
33524
33639
  }
33525
33640
  throw new ResourceNotFoundError(request.params.uri);
33526
33641
  });
@@ -33551,36 +33666,32 @@ var McpServer = class {
33551
33666
  this._promptHandlersInitialized = true;
33552
33667
  }
33553
33668
  registerResource(name, uriOrTemplate, config2, readCallback) {
33554
- const cacheHint = config2.cacheHint;
33555
- let metadata = config2;
33556
- if (cacheHint !== void 0) {
33557
- assertValidCacheHint(cacheHint, `resource ${name}`);
33558
- const rest = { ...config2 };
33559
- delete rest.cacheHint;
33560
- metadata = rest;
33561
- }
33669
+ const { cacheHint, scopeChallenge, ...resourceMetadata } = config2;
33670
+ const metadata = resourceMetadata;
33671
+ if (cacheHint !== void 0) assertValidCacheHint(cacheHint, `resource ${name}`);
33562
33672
  if (typeof uriOrTemplate === "string") {
33563
33673
  if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
33564
- const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, readCallback);
33674
+ const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
33565
33675
  if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
33566
33676
  this.setResourceRequestHandlers();
33567
33677
  this.sendResourceListChanged();
33568
33678
  return registeredResource;
33569
33679
  } else {
33570
33680
  if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
33571
- const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, readCallback);
33681
+ const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
33572
33682
  if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
33573
33683
  this.setResourceRequestHandlers();
33574
33684
  this.sendResourceListChanged();
33575
33685
  return registeredResourceTemplate;
33576
33686
  }
33577
33687
  }
33578
- _createRegisteredResource(name, title, uri, metadata, readCallback) {
33688
+ _createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
33579
33689
  const registeredResource = {
33580
33690
  name,
33581
33691
  title,
33582
33692
  metadata,
33583
33693
  readCallback,
33694
+ scopeChallenge,
33584
33695
  enabled: true,
33585
33696
  disable: () => registeredResource.update({ enabled: false }),
33586
33697
  enable: () => registeredResource.update({ enabled: true }),
@@ -33594,6 +33705,7 @@ var McpServer = class {
33594
33705
  if (updates.title !== void 0) registeredResource.title = updates.title;
33595
33706
  if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
33596
33707
  if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
33708
+ if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
33597
33709
  if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
33598
33710
  this.sendResourceListChanged();
33599
33711
  }
@@ -33601,12 +33713,13 @@ var McpServer = class {
33601
33713
  this._registeredResources[uri] = registeredResource;
33602
33714
  return registeredResource;
33603
33715
  }
33604
- _createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
33716
+ _createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
33605
33717
  const registeredResourceTemplate = {
33606
33718
  resourceTemplate: template,
33607
33719
  title,
33608
33720
  metadata,
33609
33721
  readCallback,
33722
+ scopeChallenge,
33610
33723
  enabled: true,
33611
33724
  disable: () => registeredResourceTemplate.update({ enabled: false }),
33612
33725
  enable: () => registeredResourceTemplate.update({ enabled: true }),
@@ -33620,6 +33733,7 @@ var McpServer = class {
33620
33733
  if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
33621
33734
  if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
33622
33735
  if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
33736
+ if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
33623
33737
  if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
33624
33738
  this.sendResourceListChanged();
33625
33739
  }
@@ -33629,7 +33743,7 @@ var McpServer = class {
33629
33743
  if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
33630
33744
  return registeredResourceTemplate;
33631
33745
  }
33632
- _createRegisteredPrompt(name, title, description, argsSchema, callback, icons, _meta) {
33746
+ _createRegisteredPrompt(name, title, description, argsSchema, callback, icons, scopeChallenge, _meta) {
33633
33747
  let currentArgsSchema = argsSchema;
33634
33748
  let currentCallback = callback;
33635
33749
  const registeredPrompt = {
@@ -33637,6 +33751,7 @@ var McpServer = class {
33637
33751
  description,
33638
33752
  argsSchema,
33639
33753
  icons,
33754
+ scopeChallenge,
33640
33755
  _meta,
33641
33756
  handler: createPromptHandler(name, argsSchema, callback),
33642
33757
  enabled: true,
@@ -33651,6 +33766,7 @@ var McpServer = class {
33651
33766
  if (updates.title !== void 0) registeredPrompt.title = updates.title;
33652
33767
  if (updates.description !== void 0) registeredPrompt.description = updates.description;
33653
33768
  if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
33769
+ if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
33654
33770
  if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
33655
33771
  let needsHandlerRegen = false;
33656
33772
  if (updates.argsSchema !== void 0) {
@@ -33678,7 +33794,7 @@ var McpServer = class {
33678
33794
  }
33679
33795
  return registeredPrompt;
33680
33796
  }
33681
- _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
33797
+ _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
33682
33798
  validateAndWarnToolName(name);
33683
33799
  if (inputSchema !== void 0) try {
33684
33800
  const json2 = standardSchemaToJsonSchema(inputSchema, "input");
@@ -33697,6 +33813,7 @@ var McpServer = class {
33697
33813
  annotations,
33698
33814
  icons,
33699
33815
  execution,
33816
+ scopeChallenge,
33700
33817
  _meta,
33701
33818
  handler,
33702
33819
  executor: createToolExecutor(inputSchema, handler),
@@ -33735,6 +33852,7 @@ var McpServer = class {
33735
33852
  }
33736
33853
  if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
33737
33854
  if (updates.icons !== void 0) registeredTool.icons = updates.icons;
33855
+ if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
33738
33856
  if (updates._meta !== void 0) registeredTool._meta = updates._meta;
33739
33857
  if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
33740
33858
  this.sendToolListChanged();
@@ -33747,13 +33865,13 @@ var McpServer = class {
33747
33865
  }
33748
33866
  registerTool(name, config2, cb) {
33749
33867
  if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
33750
- const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config2;
33751
- return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
33868
+ const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config2;
33869
+ return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
33752
33870
  }
33753
33871
  registerPrompt(name, config2, cb) {
33754
33872
  if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
33755
- const { title, description, argsSchema, icons, _meta } = config2;
33756
- const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, _meta);
33873
+ const { title, description, argsSchema, icons, scopeChallenge, _meta } = config2;
33874
+ const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, scopeChallenge, _meta);
33757
33875
  this.setPromptRequestHandlers();
33758
33876
  this.sendPromptListChanged();
33759
33877
  return registeredPrompt;
@@ -33865,6 +33983,7 @@ function unwrapOptionalSchema(schema) {
33865
33983
  }
33866
33984
 
33867
33985
  // ../../node_modules/@modelcontextprotocol/server/dist/stdio.mjs
33986
+ var swallowsErrorsAfterClose = /* @__PURE__ */ Symbol("swallowsErrorsAfterClose");
33868
33987
  var StdioServerTransport = class {
33869
33988
  _readBuffer;
33870
33989
  _started = false;
@@ -33891,18 +34010,27 @@ var StdioServerTransport = class {
33891
34010
  this.onerror?.(error62);
33892
34011
  };
33893
34012
  _onstdouterror = (error62) => {
34013
+ if (this._closed) return;
33894
34014
  this.onerror?.(error62);
33895
34015
  this.close().catch(() => {
33896
34016
  });
33897
34017
  };
34018
+ _onstdinclose = () => {
34019
+ this.close().catch(() => {
34020
+ });
34021
+ };
33898
34022
  /**
33899
34023
  * Starts listening for messages on `stdin`.
33900
34024
  */
33901
34025
  async start() {
33902
34026
  if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
33903
34027
  this._started = true;
34028
+ for (const listener of this._stdout.listeners("error")) if (listener[swallowsErrorsAfterClose]) this._stdout.off("error", listener);
34029
+ if (this._stdin.readableEnded || this._stdin.destroyed) setImmediate(this._onstdinclose);
33904
34030
  this._stdin.on("data", this._ondata);
33905
34031
  this._stdin.on("error", this._onerror);
34032
+ this._stdin.on("end", this._onstdinclose);
34033
+ this._stdin.on("close", this._onstdinclose);
33906
34034
  this._stdout.on("error", this._onstdouterror);
33907
34035
  }
33908
34036
  processReadBuffer() {
@@ -33919,7 +34047,9 @@ var StdioServerTransport = class {
33919
34047
  this._closed = true;
33920
34048
  this._stdin.off("data", this._ondata);
33921
34049
  this._stdin.off("error", this._onerror);
33922
- this._stdout.off("error", this._onstdouterror);
34050
+ this._stdin.off("end", this._onstdinclose);
34051
+ this._stdin.off("close", this._onstdinclose);
34052
+ this._onstdouterror[swallowsErrorsAfterClose] = true;
33923
34053
  if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
33924
34054
  this._readBuffer.clear();
33925
34055
  this.onclose?.();
@@ -34148,14 +34278,14 @@ function serveStdio(factory, options = {}) {
34148
34278
  return false;
34149
34279
  };
34150
34280
  const answerLegacyRejection = (request, reason, requestedVersion) => {
34151
- const rejection2 = modernOnlyStrictRejection({
34281
+ const rejection3 = modernOnlyStrictRejection({
34152
34282
  kind: "legacy",
34153
34283
  reason,
34154
34284
  ...requestedVersion !== void 0 && { requestedVersion }
34155
34285
  }, 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);
34286
+ if (rejection3 === void 0) return Promise.resolve();
34287
+ reportError(/* @__PURE__ */ new Error(`Rejected 2025-era request on a modern-only stdio connection (${rejection3.cell}): ${rejection3.message}`));
34288
+ return writeErrorResponse(request.id, rejection3.code, rejection3.message, rejection3.data);
34159
34289
  };
34160
34290
  const onInstanceClosed = (channel) => {
34161
34291
  if (closing || channel === discarding) return;
@@ -34196,6 +34326,7 @@ function serveStdio(factory, options = {}) {
34196
34326
  return;
34197
34327
  }
34198
34328
  if (state.era === "modern" && await tryServeListen(message)) return;
34329
+ if (isTornDown()) return;
34199
34330
  state.instance.channel.deliver(message);
34200
34331
  return;
34201
34332
  }
@@ -34262,6 +34393,7 @@ function serveStdio(factory, options = {}) {
34262
34393
  };
34263
34394
  }
34264
34395
  if (await tryServeListen(message)) return;
34396
+ if (isTornDown()) return;
34265
34397
  state.instance.channel.deliver(message, { classification: opening.classification });
34266
34398
  return;
34267
34399
  case "legacy": {
@@ -34348,6 +34480,9 @@ function toError(value) {
34348
34480
  return value instanceof Error ? value : new Error(String(value));
34349
34481
  }
34350
34482
 
34483
+ // ../../node_modules/@modelcontextprotocol/server/dist/index.mjs
34484
+ var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
34485
+
34351
34486
  // ../../node_modules/@chrischall/mcp-utils/dist/errors/index.js
34352
34487
  var McpToolError = class extends Error {
34353
34488
  /** Actionable remediation text, when one applies. */
@@ -34458,6 +34593,11 @@ function walk(value, keep, drop) {
34458
34593
  }
34459
34594
 
34460
34595
  // ../../node_modules/@chrischall/mcp-utils/dist/response/index.js
34596
+ function textResult(data) {
34597
+ return {
34598
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
34599
+ };
34600
+ }
34461
34601
  function rawTextResult(text) {
34462
34602
  return { content: [{ type: "text", text }] };
34463
34603
  }
@@ -34468,7 +34608,160 @@ function errorResult(message) {
34468
34608
  };
34469
34609
  }
34470
34610
 
34611
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34612
+ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
34613
+
34614
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/canonical.js
34615
+ function canonicalJson(value) {
34616
+ if (value === null || typeof value === "string" || typeof value === "boolean")
34617
+ return JSON.stringify(value);
34618
+ if (value === void 0)
34619
+ return "null";
34620
+ if (typeof value === "number")
34621
+ return Number.isFinite(value) ? JSON.stringify(value) : `{"$num":"${String(value)}"}`;
34622
+ if (typeof value === "bigint")
34623
+ return `{"$bigint":"${value.toString()}"}`;
34624
+ if (typeof value === "function" || typeof value === "symbol") {
34625
+ throw new TypeError(`confirmation: cannot bind a ${typeof value} argument value.`);
34626
+ }
34627
+ if (Array.isArray(value))
34628
+ return `[${value.map(canonicalJson).join(",")}]`;
34629
+ if (value instanceof Date) {
34630
+ return `{"$date":${JSON.stringify(Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString())}}`;
34631
+ }
34632
+ if (ArrayBuffer.isView(value)) {
34633
+ const bytes = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
34634
+ return `{"$bytes":${JSON.stringify(bytes.toString("base64"))}}`;
34635
+ }
34636
+ if (value instanceof ArrayBuffer)
34637
+ return `{"$bytes":${JSON.stringify(Buffer.from(value).toString("base64"))}}`;
34638
+ if (value instanceof Map) {
34639
+ const entries2 = [...value.entries()].map(([k, v]) => `[${canonicalJson(k)},${canonicalJson(v)}]`).sort();
34640
+ return `{"$map":[${entries2.join(",")}]}`;
34641
+ }
34642
+ if (value instanceof Set) {
34643
+ return `{"$set":[${[...value].map(canonicalJson).sort().join(",")}]}`;
34644
+ }
34645
+ const proto = Object.getPrototypeOf(value);
34646
+ if (proto !== Object.prototype && proto !== null) {
34647
+ throw new TypeError("confirmation: cannot bind a non-plain object argument value (class instance).");
34648
+ }
34649
+ const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
34650
+ return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
34651
+ }
34652
+ function escapeKey(key) {
34653
+ return key.startsWith("$") ? `$${key}` : key;
34654
+ }
34655
+
34656
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
34657
+ var DEFAULT_REQUEST_KEY = "confirmation";
34658
+ var DEFAULT_CONFIRMATION_LABEL = "Confirm this action should proceed.";
34659
+ 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";
34660
+ var STATE_PREFIX = "mcpu.confirm.v1.";
34661
+ function bindingKey(binding) {
34662
+ if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
34663
+ throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
34664
+ }
34665
+ const key = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
34666
+ if (key.length < 32) {
34667
+ throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
34668
+ }
34669
+ return key;
34670
+ }
34671
+ function commitment(action, args) {
34672
+ return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
34673
+ }
34674
+ function mintState(key, action, binding) {
34675
+ const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
34676
+ const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
34677
+ const mac3 = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest("base64url");
34678
+ return `${STATE_PREFIX}${body}.${mac3}`;
34679
+ }
34680
+ function verifyState(key, action, binding, state) {
34681
+ if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
34682
+ return false;
34683
+ const rest = state.slice(STATE_PREFIX.length);
34684
+ const dot = rest.indexOf(".");
34685
+ if (dot < 0)
34686
+ return false;
34687
+ const body = rest.slice(0, dot);
34688
+ const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
34689
+ const expected = createHmac("sha256", key).update(`${STATE_PREFIX}${body}`).digest();
34690
+ if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
34691
+ return false;
34692
+ let payload;
34693
+ try {
34694
+ payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34695
+ } catch {
34696
+ return false;
34697
+ }
34698
+ if (typeof payload.exp !== "number" || payload.exp * 1e3 <= Date.now())
34699
+ return false;
34700
+ const want = Buffer.from(commitment(action, binding.args));
34701
+ const got = Buffer.from(typeof payload.c === "string" ? payload.c : "");
34702
+ return got.length === want.length && timingSafeEqual(got, want);
34703
+ }
34704
+ function echoedState(ctx) {
34705
+ const accessor = ctx.mcpReq.requestState;
34706
+ return typeof accessor === "function" ? accessor() : void 0;
34707
+ }
34708
+ function requireConfirmation(ctx, options) {
34709
+ const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
34710
+ const key = options.binding ? bindingKey(options.binding) : void 0;
34711
+ const confirmationSchema = external_exports.object({
34712
+ confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
34713
+ });
34714
+ const ask = () => {
34715
+ const preview = {
34716
+ action: options.action,
34717
+ ...options.details === void 0 ? {} : { details: options.details }
34718
+ };
34719
+ return inputRequired({
34720
+ inputRequests: {
34721
+ [requestKey]: inputRequired.elicit({
34722
+ message: `${options.message}
34723
+ ${JSON.stringify(preview, null, 2)}`,
34724
+ requestedSchema: confirmationSchema
34725
+ })
34726
+ },
34727
+ ...key && options.binding ? { requestState: mintState(key, options.action, options.binding) } : {}
34728
+ });
34729
+ };
34730
+ const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
34731
+ const accepted = acceptedContent(ctx.mcpReq.inputResponses, requestKey, confirmationSchema);
34732
+ if (response.kind === "missing") {
34733
+ if (callerAcceptsFormElicitation(ctx) === false) {
34734
+ return textResult({
34735
+ confirmed: false,
34736
+ dispatched: false,
34737
+ action: options.action,
34738
+ reason: "confirmation-unsupported",
34739
+ note: options.unsupportedNote ? `${UNSUPPORTED_NOTE}. ${options.unsupportedNote}` : `${UNSUPPORTED_NOTE}.`
34740
+ });
34741
+ }
34742
+ return ask();
34743
+ }
34744
+ if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
34745
+ if (key && options.binding) {
34746
+ const state = echoedState(ctx);
34747
+ if (state === void 0 || state === null) {
34748
+ 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.`);
34749
+ }
34750
+ if (!verifyState(key, options.action, options.binding, state))
34751
+ return ask();
34752
+ }
34753
+ return void 0;
34754
+ }
34755
+ return textResult({
34756
+ confirmed: false,
34757
+ cancelled: true,
34758
+ action: options.action,
34759
+ note: "Nothing was changed because the confirmation was declined, cancelled, or left unchecked."
34760
+ });
34761
+ }
34762
+
34471
34763
  // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-token.js
34764
+ import { createHash as createHash2, createHmac as createHmac2, randomBytes, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
34472
34765
  function createSpentTokenStore() {
34473
34766
  const spent2 = /* @__PURE__ */ new Map();
34474
34767
  return {
@@ -34488,7 +34781,148 @@ function createSpentTokenStore() {
34488
34781
  };
34489
34782
  }
34490
34783
  var PROCESS_SPENT = createSpentTokenStore();
34784
+ var PREFIX = "mcpu.token.v1.";
34785
+ var DEFAULT_TTL_SECONDS = 600;
34786
+ function tokenKey(key) {
34787
+ const bytes = typeof key === "string" ? Buffer.from(key, "utf8") : Buffer.from(key);
34788
+ if (bytes.length < 32)
34789
+ throw new RangeError("confirm token: key must be at least 32 bytes.");
34790
+ return bytes;
34791
+ }
34792
+ function ttlOf(ttlSeconds) {
34793
+ if (ttlSeconds === void 0)
34794
+ return DEFAULT_TTL_SECONDS;
34795
+ if (!(Number.isFinite(ttlSeconds) && ttlSeconds > 0)) {
34796
+ throw new RangeError("confirm token: ttlSeconds must be a finite number greater than 0.");
34797
+ }
34798
+ return ttlSeconds;
34799
+ }
34800
+ function sign(key, body) {
34801
+ return createHmac2("sha256", key).update(`${PREFIX}${body}`).digest();
34802
+ }
34803
+ function hashConfirmPayload(payload) {
34804
+ return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
34805
+ }
34806
+ function issueConfirmToken(key, binding, options = {}) {
34807
+ const k = tokenKey(key);
34808
+ const now = options.now ?? Date.now();
34809
+ const exp = now + ttlOf(options.ttlSeconds) * 1e3;
34810
+ const claims = {
34811
+ t: binding.tool,
34812
+ ...binding.account === void 0 ? {} : { a: binding.account },
34813
+ g: binding.target,
34814
+ ...binding.revision === void 0 ? {} : { r: binding.revision },
34815
+ h: binding.payloadHash,
34816
+ exp,
34817
+ n: randomBytes(16).toString("base64url")
34818
+ };
34819
+ const body = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");
34820
+ return { token: `${PREFIX}${body}.${sign(k, body).toString("base64url")}`, expiresAt: new Date(exp).toISOString() };
34821
+ }
34822
+ function parseClaims(body) {
34823
+ try {
34824
+ const claims = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
34825
+ return claims && typeof claims === "object" ? claims : void 0;
34826
+ } catch {
34827
+ return void 0;
34828
+ }
34829
+ }
34830
+ function verifyConfirmToken(key, token, binding, options = {}) {
34831
+ const k = tokenKey(key);
34832
+ const now = options.now ?? Date.now();
34833
+ const spent2 = options.spent ?? PROCESS_SPENT;
34834
+ spent2.prune(now);
34835
+ if (!token.startsWith(PREFIX))
34836
+ return { ok: false, error: "TOKEN_INVALID" };
34837
+ const rest = token.slice(PREFIX.length);
34838
+ const dot = rest.indexOf(".");
34839
+ const body = dot < 0 ? "" : rest.slice(0, dot);
34840
+ const mac3 = Buffer.from(dot < 0 ? "" : rest.slice(dot + 1), "base64url");
34841
+ const expected = sign(k, body);
34842
+ if (!body || mac3.length !== expected.length || !timingSafeEqual2(mac3, expected))
34843
+ return { ok: false, error: "TOKEN_INVALID" };
34844
+ const claims = parseClaims(body);
34845
+ if (!claims)
34846
+ return { ok: false, error: "TOKEN_INVALID" };
34847
+ if (claims.t !== binding.tool || claims.a !== binding.account || claims.g !== binding.target) {
34848
+ return { ok: false, error: "TOKEN_INVALID" };
34849
+ }
34850
+ if (spent2.has(claims.n))
34851
+ return { ok: false, error: "TOKEN_REUSED" };
34852
+ if (now > claims.exp)
34853
+ return { ok: false, error: "TOKEN_EXPIRED" };
34854
+ if (claims.r !== binding.revision)
34855
+ return { ok: false, error: "DRAFT_CHANGED", reason: "revision-changed" };
34856
+ if (claims.h !== binding.payloadHash)
34857
+ return { ok: false, error: "DRAFT_CHANGED", reason: "payload-changed" };
34858
+ spent2.add(claims.n, claims.exp);
34859
+ return { ok: true };
34860
+ }
34861
+ 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.";
34491
34862
  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.`);
34863
+ var TOKEN_ERROR_NOTE = {
34864
+ 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.",
34865
+ 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.",
34866
+ 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."
34867
+ };
34868
+ var CHANGED_NOTE = {
34869
+ "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.",
34870
+ "payload-changed": "Nothing was sent or changed: what would happen no longer matches what the user approved."
34871
+ };
34872
+ function isToolResult(value) {
34873
+ return Array.isArray(value.content);
34874
+ }
34875
+ function rejection2(data) {
34876
+ return { ...textResult({ status: "confirmation-rejected", confirmed: false, dispatched: false, ...data }), isError: true };
34877
+ }
34878
+ async function tokenConfirmation(action, fb) {
34879
+ const subject = await fb.subject();
34880
+ if (isToolResult(subject))
34881
+ return subject;
34882
+ const binding = {
34883
+ tool: fb.tool,
34884
+ ...fb.account === void 0 ? {} : { account: fb.account },
34885
+ target: subject.target,
34886
+ ...subject.revision === void 0 ? {} : { revision: subject.revision },
34887
+ payloadHash: hashConfirmPayload(subject.payload)
34888
+ };
34889
+ const phaseOne = () => {
34890
+ const { token, expiresAt } = issueConfirmToken(fb.key, binding, { ttlSeconds: fb.ttlSeconds });
34891
+ return {
34892
+ action,
34893
+ preview: subject.preview,
34894
+ confirmToken: token,
34895
+ expiresAt,
34896
+ ttlSeconds: ttlOf(fb.ttlSeconds),
34897
+ instruction: fb.instruction ?? CONFIRM_TOKEN_INSTRUCTION
34898
+ };
34899
+ };
34900
+ if (!fb.confirmToken) {
34901
+ return textResult({ status: "confirmation-required", confirmed: false, dispatched: false, ...phaseOne() });
34902
+ }
34903
+ const verdict = verifyConfirmToken(fb.key, fb.confirmToken, binding, { spent: fb.spent });
34904
+ if (verdict.ok)
34905
+ return void 0;
34906
+ if (verdict.error === "DRAFT_CHANGED") {
34907
+ return rejection2({
34908
+ error: "DRAFT_CHANGED",
34909
+ reason: verdict.reason,
34910
+ note: `${CHANGED_NOTE[verdict.reason]} The current preview and a fresh confirmToken are below.`,
34911
+ ...phaseOne()
34912
+ });
34913
+ }
34914
+ return rejection2({ error: verdict.error, action, note: TOKEN_ERROR_NOTE[verdict.error] });
34915
+ }
34916
+ async function requireConfirmationWithFallback(ctx, options) {
34917
+ const { tokenFallback, ...confirmation } = options;
34918
+ if (tokenFallback && callerAcceptsFormElicitation(ctx) === false) {
34919
+ return tokenConfirmation(options.action, tokenFallback);
34920
+ }
34921
+ return requireConfirmation(ctx, confirmation);
34922
+ }
34923
+
34924
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34925
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
34492
34926
 
34493
34927
  // ../../node_modules/@chrischall/mcp-utils/dist/config/index.js
34494
34928
  import { homedir } from "node:os";
@@ -34529,6 +34963,61 @@ function expandPath(p) {
34529
34963
  return isAbsolute(expanded) ? expanded : resolve(expanded);
34530
34964
  }
34531
34965
 
34966
+ // ../../node_modules/@chrischall/mcp-utils/dist/server/confirm-env.js
34967
+ var MODES = /* @__PURE__ */ new Set(["ask-user", "auto", "refuse"]);
34968
+ var DEFAULT_TTL_SECONDS2 = 600;
34969
+ var warned = /* @__PURE__ */ new Set();
34970
+ function readConfirmMode(env = process.env) {
34971
+ const raw = readEnvVar("MCP_CONFIRM_MODE", { env })?.trim().toLowerCase();
34972
+ if (!raw)
34973
+ return "ask-user";
34974
+ if (MODES.has(raw))
34975
+ return raw;
34976
+ if (!warned.has(raw)) {
34977
+ warned.add(raw);
34978
+ process.stderr.write(`MCP_CONFIRM_MODE="${raw}" is not one of ask-user, auto, refuse; treating it as refuse.
34979
+ `);
34980
+ }
34981
+ return "refuse";
34982
+ }
34983
+ function confirmTtlFromEnv(env = process.env) {
34984
+ const raw = readEnvVar("MCP_CONFIRM_TTL_SECONDS", { env })?.trim();
34985
+ return raw && /^[1-9]\d*$/.test(raw) ? Number(raw) : DEFAULT_TTL_SECONDS2;
34986
+ }
34987
+ var processKey;
34988
+ function confirmKeyFromEnv(env = process.env) {
34989
+ const secret = readEnvVar("MCP_CONFIRM_SECRET", { env });
34990
+ if (secret)
34991
+ return createHash3("sha256").update(secret, "utf8").digest();
34992
+ processKey ??= randomBytes2(32);
34993
+ return processKey;
34994
+ }
34995
+ 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.)";
34996
+ var REFUSE_HINT = "Set MCP_CONFIRM_MODE=ask-user on the server to allow two-step confirmation instead.";
34997
+ function confirmationFromEnv(options) {
34998
+ const { tool, account, confirmToken, subject, instruction, spent: spent2, env = process.env, ...confirmation } = options;
34999
+ const mode = readConfirmMode(env);
35000
+ if (mode === "refuse") {
35001
+ return {
35002
+ ...confirmation,
35003
+ unsupportedNote: confirmation.unsupportedNote ? `${confirmation.unsupportedNote} ${REFUSE_HINT}` : REFUSE_HINT
35004
+ };
35005
+ }
35006
+ return {
35007
+ ...confirmation,
35008
+ tokenFallback: {
35009
+ key: confirmKeyFromEnv(env),
35010
+ tool,
35011
+ ...account === void 0 ? {} : { account },
35012
+ ...confirmToken === void 0 ? {} : { confirmToken },
35013
+ subject,
35014
+ ttlSeconds: confirmTtlFromEnv(env),
35015
+ instruction: mode === "auto" ? CONFIRM_TOKEN_AUTO_INSTRUCTION : instruction ?? CONFIRM_TOKEN_INSTRUCTION,
35016
+ ...spent2 === void 0 ? {} : { spent: spent2 }
35017
+ }
35018
+ };
35019
+ }
35020
+
34532
35021
  // ../../node_modules/@chrischall/mcp-utils/dist/server/index.js
34533
35022
  var SERVER_PROTOCOL_VERSIONS = Object.freeze([
34534
35023
  "2026-07-28",
@@ -34785,9 +35274,9 @@ function offsetAt(instant, tz) {
34785
35274
  const w = wallPartsIn(instant, tz);
34786
35275
  const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
34787
35276
  const minutes = Math.round((asUTC - instant.getTime()) / 6e4);
34788
- const sign = minutes < 0 ? "-" : "+";
35277
+ const sign2 = minutes < 0 ? "-" : "+";
34789
35278
  const abs = Math.abs(minutes);
34790
- return `${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
35279
+ return `${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
34791
35280
  }
34792
35281
  function wallPartsIn(instant, tz) {
34793
35282
  const parts = new Intl.DateTimeFormat("en-US", {
@@ -35492,6 +35981,7 @@ async function diagnose(err) {
35492
35981
  const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
35493
35982
  const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
35494
35983
  const hint = isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "";
35984
+ if (!isAuthError && !isInvalidGrant) return errorResult(`${errText}${hint}`);
35495
35985
  try {
35496
35986
  const accounts = formatAccountList(await run(["auth", "list"]));
35497
35987
  return errorResult(`${errText}
@@ -35582,6 +36072,42 @@ function formatAuthHealth(raw, now) {
35582
36072
 
35583
36073
  // ../gogcli-mcp/src/send-confirm-token.ts
35584
36074
  var spent = createSpentTokenStore();
36075
+ function confirmSpentStore() {
36076
+ return spent;
36077
+ }
36078
+
36079
+ // ../gogcli-mcp/src/dispatch-confirmation.ts
36080
+ var CONFIRM_ACTION_INSTRUCTION = CONFIRM_TOKEN_INSTRUCTION;
36081
+ 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.';
36082
+ function refusedInRun(what, via, does, instead) {
36083
+ return `${what} ${does} and is not available through ${via}. ${instead}`;
36084
+ }
36085
+ function gatedElsewhere(what, via, does, tool) {
36086
+ return refusedInRun(what, via, does, `Use ${tool}, which asks the user to confirm.`);
36087
+ }
36088
+ function hasCommandWord(args, words) {
36089
+ return args.find((a) => words.has(a.toLowerCase()));
36090
+ }
36091
+ async function requireDispatchConfirmation(ctx, options) {
36092
+ const { action, fallback } = options;
36093
+ const confirmation = {
36094
+ action,
36095
+ message: options.message,
36096
+ details: options.details,
36097
+ confirmationLabel: options.confirmationLabel,
36098
+ ...options.unsupportedNote ? { unsupportedNote: options.unsupportedNote } : {}
36099
+ };
36100
+ if (!fallback) return requireConfirmationWithFallback(ctx, confirmation);
36101
+ return requireConfirmationWithFallback(ctx, confirmationFromEnv({
36102
+ ...confirmation,
36103
+ tool: fallback.tool,
36104
+ account: fallback.account ?? readEnvVar("GOG_ACCOUNT") ?? "",
36105
+ confirmToken: fallback.confirmToken,
36106
+ subject: fallback.subject,
36107
+ instruction: fallback.instruction ?? CONFIRM_ACTION_INSTRUCTION,
36108
+ spent: confirmSpentStore()
36109
+ }));
36110
+ }
35585
36111
 
35586
36112
  // ../gogcli-mcp/src/tools/auth.ts
35587
36113
  var AUTH_RUN_SUBCOMMANDS = ["list", "status", "services", "remove", "alias"];
@@ -35718,6 +36244,27 @@ function authToolsFor(defaultServices) {
35718
36244
  }
35719
36245
 
35720
36246
  // ../gogcli-mcp/src/tools/calendar.ts
36247
+ var ASKS = (tool) => `Use ${tool}, which asks the user to confirm.`;
36248
+ var CALENDAR_REFUSED = {
36249
+ create: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
36250
+ add: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
36251
+ new: { does: "can change what guests see", instead: ASKS("gog_calendar_create") },
36252
+ update: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
36253
+ edit: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
36254
+ set: { does: "can change what guests see", instead: ASKS("gog_calendar_update") },
36255
+ respond: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
36256
+ rsvp: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
36257
+ reply: { does: "can change what guests see", instead: ASKS("gog_calendar_respond") },
36258
+ move: { does: "moves an event off guests' calendars (and can email them)", instead: ASKS("gog_calendar_move") },
36259
+ transfer: { does: "moves an event off guests' calendars (and can email them)", instead: ASKS("gog_calendar_move") },
36260
+ delete: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36261
+ del: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36262
+ rm: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36263
+ remove: { does: "removes an event from every guest's calendar (the whole series by default)", instead: ASKS("gog_calendar_delete") },
36264
+ "delete-calendar": { does: "deletes a calendar and every event on it", instead: ASKS("gog_calendar_delete_calendar") },
36265
+ "out-of-office": { does: "auto-declines invitations and notifies their organizers", instead: ASKS("gog_calendar_out_of_office") },
36266
+ ooo: { does: "auto-declines invitations and notifies their organizers", instead: ASKS("gog_calendar_out_of_office") }
36267
+ };
35721
36268
  var reminderParams = {
35722
36269
  reminders: external_exports.array(external_exports.string()).max(5).optional().describe(
35723
36270
  `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.`
@@ -35819,6 +36366,13 @@ function countNonEmptyCells(getOutput) {
35819
36366
  }
35820
36367
 
35821
36368
  // ../gogcli-mcp/src/tools/sheets.ts
36369
+ var DATASOURCE_ALIASES = /* @__PURE__ */ new Set(["datasource", "data-source", "data-sources", "connected-sheets"]);
36370
+ var DATASOURCE_BILLED = /* @__PURE__ */ new Set(["add", "update", "refresh"]);
36371
+ function vetSheetsRun(subcommand, args) {
36372
+ if (!DATASOURCE_ALIASES.has(subcommand.toLowerCase())) return void 0;
36373
+ const word = hasCommandWord(args, DATASOURCE_BILLED)?.toLowerCase();
36374
+ return word ? gatedElsewhere(`gog sheets datasource ${word}`, "gog_sheets_run", "runs a billed BigQuery job", `gog_sheets_datasource_${word}`) : void 0;
36375
+ }
35822
36376
  var cellValueParam = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]);
35823
36377
  var dryRunParam = external_exports.boolean().optional().describe(
35824
36378
  "Preview the operation without modifying the sheet (gog --dry-run): reports the intended actions and exits without writing."
@@ -35934,11 +36488,11 @@ function registerSheetsTools(server) {
35934
36488
  }, async ({ spreadsheetId, find, replace, account }) => {
35935
36489
  return runOrDiagnose(["sheets", "find-replace", pos(spreadsheetId), pos(find), pos(replace)], { account });
35936
36490
  });
35937
- registerRunTool(server, { service: "sheets", examples: '"freeze", "add-tab", "rename-tab"' });
36491
+ registerRunTool(server, { service: "sheets", examples: '"freeze", "add-tab", "rename-tab"', vet: vetSheetsRun });
35938
36492
  }
35939
36493
 
35940
36494
  // ../gogcli-mcp/src/server.ts
35941
- var VERSION = true ? "4.5.0" : "0.0.0";
36495
+ var VERSION = true ? "4.5.2" : "0.0.0";
35942
36496
 
35943
36497
  // ../gogcli-mcp/src/bootstrap-auth.ts
35944
36498
  import { join as join5 } from "node:path";
@@ -35975,12 +36529,12 @@ async function bootstrapGogAuth(env = process.env, options = {}) {
35975
36529
  const [clientId, clientSecret, refreshToken, account] = values;
35976
36530
  const { spawner } = options;
35977
36531
  try {
35978
- const { createHash } = await import("node:crypto");
36532
+ const { createHash: createHash4 } = await import("node:crypto");
35979
36533
  const { mkdir, readFile, writeFile, chmod } = await import("node:fs/promises");
35980
36534
  const home = options.home ?? (await import("node:os")).homedir();
35981
36535
  const dir = join5(home, ".gogcli-mcp");
35982
36536
  const marker = join5(dir, AUTH_BOOTSTRAP_MARKER);
35983
- const fingerprint = createHash("sha256").update(values.join("\0")).digest("hex");
36537
+ const fingerprint = createHash4("sha256").update(values.join("\0")).digest("hex");
35984
36538
  const previous = await readFile(marker, "utf8").catch(() => void 0);
35985
36539
  if (previous === fingerprint && await accountListed(account, spawner)) return "present";
35986
36540
  await run(
@@ -36017,6 +36571,32 @@ function resultText2(result) {
36017
36571
  const first = result.content[0];
36018
36572
  return first?.type === "text" ? first.text : void 0;
36019
36573
  }
36574
+ function spreadsheetTitle(raw) {
36575
+ try {
36576
+ const parsed = JSON.parse(String(raw));
36577
+ const title = parsed?.spreadsheet?.properties?.title ?? parsed?.properties?.title;
36578
+ return typeof title === "string" ? title : void 0;
36579
+ } catch {
36580
+ return void 0;
36581
+ }
36582
+ }
36583
+ function dataSourceSnapshot(raw) {
36584
+ let bq;
36585
+ try {
36586
+ const parsed = JSON.parse(String(raw));
36587
+ bq = (parsed?.dataSource ?? parsed)?.spec?.bigQuery;
36588
+ } catch {
36589
+ bq = void 0;
36590
+ }
36591
+ const str = (v) => typeof v === "string" ? v : void 0;
36592
+ const t = bq?.tableSpec;
36593
+ const table = [t?.tableProjectId, t?.datasetId, t?.tableId].map(str).filter(Boolean).join(".");
36594
+ return {
36595
+ ...str(bq?.projectId) ? { billingProject: str(bq?.projectId) } : {},
36596
+ ...str(bq?.querySpec?.rawQuery) ? { query: str(bq?.querySpec?.rawQuery) } : {},
36597
+ ...table ? { table } : {}
36598
+ };
36599
+ }
36020
36600
  function hexToRgb(hex3) {
36021
36601
  let h = hex3.trim().replace(/^#/, "");
36022
36602
  if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];
@@ -36055,6 +36635,25 @@ async function checkDateFormatTarget(spreadsheetId, range, account) {
36055
36635
  if (!sawSmallInt) return null;
36056
36636
  return "Warning: applying DATE/DATE_TIME format to cells holding small integers (< 10000) will render them as dates near 1899-12-30 because Sheets interprets numeric values as day-serials from that epoch. If those integers are ordinals (1, 2, 3, ...) and not day offsets, this is almost certainly not what you want. Pass force:true to suppress this warning, or convert the cells to real dates / strings first.";
36057
36637
  }
36638
+ async function confirmBilledExecution(ctx, o) {
36639
+ const got = await runOrDiagnose(["sheets", "metadata", pos(o.spreadsheetId), "--select=properties.title"], { account: o.account });
36640
+ if (got.isError) return got;
36641
+ const title = spreadsheetTitle(resultText2(got));
36642
+ const view = { spreadsheet: { id: o.spreadsheetId, ...title !== void 0 ? { title } : {} }, ...o.view };
36643
+ return requireDispatchConfirmation(ctx, {
36644
+ action: o.action,
36645
+ message: "Review and confirm starting a BigQuery execution \u2014 it is billed to the billing project:",
36646
+ confirmationLabel: "Confirm that this billed BigQuery query should run now.",
36647
+ details: view,
36648
+ unsupportedNote: "Ask the user to run it from Google Sheets (Data > Data connectors).",
36649
+ fallback: {
36650
+ tool: o.tool,
36651
+ account: o.account,
36652
+ confirmToken: o.confirmToken,
36653
+ subject: () => ({ target: o.target, payload: view, preview: view })
36654
+ }
36655
+ });
36656
+ }
36058
36657
  function registerExtraSheetsTools(server) {
36059
36658
  server.registerTool("gog_sheets_list_tabs", {
36060
36659
  description: "List tabs (sheets) in a spreadsheet with their titles, sheetIds, and indices. A friendlier view than gog_sheets_metadata when you only need the tab list \u2014 useful for restructuring a workbook over a long agent session without losing track of names.",
@@ -36975,7 +37574,7 @@ ${errorText(err)}`
36975
37574
  if (render) args.push(`--render=${render}`);
36976
37575
  return runOrDiagnose(args, { account });
36977
37576
  });
36978
- const bigQueryChargeNote = " COSTS MONEY AND RUNS ASYNCHRONOUSLY: this starts a BigQuery execution billed to the billing project, and returns once the execution has been REQUESTED \u2014 not once it has finished. Poll gog_sheets_datasource_describe until its dataExecutionStatus state is SUCCEEDED or FAILED before treating the data as current.";
37577
+ const bigQueryChargeNote = " COSTS MONEY AND RUNS ASYNCHRONOUSLY: this starts a BigQuery execution billed to the billing project, and returns once the execution has been REQUESTED \u2014 not once it has finished. Poll gog_sheets_datasource_describe until its dataExecutionStatus state is SUCCEEDED or FAILED before treating the data as current. Because it bills, it first asks the MCP host to show the user a confirmation prompt naming the spreadsheet, the query or table and the billing project; nothing runs unless they accept." + CONFIRM_FALLBACK_DESCRIPTION;
36979
37578
  server.registerTool("gog_sheets_datasource_add", {
36980
37579
  description: "Add a BigQuery Connected Sheets data source to a spreadsheet, creating its linked DATA_SOURCE sheet. Point it at EITHER a custom SQL query (query) OR an existing native table (dataset + table) \u2014 never both. billingProject is the BigQuery project charged for the query; tableProject only names which project OWNS the table, and defaults to the billing project. Returns the new dataSourceId, which every other datasource tool takes." + bigQueryChargeNote + bigQueryScopeNote,
36981
37580
  annotations: { destructiveHint: false },
@@ -36986,9 +37585,10 @@ ${errorText(err)}`
36986
37585
  dataset: external_exports.string().optional().describe("BigQuery dataset ID of an existing table. Requires table; mutually exclusive with query."),
36987
37586
  table: external_exports.string().optional().describe("BigQuery table ID. Requires dataset; mutually exclusive with query."),
36988
37587
  tableProject: external_exports.string().optional().describe("BigQuery project that owns the table (default: the billing project). Only valid with dataset/table."),
36989
- account: accountParam
37588
+ account: accountParam,
37589
+ confirmToken: confirmTokenParam
36990
37590
  })
36991
- }, async ({ spreadsheetId, billingProject, query, dataset, table, tableProject, account }) => {
37591
+ }, async ({ spreadsheetId, billingProject, query, dataset, table, tableProject, account, confirmToken }, ctx) => {
36992
37592
  const tableFlags = tableProject !== void 0 || dataset !== void 0 || table !== void 0;
36993
37593
  if (query !== void 0 && tableFlags) {
36994
37594
  throw new Error("query and the table fields (dataset, table, tableProject) are mutually exclusive \u2014 a data source is backed by one or the other.");
@@ -37001,6 +37601,17 @@ ${errorText(err)}`
37001
37601
  if (tableProject) args.push(`--table-project=${tableProject}`);
37002
37602
  if (dataset) args.push(`--dataset=${dataset}`);
37003
37603
  if (table) args.push(`--table=${table}`);
37604
+ const source = query !== void 0 ? { query } : { table: [tableProject ?? billingProject, dataset, table].join(".") };
37605
+ const confirmation = await confirmBilledExecution(ctx, {
37606
+ tool: "gog_sheets_datasource_add",
37607
+ action: "sheets.datasource-add",
37608
+ account,
37609
+ confirmToken,
37610
+ spreadsheetId,
37611
+ target: spreadsheetId,
37612
+ view: { billingProject, ...source }
37613
+ });
37614
+ if (confirmation) return confirmation;
37004
37615
  return runOrDiagnose(args, { account });
37005
37616
  });
37006
37617
  server.registerTool("gog_sheets_datasource_update", {
@@ -37014,9 +37625,10 @@ ${errorText(err)}`
37014
37625
  dataset: external_exports.string().optional().describe("Replacement dataset ID. Only valid on a table-backed source."),
37015
37626
  table: external_exports.string().optional().describe("Replacement table ID. Only valid on a table-backed source."),
37016
37627
  tableProject: external_exports.string().optional().describe("Replacement project owning the table. Only valid on a table-backed source."),
37017
- account: accountParam
37628
+ account: accountParam,
37629
+ confirmToken: confirmTokenParam
37018
37630
  })
37019
- }, async ({ spreadsheetId, dataSourceId, billingProject, query, dataset, table, tableProject, account }) => {
37631
+ }, async ({ spreadsheetId, dataSourceId, billingProject, query, dataset, table, tableProject, account, confirmToken }, ctx) => {
37020
37632
  const tableFlags = tableProject !== void 0 || dataset !== void 0 || table !== void 0;
37021
37633
  if (query !== void 0 && tableFlags) {
37022
37634
  throw new Error("query and the table fields (dataset, table, tableProject) are mutually exclusive \u2014 a data source is backed by one or the other.");
@@ -37030,6 +37642,17 @@ ${errorText(err)}`
37030
37642
  if (tableProject !== void 0) args.push(`--table-project=${tableProject}`);
37031
37643
  if (dataset !== void 0) args.push(`--dataset=${dataset}`);
37032
37644
  if (table !== void 0) args.push(`--table=${table}`);
37645
+ const changes = Object.fromEntries(Object.entries({ billingProject, query, tableProject, dataset, table }).filter(([, v]) => v !== void 0));
37646
+ const confirmation = await confirmBilledExecution(ctx, {
37647
+ tool: "gog_sheets_datasource_update",
37648
+ action: "sheets.datasource-update",
37649
+ account,
37650
+ confirmToken,
37651
+ spreadsheetId,
37652
+ target: `${spreadsheetId}/${dataSourceId}`,
37653
+ view: { dataSourceId, changes }
37654
+ });
37655
+ if (confirmation) return confirmation;
37033
37656
  return runOrDiagnose(args, { account });
37034
37657
  });
37035
37658
  server.registerTool("gog_sheets_datasource_refresh", {
@@ -37039,11 +37662,24 @@ ${errorText(err)}`
37039
37662
  spreadsheetId: external_exports.string().describe("Spreadsheet ID"),
37040
37663
  dataSourceId: external_exports.string().describe("Data source ID, as reported by gog_sheets_datasource_list"),
37041
37664
  forceRefresh: external_exports.boolean().optional().describe("Refresh even when the previous execution failed"),
37042
- account: accountParam
37665
+ account: accountParam,
37666
+ confirmToken: confirmTokenParam
37043
37667
  })
37044
- }, async ({ spreadsheetId, dataSourceId, forceRefresh, account }) => {
37668
+ }, async ({ spreadsheetId, dataSourceId, forceRefresh, account, confirmToken }, ctx) => {
37045
37669
  const args = ["sheets", "datasource", "refresh", pos(spreadsheetId), pos(dataSourceId)];
37046
37670
  if (forceRefresh) args.push("--force-refresh");
37671
+ const described = await runOrDiagnose(["sheets", "datasource", "describe", pos(spreadsheetId), pos(dataSourceId)], { account });
37672
+ if (described.isError) return described;
37673
+ const confirmation = await confirmBilledExecution(ctx, {
37674
+ tool: "gog_sheets_datasource_refresh",
37675
+ action: "sheets.datasource-refresh",
37676
+ account,
37677
+ confirmToken,
37678
+ spreadsheetId,
37679
+ target: `${spreadsheetId}/${dataSourceId}`,
37680
+ view: { dataSourceId, ...dataSourceSnapshot(resultText2(described)), forceRefresh: Boolean(forceRefresh) }
37681
+ });
37682
+ if (confirmation) return confirmation;
37047
37683
  return runOrDiagnose(args, { account });
37048
37684
  });
37049
37685
  server.registerTool("gog_sheets_datasource_delete", {
@@ -37068,7 +37704,7 @@ await runMcp({
37068
37704
  });
37069
37705
  /*! Bundled license information:
37070
37706
 
37071
- @modelcontextprotocol/server/dist/src-CX2iR2pK.mjs:
37707
+ @modelcontextprotocol/server/dist/src-D-y6h4N7.mjs:
37072
37708
  (*!
37073
37709
  * content-type
37074
37710
  * Copyright(c) 2015 Douglas Christopher Wilson