@webhooks-cc/mcp 1.23.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -23,18 +23,25 @@ __export(tools_exports, {
23
23
  LOCAL_ONLY_TOOLS: () => LOCAL_ONLY_TOOLS,
24
24
  REMOTE_MAX_WAIT_MS: () => REMOTE_MAX_WAIT_MS,
25
25
  REMOTE_MIN_POLL_MS: () => REMOTE_MIN_POLL_MS,
26
+ TOOL_CATALOG: () => TOOL_CATALOG,
27
+ TOOL_GROUPS: () => TOOL_GROUPS,
28
+ TOOL_GROUP_NAMES: () => TOOL_GROUP_NAMES,
29
+ clientLoadsEverything: () => clientLoadsEverything,
26
30
  createEndpointShape: () => createEndpointShape,
31
+ defaultToolGroups: () => defaultToolGroups,
27
32
  deleteEndpointShape: () => deleteEndpointShape,
28
33
  getEndpointShape: () => getEndpointShape,
29
34
  getRequestShape: () => getRequestShape,
30
35
  jsonContent: () => jsonContent,
31
36
  listEndpointsShape: () => listEndpointsShape,
32
37
  listRequestsShape: () => listRequestsShape,
38
+ parseToolGroups: () => parseToolGroups,
33
39
  payloadSchemaResult: () => payloadSchemaResult,
34
40
  payloadSchemaShape: () => payloadSchemaShape,
35
41
  registerTools: () => registerTools,
36
42
  shareHints: () => shareHints,
37
43
  textContent: () => textContent,
44
+ toolAnnotations: () => toolAnnotations,
38
45
  toolWords: () => toolWords,
39
46
  waitForRequestShape: () => waitForRequestShape,
40
47
  withErrorHandling: () => withErrorHandling,
@@ -252,6 +259,208 @@ function compactRequest(request) {
252
259
  return compact;
253
260
  }
254
261
 
262
+ // src/catalog.ts
263
+ var TOOL_GROUPS = {
264
+ core: "Endpoints, captured requests and emails, sending test webhooks, signatures, forwarding destinations, deliveries, previews of your local app and their logs, usage and approvals",
265
+ forwarding: "The rest of forwarding: preview what a destination would send, the endpoint's forwarding settings and signing secret, test deliveries",
266
+ layouts: "Email layouts and named fields: try layouts and fields on a captured email, add ready-made layouts, and AI setup",
267
+ extras: "Bulk endpoint changes, favourites, request counts and payload schemas",
268
+ teams: "Teams: members, invites, sharing endpoints with a team, and pricing team changes",
269
+ account: "The account: billing, API keys, connected agents, public share links to requests, and the display name",
270
+ domains: "Custom inbound email domains: add, verify, route and remove them",
271
+ sheets: "Google Sheets destinations: Google accounts, spreadsheets and their tabs",
272
+ names: "Preview names: reserve, release and password-protect them"
273
+ };
274
+ var TOOL_GROUP_NAMES = Object.keys(TOOL_GROUPS);
275
+ var read = { readOnly: true };
276
+ var write = {};
277
+ var update = { idempotent: true };
278
+ var remove = { destructive: true, idempotent: true };
279
+ var replace = { destructive: true, idempotent: true };
280
+ var outward = { openWorld: true };
281
+ function group(name, tools) {
282
+ return Object.fromEntries(
283
+ Object.entries(tools).map(([tool, behaviour]) => [tool, { group: name, ...behaviour }])
284
+ );
285
+ }
286
+ var TOOL_CATALOG = {
287
+ ...group("core", {
288
+ create_endpoint: write,
289
+ list_endpoints: read,
290
+ get_endpoint: read,
291
+ // Replaces what it is given (a mock response, the signing secret).
292
+ update_endpoint: replace,
293
+ delete_endpoint: remove,
294
+ list_requests: read,
295
+ search_requests: read,
296
+ get_request: read,
297
+ wait_for_request: read,
298
+ wait_for_requests: read,
299
+ replay_request: outward,
300
+ compare_requests: read,
301
+ extract_from_request: read,
302
+ clear_requests: remove,
303
+ send_webhook: write,
304
+ send_to: outward,
305
+ test_webhook_flow: outward,
306
+ preview_webhook: read,
307
+ preview_response: read,
308
+ list_provider_templates: read,
309
+ verify_signature: read,
310
+ list_emails: read,
311
+ get_email: read,
312
+ wait_for_email: read,
313
+ send_test_email: write,
314
+ render_email: outward,
315
+ list_destinations: read,
316
+ add_destination: write,
317
+ update_destination: replace,
318
+ remove_destination: remove,
319
+ list_deliveries: read,
320
+ redeliver: outward,
321
+ share_port: outward,
322
+ list_shares: read,
323
+ share_requests: read,
324
+ stop_share: remove,
325
+ get_usage: read,
326
+ // Collecting an approved key hands it over once: not a pure read.
327
+ wait_for_approval: write,
328
+ describe: read
329
+ }),
330
+ ...group("forwarding", {
331
+ preview_destination: read,
332
+ configure_forwarding: replace,
333
+ // rotate: true replaces the secret, and receivers holding the old one fail.
334
+ get_forwarding_secret: { destructive: true },
335
+ test_forwarding: outward
336
+ }),
337
+ ...group("layouts", {
338
+ preview_layouts: read,
339
+ list_layout_templates: read,
340
+ add_layout_template: write,
341
+ preview_email_fields: read,
342
+ ai_setup_status: read,
343
+ // Sends the chosen emails to Anthropic once the owner approves.
344
+ ai_setup: outward
345
+ }),
346
+ ...group("extras", {
347
+ create_endpoints: write,
348
+ delete_endpoints: remove,
349
+ favorite_endpoint: update,
350
+ count_requests: read,
351
+ generate_payload_schema: read
352
+ }),
353
+ ...group("teams", {
354
+ list_teams: read,
355
+ list_team_members: read,
356
+ share_endpoint: update,
357
+ unshare_endpoint: remove,
358
+ create_team: write,
359
+ rename_team: update,
360
+ delete_team: remove,
361
+ remove_team_member: remove,
362
+ leave_team: remove,
363
+ invite_to_team: outward,
364
+ list_invites: read,
365
+ answer_invite: write,
366
+ withdraw_invite: remove,
367
+ quote_team_change: read
368
+ }),
369
+ ...group("account", {
370
+ get_billing: read,
371
+ list_api_keys: read,
372
+ create_api_key: write,
373
+ revoke_api_key: remove,
374
+ rename_account: update,
375
+ list_connected_agents: read,
376
+ disconnect_agent: remove,
377
+ list_share_links: read,
378
+ create_share_link: write,
379
+ revoke_share_link: remove
380
+ }),
381
+ ...group("domains", {
382
+ list_domains: read,
383
+ add_domain: write,
384
+ // A failed check counts toward lapsing a verified domain: not safe to repeat.
385
+ verify_domain: { destructive: true },
386
+ // Replaces the routing; a missing catch-all refuses mail.
387
+ route_domain: replace,
388
+ remove_domain: remove
389
+ }),
390
+ ...group("sheets", {
391
+ list_google_connections: read,
392
+ connect_google: outward,
393
+ pick_spreadsheet: outward,
394
+ create_spreadsheet: outward,
395
+ list_sheet_tabs: { readOnly: true, openWorld: true },
396
+ disconnect_google: remove
397
+ }),
398
+ ...group("names", {
399
+ // The log of what visitors asked a running preview for.
400
+ list_names: read,
401
+ reserve_name: write,
402
+ release_name: remove,
403
+ set_name_password: update,
404
+ // Opens the name to anyone again.
405
+ clear_name_password: { destructive: true, idempotent: true }
406
+ })
407
+ };
408
+ function toolAnnotations(name) {
409
+ const entry = TOOL_CATALOG[name];
410
+ const readOnly = entry?.readOnly === true;
411
+ return {
412
+ title: toolTitle(name),
413
+ readOnlyHint: readOnly,
414
+ // MCP reads a missing destructiveHint as true on any tool that writes.
415
+ destructiveHint: !readOnly && entry?.destructive === true,
416
+ idempotentHint: readOnly || entry?.idempotent === true,
417
+ openWorldHint: entry?.openWorld === true
418
+ };
419
+ }
420
+ function toolTitle(name) {
421
+ const words = name.split("_").map((word) => TITLE_WORDS[word] ?? word);
422
+ const first = words[0] ?? "";
423
+ return [first.charAt(0).toUpperCase() + first.slice(1), ...words.slice(1)].join(" ");
424
+ }
425
+ var TITLE_WORDS = {
426
+ api: "API",
427
+ ai: "AI",
428
+ mcp: "MCP"
429
+ };
430
+ function parseToolGroups(setting) {
431
+ if (setting === null || setting === void 0 || setting.trim() === "") return null;
432
+ const groups = /* @__PURE__ */ new Set(["core"]);
433
+ const unknown = [];
434
+ for (const raw of setting.split(/[\s,+]+/)) {
435
+ const name = raw.trim().toLowerCase();
436
+ if (!name) continue;
437
+ if (name === "all") {
438
+ for (const g of TOOL_GROUP_NAMES) groups.add(g);
439
+ } else if (TOOL_GROUP_NAMES.includes(name)) {
440
+ groups.add(name);
441
+ } else {
442
+ unknown.push(raw.trim());
443
+ }
444
+ }
445
+ return { groups, unknown };
446
+ }
447
+ var LOADS_EVERYTHING = [
448
+ /^claude-code$/i,
449
+ /^claude-ai$/i,
450
+ /^claude$/i,
451
+ /codex/i,
452
+ /^openai-mcp$/i,
453
+ /chatgpt/i
454
+ ];
455
+ function clientLoadsEverything(clientName) {
456
+ if (!clientName) return false;
457
+ const name = clientName.trim().toLowerCase().replace(/[\s_]+/g, "-");
458
+ return LOADS_EVERYTHING.some((pattern) => pattern.test(name));
459
+ }
460
+ function defaultToolGroups(clientName) {
461
+ return clientLoadsEverything(clientName) ? new Set(TOOL_GROUP_NAMES) : /* @__PURE__ */ new Set(["core"]);
462
+ }
463
+
255
464
  // src/tools.ts
256
465
  var MAX_BODY_SIZE = MAX_OUTPUT;
257
466
  var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
@@ -512,6 +721,14 @@ ${JSON.stringify(result, null, 2)}`;
512
721
  if (typeof result.url === "string") {
513
722
  return `Approved. The share link is ${result.url} (anyone with it can read the copy until ${String(result.expiresAt)}).`;
514
723
  }
724
+ if (typeof result.invitedEmail === "string") {
725
+ const team = typeof result.teamName === "string" ? ` to "${result.teamName}"` : "";
726
+ const warning = typeof result.warning === "string" ? ` ${result.warning} Tell them to sign up with that address and accept from their Teams page.` : " They get an email; accepting claims one of the team's seats.";
727
+ return `Approved. Invited ${result.invitedEmail}${team} (invite ${String(result.id)}).${warning}`;
728
+ }
729
+ if (typeof result.deleted === "string" && typeof result.teamId === "string") {
730
+ return `Approved. The team ${result.deleted ? `"${result.deleted}" ` : ""}was deleted; its subscription has ended.`;
731
+ }
515
732
  if (typeof result.removed === "string") {
516
733
  return `Approved. The domain ${result.removed} was removed; mail to it is refused now.`;
517
734
  }
@@ -586,6 +803,75 @@ function fitArrayField(value, key) {
586
803
  }
587
804
  return cut(low);
588
805
  }
806
+ function isoTime(ms) {
807
+ if (ms === null || !Number.isFinite(ms)) return null;
808
+ const date = new Date(ms);
809
+ return Number.isNaN(date.getTime()) ? null : date.toISOString();
810
+ }
811
+ function searchStoppedNote(searchedUntil, order, hasCursor) {
812
+ const [direction, rest] = order === "asc" ? ["forward", "newer"] : ["back", "older"];
813
+ const reached = searchedUntil ? `Searched ${direction} to ${searchedUntil}; ${rest} requests were not searched yet.` : `The search stopped before it read everything; ${rest} requests were not searched yet.`;
814
+ return hasCursor ? `${reached} Call search_requests again with cursor to continue.` : reached;
815
+ }
816
+ var FULL_REQUEST_HINT = "The full request is available from the API (GET /api/requests/{id}), the SDKs (requests.get(id)) or the CLI (whk requests get <id>).";
817
+ var SEARCH_SHORTENED_NOTE = `Some requests were shortened to fit the output (bodyTruncated with bodySize, or shortened: true for a summary); get_request with the id returns as much of one request as fits. ${FULL_REQUEST_HINT}`;
818
+ var REQUEST_SHORTENED_NOTE = `This request was cut to fit the output: its body (bodyTruncated, with bodySize), or everything but a summary (shortened: true). ${FULL_REQUEST_HINT}`;
819
+ function clip(value, max) {
820
+ return typeof value === "string" ? sliceText(value, max) : void 0;
821
+ }
822
+ function listedSize(request) {
823
+ return jsonSize([[request]]) - 8;
824
+ }
825
+ function fitSearchRequests(requests, room) {
826
+ const share = Math.floor(room / Math.max(1, requests.length));
827
+ const fitted = requests.map(
828
+ (request) => shortenRequest(request, share, listedSize)
829
+ );
830
+ if (fitted.every((request) => listedSize(request) <= share)) return fitted;
831
+ return requests.map((request) => {
832
+ const { id, receivedAt } = request;
833
+ return { id, receivedAt, shortened: true };
834
+ });
835
+ }
836
+ function shortenRequest(request, share, sizeOf) {
837
+ if (sizeOf(request) <= share) return request;
838
+ if (typeof request.body === "string") {
839
+ const body = request.body;
840
+ let keep = body.length - (sizeOf(request) - share) - 96;
841
+ while (keep > 0) {
842
+ const cut = {
843
+ ...request,
844
+ body: sliceText(body, keep),
845
+ bodyTruncated: true,
846
+ bodySize: body.length
847
+ };
848
+ if (sizeOf(cut) <= share) return cut;
849
+ keep = Math.floor(keep / 2);
850
+ }
851
+ }
852
+ const email = request.email;
853
+ const summary = {
854
+ id: request.id,
855
+ slug: clip(request.slug, 64),
856
+ method: clip(request.method, 16),
857
+ path: clip(request.path, 200),
858
+ contentType: clip(request.contentType, 100),
859
+ size: request.size,
860
+ receivedAt: request.receivedAt,
861
+ kind: request.kind,
862
+ ...email ? { subject: clip(email.subject, 200) } : {},
863
+ shortened: true,
864
+ ...typeof request.note === "string" ? { note: request.note } : {}
865
+ };
866
+ return summary;
867
+ }
868
+ function requestContent(request) {
869
+ const compact = compactRequest(request);
870
+ if (jsonSize(compact) <= MAX_BODY_SIZE) return jsonContent(compact);
871
+ return jsonContent(
872
+ shortenRequest({ ...compact, note: REQUEST_SHORTENED_NOTE }, MAX_BODY_SIZE, jsonSize)
873
+ );
874
+ }
589
875
  function jsonContent(value) {
590
876
  return textContent(serializeJson(value));
591
877
  }
@@ -630,6 +916,13 @@ function serializeError(error) {
630
916
  } else if (error instanceof import_sdk.WebhooksCCError) {
631
917
  payload.code = error.statusCode >= 500 ? "server_error" : "validation_error";
632
918
  }
919
+ if (error instanceof import_sdk.WebhooksCCError && payload.hint === null) {
920
+ if (error.code === "invalid_cursor") {
921
+ payload.hint = "The cursor is not one this search returned, or the order changed since. Pass a cursor exactly as a result gave it, or search again without one.";
922
+ } else if (error.code === "search_busy") {
923
+ payload.hint = "The account's other searches are still running. Wait retryAfter seconds, then call again with the same inputs.";
924
+ }
925
+ }
633
926
  return JSON.stringify(payload, null, 2);
634
927
  }
635
928
  function withErrorHandling(handler) {
@@ -854,11 +1147,18 @@ function durationMs(value) {
854
1147
  return null;
855
1148
  }
856
1149
  }
857
- function toolTarget(target, remote, handles) {
1150
+ function toolTarget(target, options, handles) {
1151
+ const remote = options.remote === true;
858
1152
  return {
859
1153
  tool(name, description, shape, handler) {
860
1154
  if (remote && LOCAL_ONLY_TOOLS.has(name)) return { remove() {
861
1155
  } };
1156
+ const entry = TOOL_CATALOG[name];
1157
+ if (!entry) throw new Error(`${name} has no entry in catalog.ts`);
1158
+ if (options.groups && !options.groups.has(entry.group)) return { remove() {
1159
+ } };
1160
+ if (options.readOnly && entry.readOnly !== true) return { remove() {
1161
+ } };
862
1162
  const wrapped = remote ? async (args) => {
863
1163
  const input = args;
864
1164
  if (TARGET_URL_TOOLS.has(name) && input.targetUrl !== void 0) {
@@ -892,7 +1192,7 @@ function toolTarget(target, remote, handles) {
892
1192
  }
893
1193
  return handler(bounded);
894
1194
  } : handler;
895
- const handle = target.tool(name, description, shape, wrapped);
1195
+ const handle = target.tool(name, description, shape, wrapped, toolAnnotations(name));
896
1196
  handles.push(handle);
897
1197
  return handle;
898
1198
  }
@@ -968,7 +1268,7 @@ function withShareHints(list, remote = false) {
968
1268
  function registerTools(target, client, options = {}) {
969
1269
  const handles = [];
970
1270
  const remote = options.remote === true;
971
- const server = toolTarget(target, remote, handles);
1271
+ const server = toolTarget(target, options, handles);
972
1272
  const shareWith = remote ? REMOTE_SHARE : "share_port";
973
1273
  server.tool(
974
1274
  "create_endpoint",
@@ -1081,6 +1381,124 @@ function registerTools(target, client, options = {}) {
1081
1381
  return jsonContent({ shared: false, slug, teamId });
1082
1382
  })
1083
1383
  );
1384
+ server.tool(
1385
+ "create_team",
1386
+ "Create a team you own, to share endpoints with its members under a pooled quota. It does nothing until it has a subscription, which the person starts in the browser (Account > Teams); until then it is suspended.",
1387
+ { name: import_zod.z.string().trim().min(1).max(100).describe("The team's name") },
1388
+ withErrorHandling(async ({ name }) => jsonContent(await client.teams.create(name)))
1389
+ );
1390
+ server.tool(
1391
+ "rename_team",
1392
+ "Rename a team you own.",
1393
+ {
1394
+ teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)"),
1395
+ name: import_zod.z.string().trim().min(1).max(100).describe("The new name")
1396
+ },
1397
+ withErrorHandling(async ({ teamId, name }) => {
1398
+ await client.teams.rename(teamId, name);
1399
+ return jsonContent({ renamed: true, teamId, name });
1400
+ })
1401
+ );
1402
+ server.tool(
1403
+ "delete_team",
1404
+ "Delete a team you own: its subscription ends at once, every member loses the endpoints shared with it, and it cannot be undone. Only when the person asks for it. The team's owner must approve it: this returns a link and a code to show them, then call wait_for_approval.",
1405
+ { teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)") },
1406
+ withErrorHandling(async ({ teamId }) => {
1407
+ const pending = await client.teams.delete(teamId);
1408
+ if (!pending.id) return textContent(`Deleted the team ${teamId}.`);
1409
+ return textContent(approvalAskText(pending));
1410
+ })
1411
+ );
1412
+ server.tool(
1413
+ "remove_team_member",
1414
+ "Remove a member from a team you own: the endpoints they shared with the team stop being shared, and their seat is free for someone else. Only when the person asks for it.",
1415
+ {
1416
+ teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)"),
1417
+ userId: import_zod.z.string().min(1).describe("The member's userId (from list_team_members)")
1418
+ },
1419
+ withErrorHandling(async ({ teamId, userId }) => {
1420
+ await client.teams.removeMember(teamId, userId);
1421
+ return jsonContent({ removed: true, teamId, userId });
1422
+ })
1423
+ );
1424
+ server.tool(
1425
+ "leave_team",
1426
+ "Leave a team you belong to: the endpoints you shared with it stop being shared, and you lose access to the ones shared with you through it. An owner cannot leave; they delete the team instead (delete_team). Only when the person asks for it.",
1427
+ { teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)") },
1428
+ withErrorHandling(async ({ teamId }) => {
1429
+ await client.teams.leave(teamId);
1430
+ return jsonContent({ left: true, teamId });
1431
+ })
1432
+ );
1433
+ server.tool(
1434
+ "invite_to_team",
1435
+ "Invite an email address to a team you own. It emails that address, so the team's owner must approve it: this returns a link and a code to show them, then call wait_for_approval, which returns the invite. Accepting the invite claims one of the team's paid seats. Only when the person asks for it.",
1436
+ {
1437
+ teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)"),
1438
+ email: import_zod.z.string().trim().email().describe("The address to invite")
1439
+ },
1440
+ withErrorHandling(async ({ teamId, email }) => {
1441
+ const pending = await client.teams.invite(teamId, email);
1442
+ if (!pending.id) return textContent(approvalResultText({ ...await pending.wait() }));
1443
+ return textContent(approvalAskText(pending));
1444
+ })
1445
+ );
1446
+ server.tool(
1447
+ "list_invites",
1448
+ "List the team invites waiting for you to answer: team, who invited you, when, and the invite id for answer_invite.",
1449
+ {},
1450
+ withErrorHandling(async () => jsonContent(await client.teams.invites.list()))
1451
+ );
1452
+ server.tool(
1453
+ "answer_invite",
1454
+ "Accept or decline a team invite waiting for you (from list_invites). Accepting claims one of the team's paid seats and you join the team, seeing the endpoints shared with it; it fails when the team is full or suspended. Only when the person says which.",
1455
+ {
1456
+ inviteId: import_zod.z.string().min(1).describe("The invite's id, from list_invites"),
1457
+ answer: import_zod.z.enum(["accept", "decline"]).describe("accept joins the team; decline turns it down")
1458
+ },
1459
+ withErrorHandling(async ({ inviteId, answer }) => {
1460
+ if (answer === "accept") {
1461
+ await client.teams.invites.accept(inviteId);
1462
+ return jsonContent({ accepted: true, inviteId });
1463
+ }
1464
+ await client.teams.invites.decline(inviteId);
1465
+ return jsonContent({ declined: true, inviteId });
1466
+ })
1467
+ );
1468
+ server.tool(
1469
+ "withdraw_invite",
1470
+ "Withdraw an invite to a team you own before it is answered (pending invites and their ids are in list_team_members). The invite link stops working.",
1471
+ {
1472
+ teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)"),
1473
+ inviteId: import_zod.z.string().min(1).describe("The invite's id (from list_team_members' pendingInvites)")
1474
+ },
1475
+ withErrorHandling(async ({ teamId, inviteId }) => {
1476
+ await client.teams.withdrawInvite(teamId, inviteId);
1477
+ return jsonContent({ withdrawn: true, teamId, inviteId });
1478
+ })
1479
+ );
1480
+ server.tool(
1481
+ "quote_team_change",
1482
+ "What changing a team's seat count or plan would cost, read only (owner only): what is due now, any credit, and the price from the renewal. Give seats, or plan (with interval). The change itself is made by the person in the browser.",
1483
+ {
1484
+ teamId: import_zod.z.string().min(1).describe("Team id (from list_teams)"),
1485
+ seats: import_zod.z.number().int().min(1).optional().describe("Price this seat count"),
1486
+ plan: import_zod.z.enum(["team", "team_business"]).optional().describe("Price a move to this plan: team (Teams) or team_business (Team Business)"),
1487
+ interval: import_zod.z.enum(["month", "year"]).optional().describe("Billing interval for plan (default month; Teams is monthly only)")
1488
+ },
1489
+ withErrorHandling(async ({ teamId, seats, plan, interval }) => {
1490
+ if (seats === void 0 === (plan === void 0)) {
1491
+ throw new Error("Give seats or plan, not both.");
1492
+ }
1493
+ if (seats !== void 0) {
1494
+ if (interval !== void 0) throw new Error("interval goes with plan, not seats.");
1495
+ return jsonContent(await client.billing.quoteTeamSeats(teamId, seats));
1496
+ }
1497
+ return jsonContent(
1498
+ await client.billing.quoteTeamPlan(teamId, plan, interval)
1499
+ );
1500
+ })
1501
+ );
1084
1502
  server.tool(
1085
1503
  "get_endpoint",
1086
1504
  "Get details for a specific webhook endpoint by slug.",
@@ -1174,6 +1592,35 @@ function registerTools(target, client, options = {}) {
1174
1592
  return jsonContent(holder);
1175
1593
  })
1176
1594
  );
1595
+ server.tool(
1596
+ "list_layout_templates",
1597
+ "List the ready-made email layouts (order emails from Shopify, WooCommerce, Etsy and more, payments, bookings, attachments): each with its id, sender, kind, description, the fields it reads and whether it reads line items. Add one with add_layout_template.",
1598
+ { slug: import_zod.z.string().describe("The endpoint slug") },
1599
+ withErrorHandling(async ({ slug }) => jsonContent(await client.endpoints.layoutTemplates(slug)))
1600
+ );
1601
+ server.tool(
1602
+ "add_layout_template",
1603
+ "Add a ready-made layout (an id from list_layout_templates) to the end of an endpoint's layouts. Emails it matches are parsed from the next one on; check it on a captured email with preview_layouts. Owner only.",
1604
+ {
1605
+ slug: import_zod.z.string().describe("The endpoint slug"),
1606
+ template: import_zod.z.string().min(1).describe("The template's id, from list_layout_templates")
1607
+ },
1608
+ withErrorHandling(
1609
+ async ({ slug, template }) => jsonContent(await client.endpoints.addLayoutTemplate(slug, template))
1610
+ )
1611
+ );
1612
+ server.tool(
1613
+ "preview_email_fields",
1614
+ "Dry run of an endpoint's named email fields on a captured email: each field's value (null where it finds nothing), and problems with fields you pass. Nothing is saved. Pass emailFields to try fields before saving them with update_endpoint. Owner only.",
1615
+ {
1616
+ slug: import_zod.z.string().describe("The endpoint slug"),
1617
+ requestId: import_zod.z.string().optional().describe("A captured email on the endpoint (default: the newest)"),
1618
+ emailFields: import_zod.z.array(emailFieldSchema).max(20).optional().describe("Unsaved fields to try instead of the saved ones")
1619
+ },
1620
+ withErrorHandling(
1621
+ async ({ slug, requestId, emailFields }) => jsonContent(await client.endpoints.previewEmailFields(slug, { requestId, emailFields }))
1622
+ )
1623
+ );
1177
1624
  server.tool(
1178
1625
  "preview_response",
1179
1626
  "Dry run of an endpoint's responses: which response rule answers a captured request, and the response with its {{ placeholders }} filled in, exactly as the receiver would send it. Nothing is sent. Pass mockResponse or responseRules to try settings before saving them with update_endpoint.",
@@ -1309,56 +1756,95 @@ function registerTools(target, client, options = {}) {
1309
1756
  );
1310
1757
  server.tool(
1311
1758
  "search_requests",
1312
- "Search captured webhook requests across endpoints using retained full-text search.",
1759
+ "Search captured requests and emails across endpoints: a substring match on path, headers, body and decoded email fields. One call reads back through history for about 2 seconds and returns { requests, complete, searchedUntil, cursor }. When complete is false, older requests were not searched yet: call again with the cursor and the same filters to continue.",
1313
1760
  {
1314
1761
  slug: import_zod.z.string().optional().describe("Filter to a specific endpoint slug"),
1315
1762
  method: import_zod.z.string().optional().describe("Filter by HTTP method"),
1316
1763
  kind: kindSchema,
1317
- q: import_zod.z.string().optional().describe("Free-text search across path, body, and headers"),
1318
- from: durationOrTimestampSchema.optional().describe('Start time as a timestamp or duration like "1h" or "7d"'),
1319
- to: durationOrTimestampSchema.optional().describe('End time as a timestamp or duration like "1h" or "7d"'),
1764
+ q: import_zod.z.string().optional().describe(
1765
+ "Substring to find in the path, headers, body and decoded email fields (up to 1,000 characters)"
1766
+ ),
1767
+ from: durationOrTimestampSchema.optional().describe(
1768
+ 'Start time as a timestamp (Unix ms) or a duration back from now like "1h" or "7d". A duration is counted from each call, so when you continue with a cursor pass a timestamp to keep the same range.'
1769
+ ),
1770
+ to: durationOrTimestampSchema.optional().describe(
1771
+ 'End time as a timestamp (Unix ms) or a duration back from now like "1h" or "7d". A duration is counted from each call, so when you continue with a cursor pass a timestamp to keep the same range.'
1772
+ ),
1320
1773
  limit: import_zod.z.number().int().min(1).max(200).default(50).describe("Max results to return"),
1321
- offset: import_zod.z.number().int().min(0).max(1e4).default(0).describe("Result offset"),
1322
- order: import_zod.z.enum(["asc", "desc"]).default("desc").describe("Sort order by received time")
1774
+ offset: import_zod.z.number().int().min(0).max(1e4).default(0).describe("Matches to skip (first call only; a cursor carries what is left of it)"),
1775
+ order: import_zod.z.enum(["asc", "desc"]).default("desc").describe("Sort order by received time"),
1776
+ cursor: import_zod.z.string().optional().describe(
1777
+ "The cursor from a previous search_requests result, to continue that search. Keep the other inputs the same."
1778
+ )
1323
1779
  },
1324
- withErrorHandling(async ({ slug, method, kind, q, from, to, limit, offset, order }) => {
1325
- const results = await client.requests.search({
1326
- slug,
1327
- method,
1328
- kind,
1329
- q,
1330
- from,
1331
- to,
1332
- limit,
1333
- offset,
1334
- order
1335
- });
1336
- return jsonContent(results.map(compactRequest));
1780
+ withErrorHandling(async ({ slug, method, kind, q, from, to, limit, offset, order, cursor }) => {
1781
+ const page = await client.requests.searchPage(
1782
+ { slug, method, kind, q, from, to, limit, offset, order },
1783
+ { cursor }
1784
+ );
1785
+ const searchedUntil = isoTime(page.searchedUntil);
1786
+ const envelope = (requests2, shortened) => {
1787
+ const notes = [
1788
+ ...page.complete ? [] : [searchStoppedNote(searchedUntil, order, Boolean(page.cursor))],
1789
+ ...shortened ? [SEARCH_SHORTENED_NOTE] : []
1790
+ ];
1791
+ return {
1792
+ requests: requests2,
1793
+ complete: page.complete,
1794
+ searchedUntil,
1795
+ cursor: page.cursor,
1796
+ ...notes.length > 0 ? { note: notes.join(" ") } : {}
1797
+ };
1798
+ };
1799
+ const requests = page.requests.map(compactRequest);
1800
+ if (jsonSize(envelope(requests, false)) <= MAX_BODY_SIZE) {
1801
+ return jsonContent(envelope(requests, false));
1802
+ }
1803
+ const room = MAX_BODY_SIZE - jsonSize(envelope([], true)) - 8;
1804
+ return jsonContent(envelope(fitSearchRequests(requests, room), true));
1337
1805
  })
1338
1806
  );
1339
1807
  server.tool(
1340
1808
  "count_requests",
1341
- "Count captured webhook requests that match the given filters.",
1809
+ "Count captured requests and emails that match the given filters (q is a substring match on path, headers, body and decoded email fields). Returns { count, exact, searchedUntil, cursor }. With q or method a call counts back through history for about 2 seconds: when exact is false, count covers history back to searchedUntil only, and calling again with the cursor counts the next stretch (add the counts up).",
1342
1810
  {
1343
1811
  slug: import_zod.z.string().optional().describe("Filter to a specific endpoint slug"),
1344
1812
  method: import_zod.z.string().optional().describe("Filter by HTTP method"),
1345
1813
  kind: kindSchema,
1346
- q: import_zod.z.string().optional().describe("Free-text search across path, body, and headers"),
1347
- from: durationOrTimestampSchema.optional().describe('Start time as a timestamp or duration like "1h" or "7d"'),
1348
- to: durationOrTimestampSchema.optional().describe('End time as a timestamp or duration like "1h" or "7d"')
1814
+ q: import_zod.z.string().optional().describe(
1815
+ "Substring to find in the path, headers, body and decoded email fields (up to 1,000 characters)"
1816
+ ),
1817
+ from: durationOrTimestampSchema.optional().describe(
1818
+ 'Start time as a timestamp (Unix ms) or a duration back from now like "1h" or "7d". A duration is counted from each call, so when you continue with a cursor pass a timestamp to keep the same range.'
1819
+ ),
1820
+ to: durationOrTimestampSchema.optional().describe(
1821
+ 'End time as a timestamp (Unix ms) or a duration back from now like "1h" or "7d". A duration is counted from each call, so when you continue with a cursor pass a timestamp to keep the same range.'
1822
+ ),
1823
+ cursor: import_zod.z.string().optional().describe(
1824
+ "The cursor from a previous count_requests result, to count the next stretch. Keep the other inputs the same."
1825
+ )
1349
1826
  },
1350
- withErrorHandling(async ({ slug, method, kind, q, from, to }) => {
1351
- const count = await client.requests.count({ slug, method, kind, q, from, to });
1352
- return jsonContent({ count });
1827
+ withErrorHandling(async ({ slug, method, kind, q, from, to, cursor }) => {
1828
+ const page = await client.requests.countPage({ slug, method, kind, q, from, to }, { cursor });
1829
+ const searchedUntil = isoTime(page.searchedUntil);
1830
+ return jsonContent({
1831
+ count: page.count,
1832
+ exact: page.exact,
1833
+ searchedUntil,
1834
+ cursor: page.cursor,
1835
+ ...page.exact ? {} : {
1836
+ note: `At least ${page.count}, counted ${searchedUntil ? `back to ${searchedUntil}` : "over part of the history"}; ${page.cursor ? "call count_requests again with cursor to count further (the counts add up)." : "there is no cursor to count further with."}`
1837
+ }
1838
+ });
1353
1839
  })
1354
1840
  );
1355
1841
  server.tool(
1356
1842
  "get_request",
1357
- "Get full details for a specific captured request by ID.",
1843
+ "Get the details of a captured request by ID: method, path, headers and body. A request larger than the tool output has its body cut (bodyTruncated, bodySize) and a note saying where the whole request is available.",
1358
1844
  getRequestShape,
1359
1845
  withErrorHandling(async ({ requestId }) => {
1360
1846
  const request = await client.requests.get(requestId);
1361
- return jsonContent(compactRequest(request));
1847
+ return requestContent(request);
1362
1848
  })
1363
1849
  );
1364
1850
  server.tool(
@@ -1367,7 +1853,7 @@ function registerTools(target, client, options = {}) {
1367
1853
  waitForRequestShape,
1368
1854
  withErrorHandling(async ({ endpointSlug, timeout, pollInterval }) => {
1369
1855
  const request = await client.requests.waitFor(endpointSlug, { timeout, pollInterval });
1370
- return jsonContent(compactRequest(request));
1856
+ return requestContent(request);
1371
1857
  })
1372
1858
  );
1373
1859
  server.tool(
@@ -2121,7 +2607,7 @@ function registerTools(target, client, options = {}) {
2121
2607
  );
2122
2608
  server.tool(
2123
2609
  "wait_for_approval",
2124
- "Wait for the account's owner to answer an approval (from create_api_key, create_share_link, remove_domain, rename_account, connect_google, pick_spreadsheet or ai_setup) and collect what it grants or did, such as the new API key, the share link or AI setup's proposals. If they have not answered yet, call it again.",
2610
+ "Wait for the account's owner to answer an approval (from create_api_key, create_share_link, remove_domain, rename_account, delete_team, invite_to_team, connect_google, pick_spreadsheet or ai_setup) and collect what it grants or did, such as the new API key, the share link or AI setup's proposals. If they have not answered yet, call it again.",
2125
2611
  {
2126
2612
  id: import_zod.z.string().describe("The approval id"),
2127
2613
  timeout: durationOrTimestampSchema.default("45s").describe('How long to wait for the person, for example "45s"')
@@ -2487,18 +2973,25 @@ function registerTools(target, client, options = {}) {
2487
2973
  LOCAL_ONLY_TOOLS,
2488
2974
  REMOTE_MAX_WAIT_MS,
2489
2975
  REMOTE_MIN_POLL_MS,
2976
+ TOOL_CATALOG,
2977
+ TOOL_GROUPS,
2978
+ TOOL_GROUP_NAMES,
2979
+ clientLoadsEverything,
2490
2980
  createEndpointShape,
2981
+ defaultToolGroups,
2491
2982
  deleteEndpointShape,
2492
2983
  getEndpointShape,
2493
2984
  getRequestShape,
2494
2985
  jsonContent,
2495
2986
  listEndpointsShape,
2496
2987
  listRequestsShape,
2988
+ parseToolGroups,
2497
2989
  payloadSchemaResult,
2498
2990
  payloadSchemaShape,
2499
2991
  registerTools,
2500
2992
  shareHints,
2501
2993
  textContent,
2994
+ toolAnnotations,
2502
2995
  toolWords,
2503
2996
  waitForRequestShape,
2504
2997
  withErrorHandling,