gogcli-mcp-contacts 4.1.0 → 4.2.1

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
@@ -5,6 +5,39 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
+ // ../../node_modules/@chrischall/mcp-utils/dist/cancel/index.js
9
+ import { AsyncLocalStorage } from "node:async_hooks";
10
+ var storage = new AsyncLocalStorage();
11
+ function withCallSignal(signal, fn, request) {
12
+ return signal ? storage.run({ signal, ...request ? { request } : {} }, fn) : fn();
13
+ }
14
+ function currentCallSignal() {
15
+ return storage.getStore()?.signal;
16
+ }
17
+ function killOnCancel(child, signal = "SIGTERM") {
18
+ const ambient = currentCallSignal();
19
+ if (!ambient)
20
+ return () => {
21
+ };
22
+ if (ambient.aborted) {
23
+ child.kill(signal);
24
+ return () => {
25
+ };
26
+ }
27
+ const onAbort = () => {
28
+ child.kill(signal);
29
+ };
30
+ ambient.addEventListener("abort", onAbort, { once: true });
31
+ return () => ambient.removeEventListener("abort", onAbort);
32
+ }
33
+
34
+ // ../../node_modules/@chrischall/mcp-utils/dist/caller/index.js
35
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
36
+ var storage2 = new AsyncLocalStorage2();
37
+ function withCallerCapabilities(capabilities, fn) {
38
+ return capabilities ? storage2.run(capabilities, fn) : fn();
39
+ }
40
+
8
41
  // ../../node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
9
42
  var __create = Object.create;
10
43
  var __defProp2 = Object.defineProperty;
