gogcli-mcp 4.0.0 → 4.1.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
@@ -33037,6 +33037,207 @@ var pageSchema = {
33037
33037
 
33038
33038
  // src/runner.ts
33039
33039
  import { delimiter, join } from "node:path";
33040
+
33041
+ // src/timestamps.ts
33042
+ var DEFAULT_DISPLAY_TZ = "America/New_York";
33043
+ function isValidTimeZone(tz) {
33044
+ try {
33045
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
33046
+ return true;
33047
+ } catch {
33048
+ return false;
33049
+ }
33050
+ }
33051
+ function displayTimeZone() {
33052
+ const configured = readEnvVar("DISPLAY_TZ");
33053
+ if (configured && isValidTimeZone(configured)) return configured;
33054
+ return DEFAULT_DISPLAY_TZ;
33055
+ }
33056
+ function naiveSourceTimeZone() {
33057
+ const configured = readEnvVar("GOG_TIMEZONE");
33058
+ if (configured && isValidTimeZone(configured)) return configured;
33059
+ return displayTimeZone();
33060
+ }
33061
+ function offsetAt(instant, tz) {
33062
+ const w = wallPartsIn(instant, tz);
33063
+ const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
33064
+ const minutes = Math.round((asUTC - instant.getTime()) / 6e4);
33065
+ const sign2 = minutes < 0 ? "-" : "+";
33066
+ const abs = Math.abs(minutes);
33067
+ return `${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
33068
+ }
33069
+ function wallPartsIn(instant, tz) {
33070
+ const parts = new Intl.DateTimeFormat("en-US", {
33071
+ timeZone: tz,
33072
+ year: "numeric",
33073
+ month: "2-digit",
33074
+ day: "2-digit",
33075
+ hour: "2-digit",
33076
+ minute: "2-digit",
33077
+ second: "2-digit",
33078
+ // h23 pins midnight to hour 00; without it some ICU builds render hour 24.
33079
+ hourCycle: "h23"
33080
+ }).formatToParts(instant);
33081
+ const out = {};
33082
+ for (const p of parts) {
33083
+ if (p.type !== "literal") out[p.type] = Number(p.value);
33084
+ }
33085
+ return out;
33086
+ }
33087
+ function wallTimeToInstant(y, mo, d, h, mi, s, ms, tz) {
33088
+ let guess = Date.UTC(y, mo - 1, d, h, mi, s, ms);
33089
+ for (let i = 0; i < 2; i += 1) {
33090
+ const seen = wallPartsIn(new Date(guess), tz);
33091
+ const seenUTC = Date.UTC(seen.year, seen.month - 1, seen.day, seen.hour, seen.minute, seen.second, ms);
33092
+ const drift = Date.UTC(y, mo - 1, d, h, mi, s, ms) - seenUTC;
33093
+ if (drift === 0) break;
33094
+ guess += drift;
33095
+ }
33096
+ return new Date(guess);
33097
+ }
33098
+ function pad(n, width = 2) {
33099
+ return String(n).padStart(width, "0");
33100
+ }
33101
+ function isoWithOffset(instant, tz, offset) {
33102
+ const w = wallPartsIn(instant, tz);
33103
+ const msPart = instant.getUTCMilliseconds();
33104
+ const frac = msPart ? `.${pad(msPart, 3)}` : "";
33105
+ return `${pad(w.year, 4)}-${pad(w.month)}-${pad(w.day)}T${pad(w.hour)}:${pad(w.minute)}:${pad(w.second)}${frac}${offset}`;
33106
+ }
33107
+ function formatInstant(instant, tz = displayTimeZone()) {
33108
+ const offset = offsetAt(instant, tz);
33109
+ const display = new Intl.DateTimeFormat("en-US", {
33110
+ timeZone: tz,
33111
+ weekday: "short",
33112
+ month: "short",
33113
+ day: "numeric",
33114
+ year: "numeric",
33115
+ hour: "numeric",
33116
+ minute: "2-digit",
33117
+ timeZoneName: "short"
33118
+ }).format(instant);
33119
+ return { iso: isoWithOffset(instant, tz, offset), display };
33120
+ }
33121
+ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
33122
+ "date",
33123
+ // gog gmail message/thread listings ("2026-07-28 03:36")
33124
+ "dateTime",
33125
+ // Calendar event start/end
33126
+ "internalDate",
33127
+ // Gmail, epoch milliseconds (authoritative)
33128
+ // gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
33129
+ // (RFC3339 from internalDate), so it needs no offset repair — it is
33130
+ // allowlisted purely to gain a Display sibling, and to be re-rendered in
33131
+ // DISPLAY_TZ like every other instant. Separately sourced from the sibling
33132
+ // `date`, which is a naive re-format of the sender's Date header; the two may
33133
+ // legitimately disagree. See docs/timestamps.md.
33134
+ "internalDateIso",
33135
+ "modifiedTime",
33136
+ // Drive
33137
+ "createdTime",
33138
+ // Drive
33139
+ "createTime",
33140
+ "updateTime",
33141
+ "updated",
33142
+ "originalStartTime",
33143
+ "expirationTime",
33144
+ "lastModified",
33145
+ "sentAt",
33146
+ "viewedAt",
33147
+ "modifiedAt",
33148
+ "fetchedBodyAt",
33149
+ "asOf"
33150
+ ]);
33151
+ var ZONE_NAME_KEYS = /* @__PURE__ */ new Set(["timeZone", "timezone"]);
33152
+ var RFC3339_WITH_OFFSET = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,9}))?(Z|[+-]\d{2}:?\d{2})$/;
33153
+ var NAIVE_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,9}))?$/;
33154
+ var EPOCH_MILLIS = /^\d{13}$/;
33155
+ var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
33156
+ function isRealCalendarDate(p) {
33157
+ const utc = new Date(Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second));
33158
+ return utc.getUTCFullYear() === p.year && utc.getUTCMonth() === p.month - 1 && utc.getUTCDate() === p.day && utc.getUTCHours() === p.hour && utc.getUTCMinutes() === p.minute && utc.getUTCSeconds() === p.second;
33159
+ }
33160
+ function parseTimestampValue(key, value, assumeNaiveIn) {
33161
+ if (typeof value !== "string") return null;
33162
+ const raw = value.trim();
33163
+ if (raw === "" || DATE_ONLY.test(raw)) return null;
33164
+ if (key === "internalDate" && EPOCH_MILLIS.test(raw)) {
33165
+ return new Date(Number(raw));
33166
+ }
33167
+ if (RFC3339_WITH_OFFSET.test(raw)) {
33168
+ const parsed = new Date(raw.replace(" ", "T"));
33169
+ return Number.isNaN(parsed.getTime()) ? null : parsed;
33170
+ }
33171
+ const naive = NAIVE_DATE_TIME.exec(raw);
33172
+ if (naive) {
33173
+ const [, y, mo, d, h, mi, s, frac] = naive;
33174
+ const ms = frac ? Number(frac.padEnd(3, "0").slice(0, 3)) : 0;
33175
+ const parts = {
33176
+ year: Number(y),
33177
+ month: Number(mo),
33178
+ day: Number(d),
33179
+ hour: Number(h),
33180
+ minute: Number(mi),
33181
+ second: Number(s ?? "0")
33182
+ };
33183
+ if (!isRealCalendarDate(parts)) return null;
33184
+ return wallTimeToInstant(
33185
+ parts.year,
33186
+ parts.month,
33187
+ parts.day,
33188
+ parts.hour,
33189
+ parts.minute,
33190
+ parts.second,
33191
+ ms,
33192
+ assumeNaiveIn
33193
+ );
33194
+ }
33195
+ return null;
33196
+ }
33197
+ function walk2(node2, tz, naiveTz) {
33198
+ let changed = false;
33199
+ if (Array.isArray(node2)) {
33200
+ for (const item of node2) {
33201
+ if (walk2(item, tz, naiveTz)) changed = true;
33202
+ }
33203
+ return changed;
33204
+ }
33205
+ if (node2 === null || typeof node2 !== "object") return false;
33206
+ const obj = node2;
33207
+ for (const key of Object.keys(obj)) {
33208
+ const value = obj[key];
33209
+ if (value !== null && typeof value === "object") {
33210
+ if (walk2(value, tz, naiveTz)) changed = true;
33211
+ continue;
33212
+ }
33213
+ if (ZONE_NAME_KEYS.has(key) || !TIMESTAMP_KEYS.has(key)) continue;
33214
+ const instant = parseTimestampValue(key, value, naiveTz);
33215
+ if (!instant) continue;
33216
+ const { iso, display } = formatInstant(instant, tz);
33217
+ obj[key] = iso;
33218
+ obj[`${key}Display`] = display;
33219
+ changed = true;
33220
+ }
33221
+ return changed;
33222
+ }
33223
+ function detectIndent(text) {
33224
+ const match = /\n(\s+)\S/.exec(text);
33225
+ return match ? match[1].replace(/\t/g, " ").length : 0;
33226
+ }
33227
+ function normalizeTimestamps(text, tz = displayTimeZone(), naiveTz = naiveSourceTimeZone()) {
33228
+ const trimmed = text.trim();
33229
+ if (trimmed === "" || !/^[[{]/.test(trimmed)) return text;
33230
+ let parsed;
33231
+ try {
33232
+ parsed = JSON.parse(trimmed);
33233
+ } catch {
33234
+ return text;
33235
+ }
33236
+ if (!walk2(parsed, tz, naiveTz)) return text;
33237
+ return JSON.stringify(parsed, null, detectIndent(text));
33238
+ }
33239
+
33240
+ // src/runner.ts
33040
33241
  function isGogFileArg(arg) {
33041
33242
  return typeof arg !== "string";
33042
33243
  }
@@ -33158,7 +33359,7 @@ async function spawnGog(fullArgs, opts) {
33158
33359
  const spawn = spawner ?? (await import("node:child_process")).spawn;
33159
33360
  const effectiveTimeout = timeout ?? TIMEOUT_MS;
33160
33361
  return new Promise((resolve, reject) => {
33161
- const childEnv = { ...sanitizedEnv(), PATH: augmentedPath() };
33362
+ const childEnv = { ...sanitizedEnv(), GOG_TIMEZONE: naiveSourceTimeZone(), PATH: augmentedPath() };
33162
33363
  const child = spawn(readEnvVar("GOG_PATH") ?? "gog", fullArgs, { env: childEnv });
33163
33364
  const stdoutChunks = [];
33164
33365
  const stderrChunks = [];
@@ -33240,205 +33441,6 @@ async function runBinary(args, options = {}) {
33240
33441
  return spawnExecutor(fullArgs, { timeout, interactive: false, spawner, binary: true });
33241
33442
  }
33242
33443
 
33243
- // src/timestamps.ts
33244
- var DEFAULT_DISPLAY_TZ = "America/New_York";
33245
- function isValidTimeZone(tz) {
33246
- try {
33247
- new Intl.DateTimeFormat("en-US", { timeZone: tz });
33248
- return true;
33249
- } catch {
33250
- return false;
33251
- }
33252
- }
33253
- function displayTimeZone() {
33254
- const configured = readEnvVar("DISPLAY_TZ");
33255
- if (configured && isValidTimeZone(configured)) return configured;
33256
- return DEFAULT_DISPLAY_TZ;
33257
- }
33258
- function naiveSourceTimeZone() {
33259
- const configured = readEnvVar("GOG_TIMEZONE");
33260
- if (configured && isValidTimeZone(configured)) return configured;
33261
- return displayTimeZone();
33262
- }
33263
- function offsetAt(instant, tz) {
33264
- const w = wallPartsIn(instant, tz);
33265
- const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
33266
- const minutes = Math.round((asUTC - instant.getTime()) / 6e4);
33267
- const sign2 = minutes < 0 ? "-" : "+";
33268
- const abs = Math.abs(minutes);
33269
- return `${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
33270
- }
33271
- function wallPartsIn(instant, tz) {
33272
- const parts = new Intl.DateTimeFormat("en-US", {
33273
- timeZone: tz,
33274
- year: "numeric",
33275
- month: "2-digit",
33276
- day: "2-digit",
33277
- hour: "2-digit",
33278
- minute: "2-digit",
33279
- second: "2-digit",
33280
- // h23 pins midnight to hour 00; without it some ICU builds render hour 24.
33281
- hourCycle: "h23"
33282
- }).formatToParts(instant);
33283
- const out = {};
33284
- for (const p of parts) {
33285
- if (p.type !== "literal") out[p.type] = Number(p.value);
33286
- }
33287
- return out;
33288
- }
33289
- function wallTimeToInstant(y, mo, d, h, mi, s, ms, tz) {
33290
- let guess = Date.UTC(y, mo - 1, d, h, mi, s, ms);
33291
- for (let i = 0; i < 2; i += 1) {
33292
- const seen = wallPartsIn(new Date(guess), tz);
33293
- const seenUTC = Date.UTC(seen.year, seen.month - 1, seen.day, seen.hour, seen.minute, seen.second, ms);
33294
- const drift = Date.UTC(y, mo - 1, d, h, mi, s, ms) - seenUTC;
33295
- if (drift === 0) break;
33296
- guess += drift;
33297
- }
33298
- return new Date(guess);
33299
- }
33300
- function pad(n, width = 2) {
33301
- return String(n).padStart(width, "0");
33302
- }
33303
- function isoWithOffset(instant, tz, offset) {
33304
- const w = wallPartsIn(instant, tz);
33305
- const msPart = instant.getUTCMilliseconds();
33306
- const frac = msPart ? `.${pad(msPart, 3)}` : "";
33307
- return `${pad(w.year, 4)}-${pad(w.month)}-${pad(w.day)}T${pad(w.hour)}:${pad(w.minute)}:${pad(w.second)}${frac}${offset}`;
33308
- }
33309
- function formatInstant(instant, tz = displayTimeZone()) {
33310
- const offset = offsetAt(instant, tz);
33311
- const display = new Intl.DateTimeFormat("en-US", {
33312
- timeZone: tz,
33313
- weekday: "short",
33314
- month: "short",
33315
- day: "numeric",
33316
- year: "numeric",
33317
- hour: "numeric",
33318
- minute: "2-digit",
33319
- timeZoneName: "short"
33320
- }).format(instant);
33321
- return { iso: isoWithOffset(instant, tz, offset), display };
33322
- }
33323
- var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
33324
- "date",
33325
- // gog gmail message/thread listings ("2026-07-28 03:36")
33326
- "dateTime",
33327
- // Calendar event start/end
33328
- "internalDate",
33329
- // Gmail, epoch milliseconds (authoritative)
33330
- // gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
33331
- // (RFC3339 from internalDate), so it needs no offset repair — it is
33332
- // allowlisted purely to gain a Display sibling, and to be re-rendered in
33333
- // DISPLAY_TZ like every other instant. Separately sourced from the sibling
33334
- // `date`, which is a naive re-format of the sender's Date header; the two may
33335
- // legitimately disagree. See docs/timestamps.md.
33336
- "internalDateIso",
33337
- "modifiedTime",
33338
- // Drive
33339
- "createdTime",
33340
- // Drive
33341
- "createTime",
33342
- "updateTime",
33343
- "updated",
33344
- "originalStartTime",
33345
- "expirationTime",
33346
- "lastModified",
33347
- "sentAt",
33348
- "viewedAt",
33349
- "modifiedAt",
33350
- "fetchedBodyAt",
33351
- "asOf"
33352
- ]);
33353
- var ZONE_NAME_KEYS = /* @__PURE__ */ new Set(["timeZone", "timezone"]);
33354
- var RFC3339_WITH_OFFSET = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,9}))?(Z|[+-]\d{2}:?\d{2})$/;
33355
- var NAIVE_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,9}))?$/;
33356
- var EPOCH_MILLIS = /^\d{13}$/;
33357
- var DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
33358
- function isRealCalendarDate(p) {
33359
- const utc = new Date(Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second));
33360
- return utc.getUTCFullYear() === p.year && utc.getUTCMonth() === p.month - 1 && utc.getUTCDate() === p.day && utc.getUTCHours() === p.hour && utc.getUTCMinutes() === p.minute && utc.getUTCSeconds() === p.second;
33361
- }
33362
- function parseTimestampValue(key, value, assumeNaiveIn) {
33363
- if (typeof value !== "string") return null;
33364
- const raw = value.trim();
33365
- if (raw === "" || DATE_ONLY.test(raw)) return null;
33366
- if (key === "internalDate" && EPOCH_MILLIS.test(raw)) {
33367
- return new Date(Number(raw));
33368
- }
33369
- if (RFC3339_WITH_OFFSET.test(raw)) {
33370
- const parsed = new Date(raw.replace(" ", "T"));
33371
- return Number.isNaN(parsed.getTime()) ? null : parsed;
33372
- }
33373
- const naive = NAIVE_DATE_TIME.exec(raw);
33374
- if (naive) {
33375
- const [, y, mo, d, h, mi, s, frac] = naive;
33376
- const ms = frac ? Number(frac.padEnd(3, "0").slice(0, 3)) : 0;
33377
- const parts = {
33378
- year: Number(y),
33379
- month: Number(mo),
33380
- day: Number(d),
33381
- hour: Number(h),
33382
- minute: Number(mi),
33383
- second: Number(s ?? "0")
33384
- };
33385
- if (!isRealCalendarDate(parts)) return null;
33386
- return wallTimeToInstant(
33387
- parts.year,
33388
- parts.month,
33389
- parts.day,
33390
- parts.hour,
33391
- parts.minute,
33392
- parts.second,
33393
- ms,
33394
- assumeNaiveIn
33395
- );
33396
- }
33397
- return null;
33398
- }
33399
- function walk2(node2, tz, naiveTz) {
33400
- let changed = false;
33401
- if (Array.isArray(node2)) {
33402
- for (const item of node2) {
33403
- if (walk2(item, tz, naiveTz)) changed = true;
33404
- }
33405
- return changed;
33406
- }
33407
- if (node2 === null || typeof node2 !== "object") return false;
33408
- const obj = node2;
33409
- for (const key of Object.keys(obj)) {
33410
- const value = obj[key];
33411
- if (value !== null && typeof value === "object") {
33412
- if (walk2(value, tz, naiveTz)) changed = true;
33413
- continue;
33414
- }
33415
- if (ZONE_NAME_KEYS.has(key) || !TIMESTAMP_KEYS.has(key)) continue;
33416
- const instant = parseTimestampValue(key, value, naiveTz);
33417
- if (!instant) continue;
33418
- const { iso, display } = formatInstant(instant, tz);
33419
- obj[key] = iso;
33420
- obj[`${key}Display`] = display;
33421
- changed = true;
33422
- }
33423
- return changed;
33424
- }
33425
- function detectIndent(text) {
33426
- const match = /\n(\s+)\S/.exec(text);
33427
- return match ? match[1].replace(/\t/g, " ").length : 0;
33428
- }
33429
- function normalizeTimestamps(text, tz = displayTimeZone(), naiveTz = naiveSourceTimeZone()) {
33430
- const trimmed = text.trim();
33431
- if (trimmed === "" || !/^[[{]/.test(trimmed)) return text;
33432
- let parsed;
33433
- try {
33434
- parsed = JSON.parse(trimmed);
33435
- } catch {
33436
- return text;
33437
- }
33438
- if (!walk2(parsed, tz, naiveTz)) return text;
33439
- return JSON.stringify(parsed, null, detectIndent(text));
33440
- }
33441
-
33442
33444
  // src/pagination.ts
33443
33445
  function detectIndent2(text) {
33444
33446
  const match = /\n(\s+)\S/.exec(text);
@@ -35915,7 +35917,7 @@ function registerTasksTools(server) {
35915
35917
  }
35916
35918
 
35917
35919
  // src/server.ts
35918
- var VERSION = true ? "4.0.0" : "0.0.0";
35920
+ var VERSION = true ? "4.1.0" : "0.0.0";
35919
35921
  var BASE_TOOL_REGISTRARS = [
35920
35922
  registerApiTools,
35921
35923
  registerAppScriptTools,
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.0.0",
6
+ "version": "4.1.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",
@@ -524,7 +524,7 @@
524
524
  "win32"
525
525
  ],
526
526
  "runtimes": {
527
- "node": ">=18.0.0"
527
+ "node": ">=22.0.0"
528
528
  }
529
529
  }
530
530
  }
package/mint.yaml CHANGED
@@ -72,10 +72,10 @@ env:
72
72
  - name: GOG_TIMEZONE
73
73
  required: false
74
74
  help: >-
75
- The IANA zone gog itself formats its naive timestamps in. The wrapper
76
- reads it (naiveSourceTimeZone) to re-attach the correct offset, so it
77
- should match gog's own configuration. Falls back to DISPLAY_TZ, then to
78
- America/New_York.
75
+ The IANA zone gog formats its naive timestamps in. The wrapper passes
76
+ it to every spawned gog and reads it back (naiveSourceTimeZone) to
77
+ re-attach the offset, so the two always agree. Unset or invalid, both
78
+ use DISPLAY_TZ, then America/New_York — never the host's local zone.
79
79
  - name: DISPLAY_TZ
80
80
  required: false
81
81
  help: >-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp",
3
- "version": "4.0.0",
3
+ "version": "4.1.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": "^0.28.0",
44
+ "@chrischall/mcp-utils": "^1.0.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.0.0",
10
+ "version": "4.1.0",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "gogcli-mcp",
15
- "version": "4.0.0",
15
+ "version": "4.1.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -12,7 +12,7 @@ MCP server wrapping [gogcli](https://github.com/openclaw/gogcli) — provides Cl
12
12
  ## Requirements
13
13
 
14
14
  - [gogcli](https://github.com/openclaw/gogcli) installed and authenticated (`gog --help` works in your shell)
15
- - Node.js 18 or later
15
+ - Node.js 22 or later
16
16
 
17
17
  ## Setup
18
18
 
package/src/runner.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ChildProcess } from 'node:child_process';
2
2
  import { delimiter, join } from 'node:path';
3
3
  import { parseBoolEnv, readEnvVar, redactSecrets as redactSharedSecrets } from '@chrischall/mcp-utils';
4
+ import { naiveSourceTimeZone } from './timestamps.js';
4
5
 
5
6
  export type Spawner = (
6
7
  command: string,
@@ -371,7 +372,9 @@ async function spawnGog(
371
372
  const effectiveTimeout = timeout ?? TIMEOUT_MS;
372
373
 
373
374
  return new Promise((resolve, reject) => {
374
- const childEnv = { ...sanitizedEnv(), PATH: augmentedPath() };
375
+ // gog must format naive dates in the zone normalizeTimestamps assumes; left
376
+ // to itself it falls back to the host's local zone (UTC on mcp-host).
377
+ const childEnv = { ...sanitizedEnv(), GOG_TIMEZONE: naiveSourceTimeZone(), PATH: augmentedPath() };
375
378
  const child = spawn(readEnvVar('GOG_PATH') ?? 'gog', fullArgs, { env: childEnv });
376
379
  const stdoutChunks: Buffer[] = [];
377
380
  const stderrChunks: Buffer[] = [];
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, vi } from 'vitest';
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
  import { EventEmitter } from 'node:events';
3
3
  import { spawn as mockedSpawn } from 'node:child_process';
4
4
  import { run, runBinary } from '../src/runner.js';
@@ -588,6 +588,50 @@ describe('run', () => {
588
588
  }
589
589
  });
590
590
 
591
+ // gog formats naive dates in GOG_TIMEZONE, else the process's local zone; the
592
+ // wrapper re-attaches offsets assuming GOG_TIMEZONE, else DISPLAY_TZ. Unless
593
+ // gog is TOLD the zone the wrapper assumes, a UTC host shifts every date.
594
+ describe('pins gog to the zone the wrapper reads its naive dates in', () => {
595
+ const keys = ['GOG_TIMEZONE', 'DISPLAY_TZ'] as const;
596
+ let snapshot: Record<string, string | undefined>;
597
+ beforeEach(() => { snapshot = Object.fromEntries(keys.map((k) => [k, process.env[k]])); });
598
+ afterEach(() => {
599
+ for (const [k, v] of Object.entries(snapshot)) {
600
+ if (v === undefined) delete process.env[k];
601
+ else process.env[k] = v;
602
+ }
603
+ });
604
+ const zoneGogGets = async (): Promise<string | undefined> => {
605
+ const spawner = makeSpawner(0, '{}');
606
+ await run(['gmail', 'search', 'x'], { spawner });
607
+ return ((spawner as ReturnType<typeof vi.fn>).mock.calls[0][2].env as NodeJS.ProcessEnv).GOG_TIMEZONE;
608
+ };
609
+
610
+ it('defaults gog to America/New_York when neither zone is set', async () => {
611
+ delete process.env.GOG_TIMEZONE;
612
+ delete process.env.DISPLAY_TZ;
613
+ expect(await zoneGogGets()).toBe('America/New_York');
614
+ });
615
+
616
+ it('hands gog DISPLAY_TZ when GOG_TIMEZONE is unset', async () => {
617
+ delete process.env.GOG_TIMEZONE;
618
+ process.env.DISPLAY_TZ = 'America/Los_Angeles';
619
+ expect(await zoneGogGets()).toBe('America/Los_Angeles');
620
+ });
621
+
622
+ it('passes a valid GOG_TIMEZONE through unchanged', async () => {
623
+ process.env.GOG_TIMEZONE = 'Europe/London';
624
+ process.env.DISPLAY_TZ = 'America/Los_Angeles';
625
+ expect(await zoneGogGets()).toBe('Europe/London');
626
+ });
627
+
628
+ it('replaces an invalid GOG_TIMEZONE with the zone the wrapper falls back to', async () => {
629
+ process.env.GOG_TIMEZONE = 'Not/AZone';
630
+ delete process.env.DISPLAY_TZ;
631
+ expect(await zoneGogGets()).toBe('America/New_York');
632
+ });
633
+ });
634
+
591
635
  it('redacts Bearer with quoted/encoded characters', async () => {
592
636
  const stderrLeak = 'http 401: header was Bearer eyJ.test+slash/equal=padding more text';
593
637
  const spawner = makeSpawner(1, '', stderrLeak);