gogcli-mcp-gmail 2.21.1 → 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.
- package/README.md +26 -4
- package/SKILL.md +24 -3
- package/dist/index.js +200 -22
- package/manifest.json +6 -2
- package/package.json +1 -1
- package/src/tools/gmail-extra.ts +197 -27
- package/tests/tools/attachment-index-resolve.test.ts +76 -0
- package/tests/tools/gmail-extra.test.ts +350 -48
package/README.md
CHANGED
|
@@ -44,18 +44,19 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
44
44
|
claude mcp add gogcli-gmail -- gogcli-mcp-gmail
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
## Extra Gmail Tools (
|
|
47
|
+
## Extra Gmail Tools (45)
|
|
48
48
|
|
|
49
|
-
Plus
|
|
49
|
+
Plus 8 auth tools and 4 base Gmail tools (search, get, send, run) — 57 in all.
|
|
50
50
|
|
|
51
51
|
### Read
|
|
52
52
|
|
|
53
53
|
| Tool | Description |
|
|
54
54
|
|------|-------------|
|
|
55
55
|
| `gog_gmail_raw` | Dump the raw Gmail API JSON for a message (lossless, for scripting) |
|
|
56
|
-
| `gog_gmail_attachment` | Download an attachment and deliver its contents — inline (base64 image/resource) when
|
|
56
|
+
| `gog_gmail_attachment` | Download an attachment (by `attachmentIndex`, or the legacy opaque `attachmentId`) and deliver its contents — inline (base64 image/resource) when within the inline limit (3 MiB by default, `inlineMaxBytes`), otherwise uploaded to Google Drive with a shareable link (`deliver`: auto/inline/drive/off) |
|
|
57
57
|
| `gog_gmail_url` | Print Gmail web URLs for one or more threads |
|
|
58
58
|
| `gog_gmail_history` | List Gmail history events since a given historyId |
|
|
59
|
+
| `gog_gmail_messages_search` | Search individual messages rather than threads — one result per matching message |
|
|
59
60
|
|
|
60
61
|
### Threads
|
|
61
62
|
|
|
@@ -75,6 +76,7 @@ Plus 5 auth tools and 4 base Gmail tools (search, get, send, run).
|
|
|
75
76
|
| `gog_gmail_labels_rename` | Rename a label |
|
|
76
77
|
| `gog_gmail_labels_delete` | Delete a label |
|
|
77
78
|
| `gog_gmail_labels_modify` | Modify labels on one or more threads |
|
|
79
|
+
| `gog_gmail_labels_style` | Change a user label's color or visibility |
|
|
78
80
|
|
|
79
81
|
### Bulk Operations
|
|
80
82
|
|
|
@@ -103,10 +105,30 @@ Plus 5 auth tools and 4 base Gmail tools (search, get, send, run).
|
|
|
103
105
|
|
|
104
106
|
| Tool | Description |
|
|
105
107
|
|------|-------------|
|
|
108
|
+
| `gog_gmail_import` | Import an RFC822/EML message into the mailbox, keeping its original headers and date (does not send) |
|
|
106
109
|
| `gog_gmail_forward` | Forward a message to new recipients (with optional note) |
|
|
110
|
+
| `gog_gmail_reply` | Reply to a message (original sender only) |
|
|
111
|
+
| `gog_gmail_reply_all` | Reply to every participant (sender plus all To/Cc recipients) |
|
|
107
112
|
| `gog_gmail_autoreply` | Reply once to all messages matching a query (with dedupe label) |
|
|
108
113
|
|
|
109
|
-
|
|
114
|
+
### Settings
|
|
115
|
+
|
|
116
|
+
| Tool | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| `gog_gmail_vacation_get` | Get the vacation responder (auto-reply) settings |
|
|
119
|
+
| `gog_gmail_vacation_update` | Enable or disable the vacation responder, with optional start/end and audience limits |
|
|
120
|
+
| `gog_gmail_filters_list` | List all Gmail filters |
|
|
121
|
+
| `gog_gmail_filters_get` | Get a filter's criteria and actions by ID |
|
|
122
|
+
| `gog_gmail_filters_create` | Create a filter from match criteria plus one or more actions |
|
|
123
|
+
| `gog_gmail_filters_delete` | Delete a filter by ID |
|
|
124
|
+
| `gog_gmail_sendas_list` | List all send-as aliases |
|
|
125
|
+
| `gog_gmail_sendas_get` | Get one send-as alias by address |
|
|
126
|
+
| `gog_gmail_sendas_create` | Create a send-as alias (usually needs verification before use) |
|
|
127
|
+
| `gog_gmail_sendas_update` | Update an alias (display name, reply-to, signature, default) |
|
|
128
|
+
| `gog_gmail_sendas_delete` | Delete a send-as alias |
|
|
129
|
+
| `gog_gmail_sendas_verify` | Resend the verification email for a pending alias |
|
|
130
|
+
|
|
131
|
+
Email tracking (`track`) and the remaining admin settings (`delegates`, `forwarding`, `watch`) have no dedicated tool — reach them through the base `gog_gmail_run` escape hatch.
|
|
110
132
|
|
|
111
133
|
## License
|
|
112
134
|
|
package/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: Use when the user asks to read, organize, draft, forward, autoreply
|
|
|
5
5
|
|
|
6
6
|
# gogcli-mcp-gmail
|
|
7
7
|
|
|
8
|
-
Extended Gmail MCP server via [gogcli](https://github.com/openclaw/gogcli) —
|
|
8
|
+
Extended Gmail MCP server via [gogcli](https://github.com/openclaw/gogcli) — 57 tools: 8 auth + 4 base Gmail + 45 extra dedicated Gmail tools.
|
|
9
9
|
|
|
10
10
|
- **Source:** [github.com/chrischall/gogcli-mcp](https://github.com/chrischall/gogcli-mcp)
|
|
11
11
|
|
|
@@ -36,9 +36,10 @@ Extended Gmail MCP server via [gogcli](https://github.com/openclaw/gogcli) — 3
|
|
|
36
36
|
| Tool | What it does |
|
|
37
37
|
|------|-------------|
|
|
38
38
|
| `gog_gmail_raw` | Raw Gmail API JSON for a message |
|
|
39
|
-
| `gog_gmail_attachment` | Download an attachment and deliver its contents — inline when
|
|
39
|
+
| `gog_gmail_attachment` | Download an attachment by `attachmentIndex` (or legacy `attachmentId`) and deliver its contents — inline when within `inlineMaxBytes` (3 MiB default), else uploaded to Drive with a link (`deliver`: auto/inline/drive/off) |
|
|
40
40
|
| `gog_gmail_url` | Print web URLs for threads |
|
|
41
41
|
| `gog_gmail_history` | List history events since a historyId |
|
|
42
|
+
| `gog_gmail_messages_search` | Search individual messages, not threads — one row per message |
|
|
42
43
|
|
|
43
44
|
### Threads
|
|
44
45
|
| Tool | What it does |
|
|
@@ -56,6 +57,7 @@ Extended Gmail MCP server via [gogcli](https://github.com/openclaw/gogcli) — 3
|
|
|
56
57
|
| `gog_gmail_labels_rename` | Rename a label |
|
|
57
58
|
| `gog_gmail_labels_delete` | Delete a label |
|
|
58
59
|
| `gog_gmail_labels_modify` | Modify labels on one or more threads |
|
|
60
|
+
| `gog_gmail_labels_style` | Change a label's color or visibility |
|
|
59
61
|
|
|
60
62
|
### Bulk operations
|
|
61
63
|
| Tool | What it does |
|
|
@@ -81,7 +83,26 @@ Extended Gmail MCP server via [gogcli](https://github.com/openclaw/gogcli) — 3
|
|
|
81
83
|
### Write
|
|
82
84
|
| Tool | What it does |
|
|
83
85
|
|------|-------------|
|
|
86
|
+
| `gog_gmail_import` | Import an RFC822/EML message into the mailbox (keeps its headers/date; does not send) |
|
|
84
87
|
| `gog_gmail_forward` | Forward a message |
|
|
88
|
+
| `gog_gmail_reply` | Reply to the original sender |
|
|
89
|
+
| `gog_gmail_reply_all` | Reply to sender plus every To/Cc recipient |
|
|
85
90
|
| `gog_gmail_autoreply` | Reply once to all messages matching a query |
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
### Settings
|
|
93
|
+
| Tool | What it does |
|
|
94
|
+
|------|-------------|
|
|
95
|
+
| `gog_gmail_vacation_get` | Get the vacation responder settings |
|
|
96
|
+
| `gog_gmail_vacation_update` | Enable/disable the vacation responder |
|
|
97
|
+
| `gog_gmail_filters_list` | List all filters |
|
|
98
|
+
| `gog_gmail_filters_get` | Get a filter by ID |
|
|
99
|
+
| `gog_gmail_filters_create` | Create a filter |
|
|
100
|
+
| `gog_gmail_filters_delete` | Delete a filter |
|
|
101
|
+
| `gog_gmail_sendas_list` | List send-as aliases |
|
|
102
|
+
| `gog_gmail_sendas_get` | Get one send-as alias |
|
|
103
|
+
| `gog_gmail_sendas_create` | Create a send-as alias |
|
|
104
|
+
| `gog_gmail_sendas_update` | Update a send-as alias |
|
|
105
|
+
| `gog_gmail_sendas_delete` | Delete a send-as alias |
|
|
106
|
+
| `gog_gmail_sendas_verify` | Resend an alias verification email |
|
|
107
|
+
|
|
108
|
+
Plus 8 auth tools and 4 base Gmail tools (search, get, send, run). Use `gog_gmail_run` for the settings with no dedicated tool (`delegates`, `forwarding`, `watch`) and email tracking (`track`).
|
package/dist/index.js
CHANGED
|
@@ -31435,6 +31435,13 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
|
31435
31435
|
// Calendar event start/end
|
|
31436
31436
|
"internalDate",
|
|
31437
31437
|
// Gmail, epoch milliseconds (authoritative)
|
|
31438
|
+
// gog >= 0.35.0 Gmail message AND thread listings. Already offset-bearing
|
|
31439
|
+
// (RFC3339 from internalDate), so it needs no offset repair — it is
|
|
31440
|
+
// allowlisted purely to gain a Display sibling, and to be re-rendered in
|
|
31441
|
+
// DISPLAY_TZ like every other instant. Separately sourced from the sibling
|
|
31442
|
+
// `date`, which is a naive re-format of the sender's Date header; the two may
|
|
31443
|
+
// legitimately disagree. See docs/timestamps.md.
|
|
31444
|
+
"internalDateIso",
|
|
31438
31445
|
"modifiedTime",
|
|
31439
31446
|
// Drive
|
|
31440
31447
|
"createdTime",
|
|
@@ -31671,8 +31678,8 @@ function formatOneAccountHealth(a, now) {
|
|
|
31671
31678
|
const age = ageInDays(a.created_at, now);
|
|
31672
31679
|
const ageStr = age === null ? "" : ` Authorized ${age.toFixed(1)} day(s) ago.`;
|
|
31673
31680
|
if (a.valid === false) {
|
|
31674
|
-
const
|
|
31675
|
-
return `\u2717 ${email3}: NEEDS RE-AUTH \u2014 ${
|
|
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).`;
|
|
31676
31683
|
}
|
|
31677
31684
|
if (a.valid === true) {
|
|
31678
31685
|
let line = `\u2713 ${email3}: token valid.${ageStr}`;
|
|
@@ -31714,7 +31721,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
31714
31721
|
}
|
|
31715
31722
|
});
|
|
31716
31723
|
server.registerTool("gog_auth_status", {
|
|
31717
|
-
description: "Show gogcli auth
|
|
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.",
|
|
31718
31725
|
annotations: { readOnlyHint: true },
|
|
31719
31726
|
inputSchema: {}
|
|
31720
31727
|
}, async () => {
|
|
@@ -31725,7 +31732,7 @@ function registerAuthToolsWith(server, defaultServices) {
|
|
|
31725
31732
|
}
|
|
31726
31733
|
});
|
|
31727
31734
|
server.registerTool("gog_auth_health", {
|
|
31728
|
-
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.',
|
|
31729
31736
|
annotations: { readOnlyHint: true },
|
|
31730
31737
|
inputSchema: {}
|
|
31731
31738
|
}, async () => {
|
|
@@ -31889,14 +31896,29 @@ var failIfNotEmptyParam = external_exports.boolean().optional().describe(
|
|
|
31889
31896
|
);
|
|
31890
31897
|
|
|
31891
31898
|
// ../gogcli-mcp/src/server.ts
|
|
31892
|
-
var VERSION = true ? "2.
|
|
31899
|
+
var VERSION = true ? "2.22.0" : "0.0.0";
|
|
31893
31900
|
|
|
31894
31901
|
// ../gogcli-mcp/src/auth-log.ts
|
|
31895
31902
|
var FAILURES = /* @__PURE__ */ new Set([
|
|
31896
31903
|
"token.mint-failed",
|
|
31897
31904
|
"grant.dead",
|
|
31898
31905
|
"replay.failed",
|
|
31899
|
-
"runner.auth-failed"
|
|
31906
|
+
"runner.auth-failed",
|
|
31907
|
+
"connect.key-rejected",
|
|
31908
|
+
// An enrolment that could not proceed is a failure even though nobody is at
|
|
31909
|
+
// fault: it is the only trace a half-enrolled connector leaves behind, and
|
|
31910
|
+
// the absence of exactly this record is why DEFECT 4 could not be explained.
|
|
31911
|
+
"connect.runner-unreachable",
|
|
31912
|
+
"connect.google-unhealthy",
|
|
31913
|
+
"refusal.google-unhealthy",
|
|
31914
|
+
// The loudest record on this branch, and the only one that means "we cannot
|
|
31915
|
+
// explain this". Google refused a real call while a live check of the same
|
|
31916
|
+
// credential, taken seconds later, succeeded — so neither the 7-day cliff nor
|
|
31917
|
+
// a revoked grant accounts for it. It is filed as a failure precisely because
|
|
31918
|
+
// it is the record nobody may scroll past: it is the only evidence that could
|
|
31919
|
+
// ever justify building something on the hosted path, and its absence over
|
|
31920
|
+
// time is what retires that theory for good.
|
|
31921
|
+
"refusal.google-ok"
|
|
31900
31922
|
]);
|
|
31901
31923
|
var PREFIX = "gog-auth ";
|
|
31902
31924
|
var TAG_CHARS = 12;
|
|
@@ -32043,10 +32065,39 @@ async function exchange(refreshToken, clientId, clientSecret) {
|
|
|
32043
32065
|
return { accessToken: body.access_token, expiresAt: Date.now() + expiresInMs };
|
|
32044
32066
|
}
|
|
32045
32067
|
|
|
32068
|
+
// ../gogcli-mcp/src/google-probe.ts
|
|
32069
|
+
var bool = (value) => typeof value === "boolean" ? value : void 0;
|
|
32070
|
+
var cause = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
32071
|
+
function readGoogleProbe(body) {
|
|
32072
|
+
const record2 = typeof body === "object" && body !== null ? body : {};
|
|
32073
|
+
const measured = bool(record2.measured);
|
|
32074
|
+
const reported = cause(record2.error);
|
|
32075
|
+
if (measured === false) {
|
|
32076
|
+
return {
|
|
32077
|
+
kind: "unmeasured",
|
|
32078
|
+
reason: reported ?? "the runner reported it could not measure the Google layer"
|
|
32079
|
+
};
|
|
32080
|
+
}
|
|
32081
|
+
if (measured === true) {
|
|
32082
|
+
if (bool(record2.ok) === true) return { kind: "ok" };
|
|
32083
|
+
return {
|
|
32084
|
+
kind: "unhealthy",
|
|
32085
|
+
reason: reported ?? "the runner reported the Google layer unhealthy with no cause"
|
|
32086
|
+
};
|
|
32087
|
+
}
|
|
32088
|
+
return {
|
|
32089
|
+
kind: "unmeasured",
|
|
32090
|
+
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"
|
|
32091
|
+
};
|
|
32092
|
+
}
|
|
32093
|
+
|
|
32046
32094
|
// ../gogcli-mcp/src/connector-runtime.ts
|
|
32047
32095
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
32048
32096
|
var DEADLINE_GRACE_MS = 5e3;
|
|
32049
32097
|
var MIN_REPLAY_BUDGET_MS = 1e3;
|
|
32098
|
+
var REFUSAL_PROBE_TIMEOUT_MS = 4e3;
|
|
32099
|
+
var MIN_PROBE_BUDGET_MS = 1e3;
|
|
32100
|
+
var PROBE_INTERVAL_MS = 6e4;
|
|
32050
32101
|
var RUNNER_GOG_FAILED = 422;
|
|
32051
32102
|
var RUNNER_DRAINING = 503;
|
|
32052
32103
|
var RUNNER_BAD_REQUEST = 400;
|
|
@@ -32093,7 +32144,7 @@ function gogTarget(args) {
|
|
|
32093
32144
|
}
|
|
32094
32145
|
return { service };
|
|
32095
32146
|
}
|
|
32096
|
-
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt) {
|
|
32147
|
+
async function remintAfterGoogleRejection(err, used, args, readAccessToken, deadlineAt, probeGoogle) {
|
|
32097
32148
|
if (!(err instanceof GogFailedError)) return void 0;
|
|
32098
32149
|
const grantDead = REFRESH_TOKEN_DEAD_PATTERN.test(err.stderr);
|
|
32099
32150
|
if (!grantDead && !GOOGLE_TOKEN_REJECTED_PATTERN.test(err.stderr)) return void 0;
|
|
@@ -32108,6 +32159,7 @@ async function remintAfterGoogleRejection(err, used, args, readAccessToken, dead
|
|
|
32108
32159
|
return void 0;
|
|
32109
32160
|
}
|
|
32110
32161
|
if (!used) {
|
|
32162
|
+
await probeGoogle(where);
|
|
32111
32163
|
logAuthTransition("replay.declined", {
|
|
32112
32164
|
...where,
|
|
32113
32165
|
reason: "no access token was supplied with the call, so gog acted as the backend volume\u2019s own identity"
|
|
@@ -32155,6 +32207,64 @@ async function remintAfterGoogleRejection(err, used, args, readAccessToken, dead
|
|
|
32155
32207
|
return { token: fresh, budgetMs, invalidate: readAccessToken.invalidate, ...where };
|
|
32156
32208
|
}
|
|
32157
32209
|
function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
32210
|
+
let lastProbeAt = Number.NEGATIVE_INFINITY;
|
|
32211
|
+
const probeGoogleAfterRefusal = async (where, deadlineAt) => {
|
|
32212
|
+
const record2 = { ...where, endpoint };
|
|
32213
|
+
const now = Date.now();
|
|
32214
|
+
const remainingMs = deadlineAt - now;
|
|
32215
|
+
if (remainingMs < MIN_PROBE_BUDGET_MS) {
|
|
32216
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
32217
|
+
...record2,
|
|
32218
|
+
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`
|
|
32219
|
+
});
|
|
32220
|
+
return;
|
|
32221
|
+
}
|
|
32222
|
+
if (now - lastProbeAt < PROBE_INTERVAL_MS) {
|
|
32223
|
+
logAuthTransition("refusal.google-unmeasured", {
|
|
32224
|
+
...record2,
|
|
32225
|
+
// "attempted", not "measured". `lastProbeAt` is stamped before the
|
|
32226
|
+
// fetch and is deliberately NOT reset when the probe comes back with no
|
|
32227
|
+
// verdict (a 404 from a runner too old to have the endpoint, a timeout,
|
|
32228
|
+
// a dead socket) — the backend cost this throttle exists to bound was
|
|
32229
|
+
// paid either way, and resetting it would let a retry loop storm a
|
|
32230
|
+
// runner that is already unwell. So the timestamp stays and the sentence
|
|
32231
|
+
// has to be the true one: on this branch a log line may not assert a
|
|
32232
|
+
// measurement that never happened, and the previous probe may well have
|
|
32233
|
+
// measured nothing at all.
|
|
32234
|
+
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"
|
|
32235
|
+
});
|
|
32236
|
+
return;
|
|
32237
|
+
}
|
|
32238
|
+
lastProbeAt = now;
|
|
32239
|
+
let event;
|
|
32240
|
+
let reason;
|
|
32241
|
+
try {
|
|
32242
|
+
const res = await fetch(`${endpoint}/health/google`, {
|
|
32243
|
+
headers: { Authorization: `Bearer ${key}` },
|
|
32244
|
+
// Never more than the probe's own budget, never more than the call has
|
|
32245
|
+
// left. `Math.min` rather than a plain constant because the second
|
|
32246
|
+
// bound is the caller's, and it outranks ours.
|
|
32247
|
+
signal: AbortSignal.timeout(Math.min(REFUSAL_PROBE_TIMEOUT_MS, remainingMs))
|
|
32248
|
+
});
|
|
32249
|
+
if (!res.ok) {
|
|
32250
|
+
event = "refusal.google-unmeasured";
|
|
32251
|
+
reason = `the runner did not answer the Google probe (HTTP ${res.status})`;
|
|
32252
|
+
} else {
|
|
32253
|
+
const verdict = readGoogleProbe(await res.json());
|
|
32254
|
+
if (verdict.kind === "ok") {
|
|
32255
|
+
event = "refusal.google-ok";
|
|
32256
|
+
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";
|
|
32257
|
+
} else {
|
|
32258
|
+
event = verdict.kind === "unhealthy" ? "refusal.google-unhealthy" : "refusal.google-unmeasured";
|
|
32259
|
+
reason = verdict.reason;
|
|
32260
|
+
}
|
|
32261
|
+
}
|
|
32262
|
+
} catch (err) {
|
|
32263
|
+
event = "refusal.google-unmeasured";
|
|
32264
|
+
reason = err instanceof Error ? err.message : String(err);
|
|
32265
|
+
}
|
|
32266
|
+
logAuthTransition(event, { ...record2, reason });
|
|
32267
|
+
};
|
|
32158
32268
|
return async (args, opts) => {
|
|
32159
32269
|
const deadlineMs = (opts?.timeout ?? DEFAULT_TIMEOUT_MS) + DEADLINE_GRACE_MS;
|
|
32160
32270
|
const accessToken = await readAccessToken?.();
|
|
@@ -32167,7 +32277,8 @@ function makeFlyExecutor(endpoint, key, readAccessToken) {
|
|
|
32167
32277
|
accessToken,
|
|
32168
32278
|
args,
|
|
32169
32279
|
readAccessToken,
|
|
32170
|
-
deadlineAt
|
|
32280
|
+
deadlineAt,
|
|
32281
|
+
(where2) => probeGoogleAfterRefusal(where2, deadlineAt)
|
|
32171
32282
|
);
|
|
32172
32283
|
if (replay === void 0) throw err;
|
|
32173
32284
|
const where = { credential: replay.credential, service: replay.service, endpoint };
|
|
@@ -32314,6 +32425,7 @@ function trimThread(result, latestN, snippetsOnly) {
|
|
|
32314
32425
|
return result;
|
|
32315
32426
|
}
|
|
32316
32427
|
}
|
|
32428
|
+
var GOG_DEFAULT_INLINE_MAX_BYTES = 3145728;
|
|
32317
32429
|
var MIME_BY_EXT = {
|
|
32318
32430
|
pdf: "application/pdf",
|
|
32319
32431
|
png: "image/png",
|
|
@@ -32375,13 +32487,29 @@ async function resolveBySize(messageId, sizeBytes, account) {
|
|
|
32375
32487
|
return void 0;
|
|
32376
32488
|
}
|
|
32377
32489
|
}
|
|
32490
|
+
async function resolveByIndex(messageId, index, account) {
|
|
32491
|
+
try {
|
|
32492
|
+
const parsed = JSON.parse(
|
|
32493
|
+
await run(["gmail", "get", messageId, "--use-indexed-attachment-ids"], { account })
|
|
32494
|
+
);
|
|
32495
|
+
const attachments = parsed.attachments;
|
|
32496
|
+
if (!attachments) return void 0;
|
|
32497
|
+
const declared = attachments.find((a) => a.attachmentIndex === index);
|
|
32498
|
+
if (declared) return declared;
|
|
32499
|
+
if (attachments.every((a) => a.attachmentIndex === void 0)) return attachments[index];
|
|
32500
|
+
return void 0;
|
|
32501
|
+
} catch {
|
|
32502
|
+
return void 0;
|
|
32503
|
+
}
|
|
32504
|
+
}
|
|
32378
32505
|
function defaultOutPath(messageId, filename) {
|
|
32379
32506
|
return `/tmp/gog-attachments/${messageId}/${filename}`;
|
|
32380
32507
|
}
|
|
32381
32508
|
function sanitizeAttachmentError(err, messageId, attachmentId) {
|
|
32382
32509
|
let msg = err instanceof Error ? err.message : String(err);
|
|
32383
32510
|
msg = msg.replace(/^Command failed:.*(\n|$)/, "");
|
|
32384
|
-
msg = msg.split(attachmentId).join("<attachment>")
|
|
32511
|
+
if (attachmentId) msg = msg.split(attachmentId).join("<attachment>");
|
|
32512
|
+
msg = msg.split(messageId).join("<message>");
|
|
32385
32513
|
return msg.trim() || "the download failed on the server";
|
|
32386
32514
|
}
|
|
32387
32515
|
function inlineImageResult(summary, base643, mimeType) {
|
|
@@ -32445,21 +32573,35 @@ function registerExtraGmailTools(server) {
|
|
|
32445
32573
|
return runOrDiagnose(args, { account, lossless: true });
|
|
32446
32574
|
});
|
|
32447
32575
|
server.registerTool("gog_gmail_attachment", {
|
|
32448
|
-
description: `Download a Gmail attachment and deliver its contents so you can actually read them. The real filename and MIME type are resolved from the message part metadata, so the saved file and response are named correctly (e.g. Guest_Copy.pdf), never a generic *.bin. deliver="auto" (default) is transport-aware: images always come back as a native image block; anything else is delivered by the channel that works on your transport \u2014 a readable server-side file PATH on local (stdio) clients that share the filesystem, or a Google Drive link on the remote connector (whose backend filesystem you can't read, and which rejects inline PDF/binary blobs). deliver="inline" forces the bytes inline as an image or embedded resource blob (use only if your client consumes resource blobs; errors if over gog's 3 MiB cap). deliver="drive" always uploads to Drive; deliver="off" writes the file server-side and returns {path, fileName, mimeType, bytes}. Drive delivery creates a file in your Drive (blocked when GOG_READONLY is set).`,
|
|
32576
|
+
description: `Download a Gmail attachment and deliver its contents so you can actually read them. Identify the attachment by attachmentIndex (preferred: the 0-based position from a listing fetched with useIndexedAttachmentIds \u2014 stable, and it resolves the real name before the download) or by the legacy opaque attachmentId. The real filename and MIME type are resolved from the message part metadata, so the saved file and response are named correctly (e.g. Guest_Copy.pdf), never a generic *.bin. deliver="auto" (default) is transport-aware: images always come back as a native image block; anything else is delivered by the channel that works on your transport \u2014 a readable server-side file PATH on local (stdio) clients that share the filesystem, or a Google Drive link on the remote connector (whose backend filesystem you can't read, and which rejects inline PDF/binary blobs). deliver="inline" forces the bytes inline as an image or embedded resource blob (use only if your client consumes resource blobs; errors if over gog's 3 MiB cap). deliver="drive" always uploads to Drive; deliver="off" writes the file server-side and returns {path, fileName, mimeType, bytes}. Drive delivery creates a file in your Drive (blocked when GOG_READONLY is set).`,
|
|
32449
32577
|
inputSchema: {
|
|
32450
32578
|
messageId: external_exports.string().describe("Gmail message ID"),
|
|
32451
|
-
attachmentId: external_exports.string().describe("
|
|
32579
|
+
attachmentId: external_exports.string().optional().describe("The opaque attachment ID from a listing. Legacy addressing: Gmail re-issues a DIFFERENT id for the same part on every API call, so an id copied from an older listing can be stale. Prefer attachmentIndex. Exactly one of attachmentId / attachmentIndex is required."),
|
|
32580
|
+
attachmentIndex: external_exports.number().int().nonnegative().optional().describe("The attachment's 0-based position in its message \u2014 the `attachmentIndex` field of a listing fetched with useIndexedAttachmentIds. Stable (a message's MIME structure does not change), so this is the reliable way to name an attachment. Exactly one of attachmentId / attachmentIndex is required. NOTE: it is per-MESSAGE \u2014 in gog_gmail_thread_attachments the array is flattened across the whole thread, so use each row's messageId + attachmentIndex, never its position in that flat list."),
|
|
32581
|
+
inlineMaxBytes: external_exports.number().int().nonnegative().optional().describe("Byte ceiling under which gog embeds the attachment bytes rather than only writing the file. Defaults to gog's own 3145728, which this server pins explicitly on every call so an ambient GOG_GMAIL_INLINE_MAX_BYTES cannot change the answer. Raise it to inline something larger, lower it to force the file/Drive path."),
|
|
32452
32582
|
deliver: external_exports.enum(["auto", "inline", "drive", "off"]).optional().describe("How to return the contents: auto (image inline; else a local file path or a Drive link, per transport), inline (force bytes as image/resource blob), drive (always a Drive link), or off (server-side download only). Default: auto."),
|
|
32453
32583
|
out: external_exports.string().optional().describe("Server-side path where gog writes the file. NOTE: this resolves on the CONNECTOR/gog server's filesystem, not your machine \u2014 on the remote connector it is ignored (you can't read it; you get a Drive link instead). Locally it is honored. Omit it to use an ephemeral temp path."),
|
|
32454
32584
|
name: external_exports.string().optional().describe("Filename override. Defaults to the attachment's real filename from the message metadata; pass this to skip that lookup or force a name."),
|
|
32455
32585
|
driveFolder: external_exports.string().optional().describe("Destination Google Drive folder ID for the uploaded copy (drive/auto delivery on the remote connector, or oversized attachments)."),
|
|
32456
32586
|
account: accountParam
|
|
32457
32587
|
}
|
|
32458
|
-
}, async ({ messageId, attachmentId, deliver = "auto", out, name, driveFolder, account }) => {
|
|
32588
|
+
}, async ({ messageId, attachmentId, attachmentIndex, deliver = "auto", out, name, inlineMaxBytes, driveFolder, account }) => {
|
|
32589
|
+
if (attachmentId === void 0 === (attachmentIndex === void 0)) {
|
|
32590
|
+
return errorResult(
|
|
32591
|
+
"Pass exactly one of attachmentId or attachmentIndex. Prefer attachmentIndex \u2014 the 0-based `attachmentIndex` from a listing fetched with useIndexedAttachmentIds \u2014 because Gmail's opaque attachmentId is not stable across API calls and a copied one may no longer resolve."
|
|
32592
|
+
);
|
|
32593
|
+
}
|
|
32594
|
+
const indexed = attachmentIndex !== void 0;
|
|
32595
|
+
const attachmentRef = indexed ? String(attachmentIndex) : attachmentId;
|
|
32459
32596
|
const remote = runExecutor.getStore() !== void 0;
|
|
32460
32597
|
try {
|
|
32461
32598
|
let filename = name ? sanitizeFilename(name) : void 0;
|
|
32462
32599
|
let mimeType = filename ? MIME_BY_EXT[extOf(filename)] : void 0;
|
|
32600
|
+
if (indexed && !filename) {
|
|
32601
|
+
const meta3 = await resolveByIndex(messageId, attachmentIndex, account);
|
|
32602
|
+
if (meta3?.filename) filename = sanitizeFilename(meta3.filename);
|
|
32603
|
+
if (meta3?.mimeType) mimeType = meta3.mimeType;
|
|
32604
|
+
}
|
|
32463
32605
|
const notes = [];
|
|
32464
32606
|
let outPath = out;
|
|
32465
32607
|
if (out && remote) {
|
|
@@ -32474,12 +32616,16 @@ function registerExtraGmailTools(server) {
|
|
|
32474
32616
|
if (!mimeType && (deliver === "auto" || deliver === "inline")) {
|
|
32475
32617
|
needInline = true;
|
|
32476
32618
|
}
|
|
32477
|
-
const args = ["gmail", "attachment", messageId,
|
|
32619
|
+
const args = ["gmail", "attachment", messageId, attachmentRef];
|
|
32620
|
+
args.push(indexed ? "--use-indexed-attachment-ids" : "--use-indexed-attachment-ids=false");
|
|
32478
32621
|
if (needInline) args.push("--inline");
|
|
32622
|
+
args.push(`--inline-max-bytes=${inlineMaxBytes ?? GOG_DEFAULT_INLINE_MAX_BYTES}`);
|
|
32479
32623
|
args.push(`--out=${outPath}`, `--name=${filename ?? "attachment"}`);
|
|
32480
32624
|
const info = JSON.parse(await run(args, { account }));
|
|
32481
32625
|
const path = info.path ?? outPath;
|
|
32482
|
-
if (!filename)
|
|
32626
|
+
if (!filename && info.filename) filename = sanitizeFilename(info.filename);
|
|
32627
|
+
if (!mimeType && info.mimeType) mimeType = info.mimeType;
|
|
32628
|
+
if (!filename && !indexed) {
|
|
32483
32629
|
const meta3 = await resolveBySize(messageId, info.bytes, account);
|
|
32484
32630
|
if (meta3?.filename) filename = sanitizeFilename(meta3.filename);
|
|
32485
32631
|
if (!mimeType && meta3?.mimeType) mimeType = meta3.mimeType;
|
|
@@ -32503,7 +32649,7 @@ function registerExtraGmailTools(server) {
|
|
|
32503
32649
|
return withNote(isImage ? inlineImageResult(summary, info.contentBase64, mimeType) : inlineResourceResult(messageId, filename, summary, info.contentBase64, mimeType), notes);
|
|
32504
32650
|
}
|
|
32505
32651
|
return errorResult(
|
|
32506
|
-
`Attachment is too large to return inline (${info.reason ?? "exceeds gog's 3 MiB
|
|
32652
|
+
`Attachment is too large to return inline (${info.reason ?? "exceeds gog's inline size limit, 3 MiB by default \u2014 raise inlineMaxBytes"}). Use deliver="auto" or deliver="drive" to receive it as a Google Drive link.`
|
|
32507
32653
|
);
|
|
32508
32654
|
}
|
|
32509
32655
|
if (isImage && info.contentBase64) {
|
|
@@ -32645,15 +32791,17 @@ function registerExtraGmailTools(server) {
|
|
|
32645
32791
|
sanitizeContent: external_exports.boolean().optional().describe("Strip HTML, remove URLs, omit raw payloads from JSON (largest payload-size reduction)"),
|
|
32646
32792
|
latestN: external_exports.number().int().positive().optional().describe("Return only the most recent N messages in the thread (wrapper-side trim; avoids overflowing context on long threads)"),
|
|
32647
32793
|
snippetsOnly: external_exports.boolean().optional().describe("Reduce each message to its id, labels, snippet, and key headers (From/To/Cc/Subject/Date), dropping full bodies"),
|
|
32794
|
+
useIndexedAttachmentIds: external_exports.boolean().optional().describe("Report each attachment as a 0-based `attachmentIndex` within its message instead of an opaque `attachmentId`. The index is stable across calls (a message's MIME structure does not change) while the id is not, so this is what you want before calling gog_gmail_attachment."),
|
|
32648
32795
|
outDir: external_exports.string().optional().describe("Directory to write attachments to (default: current directory)"),
|
|
32649
32796
|
account: accountParam
|
|
32650
32797
|
}
|
|
32651
|
-
}, async ({ threadId, download, full, sanitizeContent, latestN, snippetsOnly, outDir, account }) => {
|
|
32798
|
+
}, async ({ threadId, download, full, sanitizeContent, latestN, snippetsOnly, useIndexedAttachmentIds, outDir, account }) => {
|
|
32652
32799
|
const args = ["gmail", "thread", "get", threadId];
|
|
32653
32800
|
if (download) args.push("--download");
|
|
32654
32801
|
if (full) args.push("--full");
|
|
32655
32802
|
if (sanitizeContent) args.push("--sanitize-content");
|
|
32656
32803
|
if (outDir) args.push(`--out-dir=${outDir}`);
|
|
32804
|
+
args.push(useIndexedAttachmentIds ? "--use-indexed-attachment-ids" : "--use-indexed-attachment-ids=false");
|
|
32657
32805
|
const result = await runOrDiagnose(args, { account });
|
|
32658
32806
|
if (latestN === void 0 && !snippetsOnly) return result;
|
|
32659
32807
|
return trimThread(result, latestN, snippetsOnly);
|
|
@@ -32679,13 +32827,15 @@ function registerExtraGmailTools(server) {
|
|
|
32679
32827
|
inputSchema: {
|
|
32680
32828
|
threadId: external_exports.string().describe("Gmail thread ID"),
|
|
32681
32829
|
download: external_exports.boolean().optional().describe("Download all attachments to the SERVER filesystem (see the note above; on the remote connector the files aren't reachable \u2014 fetch individually with gog_gmail_attachment instead)."),
|
|
32830
|
+
useIndexedAttachmentIds: external_exports.boolean().optional().describe("Report each attachment as a 0-based `attachmentIndex` instead of an opaque `attachmentId`. Set this before calling gog_gmail_attachment: the index is stable across calls, the id is not. The index counts WITHIN each message, and this listing flattens every message's attachments into one array \u2014 so pair each row's `messageId` with its own `attachmentIndex`; a row's position in the flat array is NOT the index."),
|
|
32682
32831
|
outDir: external_exports.string().optional().describe("Directory to write attachments to, resolved on the gog SERVER's filesystem (default: current directory). Not your local machine on the remote connector."),
|
|
32683
32832
|
account: accountParam
|
|
32684
32833
|
}
|
|
32685
|
-
}, async ({ threadId, download, outDir, account }) => {
|
|
32834
|
+
}, async ({ threadId, download, useIndexedAttachmentIds, outDir, account }) => {
|
|
32686
32835
|
const args = ["gmail", "thread", "attachments", threadId];
|
|
32687
32836
|
if (download) args.push("--download");
|
|
32688
32837
|
if (outDir) args.push(`--out-dir=${outDir}`);
|
|
32838
|
+
args.push(useIndexedAttachmentIds ? "--use-indexed-attachment-ids" : "--use-indexed-attachment-ids=false");
|
|
32689
32839
|
return runOrDiagnose(args, { account });
|
|
32690
32840
|
});
|
|
32691
32841
|
server.registerTool("gog_gmail_labels_list", {
|
|
@@ -32774,11 +32924,13 @@ function registerExtraGmailTools(server) {
|
|
|
32774
32924
|
inputSchema: {
|
|
32775
32925
|
draftId: external_exports.string().describe("Draft ID"),
|
|
32776
32926
|
download: external_exports.boolean().optional().describe("Download draft attachments"),
|
|
32927
|
+
useIndexedAttachmentIds: external_exports.boolean().optional().describe("Report each attachment as a 0-based `attachmentIndex` instead of an opaque `attachmentId` (stable across calls, unlike the id)."),
|
|
32777
32928
|
account: accountParam
|
|
32778
32929
|
}
|
|
32779
|
-
}, async ({ draftId, download, account }) => {
|
|
32930
|
+
}, async ({ draftId, download, useIndexedAttachmentIds, account }) => {
|
|
32780
32931
|
const args = ["gmail", "drafts", "get", draftId];
|
|
32781
32932
|
if (download) args.push("--download");
|
|
32933
|
+
args.push(useIndexedAttachmentIds ? "--use-indexed-attachment-ids" : "--use-indexed-attachment-ids=false");
|
|
32782
32934
|
return runOrDiagnose(args, { account });
|
|
32783
32935
|
});
|
|
32784
32936
|
const draftWriteSchema = {
|
|
@@ -32788,7 +32940,7 @@ function registerExtraGmailTools(server) {
|
|
|
32788
32940
|
subject: external_exports.string().describe("Subject"),
|
|
32789
32941
|
body: external_exports.string().describe("Body (plain text). Any size \u2014 a large body is written to a temp file on the gog server rather than inlined into the command line. Note gog strips trailing newlines from a file-delivered body."),
|
|
32790
32942
|
bodyHtml: external_exports.string().optional().describe("Body (HTML; optional). Pass the HTML itself at any size \u2014 a large body is written to a temp file on the gog server rather than inlined into the command line. Mutually exclusive with bodyHtmlFile."),
|
|
32791
|
-
bodyHtmlFile: external_exports.string().optional().describe(
|
|
32943
|
+
bodyHtmlFile: external_exports.string().optional().describe(`Path to an HTML file that ALREADY EXISTS on the gog server to use as the HTML body. gog also accepts "-" for stdin, but this server never writes to gog's stdin, so "-" would hang until the call times out. Mutually exclusive with bodyHtml \u2014 supplying both is rejected. You rarely need this: bodyHtml handles large bodies on its own.`),
|
|
32792
32944
|
replyToMessageId: external_exports.string().optional().describe("Reply to a specific Gmail MESSAGE id \u2014 the short hex `id` field from gog_gmail_get / _search / _thread_get (e.g. 19e7593d77fd9636), NOT a thread id and NOT the RFC822 `<\u2026@host>` Message-Id header. Anchors In-Reply-To/References to that exact message. To reply to a thread when you don't know the latest message, use replyToThreadId instead. If both are given, replyToMessageId wins."),
|
|
32793
32945
|
replyToThreadId: external_exports.string().optional().describe(`Reply to a Gmail THREAD id \u2014 passed to gog as --thread-id, which threads the draft using the thread's latest-message headers (In-Reply-To/References). This is what "reply to this thread" almost always means. Mutually exclusive with replyToMessageId (which wins if both are set). Thread ids and message ids are both 16-hex strings and easy to confuse \u2014 use this param, not replyToMessageId, when the id came from a thread.`),
|
|
32794
32946
|
replyTo: external_exports.string().optional().describe("Reply-To header address"),
|
|
@@ -32796,6 +32948,7 @@ function registerExtraGmailTools(server) {
|
|
|
32796
32948
|
replyAll: external_exports.boolean().optional().describe("Auto-populate recipients from the original message (reply-all), inferring To/Cc from it. Requires replyToMessageId or replyToThreadId. Explicit to/cc/bcc still apply on top; omitRecipients still suppresses them."),
|
|
32797
32949
|
attach: external_exports.array(external_exports.string()).optional().describe("Local file paths to attach (repeatable). Read on the gog server, base64-encoded with a MIME type inferred from the extension. The JSON result echoes attached filenames and byte sizes \u2014 check it to confirm the files were found and embedded. On gog_gmail_drafts_update, supplying attach REPLACES the draft's existing attachments; omitting it preserves them (use clearAttachments to remove all)."),
|
|
32798
32950
|
from: external_exports.string().optional().describe("Send from this email address (must be a verified send-as alias)"),
|
|
32951
|
+
autoFromAddressedAlias: external_exports.boolean().optional().describe("When from is omitted, send from the verified send-as alias the original message was addressed TO, instead of the account's primary address \u2014 so a reply to mail sent to an alias goes back out from that alias. Ignored when from is set."),
|
|
32799
32952
|
omitRecipients: external_exports.boolean().optional().describe("Create the draft with no recipients even if to/cc/bcc are supplied \u2014 an accidental-send guard. Populate recipients in a later update before sending."),
|
|
32800
32953
|
returnFull: external_exports.boolean().optional().describe("After writing, re-fetch and return the full stored draft (subject, body, recipients) instead of just the write acknowledgement. Costs one extra read."),
|
|
32801
32954
|
account: accountParam
|
|
@@ -32818,6 +32971,7 @@ function registerExtraGmailTools(server) {
|
|
|
32818
32971
|
if (f.quote) args.push("--quote");
|
|
32819
32972
|
if (f.attach) for (const path of f.attach) args.push(`--attach=${path}`);
|
|
32820
32973
|
if (f.from) args.push(`--from=${f.from}`);
|
|
32974
|
+
args.push(f.autoFromAddressedAlias ? "--auto-from-addressed-alias" : "--auto-from-addressed-alias=false");
|
|
32821
32975
|
}
|
|
32822
32976
|
async function writeDraft(args, account, returnFull, knownDraftId) {
|
|
32823
32977
|
const result = await runOrDiagnose(args, { account });
|
|
@@ -32830,7 +32984,7 @@ function registerExtraGmailTools(server) {
|
|
|
32830
32984
|
}
|
|
32831
32985
|
const draftId = knownDraftId ?? parsed.draftId;
|
|
32832
32986
|
if (!draftId) return result;
|
|
32833
|
-
return runOrDiagnose(["gmail", "drafts", "get", draftId], { account });
|
|
32987
|
+
return runOrDiagnose(["gmail", "drafts", "get", draftId, "--use-indexed-attachment-ids=false"], { account });
|
|
32834
32988
|
}
|
|
32835
32989
|
server.registerTool("gog_gmail_drafts_create", {
|
|
32836
32990
|
description: "Create a new Gmail draft. Recipients (to/cc/bcc) are optional; omit them (or set omitRecipients) to create a recipient-less draft as an accidental-send guard. For replies, prefer replyToThreadId (anchors to the thread's latest message) or replyToMessageId (a specific message) \u2014 don't pass a thread id into replyToMessageId, which mis-threads silently.",
|
|
@@ -32879,6 +33033,24 @@ function registerExtraGmailTools(server) {
|
|
|
32879
33033
|
}, async ({ draftId, account }) => {
|
|
32880
33034
|
return runOrDiagnose(["gmail", "drafts", "send", draftId], { account });
|
|
32881
33035
|
});
|
|
33036
|
+
server.registerTool("gog_gmail_import", {
|
|
33037
|
+
description: "Import an existing RFC822/EML message INTO the mailbox. This is Gmail's import path, not a send: nothing leaves the account, and the message keeps its own From/Date/Message-Id headers so it files where it belongs chronologically. Use it to restore an exported message or to file a .eml under a label; to actually send mail use gog_gmail_send, and to stage one use gog_gmail_drafts_create. The file is read on the gog SERVER, not your machine.",
|
|
33038
|
+
inputSchema: {
|
|
33039
|
+
file: external_exports.string().describe(`Path to an RFC822/EML file that ALREADY EXISTS 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.`),
|
|
33040
|
+
labels: external_exports.array(external_exports.string()).optional().describe(`Labels to apply to the imported message (repeatable). Each may be a label ID or a label name \u2014 names are resolved server-side. A name containing a COMMA cannot be passed here: gog declares --label as a Kong slice with no separator override, so Kong splits each value on commas and "Clients, Inc" is looked up as two labels ("Clients" and "Inc") and fails. Use that label's ID instead \u2014 ids never contain a comma; gog_gmail_labels_list gives you one.`),
|
|
33041
|
+
internalDateSource: external_exports.enum(["dateHeader", "receivedTime"]).optional().describe("Which clock sets Gmail's internal date: dateHeader (gog default \u2014 the message's own Date header, so it sorts into the mailbox at its original time) or receivedTime (now)."),
|
|
33042
|
+
neverMarkSpam: external_exports.boolean().optional().describe("Never classify the imported message as spam."),
|
|
33043
|
+
processForCalendar: external_exports.boolean().optional().describe("Process calendar invitations inside the imported message \u2014 this can ADD EVENTS to your calendar."),
|
|
33044
|
+
account: accountParam
|
|
33045
|
+
}
|
|
33046
|
+
}, async ({ file: file2, labels, internalDateSource, neverMarkSpam, processForCalendar, account }) => {
|
|
33047
|
+
const args = ["gmail", "import", file2];
|
|
33048
|
+
if (labels) for (const label of labels) args.push(`--label=${label}`);
|
|
33049
|
+
if (internalDateSource) args.push(`--internal-date-source=${internalDateSource}`);
|
|
33050
|
+
if (neverMarkSpam) args.push("--never-mark-spam");
|
|
33051
|
+
if (processForCalendar) args.push("--process-for-calendar");
|
|
33052
|
+
return runOrDiagnose(args, { account });
|
|
33053
|
+
});
|
|
32882
33054
|
server.registerTool("gog_gmail_forward", {
|
|
32883
33055
|
description: "Forward an existing Gmail message to new recipients.",
|
|
32884
33056
|
annotations: { destructiveHint: true },
|
|
@@ -32905,7 +33077,7 @@ function registerExtraGmailTools(server) {
|
|
|
32905
33077
|
messageId: external_exports.string().describe("Gmail message ID to reply to \u2014 the short hex `id` from gog_gmail_get / _search / _messages_search (NOT the threadId, NOT the RFC822 `<\u2026@host>` Message-Id header)."),
|
|
32906
33078
|
body: external_exports.string().optional().describe("Reply body (plain text; required unless bodyHtml or bodyHtmlFile is set). Any size \u2014 a large body is written to a temp file on the gog server rather than inlined into the command line. Note gog strips trailing newlines from a file-delivered body."),
|
|
32907
33079
|
bodyHtml: external_exports.string().optional().describe("Reply body (HTML; optional). Pass the HTML itself at any size \u2014 a large body is written to a temp file on the gog server rather than inlined into the command line. Mutually exclusive with bodyHtmlFile."),
|
|
32908
|
-
bodyHtmlFile: external_exports.string().optional().describe(
|
|
33080
|
+
bodyHtmlFile: external_exports.string().optional().describe(`Path to an HTML file that ALREADY EXISTS on the gog server for the reply body. gog also accepts "-" for stdin, but this server never writes to gog's stdin, so "-" would hang until the call times out. Mutually exclusive with bodyHtml \u2014 supplying both is rejected. You rarely need this: bodyHtml handles large bodies on its own.`),
|
|
32909
33081
|
to: external_exports.array(external_exports.string()).optional().describe("Add or move recipients to To (repeatable). Added on top of the recipients inherited from the original message."),
|
|
32910
33082
|
cc: external_exports.array(external_exports.string()).optional().describe("Add or move recipients to Cc (repeatable)"),
|
|
32911
33083
|
bcc: external_exports.array(external_exports.string()).optional().describe("Add or move recipients to Bcc (repeatable)"),
|
|
@@ -32914,6 +33086,7 @@ function registerExtraGmailTools(server) {
|
|
|
32914
33086
|
noQuote: external_exports.boolean().optional().describe("Do not include the original message quoted below the reply (default: the original is quoted)"),
|
|
32915
33087
|
attach: external_exports.array(external_exports.string()).optional().describe("Local file paths to attach (repeatable). Read on the gog server, base64-encoded with a MIME type inferred from the extension."),
|
|
32916
33088
|
from: external_exports.string().optional().describe("Send from this email address (must be a verified send-as alias)"),
|
|
33089
|
+
autoFromAddressedAlias: external_exports.boolean().optional().describe("When from is omitted, send from the verified send-as alias the original message was addressed TO, instead of the account's primary address \u2014 so a reply to mail sent to an alias goes back out from that alias. Ignored when from is set."),
|
|
32917
33090
|
signature: external_exports.boolean().optional().describe("Append the Gmail signature from the active send-as address"),
|
|
32918
33091
|
signatureFrom: external_exports.string().optional().describe("Append the Gmail signature from this send-as email address"),
|
|
32919
33092
|
signatureFile: external_exports.string().optional().describe("Append a local signature file (plain text or HTML), read on the gog server"),
|
|
@@ -32935,6 +33108,7 @@ function registerExtraGmailTools(server) {
|
|
|
32935
33108
|
if (f.signature) args.push("--signature");
|
|
32936
33109
|
if (f.signatureFrom) args.push(`--signature-from=${f.signatureFrom}`);
|
|
32937
33110
|
if (f.signatureFile) args.push(`--signature-file=${f.signatureFile}`);
|
|
33111
|
+
args.push(f.autoFromAddressedAlias ? "--auto-from-addressed-alias" : "--auto-from-addressed-alias=false");
|
|
32938
33112
|
}
|
|
32939
33113
|
server.registerTool("gog_gmail_reply", {
|
|
32940
33114
|
description: 'Reply to a Gmail message (sends to the original sender only). Threads off the message and inherits a "Re:" subject and the quoted original by default. For replying to every participant use gog_gmail_reply_all; to reply across many messages matching a query use gog_gmail_autoreply; to stage a reply without sending use gog_gmail_drafts_create.',
|
|
@@ -32998,9 +33172,11 @@ function registerExtraGmailTools(server) {
|
|
|
32998
33172
|
includeBody: external_exports.boolean().optional().describe("Include the decoded message body in each result"),
|
|
32999
33173
|
full: external_exports.boolean().optional().describe("Show full message bodies without truncation (implies includeBody)"),
|
|
33000
33174
|
bodyFormat: external_exports.enum(["text", "html"]).optional().describe("Body format preference when includeBody is set"),
|
|
33175
|
+
includeAttachments: external_exports.boolean().optional().describe("Include each message's attachment metadata (filename, size, mimeType, id or index). NOT a cheap add-on: like includeBody it makes gog fetch every matching message at format=full, so it costs a full per-message read \u2014 narrow the query or lower max before turning it on."),
|
|
33176
|
+
useIndexedAttachmentIds: external_exports.boolean().optional().describe("Report each attachment as a 0-based `attachmentIndex` within its message instead of an opaque `attachmentId` (stable across calls, unlike the id). Only has an effect alongside includeAttachments or includeBody."),
|
|
33001
33177
|
account: accountParam
|
|
33002
33178
|
}
|
|
33003
|
-
}, async ({ query, max, page, all, includeBody, full, bodyFormat, account }) => {
|
|
33179
|
+
}, async ({ query, max, page, all, includeBody, full, bodyFormat, includeAttachments, useIndexedAttachmentIds, account }) => {
|
|
33004
33180
|
const args = ["gmail", "messages", "search", query];
|
|
33005
33181
|
if (max !== void 0) args.push(`--max=${max}`);
|
|
33006
33182
|
if (page) args.push(`--page=${page}`);
|
|
@@ -33008,6 +33184,8 @@ function registerExtraGmailTools(server) {
|
|
|
33008
33184
|
if (includeBody) args.push("--include-body");
|
|
33009
33185
|
if (full) args.push("--full");
|
|
33010
33186
|
if (bodyFormat) args.push(`--body-format=${bodyFormat}`);
|
|
33187
|
+
args.push(includeAttachments ? "--include-attachments" : "--include-attachments=false");
|
|
33188
|
+
args.push(useIndexedAttachmentIds ? "--use-indexed-attachment-ids" : "--use-indexed-attachment-ids=false");
|
|
33011
33189
|
return runOrDiagnose(args, { account });
|
|
33012
33190
|
});
|
|
33013
33191
|
server.registerTool("gog_gmail_labels_style", {
|
package/manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest_version": "0.3",
|
|
4
4
|
"name": "gogcli-mcp-gmail",
|
|
5
5
|
"display_name": "gogcli (Gmail)",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.22.0",
|
|
7
7
|
"description": "Extended Gmail for Claude via gogcli — auth + full Gmail support (threads, labels, drafts, attachments, forward, autoreply, bulk operations)",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Chris Hall",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
113
|
"name": "gog_gmail_attachment",
|
|
114
|
-
"description": "Download a Gmail attachment and deliver its contents: inline (base64 image/resource) when within the
|
|
114
|
+
"description": "Download a Gmail attachment by 0-based attachmentIndex (or legacy attachmentId) and deliver its contents: inline (base64 image/resource) when within the inline limit, otherwise uploaded to Google Drive with a shareable link"
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
"name": "gog_gmail_url",
|
|
@@ -209,6 +209,10 @@
|
|
|
209
209
|
"name": "gog_gmail_drafts_send",
|
|
210
210
|
"description": "Send an existing Gmail draft"
|
|
211
211
|
},
|
|
212
|
+
{
|
|
213
|
+
"name": "gog_gmail_import",
|
|
214
|
+
"description": "Import an RFC822/EML message into the mailbox (keeps its original headers and date; does not send)"
|
|
215
|
+
},
|
|
212
216
|
{
|
|
213
217
|
"name": "gog_gmail_forward",
|
|
214
218
|
"description": "Forward a Gmail message to new recipients"
|