@@ -34433,17 +34466,73 @@ Hint: ${err.hint}`);
34433
34466
  }
34434
34467
  throw err;
34435
34468
  }
34469
+ function mcpRequestFrom(args) {
34470
+ const ctx = args.at(-1);
34471
+ if (typeof ctx !== "object" || ctx === null)
34472
+ return void 0;
34473
+ const req = ctx.mcpReq;
34474
+ if (typeof req !== "object" || req === null)
34475
+ return void 0;
34476
+ return typeof req.notify === "function" ? req : void 0;
34477
+ }
34478
+ function callSignalFrom(args) {
34479
+ const ctx = args.at(-1);
34480
+ if (typeof ctx !== "object" || ctx === null)
34481
+ return void 0;
34482
+ const req = ctx.mcpReq;
34483
+ if (typeof req !== "object" || req === null)
34484
+ return void 0;
34485
+ const signal = req.signal;
34486
+ return signal instanceof AbortSignal ? signal : void 0;
34487
+ }
34488
+ function declaredCapabilitiesFrom(server) {
34489
+ const inner = server.server;
34490
+ if (typeof inner !== "object" || inner === null)
34491
+ return void 0;
34492
+ const read = inner.getClientCapabilities;
34493
+ if (typeof read !== "function")
34494
+ return void 0;
34495
+ try {
34496
+ const declared = read.call(inner);
34497
+ return typeof declared === "object" && declared !== null ? declared : void 0;
34498
+ } catch {
34499
+ return void 0;
34500
+ }
34501
+ }
34436
34502
  function surfaceToolHints(server) {
34437
34503
  const register2 = server.registerTool.bind(server);
34438
- server.registerTool = (name, config2, cb) => register2(name, config2, (...args) => {
34439
- let result;
34440
- try {
34441
- result = cb(...args);
34442
- } catch (err) {
34443
- return hintResultOrRethrow(err);
34444
- }
34445
- return result instanceof Promise ? result.catch(hintResultOrRethrow) : result;
34446
- });
34504
+ server.registerTool = (name, config2, cb) => register2(name, config2, (...args) => (
34505
+ // THE CALLER'S CANCELLATION, made ambient for the whole handler
34506
+ // (`cancel/index.ts`). The SDK delivers it and the fleet ignored it:
34507
+ // measured against @modelcontextprotocol/server 2.0.0, a cancelled
34508
+ // call aborts `ctx.mcpReq.signal` with the caller's reason and the
34509
+ // handler runs to completion regardless — so the HTTP request stays
34510
+ // in flight, the child keeps burning metered CPU, and the upstream
34511
+ // keeps being hit for somebody who has gone. claude.ai sent 101
34512
+ // cancellations in the week to 2026-09-20.
34513
+ //
34514
+ // Here because this is the one wrapper every tool already passes
34515
+ // through: threading the signal by hand would mean editing several
34516
+ // hundred handlers and missing exactly the ones nobody edits.
34517
+ withCallSignal(callSignalFrom(args), () => (
34518
+ // WHAT THE CALLER CAN DO, made ambient for the same reason and in
34519
+ // the same place (`caller/index.ts`). Only the 2025-era half needs
34520
+ // the wrapper — a 2026-07-28 request answers for itself off its own
34521
+ // envelope — but a guarded tool that cannot tell whether the caller
34522
+ // can be shown a prompt returns one the SDK then refuses to deliver,
34523
+ // and that refusal reaches the caller as an unexplained protocol
34524
+ // error it had no chance to catch.
34525
+ withCallerCapabilities(declaredCapabilitiesFrom(server), () => {
34526
+ let result;
34527
+ try {
34528
+ result = cb(...args);
34529
+ } catch (err) {
34530
+ return hintResultOrRethrow(err);
34531
+ }
34532
+ return result instanceof Promise ? result.catch(hintResultOrRethrow) : result;
34533
+ })
34534
+ ), mcpRequestFrom(args))
34535
+ ));
34447
34536
  }
34448
34537
  async function createMcpServer(opts) {
34449
34538
  const server = new McpServer({ name: opts.name, version: opts.version }, { supportedProtocolVersions: [...SERVER_PROTOCOL_VERSIONS] });
@@ -34878,8 +34967,15 @@ async function spawnGog(fullArgs, opts) {
34878
34967
  const stdoutChunks = [];
34879
34968
  const stderrChunks = [];
34880
34969
  let settled = false;
34970
+ const cancelled = currentCallSignal();
34971
+ const stopWatchingCancel = killOnCancel(child);
34972
+ const stopWatching = () => {
34973
+ clearTimeout(timer);
34974
+ stopWatchingCancel();
34975
+ };
34881
34976
  const timer = setTimeout(() => {
34882
34977
  settled = true;
34978
+ stopWatchingCancel();
34883
34979
  child.kill();
34884
34980
  reject(new Error(`gog timed out after ${formatTimeout(effectiveTimeout)}`));
34885
34981
  }, effectiveTimeout);
@@ -34890,9 +34986,13 @@ async function spawnGog(fullArgs, opts) {
34890
34986
  stderrChunks.push(chunk);
34891
34987
  });
34892
34988
  child.on("close", (code) => {
34893
- clearTimeout(timer);
34989
+ stopWatching();
34894
34990
  if (settled) return;
34895
34991
  settled = true;
34992
+ if (cancelled?.aborted) {
34993
+ reject(cancelled.reason instanceof Error ? cancelled.reason : new Error("the caller cancelled this call"));
34994
+ return;
34995
+ }
34896
34996
  const stderr = Buffer.concat(stderrChunks).toString().trim();
34897
34997
  if (code === 0) {
34898
34998
  if (binary) {
@@ -34910,7 +35010,7 @@ async function spawnGog(fullArgs, opts) {
34910
35010
  }
34911
35011
  });
34912
35012
  child.on("error", (err) => {
34913
- clearTimeout(timer);
35013
+ stopWatching();
34914
35014
  if (settled) return;
34915
35015
  settled = true;
34916
35016
  if (err.code === "ENOENT") {
@@ -35400,7 +35500,7 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
35400
35500
  );
35401
35501
 
35402
35502
  // ../gogcli-mcp/src/server.ts
35403
- var VERSION = true ? "4.1.0" : "0.0.0";
35503
+ var VERSION = true ? "4.2.1" : "0.0.0";
35404
35504
 
35405
35505
  // ../gogcli-mcp/src/bootstrap-auth.ts
35406
35506
  import { join as join2 } from "node:path";
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp-contacts",
5
5
  "display_name": "gogcli (Contacts)",
6
- "version": "4.1.0",
6
+ "version": "4.2.1",
7
7
  "description": "Extended Google Contacts for Claude via gogcli — auth + Contacts + Workspace directory (People API)",
8
8
  "author": {
9
9
  "name": "Chris Hall",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp-contacts",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp-contacts",
5
5
  "description": "Extended Google Contacts + People MCP server via gogcli — auth + Contacts + Workspace directory (People API)",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
@@ -24,7 +24,7 @@
24
24
  "test:coverage": "vitest run --coverage"
25
25
  },
26
26
  "dependencies": {
27
- "@chrischall/mcp-utils": "^1.0.0",
27
+ "@chrischall/mcp-utils": "^2.1.0",
28
28
  "@modelcontextprotocol/server": "^2.0.0",
29
29
  "zod": "^4.6.1"
30
30
  },