gogcli-mcp 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30115,6 +30115,7 @@ var StdioServerTransport = class {
30115
30115
 
30116
30116
  // src/runner.ts
30117
30117
  import { spawn } from "node:child_process";
30118
+ var TIMEOUT_MS = 3e4;
30118
30119
  async function run(args, options = {}) {
30119
30120
  const { account, spawner = spawn } = options;
30120
30121
  const effectiveAccount = account ?? process.env.GOG_ACCOUNT;
@@ -30124,10 +30125,15 @@ async function run(args, options = {}) {
30124
30125
  }
30125
30126
  fullArgs.push(...args);
30126
30127
  return new Promise((resolve, reject) => {
30127
- const child = spawner("gog", fullArgs, { env: process.env });
30128
+ const child = spawner(process.env.GOG_PATH ?? "gog", fullArgs, { env: process.env });
30128
30129
  let stdout = "";
30129
30130
  let stderr = "";
30130
30131
  let settled = false;
30132
+ const timer = setTimeout(() => {
30133
+ settled = true;
30134
+ child.kill();
30135
+ reject(new Error(`gog timed out after ${TIMEOUT_MS}ms`));
30136
+ }, TIMEOUT_MS);
30131
30137
  child.stdout.on("data", (chunk) => {
30132
30138
  stdout += chunk.toString();
30133
30139
  });
@@ -30135,6 +30141,7 @@ async function run(args, options = {}) {
30135
30141
  stderr += chunk.toString();
30136
30142
  });
30137
30143
  child.on("close", (code) => {
30144
+ clearTimeout(timer);
30138
30145
  if (settled) return;
30139
30146
  settled = true;
30140
30147
  if (code === 0) {
@@ -30144,6 +30151,7 @@ async function run(args, options = {}) {
30144
30151
  }
30145
30152
  });
30146
30153
  child.on("error", (err) => {
30154
+ clearTimeout(timer);
30147
30155
  if (settled) return;
30148
30156
  settled = true;
30149
30157
  reject(err);
@@ -30151,7 +30159,7 @@ async function run(args, options = {}) {
30151
30159
  });
30152
30160
  }
30153
30161
 
30154
- // src/tools/sheets.ts
30162
+ // src/tools/utils.ts
30155
30163
  var accountParam = external_exports3.string().optional().describe(
30156
30164
  "Google account email to use (overrides GOG_ACCOUNT env var)"
30157
30165
  );
@@ -30161,6 +30169,510 @@ function toText(output) {
30161
30169
  function toError(err) {
30162
30170
  return toText(err instanceof Error ? `Error: ${err.message}` : String(err));
30163
30171
  }
30172
+ async function runOrDiagnose(args, options) {
30173
+ try {
30174
+ return toText(await run(args, options));
30175
+ } catch (err) {
30176
+ const base = toError(err);
30177
+ try {
30178
+ const accounts = await run(["auth", "list"]);
30179
+ return toText(`${base.content[0].text}
30180
+
30181
+ Configured accounts:
30182
+ ${accounts}`);
30183
+ } catch {
30184
+ return base;
30185
+ }
30186
+ }
30187
+ }
30188
+
30189
+ // src/tools/auth.ts
30190
+ function registerAuthTools(server2) {
30191
+ server2.registerTool("gog_auth_list", {
30192
+ description: "List all Google accounts stored in gogcli. Use this to check which accounts are configured and available.",
30193
+ annotations: { readOnlyHint: true },
30194
+ inputSchema: {}
30195
+ }, async () => {
30196
+ try {
30197
+ return toText(await run(["auth", "list"]));
30198
+ } catch (err) {
30199
+ return toError(err);
30200
+ }
30201
+ });
30202
+ server2.registerTool("gog_auth_status", {
30203
+ description: "Show gogcli auth configuration: keyring backend, credential files, and auth setup.",
30204
+ annotations: { readOnlyHint: true },
30205
+ inputSchema: {}
30206
+ }, async () => {
30207
+ try {
30208
+ return toText(await run(["auth", "status"]));
30209
+ } catch (err) {
30210
+ return toError(err);
30211
+ }
30212
+ });
30213
+ server2.registerTool("gog_auth_services", {
30214
+ description: "List all Google services supported by gogcli and the OAuth scopes each requires.",
30215
+ annotations: { readOnlyHint: true },
30216
+ inputSchema: {}
30217
+ }, async () => {
30218
+ try {
30219
+ return toText(await run(["auth", "services"]));
30220
+ } catch (err) {
30221
+ return toError(err);
30222
+ }
30223
+ });
30224
+ server2.registerTool("gog_auth_run", {
30225
+ description: "Run any gog auth subcommand. Run `gog auth --help` to see all available subcommands and flags. Note: gog auth add requires interactive browser auth and cannot be completed over MCP \u2014 run it in your terminal instead: gog auth add <email> --services <service>",
30226
+ annotations: { destructiveHint: true },
30227
+ inputSchema: {
30228
+ subcommand: external_exports3.string().describe('The gog auth subcommand, e.g. "remove", "alias", "tokens"'),
30229
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags")
30230
+ }
30231
+ }, async ({ subcommand, args }) => {
30232
+ try {
30233
+ return toText(await run(["auth", subcommand, ...args]));
30234
+ } catch (err) {
30235
+ return toError(err);
30236
+ }
30237
+ });
30238
+ }
30239
+
30240
+ // src/tools/calendar.ts
30241
+ function registerCalendarTools(server2) {
30242
+ server2.registerTool("gog_calendar_events", {
30243
+ description: "List calendar events. Filters can be combined (e.g. --from + --to for a range, or --today for just today).",
30244
+ annotations: { readOnlyHint: true },
30245
+ inputSchema: {
30246
+ calendarId: external_exports3.string().optional().describe("Calendar ID (default: primary calendar)"),
30247
+ from: external_exports3.string().optional().describe("Start time filter (RFC3339, date, or natural language)"),
30248
+ to: external_exports3.string().optional().describe("End time filter (RFC3339, date, or natural language)"),
30249
+ today: external_exports3.boolean().optional().describe("Only show today's events"),
30250
+ query: external_exports3.string().optional().describe("Free text search within events"),
30251
+ all: external_exports3.boolean().optional().describe("Fetch events from all calendars"),
30252
+ account: accountParam
30253
+ }
30254
+ }, async ({ calendarId, from, to, today, query, all, account }) => {
30255
+ const args = ["calendar", "events"];
30256
+ if (calendarId) args.push(calendarId);
30257
+ if (from) args.push(`--from=${from}`);
30258
+ if (to) args.push(`--to=${to}`);
30259
+ if (today) args.push("--today");
30260
+ if (query) args.push(`--query=${query}`);
30261
+ if (all) args.push("--all");
30262
+ return runOrDiagnose(args, { account });
30263
+ });
30264
+ server2.registerTool("gog_calendar_get", {
30265
+ description: "Get a specific calendar event by ID.",
30266
+ annotations: { readOnlyHint: true },
30267
+ inputSchema: {
30268
+ calendarId: external_exports3.string().describe("Calendar ID"),
30269
+ eventId: external_exports3.string().describe("Event ID"),
30270
+ account: accountParam
30271
+ }
30272
+ }, async ({ calendarId, eventId, account }) => {
30273
+ return runOrDiagnose(["calendar", "event", calendarId, eventId], { account });
30274
+ });
30275
+ server2.registerTool("gog_calendar_create", {
30276
+ description: "Create a calendar event.",
30277
+ annotations: { destructiveHint: false },
30278
+ inputSchema: {
30279
+ calendarId: external_exports3.string().describe('Calendar ID (use "primary" for the default calendar)'),
30280
+ summary: external_exports3.string().describe("Event title"),
30281
+ from: external_exports3.string().describe("Start time (RFC3339 or date for all-day events)"),
30282
+ to: external_exports3.string().describe("End time (RFC3339 or date for all-day events)"),
30283
+ description: external_exports3.string().optional().describe("Event description"),
30284
+ location: external_exports3.string().optional().describe("Event location"),
30285
+ attendees: external_exports3.string().optional().describe("Attendee emails, comma-separated"),
30286
+ allDay: external_exports3.boolean().optional().describe("All-day event (use date-only in from/to)"),
30287
+ account: accountParam
30288
+ }
30289
+ }, async ({ calendarId, summary, from, to, description, location, attendees, allDay, account }) => {
30290
+ const args = ["calendar", "create", calendarId, `--summary=${summary}`, `--from=${from}`, `--to=${to}`];
30291
+ if (description) args.push(`--description=${description}`);
30292
+ if (location) args.push(`--location=${location}`);
30293
+ if (attendees) args.push(`--attendees=${attendees}`);
30294
+ if (allDay) args.push("--all-day");
30295
+ return runOrDiagnose(args, { account });
30296
+ });
30297
+ server2.registerTool("gog_calendar_update", {
30298
+ description: "Update an existing calendar event.",
30299
+ annotations: { destructiveHint: false },
30300
+ inputSchema: {
30301
+ calendarId: external_exports3.string().describe("Calendar ID"),
30302
+ eventId: external_exports3.string().describe("Event ID"),
30303
+ summary: external_exports3.string().optional().describe("New event title"),
30304
+ from: external_exports3.string().optional().describe("New start time (RFC3339)"),
30305
+ to: external_exports3.string().optional().describe("New end time (RFC3339)"),
30306
+ description: external_exports3.string().optional().describe("New description"),
30307
+ location: external_exports3.string().optional().describe("New location"),
30308
+ attendees: external_exports3.string().optional().describe("New attendee emails, comma-separated (replaces existing)"),
30309
+ account: accountParam
30310
+ }
30311
+ }, async ({ calendarId, eventId, summary, from, to, description, location, attendees, account }) => {
30312
+ const args = ["calendar", "update", calendarId, eventId];
30313
+ if (summary !== void 0) args.push(`--summary=${summary}`);
30314
+ if (from !== void 0) args.push(`--from=${from}`);
30315
+ if (to !== void 0) args.push(`--to=${to}`);
30316
+ if (description !== void 0) args.push(`--description=${description}`);
30317
+ if (location !== void 0) args.push(`--location=${location}`);
30318
+ if (attendees !== void 0) args.push(`--attendees=${attendees}`);
30319
+ return runOrDiagnose(args, { account });
30320
+ });
30321
+ server2.registerTool("gog_calendar_delete", {
30322
+ description: "Delete a calendar event.",
30323
+ annotations: { destructiveHint: true },
30324
+ inputSchema: {
30325
+ calendarId: external_exports3.string().describe("Calendar ID"),
30326
+ eventId: external_exports3.string().describe("Event ID"),
30327
+ account: accountParam
30328
+ }
30329
+ }, async ({ calendarId, eventId, account }) => {
30330
+ return runOrDiagnose(["calendar", "delete", calendarId, eventId], { account });
30331
+ });
30332
+ server2.registerTool("gog_calendar_respond", {
30333
+ description: "Respond to a calendar event invitation.",
30334
+ annotations: { destructiveHint: true },
30335
+ inputSchema: {
30336
+ calendarId: external_exports3.string().describe("Calendar ID"),
30337
+ eventId: external_exports3.string().describe("Event ID"),
30338
+ status: external_exports3.enum(["accepted", "declined", "tentative"]).describe("Response status"),
30339
+ comment: external_exports3.string().optional().describe("Optional comment to include with response"),
30340
+ account: accountParam
30341
+ }
30342
+ }, async ({ calendarId, eventId, status, comment, account }) => {
30343
+ const args = ["calendar", "respond", calendarId, eventId, `--status=${status}`];
30344
+ if (comment) args.push(`--comment=${comment}`);
30345
+ return runOrDiagnose(args, { account });
30346
+ });
30347
+ server2.registerTool("gog_calendar_run", {
30348
+ description: "Run any gog calendar subcommand not covered by the other tools. Run `gog calendar --help` for the full list of subcommands, or `gog calendar <subcommand> --help` for flags on a specific subcommand.",
30349
+ annotations: { destructiveHint: true },
30350
+ inputSchema: {
30351
+ subcommand: external_exports3.string().describe('The gog calendar subcommand to run, e.g. "calendars", "freebusy"'),
30352
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags"),
30353
+ account: accountParam
30354
+ }
30355
+ }, async ({ subcommand, args, account }) => {
30356
+ return runOrDiagnose(["calendar", subcommand, ...args], { account });
30357
+ });
30358
+ }
30359
+
30360
+ // src/tools/contacts.ts
30361
+ function registerContactsTools(server2) {
30362
+ server2.registerTool("gog_contacts_search", {
30363
+ description: "Search Google Contacts by name, email, or phone.",
30364
+ annotations: { readOnlyHint: true },
30365
+ inputSchema: {
30366
+ query: external_exports3.string().describe("Search query (name, email, or phone)"),
30367
+ account: accountParam
30368
+ }
30369
+ }, async ({ query, account }) => {
30370
+ return runOrDiagnose(["contacts", "search", query], { account });
30371
+ });
30372
+ server2.registerTool("gog_contacts_list", {
30373
+ description: "List all Google Contacts.",
30374
+ annotations: { readOnlyHint: true },
30375
+ inputSchema: {
30376
+ account: accountParam
30377
+ }
30378
+ }, async ({ account }) => {
30379
+ return runOrDiagnose(["contacts", "list"], { account });
30380
+ });
30381
+ server2.registerTool("gog_contacts_get", {
30382
+ description: "Get a contact by resource name.",
30383
+ annotations: { readOnlyHint: true },
30384
+ inputSchema: {
30385
+ resourceName: external_exports3.string().describe("Contact resource name (e.g. people/c12345)"),
30386
+ account: accountParam
30387
+ }
30388
+ }, async ({ resourceName, account }) => {
30389
+ return runOrDiagnose(["contacts", "get", resourceName], { account });
30390
+ });
30391
+ server2.registerTool("gog_contacts_create", {
30392
+ description: "Create a new Google Contact.",
30393
+ annotations: { destructiveHint: false },
30394
+ inputSchema: {
30395
+ givenName: external_exports3.string().describe("Given (first) name"),
30396
+ familyName: external_exports3.string().optional().describe("Family (last) name"),
30397
+ email: external_exports3.string().optional().describe("Email address"),
30398
+ phone: external_exports3.string().optional().describe("Phone number"),
30399
+ org: external_exports3.string().optional().describe("Organization/company name"),
30400
+ title: external_exports3.string().optional().describe("Job title"),
30401
+ account: accountParam
30402
+ }
30403
+ }, async ({ givenName, familyName, email: email3, phone, org, title, account }) => {
30404
+ const args = ["contacts", "create", `--given=${givenName}`];
30405
+ if (familyName) args.push(`--family=${familyName}`);
30406
+ if (email3) args.push(`--email=${email3}`);
30407
+ if (phone) args.push(`--phone=${phone}`);
30408
+ if (org) args.push(`--org=${org}`);
30409
+ if (title) args.push(`--title=${title}`);
30410
+ return runOrDiagnose(args, { account });
30411
+ });
30412
+ server2.registerTool("gog_contacts_run", {
30413
+ description: "Run any gog contacts subcommand not covered by the other tools. Run `gog contacts --help` for the full list of subcommands, or `gog contacts <subcommand> --help` for flags on a specific subcommand.",
30414
+ annotations: { destructiveHint: true },
30415
+ inputSchema: {
30416
+ subcommand: external_exports3.string().describe('The gog contacts subcommand to run, e.g. "update", "delete", "directory"'),
30417
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags"),
30418
+ account: accountParam
30419
+ }
30420
+ }, async ({ subcommand, args, account }) => {
30421
+ return runOrDiagnose(["contacts", subcommand, ...args], { account });
30422
+ });
30423
+ }
30424
+
30425
+ // src/tools/docs.ts
30426
+ function registerDocsTools(server2) {
30427
+ server2.registerTool("gog_docs_info", {
30428
+ description: "Get Google Doc metadata: title, ID, and other properties.",
30429
+ annotations: { readOnlyHint: true },
30430
+ inputSchema: {
30431
+ docId: external_exports3.string().describe("Doc ID (from the URL)"),
30432
+ account: accountParam
30433
+ }
30434
+ }, async ({ docId, account }) => {
30435
+ return runOrDiagnose(["docs", "info", docId], { account });
30436
+ });
30437
+ server2.registerTool("gog_docs_cat", {
30438
+ description: "Read a Google Doc as plain text.",
30439
+ annotations: { readOnlyHint: true },
30440
+ inputSchema: {
30441
+ docId: external_exports3.string().describe("Doc ID (from the URL)"),
30442
+ account: accountParam
30443
+ }
30444
+ }, async ({ docId, account }) => {
30445
+ return runOrDiagnose(["docs", "cat", docId], { account });
30446
+ });
30447
+ server2.registerTool("gog_docs_create", {
30448
+ description: "Create a new Google Doc. Returns JSON with the new docId and URL.",
30449
+ annotations: { destructiveHint: false },
30450
+ inputSchema: {
30451
+ title: external_exports3.string().describe("Title for the new document"),
30452
+ account: accountParam
30453
+ }
30454
+ }, async ({ title, account }) => {
30455
+ return runOrDiagnose(["docs", "create", title], { account });
30456
+ });
30457
+ server2.registerTool("gog_docs_write", {
30458
+ description: "Write text content to a Google Doc, replacing existing body content by default. Set append=true to add after existing content.",
30459
+ annotations: { destructiveHint: true },
30460
+ inputSchema: {
30461
+ docId: external_exports3.string().describe("Doc ID (from the URL)"),
30462
+ text: external_exports3.string().describe("Text content to write"),
30463
+ append: external_exports3.boolean().optional().describe("Append to existing content instead of replacing (default: false)"),
30464
+ account: accountParam
30465
+ }
30466
+ }, async ({ docId, text, append, account }) => {
30467
+ const args = ["docs", "write", docId, `--text=${text}`];
30468
+ if (append) args.push("--append");
30469
+ return runOrDiagnose(args, { account });
30470
+ });
30471
+ server2.registerTool("gog_docs_find_replace", {
30472
+ description: "Find and replace text in a Google Doc.",
30473
+ annotations: { destructiveHint: true },
30474
+ inputSchema: {
30475
+ docId: external_exports3.string().describe("Doc ID (from the URL)"),
30476
+ find: external_exports3.string().describe("Text to find"),
30477
+ replace: external_exports3.string().describe("Replacement text"),
30478
+ account: accountParam
30479
+ }
30480
+ }, async ({ docId, find, replace, account }) => {
30481
+ return runOrDiagnose(["docs", "find-replace", docId, find, replace], { account });
30482
+ });
30483
+ server2.registerTool("gog_docs_structure", {
30484
+ description: "Show a Google Doc's structure with numbered paragraphs. Useful for understanding the document layout before making index-based edits.",
30485
+ annotations: { readOnlyHint: true },
30486
+ inputSchema: {
30487
+ docId: external_exports3.string().describe("Doc ID (from the URL)"),
30488
+ account: accountParam
30489
+ }
30490
+ }, async ({ docId, account }) => {
30491
+ return runOrDiagnose(["docs", "structure", docId], { account });
30492
+ });
30493
+ server2.registerTool("gog_docs_run", {
30494
+ description: "Run any gog docs subcommand not covered by the other tools. Run `gog docs --help` for the full list of subcommands, or `gog docs <subcommand> --help` for flags on a specific subcommand.",
30495
+ annotations: { destructiveHint: true },
30496
+ inputSchema: {
30497
+ subcommand: external_exports3.string().describe('The gog docs subcommand to run, e.g. "copy", "clear", "insert", "sed", "export"'),
30498
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags"),
30499
+ account: accountParam
30500
+ }
30501
+ }, async ({ subcommand, args, account }) => {
30502
+ return runOrDiagnose(["docs", subcommand, ...args], { account });
30503
+ });
30504
+ }
30505
+
30506
+ // src/tools/drive.ts
30507
+ function registerDriveTools(server2) {
30508
+ server2.registerTool("gog_drive_ls", {
30509
+ description: "List files in a Google Drive folder (default: root).",
30510
+ annotations: { readOnlyHint: true },
30511
+ inputSchema: {
30512
+ folderId: external_exports3.string().optional().describe("Folder ID to list (default: root)"),
30513
+ account: accountParam
30514
+ }
30515
+ }, async ({ folderId, account }) => {
30516
+ const args = ["drive", "ls"];
30517
+ if (folderId) args.push(folderId);
30518
+ return runOrDiagnose(args, { account });
30519
+ });
30520
+ server2.registerTool("gog_drive_search", {
30521
+ description: "Search Google Drive files by full-text query.",
30522
+ annotations: { readOnlyHint: true },
30523
+ inputSchema: {
30524
+ query: external_exports3.string().describe("Search query"),
30525
+ account: accountParam
30526
+ }
30527
+ }, async ({ query, account }) => {
30528
+ return runOrDiagnose(["drive", "search", query], { account });
30529
+ });
30530
+ server2.registerTool("gog_drive_get", {
30531
+ description: "Get metadata for a Google Drive file.",
30532
+ annotations: { readOnlyHint: true },
30533
+ inputSchema: {
30534
+ fileId: external_exports3.string().describe("File ID"),
30535
+ account: accountParam
30536
+ }
30537
+ }, async ({ fileId, account }) => {
30538
+ return runOrDiagnose(["drive", "get", fileId], { account });
30539
+ });
30540
+ server2.registerTool("gog_drive_mkdir", {
30541
+ description: "Create a new folder in Google Drive.",
30542
+ annotations: { destructiveHint: false },
30543
+ inputSchema: {
30544
+ name: external_exports3.string().describe("Folder name"),
30545
+ account: accountParam
30546
+ }
30547
+ }, async ({ name, account }) => {
30548
+ return runOrDiagnose(["drive", "mkdir", name], { account });
30549
+ });
30550
+ server2.registerTool("gog_drive_rename", {
30551
+ description: "Rename a file or folder in Google Drive.",
30552
+ annotations: { destructiveHint: true },
30553
+ inputSchema: {
30554
+ fileId: external_exports3.string().describe("File or folder ID"),
30555
+ newName: external_exports3.string().describe("New name"),
30556
+ account: accountParam
30557
+ }
30558
+ }, async ({ fileId, newName, account }) => {
30559
+ return runOrDiagnose(["drive", "rename", fileId, newName], { account });
30560
+ });
30561
+ server2.registerTool("gog_drive_move", {
30562
+ description: "Move a file to a different folder in Google Drive.",
30563
+ annotations: { destructiveHint: true },
30564
+ inputSchema: {
30565
+ fileId: external_exports3.string().describe("File ID to move"),
30566
+ parentId: external_exports3.string().describe("Destination folder ID"),
30567
+ account: accountParam
30568
+ }
30569
+ }, async ({ fileId, parentId, account }) => {
30570
+ return runOrDiagnose(["drive", "move", fileId, `--parent=${parentId}`], { account });
30571
+ });
30572
+ server2.registerTool("gog_drive_delete", {
30573
+ description: "Move a Google Drive file to trash.",
30574
+ annotations: { destructiveHint: true },
30575
+ inputSchema: {
30576
+ fileId: external_exports3.string().describe("File ID to trash"),
30577
+ account: accountParam
30578
+ }
30579
+ }, async ({ fileId, account }) => {
30580
+ return runOrDiagnose(["drive", "delete", fileId], { account });
30581
+ });
30582
+ server2.registerTool("gog_drive_share", {
30583
+ description: "Share a Google Drive file or folder.",
30584
+ annotations: { destructiveHint: true },
30585
+ inputSchema: {
30586
+ fileId: external_exports3.string().describe("File or folder ID"),
30587
+ to: external_exports3.enum(["user", "anyone", "domain"]).describe("Share target type"),
30588
+ email: external_exports3.string().optional().describe("User email (required when to=user)"),
30589
+ domain: external_exports3.string().optional().describe("Domain (required when to=domain)"),
30590
+ role: external_exports3.enum(["reader", "writer"]).optional().describe("Permission role (default: reader)"),
30591
+ account: accountParam
30592
+ }
30593
+ }, async ({ fileId, to, email: email3, domain: domain2, role, account }) => {
30594
+ const args = ["drive", "share", fileId, `--to=${to}`];
30595
+ if (email3) args.push(`--email=${email3}`);
30596
+ if (domain2) args.push(`--domain=${domain2}`);
30597
+ if (role) args.push(`--role=${role}`);
30598
+ return runOrDiagnose(args, { account });
30599
+ });
30600
+ server2.registerTool("gog_drive_run", {
30601
+ description: "Run any gog drive subcommand not covered by the other tools. Run `gog drive --help` for the full list of subcommands, or `gog drive <subcommand> --help` for flags on a specific subcommand.",
30602
+ annotations: { destructiveHint: true },
30603
+ inputSchema: {
30604
+ subcommand: external_exports3.string().describe('The gog drive subcommand to run, e.g. "copy", "upload", "download", "permissions"'),
30605
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags"),
30606
+ account: accountParam
30607
+ }
30608
+ }, async ({ subcommand, args, account }) => {
30609
+ return runOrDiagnose(["drive", subcommand, ...args], { account });
30610
+ });
30611
+ }
30612
+
30613
+ // src/tools/gmail.ts
30614
+ function registerGmailTools(server2) {
30615
+ server2.registerTool("gog_gmail_search", {
30616
+ description: 'Search Gmail threads using Gmail query syntax (e.g. "from:alice subject:invoice is:unread").',
30617
+ annotations: { readOnlyHint: true },
30618
+ inputSchema: {
30619
+ query: external_exports3.string().describe("Gmail search query"),
30620
+ max: external_exports3.number().int().optional().describe("Max results to return (default: 10)"),
30621
+ account: accountParam
30622
+ }
30623
+ }, async ({ query, max, account }) => {
30624
+ const args = ["gmail", "search", query];
30625
+ if (max !== void 0) args.push(`--max=${max}`);
30626
+ return runOrDiagnose(args, { account });
30627
+ });
30628
+ server2.registerTool("gog_gmail_get", {
30629
+ description: "Get a Gmail message by ID.",
30630
+ annotations: { readOnlyHint: true },
30631
+ inputSchema: {
30632
+ messageId: external_exports3.string().describe("Message ID"),
30633
+ format: external_exports3.enum(["full", "metadata", "raw"]).optional().describe("Message format (default: full)"),
30634
+ account: accountParam
30635
+ }
30636
+ }, async ({ messageId, format, account }) => {
30637
+ const args = ["gmail", "get", messageId];
30638
+ if (format) args.push(`--format=${format}`);
30639
+ return runOrDiagnose(args, { account });
30640
+ });
30641
+ server2.registerTool("gog_gmail_send", {
30642
+ description: "Send an email.",
30643
+ annotations: { destructiveHint: true },
30644
+ inputSchema: {
30645
+ to: external_exports3.string().describe("Recipient(s), comma-separated"),
30646
+ subject: external_exports3.string().describe("Subject line"),
30647
+ body: external_exports3.string().describe("Email body (plain text)"),
30648
+ cc: external_exports3.string().optional().describe("CC recipients, comma-separated"),
30649
+ bcc: external_exports3.string().optional().describe("BCC recipients, comma-separated"),
30650
+ replyToMessageId: external_exports3.string().optional().describe("Message ID to reply to"),
30651
+ threadId: external_exports3.string().optional().describe("Thread ID to reply within"),
30652
+ account: accountParam
30653
+ }
30654
+ }, async ({ to, subject, body, cc, bcc, replyToMessageId, threadId, account }) => {
30655
+ const args = ["gmail", "send", `--to=${to}`, `--subject=${subject}`, `--body=${body}`];
30656
+ if (cc) args.push(`--cc=${cc}`);
30657
+ if (bcc) args.push(`--bcc=${bcc}`);
30658
+ if (replyToMessageId) args.push(`--reply-to-message-id=${replyToMessageId}`);
30659
+ if (threadId) args.push(`--thread-id=${threadId}`);
30660
+ return runOrDiagnose(args, { account });
30661
+ });
30662
+ server2.registerTool("gog_gmail_run", {
30663
+ description: "Run any gog gmail subcommand not covered by the other tools. Run `gog gmail --help` for the full list of subcommands, or `gog gmail <subcommand> --help` for flags on a specific subcommand.",
30664
+ annotations: { destructiveHint: true },
30665
+ inputSchema: {
30666
+ subcommand: external_exports3.string().describe('The gog gmail subcommand to run, e.g. "archive", "mark-read", "labels"'),
30667
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags"),
30668
+ account: accountParam
30669
+ }
30670
+ }, async ({ subcommand, args, account }) => {
30671
+ return runOrDiagnose(["gmail", subcommand, ...args], { account });
30672
+ });
30673
+ }
30674
+
30675
+ // src/tools/sheets.ts
30164
30676
  function registerSheetsTools(server2) {
30165
30677
  server2.registerTool("gog_sheets_get", {
30166
30678
  description: 'Read values from a Google Sheets range. Returns a JSON object with a "values" array of rows.',
@@ -30171,11 +30683,7 @@ function registerSheetsTools(server2) {
30171
30683
  account: accountParam
30172
30684
  }
30173
30685
  }, async ({ spreadsheetId, range, account }) => {
30174
- try {
30175
- return toText(await run(["sheets", "get", spreadsheetId, range], { account }));
30176
- } catch (err) {
30177
- return toError(err);
30178
- }
30686
+ return runOrDiagnose(["sheets", "get", spreadsheetId, range], { account });
30179
30687
  });
30180
30688
  server2.registerTool("gog_sheets_update", {
30181
30689
  description: "Write values to a Google Sheets range, overwriting existing content.",
@@ -30187,14 +30695,10 @@ function registerSheetsTools(server2) {
30187
30695
  account: accountParam
30188
30696
  }
30189
30697
  }, async ({ spreadsheetId, range, values, account }) => {
30190
- try {
30191
- return toText(await run(
30192
- ["sheets", "update", spreadsheetId, range, `--values-json=${JSON.stringify(values)}`],
30193
- { account }
30194
- ));
30195
- } catch (err) {
30196
- return toError(err);
30197
- }
30698
+ return runOrDiagnose(
30699
+ ["sheets", "update", spreadsheetId, range, `--values-json=${JSON.stringify(values)}`],
30700
+ { account }
30701
+ );
30198
30702
  });
30199
30703
  server2.registerTool("gog_sheets_append", {
30200
30704
  description: "Append rows to a Google Sheet after the last row with data in the given range.",
@@ -30206,14 +30710,10 @@ function registerSheetsTools(server2) {
30206
30710
  account: accountParam
30207
30711
  }
30208
30712
  }, async ({ spreadsheetId, range, values, account }) => {
30209
- try {
30210
- return toText(await run(
30211
- ["sheets", "append", spreadsheetId, range, `--values-json=${JSON.stringify(values)}`],
30212
- { account }
30213
- ));
30214
- } catch (err) {
30215
- return toError(err);
30216
- }
30713
+ return runOrDiagnose(
30714
+ ["sheets", "append", spreadsheetId, range, `--values-json=${JSON.stringify(values)}`],
30715
+ { account }
30716
+ );
30217
30717
  });
30218
30718
  server2.registerTool("gog_sheets_clear", {
30219
30719
  description: "Clear all values in a Google Sheets range (formatting is preserved).",
@@ -30224,11 +30724,7 @@ function registerSheetsTools(server2) {
30224
30724
  account: accountParam
30225
30725
  }
30226
30726
  }, async ({ spreadsheetId, range, account }) => {
30227
- try {
30228
- return toText(await run(["sheets", "clear", spreadsheetId, range], { account }));
30229
- } catch (err) {
30230
- return toError(err);
30231
- }
30727
+ return runOrDiagnose(["sheets", "clear", spreadsheetId, range], { account });
30232
30728
  });
30233
30729
  server2.registerTool("gog_sheets_metadata", {
30234
30730
  description: "Get spreadsheet metadata: title, sheet tabs, named ranges, and other properties.",
@@ -30238,25 +30734,17 @@ function registerSheetsTools(server2) {
30238
30734
  account: accountParam
30239
30735
  }
30240
30736
  }, async ({ spreadsheetId, account }) => {
30241
- try {
30242
- return toText(await run(["sheets", "metadata", spreadsheetId], { account }));
30243
- } catch (err) {
30244
- return toError(err);
30245
- }
30737
+ return runOrDiagnose(["sheets", "metadata", spreadsheetId], { account });
30246
30738
  });
30247
30739
  server2.registerTool("gog_sheets_create", {
30248
30740
  description: "Create a new Google Spreadsheet. Returns JSON with the new spreadsheetId and URL.",
30249
- annotations: { destructiveHint: true },
30741
+ annotations: { destructiveHint: false },
30250
30742
  inputSchema: {
30251
30743
  title: external_exports3.string().describe("Title for the new spreadsheet"),
30252
30744
  account: accountParam
30253
30745
  }
30254
30746
  }, async ({ title, account }) => {
30255
- try {
30256
- return toText(await run(["sheets", "create", title], { account }));
30257
- } catch (err) {
30258
- return toError(err);
30259
- }
30747
+ return runOrDiagnose(["sheets", "create", title], { account });
30260
30748
  });
30261
30749
  server2.registerTool("gog_sheets_find_replace", {
30262
30750
  description: "Find and replace text across an entire Google Spreadsheet.",
@@ -30268,14 +30756,10 @@ function registerSheetsTools(server2) {
30268
30756
  account: accountParam
30269
30757
  }
30270
30758
  }, async ({ spreadsheetId, find, replace, account }) => {
30271
- try {
30272
- return toText(await run(["sheets", "find-replace", spreadsheetId, find, replace], { account }));
30273
- } catch (err) {
30274
- return toError(err);
30275
- }
30759
+ return runOrDiagnose(["sheets", "find-replace", spreadsheetId, find, replace], { account });
30276
30760
  });
30277
30761
  server2.registerTool("gog_sheets_run", {
30278
- description: "Run any gog sheets subcommand not covered by the other tools. See `gog sheets --help` for the full list of subcommands and their flags.",
30762
+ description: "Run any gog sheets subcommand not covered by the other tools. Run `gog sheets --help` for the full list of subcommands, or `gog sheets <subcommand> --help` for flags on a specific subcommand.",
30279
30763
  annotations: { destructiveHint: true },
30280
30764
  inputSchema: {
30281
30765
  subcommand: external_exports3.string().describe('The gog sheets subcommand to run, e.g. "freeze", "add-tab", "rename-tab"'),
@@ -30283,16 +30767,102 @@ function registerSheetsTools(server2) {
30283
30767
  account: accountParam
30284
30768
  }
30285
30769
  }, async ({ subcommand, args, account }) => {
30286
- try {
30287
- return toText(await run(["sheets", subcommand, ...args], { account }));
30288
- } catch (err) {
30289
- return toError(err);
30770
+ return runOrDiagnose(["sheets", subcommand, ...args], { account });
30771
+ });
30772
+ }
30773
+
30774
+ // src/tools/tasks.ts
30775
+ function registerTasksTools(server2) {
30776
+ server2.registerTool("gog_tasks_lists", {
30777
+ description: "List all Google Task lists.",
30778
+ annotations: { readOnlyHint: true },
30779
+ inputSchema: {
30780
+ account: accountParam
30781
+ }
30782
+ }, async ({ account }) => {
30783
+ return runOrDiagnose(["tasks", "lists", "list"], { account });
30784
+ });
30785
+ server2.registerTool("gog_tasks_list", {
30786
+ description: "List tasks in a Google Task list.",
30787
+ annotations: { readOnlyHint: true },
30788
+ inputSchema: {
30789
+ tasklistId: external_exports3.string().describe("Task list ID (use gog_tasks_lists to find IDs)"),
30790
+ account: accountParam
30290
30791
  }
30792
+ }, async ({ tasklistId, account }) => {
30793
+ return runOrDiagnose(["tasks", "list", tasklistId], { account });
30794
+ });
30795
+ server2.registerTool("gog_tasks_get", {
30796
+ description: "Get a specific task by ID.",
30797
+ annotations: { readOnlyHint: true },
30798
+ inputSchema: {
30799
+ tasklistId: external_exports3.string().describe("Task list ID"),
30800
+ taskId: external_exports3.string().describe("Task ID"),
30801
+ account: accountParam
30802
+ }
30803
+ }, async ({ tasklistId, taskId, account }) => {
30804
+ return runOrDiagnose(["tasks", "get", tasklistId, taskId], { account });
30805
+ });
30806
+ server2.registerTool("gog_tasks_add", {
30807
+ description: "Add a task to a Google Task list.",
30808
+ annotations: { destructiveHint: false },
30809
+ inputSchema: {
30810
+ tasklistId: external_exports3.string().describe("Task list ID"),
30811
+ title: external_exports3.string().describe("Task title"),
30812
+ notes: external_exports3.string().optional().describe("Task notes/description"),
30813
+ due: external_exports3.string().optional().describe("Due date (YYYY-MM-DD or RFC3339)"),
30814
+ account: accountParam
30815
+ }
30816
+ }, async ({ tasklistId, title, notes, due, account }) => {
30817
+ const args = ["tasks", "add", tasklistId, `--title=${title}`];
30818
+ if (notes) args.push(`--notes=${notes}`);
30819
+ if (due) args.push(`--due=${due}`);
30820
+ return runOrDiagnose(args, { account });
30821
+ });
30822
+ server2.registerTool("gog_tasks_done", {
30823
+ description: "Mark a task as completed.",
30824
+ annotations: { destructiveHint: true },
30825
+ inputSchema: {
30826
+ tasklistId: external_exports3.string().describe("Task list ID"),
30827
+ taskId: external_exports3.string().describe("Task ID"),
30828
+ account: accountParam
30829
+ }
30830
+ }, async ({ tasklistId, taskId, account }) => {
30831
+ return runOrDiagnose(["tasks", "done", tasklistId, taskId], { account });
30832
+ });
30833
+ server2.registerTool("gog_tasks_delete", {
30834
+ description: "Delete a task.",
30835
+ annotations: { destructiveHint: true },
30836
+ inputSchema: {
30837
+ tasklistId: external_exports3.string().describe("Task list ID"),
30838
+ taskId: external_exports3.string().describe("Task ID"),
30839
+ account: accountParam
30840
+ }
30841
+ }, async ({ tasklistId, taskId, account }) => {
30842
+ return runOrDiagnose(["tasks", "delete", tasklistId, taskId], { account });
30843
+ });
30844
+ server2.registerTool("gog_tasks_run", {
30845
+ description: "Run any gog tasks subcommand not covered by the other tools. Run `gog tasks --help` for the full list of subcommands, or `gog tasks <subcommand> --help` for flags on a specific subcommand.",
30846
+ annotations: { destructiveHint: true },
30847
+ inputSchema: {
30848
+ subcommand: external_exports3.string().describe('The gog tasks subcommand to run, e.g. "update", "undo", "clear"'),
30849
+ args: external_exports3.array(external_exports3.string()).describe("Additional positional args and flags"),
30850
+ account: accountParam
30851
+ }
30852
+ }, async ({ subcommand, args, account }) => {
30853
+ return runOrDiagnose(["tasks", subcommand, ...args], { account });
30291
30854
  });
30292
30855
  }
30293
30856
 
30294
30857
  // src/index.ts
30295
- var server = new McpServer({ name: "gogcli", version: "1.0.0" });
30858
+ var server = new McpServer({ name: "gogcli", version: "1.0.2" });
30859
+ registerAuthTools(server);
30860
+ registerCalendarTools(server);
30861
+ registerContactsTools(server);
30862
+ registerDocsTools(server);
30863
+ registerDriveTools(server);
30864
+ registerGmailTools(server);
30296
30865
  registerSheetsTools(server);
30866
+ registerTasksTools(server);
30297
30867
  var transport = new StdioServerTransport();
30298
30868
  await server.connect(transport);