gogcli-mcp-docs 2.21.0 → 2.22.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.
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "metadata": {
9
9
  "description": "Extended Google Docs for Claude via gogcli — auth + full Docs and comments support",
10
- "version": "2.21.0"
10
+ "version": "2.22.0"
11
11
  },
12
12
  "plugins": [
13
13
  {
@@ -15,7 +15,7 @@
15
15
  "displayName": "gogcli (Docs)",
16
16
  "source": "./",
17
17
  "description": "Extended Google Docs for Claude via gogcli — auth + full Docs and comments support",
18
- "version": "2.21.0",
18
+ "version": "2.22.0",
19
19
  "author": {
20
20
  "name": "Chris Hall"
21
21
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gogcli-mcp-docs",
3
3
  "displayName": "gogcli (Docs)",
4
- "version": "2.21.0",
4
+ "version": "2.22.0",
5
5
  "description": "Extended Google Docs for Claude via gogcli — auth + full Docs and comments support",
6
6
  "author": {
7
7
  "name": "Chris Hall",
package/README.md CHANGED
@@ -62,7 +62,7 @@ Plus 5 auth tools and 7 base Docs tools (info, cat, create, write, find-replace,
62
62
  | `gog_docs_sed` | Stream-edit with sed-like regex expressions |
63
63
  | `gog_docs_trash` | Move a doc to Drive trash |
64
64
  | `gog_docs_update` | Update document content at a specific position |
65
- | `gog_docs_comments_list` | List comments (open or resolved) |
65
+ | `gog_docs_comments_list` | List comments (open or resolved), optionally with each comment's tab and index ranges |
66
66
  | `gog_docs_comments_get` | Get a comment with its replies |
67
67
  | `gog_docs_comments_add` | Add a comment with optional quoted text |
68
68
  | `gog_docs_comments_reply` | Reply to a comment |
package/SKILL.md CHANGED
@@ -46,7 +46,7 @@ Extended Google Docs MCP server via [gogcli](https://github.com/openclaw/gogcli)
46
46
  | `gog_docs_sed` | Stream-edit with sed-like regex |
47
47
  | `gog_docs_trash` | Move a doc to Drive trash |
48
48
  | `gog_docs_update` | Update content at a specific position |
49
- | `gog_docs_comments_list` | List comments (open or resolved) |
49
+ | `gog_docs_comments_list` | List comments (open or resolved), optionally with each comment's tab and index ranges |
50
50
  | `gog_docs_comments_get` | Get a comment with replies |
51
51
  | `gog_docs_comments_add` | Add a comment with optional quoted text |
52
52
  | `gog_docs_comments_reply` | Reply to a comment |
package/dist/index.js CHANGED
@@ -31140,6 +31140,21 @@ import { delimiter, join } from "node:path";
31140
31140
  function isGogFileArg(arg) {
31141
31141
  return typeof arg !== "string";
31142
31142
  }
31143
+ var RUNNER_TRANSPORT_BRAND = /* @__PURE__ */ Symbol.for("gogcli.RunnerTransportError");
31144
+ var RunnerTransportError = class extends Error {
31145
+ kind;
31146
+ status;
31147
+ constructor(message, kind, status) {
31148
+ super(message);
31149
+ this.name = "RunnerTransportError";
31150
+ this.kind = kind;
31151
+ this.status = status;
31152
+ Object.defineProperty(this, RUNNER_TRANSPORT_BRAND, { value: true });
31153
+ }
31154
+ };
31155
+ function isRunnerTransportError(err) {
31156
+ return err instanceof Error && err[RUNNER_TRANSPORT_BRAND] === true;
31157
+ }
31143
31158
  var runExecutor = new AsyncLocalStorage();
31144
31159
  var defaultExecutor;
31145
31160
  function setDefaultGogExecutor(executor) {
@@ -31320,7 +31335,11 @@ async function run(args, options = {}) {
31320
31335
  }
31321
31336
  return redact(output);
31322
31337
  } catch (err) {
31323
- throw new Error(redact(err instanceof Error ? err.message : String(err)));
31338
+ const message = redact(err instanceof Error ? err.message : String(err));
31339
+ if (isRunnerTransportError(err)) {
31340
+ throw new RunnerTransportError(message, err.kind, err.status);
31341
+ }
31342
+ throw new Error(message);
31324
31343
  }
31325
31344
  }
31326
31345
 
@@ -31411,6 +31430,13 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
31411
31430
  // Calendar event start/end
31412
31431
  "internalDate",
31413
31432
  // Gmail, epoch milliseconds (authoritative)
31433
+ // gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
31434
+ // (RFC3339 from internalDate), so it needs no offset repair — it is
31435
+ // allowlisted purely to gain a Display sibling, and to be re-rendered in
31436
+ // DISPLAY_TZ like every other instant. Separately sourced from the sibling
31437
+ // `date`, which is a naive re-format of the sender's Date header; the two may
31438
+ // legitimately disagree. See docs/timestamps.md.
31439
+ "internalDateIso",
31414
31440
  "modifiedTime",
31415
31441
  // Drive
31416
31442
  "createdTime",
@@ -31584,7 +31610,7 @@ function registerRunTool(server, options) {
31584
31610
  function errorText(err) {
31585
31611
  return err instanceof Error ? `Error: ${err.message}` : String(err);
31586
31612
  }
31587
- var DEFINITE_AUTH_PATTERN = /\b(401|unauthorized|invalid_grant)\b/i;
31613
+ var DEFINITE_AUTH_PATTERN = /\b(?:unauthorized|invalid_grant)\b|\b(?:error|status|code|http|responded|response)["']?[\s:=(,]{0,4}401\b/i;
31588
31614
  var STALE_TOKEN_PATTERN = /\b(?:access[ _-]?)?token\b[^.;\n]{0,40}\b(?:has\s+)?(?:been\s+)?(?:expired|revoked)\b|\b(?:expired|revoked)\s+(?:access[ _-]?)?token\b/i;
31589
31615
  var AUTH_ERROR_PATTERN = new RegExp(`${DEFINITE_AUTH_PATTERN.source}|${STALE_TOKEN_PATTERN.source}`, "i");
31590
31616
  var INVALID_GRANT_PATTERN = /invalid_grant|token has been expired or revoked/i;
@@ -31594,6 +31620,14 @@ var AUTH_HINT = "\n\nAuthentication may have expired. Use gog_auth_add to re-aut
31594
31620
  var INVALID_GRANT_HINT = '\n\nThe stored refresh token was rejected (invalid_grant): it has expired or been revoked, so the whole account is signed out and re-authorization is required. The most common cause is the 7-day refresh-token limit Google applies to OAuth apps whose consent screen is still in "Testing" mode. Re-authorize with gog_auth_add (opens a browser) or gog_auth_add_url + gog_auth_add_complete (remote/headless). To stop this recurring, publish the OAuth consent screen to "In production" in the Google Cloud project that owns the OAuth client. Ask the user if they would like to re-authenticate.';
31595
31621
  var TRANSIENT_HINT = "\n\nThis error is often transient. Retry the same call before trying a different approach (do not fall back to smaller writes or row-by-row operations).";
31596
31622
  var GRID_LIMIT_HINT = "\n\nThe target range is outside the sheet's current grid. Add the missing rows or columns first with gog_sheets_insert (dimension: rows or cols), then retry the write.";
31623
+ var RUNNER_TRANSPORT_AUTH_HINT = "\n\nThis is the CONNECTOR's own transport auth failing, not your Google sign-in. The gog-runner backend rejected the bearer token this server sent, so the request never reached gog and no Google credential was checked \u2014 the Google account is not the problem and re-authorizing it cannot fix this. An operator must make the Worker secret GOG_RUNNER_KEY equal RUNNER_KEY on the Fly app (wrangler secret put GOG_RUNNER_KEY / fly secrets set RUNNER_KEY), then retry.";
31624
+ var RUNNER_TRANSPORT_HINTS = {
31625
+ "transport-auth": RUNNER_TRANSPORT_AUTH_HINT,
31626
+ // The request itself was malformed, so the runner will refuse it identically
31627
+ // every time. Nothing to advise beyond the message the runner already gave.
31628
+ "transport-request": "",
31629
+ "transport-retryable": TRANSIENT_HINT
31630
+ };
31597
31631
  function formatAccountList(raw) {
31598
31632
  try {
31599
31633
  const parsed = JSON.parse(raw);
@@ -31606,11 +31640,12 @@ function formatAccountList(raw) {
31606
31640
  }
31607
31641
  async function diagnose(err) {
31608
31642
  const errText = errorText(err);
31643
+ const transportHint = isRunnerTransportError(err) ? RUNNER_TRANSPORT_HINTS[err.kind] : void 0;
31609
31644
  const isInvalidGrant = INVALID_GRANT_PATTERN.test(errText);
31610
31645
  const isTransientError = !DEFINITE_AUTH_PATTERN.test(errText) && TRANSIENT_ERROR_PATTERN.test(errText);
31611
31646
  const isAuthError = !isTransientError && AUTH_ERROR_PATTERN.test(errText);
31612
31647
  const isGridLimitError = GRID_LIMIT_ERROR_PATTERN.test(errText);
31613
- const hint = isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "";
31648
+ const hint = transportHint ?? (isInvalidGrant ? INVALID_GRANT_HINT : isAuthError ? AUTH_HINT : isTransientError ? TRANSIENT_HINT : isGridLimitError ? GRID_LIMIT_HINT : "");
31614
31649
  try {
31615
31650
  const accounts = formatAccountList(await run(["auth", "list"]));
31616
31651
  return errorResult(`${errText}
@@ -31643,8 +31678,8 @@ function formatOneAccountHealth(a, now) {
31643
31678
  const age = ageInDays(a.created_at, now);
31644
31679
  const ageStr = age === null ? "" : ` Authorized ${age.toFixed(1)} day(s) ago.`;
31645
31680
  if (a.valid === false) {
31646
- const cause = INVALID_GRANT_PATTERN.test(a.error ?? "") ? 'refresh token expired or revoked \u2014 commonly the 7-day limit on OAuth consent screens still in "Testing" mode' : a.error?.trim() || "unknown error";
31647
- return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${cause}.${ageStr} Re-authorize with gog_auth_add (browser) or gog_auth_add_url + gog_auth_add_complete (remote/headless).`;
31681
+ const cause2 = INVALID_GRANT_PATTERN.test(a.error ?? "") ? 'refresh token expired or revoked \u2014 commonly the 7-day limit on OAuth consent screens still in "Testing" mode' : a.error?.trim() || "unknown error";
31682
+ return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${cause2}.${ageStr} Re-authorize with gog_auth_add (browser) or gog_auth_add_url + gog_auth_add_complete (remote/headless).`;
31648
31683
  }
31649
31684
  if (a.valid === true) {
31650
31685
  let line = `\u2713 ${email3}: token valid.${ageStr}`;
@@ -31686,7 +31721,7 @@ function registerAuthToolsWith(server, defaultServices) {
31686
31721
  }
31687
31722
  });
31688
31723
  server.registerTool("gog_auth_status", {
31689
- description: "Show gogcli auth configuration: keyring backend, credential files, and auth setup.",
31724
+ description: "Show gogcli auth CONFIGURATION: keyring backend, credential files, and auth setup. Despite the name this is not a health check \u2014 it reads local setup and does not contact Google, so it says nothing about whether an account can still authenticate. Use gog_auth_health for that.",
31690
31725
  annotations: { readOnlyHint: true },
31691
31726
  inputSchema: {}
31692
31727
  }, async () => {
@@ -31697,7 +31732,7 @@ function registerAuthToolsWith(server, defaultServices) {
31697
31732
  }
31698
31733
  });
31699
31734
  server.registerTool("gog_auth_health", {
31700
- description: 'Check the LIVE health of each stored Google account. Unlike gog_auth_status (which only reports keyring/config setup), this performs a real token refresh against Google, so it detects expired or revoked (invalid_grant) refresh tokens \u2014 the account-wide sign-out that blocks every service. Reports per account: whether the token is currently valid, the mapped cause when it is not, how long ago it was authorized, and a warning as it approaches the 7-day refresh-token limit that applies to OAuth apps whose consent screen is still in "Testing" mode. Run it proactively to re-authorize on your own schedule instead of mid-task.',
31735
+ description: 'Check the LIVE health of each stored Google account. Unlike gog_auth_status (which only reports keyring/config setup), this performs a real token refresh against Google, so it detects expired or revoked (invalid_grant) refresh tokens \u2014 the account-wide sign-out that blocks every service. Reports per account: whether the token is currently valid, the mapped cause when it is not, how long ago it was authorized, and a warning as it approaches the 7-day refresh-token limit that applies to OAuth apps whose consent screen is still in "Testing" mode. Run it proactively to re-authorize on your own schedule instead of mid-task. On the hosted connector this is the ONLY check that measures Google: a connector showing "connected" or "refreshed" has verified the connector key that reaches the gog machine, and nothing else \u2014 the Google credential lives on that machine and can be dead while the connection looks perfectly healthy.',
31701
31736
  annotations: { readOnlyHint: true },
31702
31737
  inputSchema: {}
31703
31738
  }, async () => {
@@ -31904,7 +31939,40 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
31904
31939
  );
31905
31940
 
31906
31941
  // ../gogcli-mcp/src/server.ts
31907
- var VERSION = true ? "2.21.0" : "0.0.0";
31942
+ var VERSION = true ? "2.22.0" : "0.0.0";
31943
+
31944
+ // ../gogcli-mcp/src/auth-log.ts
31945
+ var FAILURES = /* @__PURE__ */ new Set([
31946
+ "token.mint-failed",
31947
+ "grant.dead",
31948
+ "replay.failed",
31949
+ "runner.auth-failed",
31950
+ "connect.key-rejected",
31951
+ // An enrolment that could not proceed is a failure even though nobody is at
31952
+ // fault: it is the only trace a half-enrolled connector leaves behind, and
31953
+ // the absence of exactly this record is why DEFECT 4 could not be explained.
31954
+ "connect.runner-unreachable",
31955
+ "connect.google-unhealthy",
31956
+ "refusal.google-unhealthy",
31957
+ // The loudest record on this branch, and the only one that means "we cannot
31958
+ // explain this". Google refused a real call while a live check of the same
31959
+ // credential, taken seconds later, succeeded — so neither the 7-day cliff nor
31960
+ // a revoked grant accounts for it. It is filed as a failure precisely because
31961
+ // it is the record nobody may scroll past: it is the only evidence that could
31962
+ // ever justify building something on the hosted path, and its absence over
31963
+ // time is what retires that theory for good.
31964
+ "refusal.google-ok"
31965
+ ]);
31966
+ var PREFIX = "gog-auth ";
31967
+ var TAG_CHARS = 12;
31968
+ function credentialTag(cacheKeyHash) {
31969
+ return cacheKeyHash.slice(0, TAG_CHARS);
31970
+ }
31971
+ function logAuthTransition(event, context) {
31972
+ const record2 = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), event, ...context });
31973
+ const write = FAILURES.has(event) ? console.error : console.warn;
31974
+ write(PREFIX + redactSecrets2(record2));
31975
+ }
31908
31976
 
31909
31977
  // ../gogcli-mcp/src/google-token.ts
31910
31978
  var TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
@@ -31931,22 +31999,73 @@ function makeAccessTokenSource(env) {
31931
31999
  );
31932
32000
  };
31933
32001
  }
31934
- return async () => {
31935
- const key = await cacheKey(refreshToken, clientId);
31936
- const hit = cache.get(key);
31937
- if (hit && hit.expiresAt - EXPIRY_MARGIN_MS > Date.now()) return hit.accessToken;
31938
- let pending = inFlight.get(key);
32002
+ let keyPromise;
32003
+ const key = () => keyPromise ??= cacheKey(refreshToken, clientId);
32004
+ const logCacheHits = parseBoolEnv("GOG_AUTH_LOG_CACHE_HITS", { env });
32005
+ const read = async () => {
32006
+ const k = await key();
32007
+ const hit = cache.get(k);
32008
+ if (hit && hit.expiresAt - EXPIRY_MARGIN_MS > Date.now()) {
32009
+ if (logCacheHits) logAuthTransition("token.cache-hit", { credential: credentialTag(k) });
32010
+ return hit.accessToken;
32011
+ }
32012
+ let pending = inFlight.get(k);
31939
32013
  if (!pending) {
31940
32014
  pending = exchange(refreshToken, clientId, clientSecret).then((minted2) => {
31941
- cache.set(key, minted2);
32015
+ cache.set(k, minted2);
32016
+ logAuthTransition("token.minted", {
32017
+ credential: credentialTag(k),
32018
+ reason: `valid for ${Math.round((minted2.expiresAt - Date.now()) / 1e3)}s`
32019
+ });
31942
32020
  return minted2;
31943
- }).finally(() => inFlight.delete(key));
31944
- inFlight.set(key, pending);
32021
+ }).catch((err) => {
32022
+ logAuthTransition(err.grantDead ? "grant.dead" : "token.mint-failed", {
32023
+ credential: credentialTag(k),
32024
+ reason: err.message
32025
+ });
32026
+ throw err;
32027
+ }).finally(() => inFlight.delete(k));
32028
+ inFlight.set(k, pending);
31945
32029
  }
31946
32030
  const minted = await pending;
31947
32031
  return minted.accessToken;
31948
32032
  };
32033
+ const invalidate = async (rejected) => {
32034
+ const k = await key();
32035
+ const hit = cache.get(k);
32036
+ if (!hit || hit.accessToken !== rejected) {
32037
+ logAuthTransition("token.evict-noop", {
32038
+ credential: credentialTag(k),
32039
+ reason: hit ? "a concurrent caller had already replaced this credential\u2019s token" : "no token was cached for this credential"
32040
+ });
32041
+ return false;
32042
+ }
32043
+ cache.delete(k);
32044
+ logAuthTransition("token.evicted", {
32045
+ credential: credentialTag(k),
32046
+ reason: "Google rejected this access token; the next read will mint a new one"
32047
+ });
32048
+ return true;
32049
+ };
32050
+ return Object.assign(read, {
32051
+ invalidate,
32052
+ credentialId: async () => credentialTag(await key())
32053
+ });
31949
32054
  }
32055
+ var TokenExchangeError = class extends Error {
32056
+ /**
32057
+ * The REFRESH token is dead (Google's `invalid_grant`), not merely the access
32058
+ * token. Carried as a flag rather than re-read from the message, because
32059
+ * inferring the author of a failure from prose several authors can produce is
32060
+ * precisely the mistake this branch exists to undo. `instanceof` is safe: the
32061
+ * class is thrown and caught inside this one module.
32062
+ */
32063
+ grantDead;
32064
+ constructor(message, grantDead) {
32065
+ super(message);
32066
+ this.grantDead = grantDead;
32067
+ }
32068
+ };
31950
32069
  async function exchange(refreshToken, clientId, clientSecret) {
31951
32070
  let res;
31952
32071
  try {
@@ -31961,79 +32080,338 @@ async function exchange(refreshToken, clientId, clientSecret) {
31961
32080
  }).toString()
31962
32081
  });
31963
32082
  } catch (err) {
31964
- throw new Error(
31965
- `the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}`
32083
+ throw new TokenExchangeError(
32084
+ `the Google token exchange could not be reached: ${err instanceof Error ? err.message : String(err)}`,
32085
+ false
31966
32086
  );
31967
32087
  }
31968
32088
  const body = await res.json().catch(() => ({}));
31969
32089
  if (!res.ok) {
31970
32090
  if (body.error === "invalid_grant") {
31971
- throw new Error(
31972
- 'the stored refresh token has expired or been revoked, so this account must be re-authorized (commonly the 7-day limit on OAuth consent screens still in "Testing" mode). Re-enrol with gog_auth_add_url + gog_auth_add_complete and store the new refresh token.'
32091
+ throw new TokenExchangeError(
32092
+ 'the stored refresh token was rejected (invalid_grant): it has expired or been revoked, so this account must be re-authorized (commonly the 7-day limit on OAuth consent screens still in "Testing" mode). Re-enrol with gog_auth_add_url + gog_auth_add_complete and store the new refresh token.',
32093
+ true
31973
32094
  );
31974
32095
  }
31975
- throw new Error(
31976
- `the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})`
32096
+ throw new TokenExchangeError(
32097
+ `the access token could not be refreshed (HTTP ${res.status}${body.error ? `, ${body.error}` : ""})`,
32098
+ false
31977
32099
  );
31978
32100
  }
31979
32101
  if (!body.access_token) {
31980
- throw new Error("the access token could not be refreshed: Google returned no access_token");
32102
+ throw new TokenExchangeError(
32103
+ "the access token could not be refreshed: Google returned no access_token",
32104
+ false
32105
+ );
31981
32106
  }
31982
32107
  const expiresInMs = (body.expires_in ?? 3600) * 1e3;
31983
32108
  return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
31984
32109
  }
31985
32110
 
32111
+ // ../gogcli-mcp/src/google-probe.ts
32112
+ var bool = (value) => typeof value === "boolean" ? value : void 0;
32113
+ var cause = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
32114
+ function readGoogleProbe(body) {
32115
+ const record2 = typeof body === "object" && body !== null ? body : {};
32116
+ const measured = bool(record2.measured);
32117
+ const reported = cause(record2.error);
32118
+ if (measured === false) {
32119
+ return {
32120
+ kind: "unmeasured",
32121
+ reason: reported ?? "the runner reported it could not measure the Google layer"
32122
+ };
32123
+ }
32124
+ if (measured === true) {
32125
+ if (bool(record2.ok) === true) return { kind: "ok" };
32126
+ return {
32127
+ kind: "unhealthy",
32128
+ reason: reported ?? "the runner reported the Google layer unhealthy with no cause"
32129
+ };
32130
+ }
32131
+ return {
32132
+ kind: "unmeasured",
32133
+ reason: reported ? `the runner did not report whether it measured the Google layer; it said: ${reported}` : "the runner did not report whether it measured the Google layer"
32134
+ };
32135
+ }
32136
+
31986
32137
  // ../gogcli-mcp/src/connector-runtime.ts
31987
32138
  var DEFAULT_TIMEOUT_MS = 3e4;
31988
32139
  var DEADLINE_GRACE_MS = 5e3;
32140
+ var MIN_REPLAY_BUDGET_MS = 1e3;
32141
+ var REFUSAL_PROBE_TIMEOUT_MS = 4e3;
32142
+ var MIN_PROBE_BUDGET_MS = 1e3;
32143
+ var PROBE_INTERVAL_MS = 6e4;
31989
32144
  var RUNNER_GOG_FAILED = 422;
31990
32145
  var RUNNER_DRAINING = 503;
32146
+ var RUNNER_BAD_REQUEST = 400;
32147
+ var RUNNER_BAD_KEY = 401;
32148
+ var GogFailedError = class extends Error {
32149
+ /** gog's stderr alone, with no echoed argv mixed in. */
32150
+ stderr;
32151
+ constructor(message, stderr) {
32152
+ super(message);
32153
+ this.stderr = stderr;
32154
+ }
32155
+ };
32156
+ var GOOGLE_TOKEN_REJECTED_PATTERN = /Google API error \(401\b|invalid[ _]authentication[ _]credentials|\bACCESS_TOKEN_EXPIRED\b|\binvalid_token\b/i;
32157
+ var REFRESH_TOKEN_DEAD_PATTERN = /\binvalid_grant\b/i;
32158
+ var READ_ONLY_SUBCOMMANDS = /* @__PURE__ */ new Set([
32159
+ "cat",
32160
+ "describe",
32161
+ "get",
32162
+ "info",
32163
+ "list",
32164
+ "list-slides",
32165
+ "ls",
32166
+ "metadata",
32167
+ "read-slide",
32168
+ "search",
32169
+ "services",
32170
+ "status",
32171
+ "structure"
32172
+ ]);
32173
+ function gogTarget(args) {
32174
+ const words = args.filter((arg) => typeof arg === "string");
32175
+ let service;
32176
+ for (let i = 0; i < words.length; i += 1) {
32177
+ const word = words[i];
32178
+ if (word.startsWith("-")) {
32179
+ if (word === "--account") i += 1;
32180
+ continue;
32181
+ }
32182
+ if (service === void 0) {
32183
+ service = word;
32184
+ continue;
32185
+ }
32186
+ return { service, subcommand: word };
32187
+ }
32188
+ return { service };
32189
+ }
32190
+ async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt, probeGoogle) {
32191
+ if (!(err instanceof GogFailedError)) return void 0;
32192
+ const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
32193
+ if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
32194
+ const { service, subcommand } = gogTarget(args);
32195
+ const credential = await readAccessToken?.credentialId?.();
32196
+ const where = { credential, service };
32197
+ if (grantDead) {
32198
+ logAuthTransition("grant.dead", {
32199
+ ...where,
32200
+ reason: "gog reported invalid_grant: the stored refresh token is dead, so no token can be minted and this account must be re-authorized"
32201
+ });
32202
+ return void 0;
32203
+ }
32204
+ if (!used) {
32205
+ await probeGoogle(where);
32206
+ logAuthTransition("replay.declined", {
32207
+ ...where,
32208
+ reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
32209
+ });
32210
+ return void 0;
32211
+ }
32212
+ if (!readAccessToken?.invalidate) {
32213
+ logAuthTransition("replay.declined", {
32214
+ ...where,
32215
+ reason: "this token source cannot mint a replacement, so a replay would resend the rejected token"
32216
+ });
32217
+ return void 0;
32218
+ }
32219
+ const evicted = await readAccessToken.invalidate(used);
32220
+ if (subcommand === void 0 || !READ_ONLY_SUBCOMMANDS.has(subcommand)) {
32221
+ logAuthTransition("replay.declined", {
32222
+ ...where,
32223
+ reason: `not replayable: '${subcommand ?? "(none)"}' is not a known read-only subcommand and a write could double-apply`
32224
+ });
32225
+ return void 0;
32226
+ }
32227
+ if (!evicted) {
32228
+ logAuthTransition("replay.declined", {
32229
+ ...where,
32230
+ reason: "the rejected token was already superseded, so the cache holds the token a replay would send"
32231
+ });
32232
+ return void 0;
32233
+ }
32234
+ const fresh = await readAccessToken();
32235
+ if (!fresh) {
32236
+ logAuthTransition("replay.declined", {
32237
+ ...where,
32238
+ reason: "the token source produced no token after eviction; replaying without one would act as the backend"
32239
+ });
32240
+ return void 0;
32241
+ }
32242
+ const budgetMs = deadlineAt - Date.now();
32243
+ if (budgetMs < MIN_REPLAY_BUDGET_MS) {
32244
+ logAuthTransition("replay.declined", {
32245
+ ...where,
32246
+ reason: `only ${budgetMs}ms of the call\u2019s deadline remained, so a replay could only time out; the rejected token was evicted, so the next call mints a fresh one`
32247
+ });
32248
+ return void 0;
32249
+ }
32250
+ return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
32251
+ }
31991
32252
  function makeFlyExecutor(endpoint, key, readAccessToken) {
32253
+ let lastProbeAt = Number.NEGATIVE_INFINITY;
32254
+ const probeGoogleAfterRefusal = async (where, deadlineAt) => {
32255
+ const record2 = { ...where, endpoint };
32256
+ const now = Date.now();
32257
+ const remainingMs = deadlineAt - now;
32258
+ if (remainingMs < MIN_PROBE_BUDGET_MS) {
32259
+ logAuthTransition("refusal.google-unmeasured", {
32260
+ ...record2,
32261
+ reason: `only ${remainingMs}ms of the call\u2019s deadline remained, so the Google layer was not measured rather than delay the caller\u2019s own error`
32262
+ });
32263
+ return;
32264
+ }
32265
+ if (now - lastProbeAt < PROBE_INTERVAL_MS) {
32266
+ logAuthTransition("refusal.google-unmeasured", {
32267
+ ...record2,
32268
+ // "attempted", not "measured". `lastProbeAt` is stamped before the
32269
+ // fetch and is deliberately NOT reset when the probe comes back with no
32270
+ // verdict (a 404 from a runner too old to have the endpoint, a timeout,
32271
+ // a dead socket) — the backend cost this throttle exists to bound was
32272
+ // paid either way, and resetting it would let a retry loop storm a
32273
+ // runner that is already unwell. So the timestamp stays and the sentence
32274
+ // has to be the true one: on this branch a log line may not assert a
32275
+ // measurement that never happened, and the previous probe may well have
32276
+ // measured nothing at all.
32277
+ reason: "a Google probe was attempted recently, so another was not sent: this probe spawns gog on the backend and takes the keyring\u2019s exclusive lock"
32278
+ });
32279
+ return;
32280
+ }
32281
+ lastProbeAt = now;
32282
+ let event;
32283
+ let reason;
32284
+ try {
32285
+ const res = await fetch(`${endpoint}/health/google`, {
32286
+ headers: { Authorization: `Bearer ${key}` },
32287
+ // Never more than the probe's own budget, never more than the call has
32288
+ // left. `Math.min` rather than a plain constant because the second
32289
+ // bound is the caller's, and it outranks ours.
32290
+ signal: AbortSignal.timeout(Math.min(REFUSAL_PROBE_TIMEOUT_MS, remainingMs))
32291
+ });
32292
+ if (!res.ok) {
32293
+ event = "refusal.google-unmeasured";
32294
+ reason = `the runner did not answer the Google probe (HTTP ${res.status})`;
32295
+ } else {
32296
+ const verdict = readGoogleProbe(await res.json());
32297
+ if (verdict.kind === "ok") {
32298
+ event = "refusal.google-ok";
32299
+ reason = "Google refused this call, yet a live token check on the same volume succeeded \u2014 so a dead or expired refresh token does not explain this refusal";
32300
+ } else {
32301
+ event = verdict.kind === "unhealthy" ? "refusal.google-unhealthy" : "refusal.google-unmeasured";
32302
+ reason = verdict.reason;
32303
+ }
32304
+ }
32305
+ } catch (err) {
32306
+ event = "refusal.google-unmeasured";
32307
+ reason = err instanceof Error ? err.message : String(err);
32308
+ }
32309
+ logAuthTransition(event, { ...record2, reason });
32310
+ };
31992
32311
  return async (args, opts) => {
31993
32312
  const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
31994
32313
  const accessToken = await readAccessToken?.();
31995
- let res;
32314
+ const deadlineAt = Date.now() + deadlineMs;
31996
32315
  try {
31997
- res = await fetch(endpoint + "/run", {
31998
- method: "POST",
31999
- headers: {
32000
- Authorization: "Bearer " + key,
32001
- "Content-Type": "application/json"
32002
- },
32003
- body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
32004
- signal: AbortSignal.timeout(deadlineMs)
32005
- });
32316
+ return await attempt(endpoint, key, args, accessToken, deadlineMs);
32006
32317
  } catch (err) {
32007
- const name = err instanceof Error ? err.name : "";
32008
- if (name === "TimeoutError" || name === "AbortError") {
32009
- throw new Error(
32010
- `gog-runner did not respond within ${deadlineMs}ms (${endpoint}) \u2014 the Fly backend may be cold or wedged`
32011
- );
32318
+ const replay = await remintAfterGoogleRejection(
32319
+ err,
32320
+ accessToken,
32321
+ args,
32322
+ readAccessToken,
32323
+ deadlineAt,
32324
+ (where2) => probeGoogleAfterRefusal(where2, deadlineAt)
32325
+ );
32326
+ if (replay === void 0) throw err;
32327
+ const where = { credential: replay.credential, service: replay.service, endpoint };
32328
+ logAuthTransition("replay.attempted", {
32329
+ ...where,
32330
+ reason: "Google rejected the access token; replaying this read once with a freshly minted one"
32331
+ });
32332
+ try {
32333
+ const stdout = await attempt(endpoint, key, args, replay.token, replay.budgetMs);
32334
+ logAuthTransition("replay.succeeded", where);
32335
+ return stdout;
32336
+ } catch (replayErr) {
32337
+ logAuthTransition("replay.failed", { ...where, reason: String(replayErr) });
32338
+ if (replayErr instanceof GogFailedError && GOOGLE_TOKEN_REJECTED_PATTERN.test(replayErr.stderr)) {
32339
+ await replay.invalidate(replay.token);
32340
+ }
32341
+ throw replayErr;
32012
32342
  }
32013
- throw err;
32014
32343
  }
32015
- if (!res.ok) {
32016
- const body = await res.json().catch(() => null);
32017
- const detail = body && typeof body.error === "string" ? body.stderr && body.stderr.trim() && body.stderr.trim() !== body.error.trim() ? `${body.error}
32344
+ };
32345
+ }
32346
+ async function attempt(endpoint, key, args, accessToken, deadlineMs) {
32347
+ let res;
32348
+ try {
32349
+ res = await fetch(endpoint + "/run", {
32350
+ method: "POST",
32351
+ headers: {
32352
+ Authorization: "Bearer " + key,
32353
+ "Content-Type": "application/json"
32354
+ },
32355
+ body: JSON.stringify(accessToken ? { args, accessToken } : { args }),
32356
+ signal: AbortSignal.timeout(deadlineMs)
32357
+ });
32358
+ } catch (err) {
32359
+ const name = err instanceof Error ? err.name : "";
32360
+ if (name === "TimeoutError" || name === "AbortError") {
32361
+ throw new RunnerTransportError(
32362
+ `gog-runner did not respond within ${deadlineMs}ms (${endpoint}) \u2014 the Fly backend may be cold or wedged`,
32363
+ "transport-retryable"
32364
+ );
32365
+ }
32366
+ throw err;
32367
+ }
32368
+ if (!res.ok) {
32369
+ const body = await res.json().catch(() => null);
32370
+ const detail = body && typeof body.error === "string" ? body.stderr && body.stderr.trim() && body.stderr.trim() !== body.error.trim() ? `${body.error}
32018
32371
  ${body.stderr}` : body.error : "";
32019
- if (res.status === RUNNER_GOG_FAILED) {
32020
- throw new Error(detail || "gog failed on the runner (no detail supplied)");
32021
- }
32022
- if (res.status === RUNNER_DRAINING || body?.retryable === true) {
32023
- throw new Error(
32024
- `gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`
32025
- );
32026
- }
32027
- if (detail) {
32028
- throw new Error(detail);
32029
- }
32030
- throw new Error(
32031
- `gog-runner HTTP ${res.status}: the response did not come from the runner, so the request never reached gog. The backend Machine was most likely starting or shutting down \u2014 this is transient, retry the same call.`
32372
+ if (res.status === RUNNER_GOG_FAILED) {
32373
+ throw new GogFailedError(
32374
+ detail || "gog failed on the runner (no detail supplied)",
32375
+ typeof body?.stderr === "string" ? body.stderr : ""
32032
32376
  );
32033
32377
  }
32034
- const { stdout } = await res.json();
32035
- return stdout;
32036
- };
32378
+ if (res.status === RUNNER_BAD_KEY) {
32379
+ logAuthTransition("runner.auth-failed", {
32380
+ service: gogTarget(args).service,
32381
+ endpoint,
32382
+ reason: "the gog-runner rejected the connector\u2019s bearer token, so gog never ran and no Google credential was read; GOG_RUNNER_KEY does not match the Fly app\u2019s RUNNER_KEY"
32383
+ });
32384
+ throw new RunnerTransportError(
32385
+ "gog-runner rejected the connector's bearer token, so the request never reached gog and no Google credential was involved. The Worker secret GOG_RUNNER_KEY no longer matches RUNNER_KEY on the Fly app; set them to the same value (wrangler secret put GOG_RUNNER_KEY / fly secrets set RUNNER_KEY) and retry.",
32386
+ "transport-auth",
32387
+ res.status
32388
+ );
32389
+ }
32390
+ if (res.status === RUNNER_BAD_REQUEST) {
32391
+ throw new RunnerTransportError(
32392
+ detail || "gog-runner rejected the request (no detail supplied)",
32393
+ "transport-request",
32394
+ res.status
32395
+ );
32396
+ }
32397
+ if (res.status === RUNNER_DRAINING || body?.retryable === true) {
32398
+ throw new RunnerTransportError(
32399
+ `gog-runner is restarting; retry this call.${detail ? ` ${detail}` : ""}`,
32400
+ "transport-retryable",
32401
+ res.status
32402
+ );
32403
+ }
32404
+ if (detail) {
32405
+ throw new Error(detail);
32406
+ }
32407
+ throw new RunnerTransportError(
32408
+ `gog-runner HTTP ${res.status}: the response did not come from the runner, so the request never reached gog. The backend Machine was most likely starting or shutting down \u2014 this is transient, retry the same call.`,
32409
+ "transport-retryable",
32410
+ res.status
32411
+ );
32412
+ }
32413
+ const { stdout } = await res.json();
32414
+ return stdout;
32037
32415
  }
32038
32416
 
32039
32417
  // ../gogcli-mcp/src/remote-runner.ts
@@ -32292,7 +32670,7 @@ function registerExtraDocsTools(server) {
32292
32670
  inputSchema: {
32293
32671
  docId: external_exports.string().describe("Doc ID (from the URL)"),
32294
32672
  text: external_exports.string().optional().describe("Text content to append"),
32295
- file: external_exports.string().optional().describe('Path to a text file to append (use "-" for stdin)'),
32673
+ file: external_exports.string().optional().describe(`Path to a text file to append, read on the gog server. gog also accepts "-" for stdin, but this server never writes to gog's stdin, so "-" would hang until the call times out.`),
32296
32674
  markdown: external_exports.boolean().optional().describe("Convert markdown to Google Docs formatting (headings, bold, lists, etc.). See the tool description for known upstream limitations around tables."),
32297
32675
  tab: external_exports.string().optional().describe("Target tab title or ID (for multi-tab docs)"),
32298
32676
  account: accountParam
@@ -32374,19 +32752,23 @@ function registerExtraDocsTools(server) {
32374
32752
  return runOrDiagnose(args, { account });
32375
32753
  });
32376
32754
  server.registerTool("gog_docs_comments_list", {
32377
- description: "List comments on a Google Doc. Returns open comments by default; set includeResolved=true to include resolved comments.",
32755
+ description: "List comments on a Google Doc. Returns open comments by default; set includeResolved=true to include resolved comments. Set locate=true (or pass tab) to attach each comment's tab and Docs index ranges as location.matches[] plus location.orphaned \u2014 that costs one extra document fetch, but only one for the whole listing, where gog_docs_comments_locate costs one per comment. Either flag additionally requires the Docs scope; the plain listing needs only Drive. matches[] always spans every tab, so a quote appearing in two tabs is visible as an ambiguity rather than silently resolved. tab keeps only comments with a match in that tab, which drops orphaned comments and comments that quote nothing.",
32378
32756
  annotations: { readOnlyHint: true },
32379
32757
  inputSchema: {
32380
32758
  docId: external_exports.string().describe("Doc ID (from the URL)"),
32381
32759
  includeResolved: external_exports.boolean().optional().describe("Include resolved comments (default: false, open only)"),
32382
32760
  since: external_exports.string().optional().describe("Only return comments modified at or after this RFC3339 timestamp (e.g. 2026-06-01T00:00:00Z)"),
32761
+ locate: external_exports.boolean().optional().describe("Attach each comment's tab and Docs index ranges (location.matches[] + location.orphaned) using one extra document fetch shared across the whole listing"),
32762
+ tab: external_exports.string().optional().describe("Only return comments whose quoted text resolves inside this tab (title or ID). Implies locate, and drops orphaned and unquoted comments."),
32383
32763
  ...paginationParams,
32384
32764
  account: accountParam
32385
32765
  }
32386
- }, async ({ docId, includeResolved, since, max, page, all, account }) => {
32766
+ }, async ({ docId, includeResolved, since, locate, tab, max, page, all, account }) => {
32387
32767
  const args = ["docs", "comments", "list", docId];
32388
32768
  if (includeResolved) args.push("--include-resolved");
32389
32769
  if (since) args.push(`--since=${since}`);
32770
+ if (locate) args.push("--locate");
32771
+ if (tab) args.push(`--tab=${tab}`);
32390
32772
  pushPaginationFlags(args, { max, page, all });
32391
32773
  return runOrDiagnose(args, { account });
32392
32774
  });
@@ -33119,7 +33501,7 @@ function registerExtraDocsTools(server) {
33119
33501
  inputSchema: {
33120
33502
  docId: external_exports.string().describe("Doc ID (from the URL)"),
33121
33503
  text: external_exports.string().optional().describe("Footnote text"),
33122
- file: external_exports.string().optional().describe('Read footnote text from a file ("-" for stdin)'),
33504
+ file: external_exports.string().optional().describe(`Read footnote text from a file on the gog server. gog also accepts "-" for stdin, but this server never writes to gog's stdin, so "-" would hang until the call times out.`),
33123
33505
  index: external_exports.number().int().optional().describe("Character index to place the reference mark at (1 = beginning). Omit or use atEnd for end-of-doc."),
33124
33506
  atEnd: external_exports.boolean().optional().describe("Target end-of-doc/tab (mutually exclusive with index and at)"),
33125
33507
  at: external_exports.string().optional().describe("Anchor by literal text and place the reference mark at the start of the matched range"),
@@ -33238,7 +33620,7 @@ function registerExtraDocsTools(server) {
33238
33620
  inputSchema: {
33239
33621
  docId: external_exports.string().describe("Doc ID (from the URL)"),
33240
33622
  text: external_exports.string().optional().describe("Initial header text"),
33241
- file: external_exports.string().optional().describe('Read initial header text from a file ("-" for stdin)'),
33623
+ file: external_exports.string().optional().describe(`Read initial header text from a file on the gog server. gog also accepts "-" for stdin, but this server never writes to gog's stdin, so "-" would hang until the call times out.`),
33242
33624
  index: external_exports.number().int().optional().describe("Character index identifying the section the header belongs to (1 = beginning). Omit or use atEnd for end-of-doc."),
33243
33625
  atEnd: external_exports.boolean().optional().describe("Target end-of-doc/tab (mutually exclusive with index and at)"),
33244
33626
  at: external_exports.string().optional().describe("Anchor by literal text and target the section at the start of the matched range"),
@@ -33292,7 +33674,7 @@ function registerExtraDocsTools(server) {
33292
33674
  inputSchema: {
33293
33675
  docId: external_exports.string().describe("Doc ID (from the URL)"),
33294
33676
  text: external_exports.string().optional().describe("Initial footer text"),
33295
- file: external_exports.string().optional().describe('Read initial footer text from a file ("-" for stdin)'),
33677
+ file: external_exports.string().optional().describe(`Read initial footer text from a file on the gog server. gog also accepts "-" for stdin, but this server never writes to gog's stdin, so "-" would hang until the call times out.`),
33296
33678
  index: external_exports.number().int().optional().describe("Character index identifying the section the footer belongs to (1 = beginning). Omit or use atEnd for end-of-doc."),
33297
33679
  atEnd: external_exports.boolean().optional().describe("Target end-of-doc/tab (mutually exclusive with index and at)"),
33298
33680
  at: external_exports.string().optional().describe("Anchor by literal text and target the section at the start of the matched range"),
package/manifest.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "manifest_version": "0.3",
4
4
  "name": "gogcli-mcp-docs",
5
5
  "display_name": "gogcli (Docs)",
6
- "version": "2.21.0",
6
+ "version": "2.22.0",
7
7
  "description": "Extended Google Docs for Claude via gogcli — auth + full Docs and comments support",
8
8
  "author": {
9
9
  "name": "Chris Hall",
@@ -165,7 +165,7 @@
165
165
  },
166
166
  {
167
167
  "name": "gog_docs_comments_list",
168
- "description": "List comments on a Google Doc. Returns open comments by default; set includeResolved=true to include resolved comments."
168
+ "description": "List comments on a Google Doc. Returns open comments by default; set includeResolved=true to include resolved comments, or locate/tab to attach each comment's tab and index ranges in one extra fetch."
169
169
  },
170
170
  {
171
171
  "name": "gog_docs_comments_get",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gogcli-mcp-docs",
3
- "version": "2.21.0",
3
+ "version": "2.22.0",
4
4
  "mcpName": "io.github.chrischall/gogcli-mcp-docs",
5
5
  "description": "Extended Google Docs MCP server via gogcli — all base tools plus full Docs support",
6
6
  "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "source": "github",
8
8
  "subfolder": "packages/gogcli-mcp-docs"
9
9
  },
10
- "version": "2.21.0",
10
+ "version": "2.22.0",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "gogcli-mcp-docs",
15
- "version": "2.21.0",
15
+ "version": "2.22.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -284,7 +284,7 @@ export function registerExtraDocsTools(server: McpServer): void {
284
284
  inputSchema: {
285
285
  docId: z.string().describe('Doc ID (from the URL)'),
286
286
  text: z.string().optional().describe('Text content to append'),
287
- file: z.string().optional().describe('Path to a text file to append (use "-" for stdin)'),
287
+ file: z.string().optional().describe('Path to a text file to append, read on the gog server. gog also accepts "-" for stdin, but this server never writes to gog\'s stdin, so "-" would hang until the call times out.'),
288
288
  markdown: z.boolean().optional().describe('Convert markdown to Google Docs formatting (headings, bold, lists, etc.). See the tool description for known upstream limitations around tables.'),
289
289
  tab: z.string().optional().describe('Target tab title or ID (for multi-tab docs)'),
290
290
  account: accountParam,
@@ -372,19 +372,28 @@ export function registerExtraDocsTools(server: McpServer): void {
372
372
  // Comment-thread tools
373
373
  server.registerTool('gog_docs_comments_list', {
374
374
  description:
375
- 'List comments on a Google Doc. Returns open comments by default; set includeResolved=true to include resolved comments.',
375
+ 'List comments on a Google Doc. Returns open comments by default; set includeResolved=true to include resolved comments. ' +
376
+ 'Set locate=true (or pass tab) to attach each comment\'s tab and Docs index ranges as location.matches[] plus location.orphaned — ' +
377
+ 'that costs one extra document fetch, but only one for the whole listing, where gog_docs_comments_locate costs one per comment. ' +
378
+ 'Either flag additionally requires the Docs scope; the plain listing needs only Drive. ' +
379
+ 'matches[] always spans every tab, so a quote appearing in two tabs is visible as an ambiguity rather than silently resolved. ' +
380
+ 'tab keeps only comments with a match in that tab, which drops orphaned comments and comments that quote nothing.',
376
381
  annotations: { readOnlyHint: true },
377
382
  inputSchema: {
378
383
  docId: z.string().describe('Doc ID (from the URL)'),
379
384
  includeResolved: z.boolean().optional().describe('Include resolved comments (default: false, open only)'),
380
385
  since: z.string().optional().describe('Only return comments modified at or after this RFC3339 timestamp (e.g. 2026-06-01T00:00:00Z)'),
386
+ locate: z.boolean().optional().describe('Attach each comment\'s tab and Docs index ranges (location.matches[] + location.orphaned) using one extra document fetch shared across the whole listing'),
387
+ tab: z.string().optional().describe('Only return comments whose quoted text resolves inside this tab (title or ID). Implies locate, and drops orphaned and unquoted comments.'),
381
388
  ...paginationParams,
382
389
  account: accountParam,
383
390
  },
384
- }, async ({ docId, includeResolved, since, max, page, all, account }) => {
391
+ }, async ({ docId, includeResolved, since, locate, tab, max, page, all, account }) => {
385
392
  const args = ['docs', 'comments', 'list', docId];
386
393
  if (includeResolved) args.push('--include-resolved');
387
394
  if (since) args.push(`--since=${since}`);
395
+ if (locate) args.push('--locate');
396
+ if (tab) args.push(`--tab=${tab}`);
388
397
  pushPaginationFlags(args, { max, page, all });
389
398
  return runOrDiagnose(args, { account });
390
399
  });
@@ -1177,7 +1186,7 @@ export function registerExtraDocsTools(server: McpServer): void {
1177
1186
  inputSchema: {
1178
1187
  docId: z.string().describe('Doc ID (from the URL)'),
1179
1188
  text: z.string().optional().describe('Footnote text'),
1180
- file: z.string().optional().describe('Read footnote text from a file ("-" for stdin)'),
1189
+ file: z.string().optional().describe('Read footnote text from a file on the gog server. gog also accepts "-" for stdin, but this server never writes to gog\'s stdin, so "-" would hang until the call times out.'),
1181
1190
  index: z.number().int().optional().describe('Character index to place the reference mark at (1 = beginning). Omit or use atEnd for end-of-doc.'),
1182
1191
  atEnd: z.boolean().optional().describe('Target end-of-doc/tab (mutually exclusive with index and at)'),
1183
1192
  at: z.string().optional().describe('Anchor by literal text and place the reference mark at the start of the matched range'),
@@ -1304,7 +1313,7 @@ export function registerExtraDocsTools(server: McpServer): void {
1304
1313
  inputSchema: {
1305
1314
  docId: z.string().describe('Doc ID (from the URL)'),
1306
1315
  text: z.string().optional().describe('Initial header text'),
1307
- file: z.string().optional().describe('Read initial header text from a file ("-" for stdin)'),
1316
+ file: z.string().optional().describe('Read initial header text from a file on the gog server. gog also accepts "-" for stdin, but this server never writes to gog\'s stdin, so "-" would hang until the call times out.'),
1308
1317
  index: z.number().int().optional().describe('Character index identifying the section the header belongs to (1 = beginning). Omit or use atEnd for end-of-doc.'),
1309
1318
  atEnd: z.boolean().optional().describe('Target end-of-doc/tab (mutually exclusive with index and at)'),
1310
1319
  at: z.string().optional().describe('Anchor by literal text and target the section at the start of the matched range'),
@@ -1361,7 +1370,7 @@ export function registerExtraDocsTools(server: McpServer): void {
1361
1370
  inputSchema: {
1362
1371
  docId: z.string().describe('Doc ID (from the URL)'),
1363
1372
  text: z.string().optional().describe('Initial footer text'),
1364
- file: z.string().optional().describe('Read initial footer text from a file ("-" for stdin)'),
1373
+ file: z.string().optional().describe('Read initial footer text from a file on the gog server. gog also accepts "-" for stdin, but this server never writes to gog\'s stdin, so "-" would hang until the call times out.'),
1365
1374
  index: z.number().int().optional().describe('Character index identifying the section the footer belongs to (1 = beginning). Omit or use atEnd for end-of-doc.'),
1366
1375
  atEnd: z.boolean().optional().describe('Target end-of-doc/tab (mutually exclusive with index and at)'),
1367
1376
  at: z.string().optional().describe('Anchor by literal text and target the section at the start of the matched range'),
@@ -503,6 +503,82 @@ describe('gog_docs_comments_list', () => {
503
503
  { account: undefined },
504
504
  );
505
505
  });
506
+
507
+ // gog 0.35.0 (openclaw/gogcli#965) adds --locate/--tab, which share ONE
508
+ // documents.get(includeTabsContent=true) across every comment on the page.
509
+ // The pre-0.35.0 way to answer "which tab is this comment in?" was one
510
+ // `docs comments locate` per comment — 30 fetches for a 30-comment doc.
511
+ it('includes --locate when requested', async () => {
512
+ vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
513
+ const harness = await setupHandlers();
514
+ await harness.callTool('gog_docs_comments_list', { docId: 'abc', locate: true });
515
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(
516
+ ['docs', 'comments', 'list', 'abc', '--locate'],
517
+ { account: undefined },
518
+ );
519
+ });
520
+
521
+ it('omits --locate when false', async () => {
522
+ vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
523
+ const harness = await setupHandlers();
524
+ await harness.callTool('gog_docs_comments_list', { docId: 'abc', locate: false });
525
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', 'abc'], { account: undefined });
526
+ });
527
+
528
+ it('includes --tab, which gog treats as implying --locate', async () => {
529
+ vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
530
+ const harness = await setupHandlers();
531
+ await harness.callTool('gog_docs_comments_list', { docId: 'abc', tab: 'Notes' });
532
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(
533
+ ['docs', 'comments', 'list', 'abc', '--tab=Notes'],
534
+ { account: undefined },
535
+ );
536
+ });
537
+
538
+ // gog rejects an explicitly empty --tab (`--tab requires a non-empty tab
539
+ // title or ID`), so an empty string must never reach the arg array.
540
+ it('never emits an empty --tab', async () => {
541
+ vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
542
+ const harness = await setupHandlers();
543
+ await harness.callTool('gog_docs_comments_list', { docId: 'abc', tab: '' });
544
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', 'abc'], { account: undefined });
545
+ });
546
+
547
+ it('combines --locate and --tab with the existing filters and pagination', async () => {
548
+ vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
549
+ const harness = await setupHandlers();
550
+ await harness.callTool('gog_docs_comments_list', {
551
+ docId: 'abc', includeResolved: true, since: '2026-06-01T00:00:00Z',
552
+ locate: true, tab: 'Notes', max: 10, page: 'tok', all: true,
553
+ });
554
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(
555
+ [
556
+ 'docs', 'comments', 'list', 'abc',
557
+ '--include-resolved',
558
+ '--since=2026-06-01T00:00:00Z',
559
+ '--locate',
560
+ '--tab=Notes',
561
+ '--max=10', '--page=tok', '--all',
562
+ ],
563
+ { account: undefined },
564
+ );
565
+ });
566
+
567
+ it('description states the extra fetch, the Docs scope, and that --tab drops orphans', async () => {
568
+ const { McpServer } = await import('@modelcontextprotocol/sdk/server/mcp.js');
569
+ const server = new McpServer({ name: 'test', version: '0.0.0' });
570
+ const configs = new Map<string, { description?: string }>();
571
+ vi.spyOn(server, 'registerTool').mockImplementation((name, config) => {
572
+ configs.set(name, config as { description?: string });
573
+ return undefined as never;
574
+ });
575
+ const { registerExtraDocsTools } = await import('../../src/tools/docs-extra.js');
576
+ registerExtraDocsTools(server);
577
+ const desc = configs.get('gog_docs_comments_list')?.description ?? '';
578
+ expect(desc).toMatch(/one extra/i);
579
+ expect(desc).toMatch(/Docs scope/);
580
+ expect(desc).toMatch(/orphan/i);
581
+ });
506
582
  });
507
583
 
508
584
  describe('gog_docs_table_column_width', () => {
@@ -2156,3 +2232,35 @@ describe('gog_docs_format spacingMode', () => {
2156
2232
  );
2157
2233
  });
2158
2234
  });
2235
+
2236
+ // Same trap the gmail package documents: gog resolves a "-" path through
2237
+ // io.ReadAll(stdinReader(ctx)) (docs_helpers.go resolveContentInput:26 and
2238
+ // readTextInput:83 at upstream-v0.35.0 — os.Stdin, unaffected by --no-input),
2239
+ // but runner.ts spawns with default stdio and never writes to or ends
2240
+ // child.stdin, so the call blocks until the 30s timeout fires. Reproduced
2241
+ // against a live gog v0.35.0: the child was still running with zero output
2242
+ // after 5s. These descriptions must warn, not offer.
2243
+ describe('server-side file params never advertise stdin as usable', () => {
2244
+ const STDIN_PARAMS: Array<[tool: string, param: string]> = [
2245
+ ['gog_docs_append', 'file'],
2246
+ ['gog_docs_insert_footnote', 'file'],
2247
+ ['gog_docs_header_create', 'file'],
2248
+ ['gog_docs_footer_create', 'file'],
2249
+ ];
2250
+
2251
+ it.each(STDIN_PARAMS)('%s.%s warns that stdin hangs instead of offering it', async (tool, param) => {
2252
+ const { McpServer } = await import('@modelcontextprotocol/sdk/server/mcp.js');
2253
+ const server = new McpServer({ name: 'test', version: '0.0.0' });
2254
+ const schemas = new Map<string, Record<string, { description?: string }>>();
2255
+ vi.spyOn(server, 'registerTool').mockImplementation((name, config) => {
2256
+ schemas.set(name, (config as { inputSchema: Record<string, { description?: string }> }).inputSchema);
2257
+ return undefined as never;
2258
+ });
2259
+ registerExtraDocsTools(server);
2260
+ const desc = schemas.get(tool)?.[param]?.description ?? '';
2261
+ expect(desc).not.toBe('');
2262
+ expect(desc).not.toMatch(/(?:use|or)\s+"?-"?\s*(?:for|to read)/i);
2263
+ expect(desc).toMatch(/stdin/i);
2264
+ expect(desc).toMatch(/hang|never writes/i);
2265
+ });
2266
+ });