@datadive-tools/mcp 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -26,6 +26,13 @@ import { z } from "zod";
26
26
 
27
27
  // src/http/errors.ts
28
28
  var KEY_HELP_URL2 = "https://2.datadive.tools/api-key";
29
+ var FEATURE_LABELS = {
30
+ DIVED_ASINS: "Dive tokens",
31
+ RANK_RADAR_KEYWORDS: "Rank Radar tracked keywords",
32
+ PRODUCT_BRIEF_ASINS: "Product Brief ASINs",
33
+ AI_COPYWRITER_PROMPTS: "AI Copywriter prompts",
34
+ INDEXING_DIAGNOSIS: "Indexing Diagnosis checks"
35
+ };
29
36
  var ApiError = class _ApiError extends Error {
30
37
  kind;
31
38
  status;
@@ -38,6 +45,9 @@ var ApiError = class _ApiError extends Error {
38
45
  this.body = body;
39
46
  }
40
47
  static fromHttp(status, body) {
48
+ if (isQuotaExceededBody(body)) {
49
+ return new _ApiError("quota", status, quotaExceededMessage(body), body);
50
+ }
41
51
  const serverMsg = extractMessage(body);
42
52
  if (status === 400) {
43
53
  return new _ApiError(
@@ -88,6 +98,35 @@ var ApiError = class _ApiError extends Error {
88
98
  return new _ApiError("http", status, serverMsg ?? `HTTP ${status}`, body);
89
99
  }
90
100
  };
101
+ function isQuotaExceededBody(body) {
102
+ if (!body || typeof body !== "object") return false;
103
+ const b = body;
104
+ return b.error === "QUOTA_EXCEEDED" && typeof b.subscriptionUrl === "string";
105
+ }
106
+ function quotaExceededMessage(body) {
107
+ const lead = typeof body.message === "string" && body.message.length > 0 ? body.message : "Quota exceeded";
108
+ const feature = body.feature ? FEATURE_LABELS[body.feature] ?? body.feature : null;
109
+ const parts = [];
110
+ if (feature) {
111
+ parts.push(`This subscription has used up its ${feature} quota${usageSuffix(body)}.`);
112
+ } else {
113
+ parts.push(`This subscription has used up its quota for this action${usageSuffix(body)}.`);
114
+ }
115
+ if (body.nextRefreshDate) {
116
+ parts.push(`It refreshes on ${body.nextRefreshDate.slice(0, 10)}.`);
117
+ }
118
+ parts.push(
119
+ `Tell the user which quota ran out and that they can review or raise it on their subscription page: ${body.subscriptionUrl}`
120
+ );
121
+ parts.push("Do not retry this call until the quota has been raised.");
122
+ return `${lead}. ${parts.join(" ")}`;
123
+ }
124
+ function usageSuffix(body) {
125
+ if (typeof body.used === "number" && typeof body.capacity === "number") {
126
+ return ` (${body.used} of ${body.capacity} used)`;
127
+ }
128
+ return "";
129
+ }
91
130
  function extractMessage(body) {
92
131
  if (!body || typeof body !== "object") return null;
93
132
  const b = body;
@@ -100,7 +139,7 @@ function extractMessage(body) {
100
139
  }
101
140
 
102
141
  // package.json
103
- var version = "0.10.0";
142
+ var version = "0.12.0";
104
143
 
105
144
  // src/http/client.ts
106
145
  var PKG_VERSION = version;
@@ -168,6 +207,23 @@ async function httpPost(ctx, path, body) {
168
207
  }
169
208
  return handleResponse(res);
170
209
  }
210
+ async function httpDelete(ctx, path) {
211
+ const url = buildUrl(ctx.config.baseUrl, path);
212
+ let res;
213
+ try {
214
+ res = await fetch(url, {
215
+ method: "DELETE",
216
+ headers: {
217
+ ...authHeaders(ctx.config),
218
+ accept: "application/json",
219
+ "user-agent": userAgent(ctx.toolName)
220
+ }
221
+ });
222
+ } catch (e) {
223
+ throw networkError(url, e);
224
+ }
225
+ return handleResponse(res);
226
+ }
171
227
  function networkError(url, e) {
172
228
  const msg = e instanceof Error ? e.message : String(e);
173
229
  return new ApiError("network", 0, `Network error reaching ${url}: ${msg}`);
@@ -298,7 +354,7 @@ var inputSchema4 = {
298
354
  var getNicheCompetitorsTool = {
299
355
  name: "get_niche_competitors",
300
356
  title: "Get Competitors and Niche Statistics",
301
- description: "Use this for competitor ASINs, sales/revenue benchmarks, or niche opportunity scoring. Retrieves the list of Competitors within the specified Niche along with Niche statistics. For the Niche: keyword statistics, opportunity evaluation, benchmark median values, and overall competitor strength assessment. For each Competitor: ASIN, sales, revenue, ratings, reviews, price, image URL, and ranking data.",
357
+ description: "Use this for competitor ASINs, product titles, BSR, sales/revenue benchmarks, or niche opportunity scoring. Retrieves the list of Competitors within the specified Niche along with Niche statistics. For the Niche: keyword statistics, opportunity evaluation, benchmark median values, and overall competitor strength assessment. For each Competitor: ASIN, product title, BSR, category and full category tree, sales, revenue, ratings, reviews, price, number of variations, image URL, total Ranking Juice, and ranking data. BSR supports ranking Competitors by sales position within mentioned category. For the Ranking Juice breakdown by title, bullets and description, use `get_ranking_juice`.",
302
358
  inputSchema: inputSchema4,
303
359
  annotations: { readOnlyHint: true },
304
360
  handler: async (args, ctx) => {
@@ -345,7 +401,8 @@ var SUPPORTED_MARKETPLACES = [
345
401
  "it",
346
402
  "co.jp"
347
403
  ];
348
- var RANK_RADAR_STATUSES = ["ACTIVE", "PAUSED", "ARCHIVED"];
404
+ var RANK_RADAR_STATES = ["ACTIVE", "PAUSED", "ARCHIVED"];
405
+ var RANK_RADAR_STATUSES = [...RANK_RADAR_STATES, "ALL"];
349
406
  var ALERT_STATUSES = ["active", "resolved", "all"];
350
407
  var BILLABLE_FEATURE_TYPES = [
351
408
  "DIVED_ASINS",
@@ -357,25 +414,32 @@ var CATALOG_STATUSES = ["Active", "all"];
357
414
  var LISTING_CHANGE_TYPES = ["Price", "Content", "Image"];
358
415
  var LISTING_CHANGE_SORT_BY = ["date", "type"];
359
416
  var SORT_ORDER = ["ASC", "DESC"];
417
+ var ADD_SEARCH_TERMS_MAX = 1e3;
418
+ var LISTING_COPY_STRATEGIES = ["cosmo", "ranking-juice", "nlp", "cosmo-rufus"];
360
419
 
361
420
  // src/tools/list-rank-radars.ts
421
+ var LIST_RANK_RADARS_MAX_PAGE_SIZE = 50;
362
422
  var inputSchema6 = {
363
423
  currentPage: z6.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
364
- pageSize: z6.number().int().min(1).max(100).optional().describe("Items per page (max 100). Defaults to 20."),
424
+ pageSize: z6.number().int().min(1).max(LIST_RANK_RADARS_MAX_PAGE_SIZE).optional().describe(`Items per page (max ${LIST_RANK_RADARS_MAX_PAGE_SIZE}). Defaults to 20.`),
365
425
  nicheId: z6.string().min(1).optional().describe("Filter Rank Radars by Niche identifier. Use after `list_niches`."),
366
426
  status: z6.enum(RANK_RADAR_STATUSES).optional().describe(
367
- "Filter by Rank Radar status. By default, returns only ACTIVE Rank Radars. Allowed: ACTIVE, PAUSED, ARCHIVED."
427
+ "Which Rank Radars to return. ACTIVE (the default) are tracking; PAUSED have been stopped but keep their history and can be resumed; ARCHIVED have been deleted; ALL means active and paused together. Archived Rank Radars are returned only by an explicit ARCHIVED."
368
428
  ),
369
429
  searchText: z6.string().optional().describe("Filter Rank Radars by ASIN or product title.")
370
430
  };
431
+ function minimize(item) {
432
+ const { asin, ...rest } = item;
433
+ return { ...rest, asin: asin?.asin };
434
+ }
371
435
  var listRankRadarsTool = {
372
436
  name: "list_rank_radars",
373
437
  title: "List Rank Radars",
374
- description: "Use this to find a `rankRadarId` before calling `get_rank_radar_data`. Filter by `nicheId` if the user has already identified a niche. Retrieves a paginated list of Rank Radars \u2014 keyword-rank trackers monitoring organic and sponsored positions for specific ASINs over time. Each item includes id, asin (with id, krtId, asin), marketplace, keywordCount, title, imageUrl, and summary metrics: top10KW, top10SV, top50KW, top50SV. Supports pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev).",
438
+ description: `Use this to find a \`rankRadarId\` before calling \`get_rank_radar_data\`. Filter by \`nicheId\` if the user has already identified a niche. Retrieves a paginated list of Rank Radars \u2014 keyword-rank trackers monitoring organic and sponsored positions for specific ASINs over time. Each item includes id, status (ACTIVE, PAUSED or ARCHIVED), asin, marketplace, keywordCount, title, imageUrl, and summary metrics: top10KW, top10SV, top50KW, top50SV. Supports pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev); a page holds at most ${LIST_RANK_RADARS_MAX_PAGE_SIZE} Rank Radars, so a large account needs several calls.`,
375
439
  inputSchema: inputSchema6,
376
440
  annotations: { readOnlyHint: true },
377
441
  handler: async (args, ctx) => {
378
- return await httpGet(
442
+ const page = await httpGet(
379
443
  { config: ctx.config, toolName: "list_rank_radars" },
380
444
  "/v1/niches/rank-radars",
381
445
  {
@@ -386,6 +450,7 @@ var listRankRadarsTool = {
386
450
  searchText: args.searchText
387
451
  }
388
452
  );
453
+ return { ...page, data: (page.data ?? []).map(minimize) };
389
454
  }
390
455
  };
391
456
 
@@ -442,7 +507,7 @@ var createRankRadarTool = {
442
507
  // destructiveHint is technically "additive" here (this creates a new Rank Radar, it
443
508
  // doesn't destroy data), but we flag it destructive so clients prompt before the
444
509
  // irreversible token spend. The confirm gate enforces this server-side regardless.
445
- annotations: { readOnlyHint: false, destructiveHint: true },
510
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
446
511
  handler: async (args, ctx) => {
447
512
  const pending = requireConfirmation(
448
513
  args.confirm,
@@ -480,7 +545,7 @@ var createNicheDiveTool = {
480
545
  // destructiveHint is technically "additive" here (a dive creates a new niche, it
481
546
  // doesn't destroy data), but we flag it destructive so clients prompt before the
482
547
  // irreversible token spend. The confirm gate enforces this server-side regardless.
483
- annotations: { readOnlyHint: false, destructiveHint: true },
548
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
484
549
  handler: async (args, ctx) => {
485
550
  const pending = requireConfirmation(
486
551
  args.confirm,
@@ -528,7 +593,7 @@ var rediveNicheTool = {
528
593
  inputSchema: inputSchema10,
529
594
  // Same reasoning as create_niche_dive: a re-dive is additive rather than destructive, but the
530
595
  // irreversible token spend is what clients need to prompt on. The confirm gate enforces it regardless.
531
- annotations: { readOnlyHint: false, destructiveHint: true },
596
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
532
597
  handler: async (args, ctx) => {
533
598
  if (args.mode === "discover" && args.numberOfCompetitors === void 0) {
534
599
  throw new ApiError(
@@ -576,17 +641,251 @@ var getDiveStatusTool = {
576
641
  }
577
642
  };
578
643
 
579
- // src/tools/list-seller-profiles.ts
644
+ // src/tools/delete-niche.ts
580
645
  import { z as z12 } from "zod";
581
646
  var inputSchema12 = {
582
- currentPage: z12.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
583
- pageSize: z12.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
647
+ nicheId: z12.string().min(1).describe("The niche to delete. Get one from `list_niches`."),
648
+ confirm: z12.boolean().optional().describe(
649
+ "Must be true to proceed \u2014 deleting a niche destroys its keywords, competitors and dive history permanently. Confirm with the user first."
650
+ )
651
+ };
652
+ var deleteNicheTool = {
653
+ name: "delete_niche",
654
+ title: "Delete a Niche",
655
+ description: "Use this to permanently remove a niche the user no longer needs. \u26A0\uFE0F Deletes the niche and everything attached to it \u2014 keywords, competitors, all dives and diveboxes \u2014 and cannot be undone; the dive tokens already spent on it are NOT refunded. Set `confirm: true` only after the user approves. A niche used by any Rank Radar cannot be deleted: the call fails with a conflict, so delete or archive those rank radars first (`list_rank_radars` with the `nicheId` filter shows them).",
656
+ inputSchema: inputSchema12,
657
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
658
+ handler: async (args, ctx) => {
659
+ const pending = requireConfirmation(
660
+ args.confirm,
661
+ ctx,
662
+ "Deleting this niche removes its keywords, competitors and all dive history permanently. The dive tokens already spent on it are not refunded."
663
+ );
664
+ if (pending) return pending;
665
+ await httpDelete(
666
+ { config: ctx.config, toolName: "delete_niche" },
667
+ `/v1/niches/${encodeURIComponent(args.nicheId)}`
668
+ );
669
+ return { status: "deleted", nicheId: args.nicheId };
670
+ }
671
+ };
672
+
673
+ // src/tools/pause-rank-radar.ts
674
+ import { z as z13 } from "zod";
675
+ var inputSchema13 = {
676
+ rankRadarId: z13.string().uuid().describe("The Rank Radar UUID to pause (from `list_rank_radars`).")
677
+ };
678
+ var pauseRankRadarTool = {
679
+ name: "pause_rank_radar",
680
+ title: "Pause a Rank Radar",
681
+ description: "Use this to pause tracking on a Rank Radar without losing anything \u2014 the action the DataDive API calls 'archiving', so when a user asks to archive a Rank Radar, this is the tool they mean. Tracking stops for all of its keywords and the Daily Tracked Keywords quota they held is freed for other Rank Radars, while the Rank Radar and its ranking history are kept. Fully reversible with `resume_rank_radar`, so it needs no `confirm` \u2014 prefer it over `delete_rank_radar` whenever the user may want the data back. Paused Rank Radars show up in `list_rank_radars` under `status: PAUSED` \u2014 not `ARCHIVED`, which covers Rank Radars removed with `delete_rank_radar`. Safe to repeat: pausing an already paused Rank Radar succeeds and changes nothing.",
682
+ inputSchema: inputSchema13,
683
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
684
+ handler: async (args, ctx) => {
685
+ await httpPost(
686
+ { config: ctx.config, toolName: "pause_rank_radar" },
687
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/archive`,
688
+ {}
689
+ );
690
+ return { status: "paused", rankRadarId: args.rankRadarId };
691
+ }
692
+ };
693
+
694
+ // src/tools/resume-rank-radar.ts
695
+ import { z as z14 } from "zod";
696
+ var inputSchema14 = {
697
+ rankRadarId: z14.string().uuid().describe("The Rank Radar UUID to resume (from `list_rank_radars`).")
698
+ };
699
+ var resumeRankRadarTool = {
700
+ name: "resume_rank_radar",
701
+ title: "Resume a Paused Rank Radar",
702
+ description: "Use this to restart tracking on a Rank Radar that was paused with `pause_rank_radar` (shown by `list_rank_radars` under `status: PAUSED`; a deleted, `ARCHIVED` one cannot be resumed). Keywords are resumed as far as the available Daily Tracked Keywords quota allows, most relevant first \u2014 so with a tight quota only part of the original keyword set comes back; check `get_quota` first if that matters. Reversible with `pause_rank_radar`, so it needs no `confirm`. Fails with a bad-request error when there is no quota left at all. Safe to repeat: resuming an already active Rank Radar changes nothing.",
703
+ inputSchema: inputSchema14,
704
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
705
+ handler: async (args, ctx) => {
706
+ await httpPost(
707
+ { config: ctx.config, toolName: "resume_rank_radar" },
708
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/resume`,
709
+ {}
710
+ );
711
+ return { status: "resumed", rankRadarId: args.rankRadarId };
712
+ }
713
+ };
714
+
715
+ // src/tools/delete-rank-radar.ts
716
+ import { z as z15 } from "zod";
717
+ var inputSchema15 = {
718
+ rankRadarId: z15.string().uuid().describe("The Rank Radar UUID to delete (from `list_rank_radars`)."),
719
+ confirm: z15.boolean().optional().describe(
720
+ "Must be true to proceed \u2014 deleting a Rank Radar destroys its ranking history permanently. Confirm with the user first."
721
+ )
722
+ };
723
+ var deleteRankRadarTool = {
724
+ name: "delete_rank_radar",
725
+ title: "Delete a Rank Radar",
726
+ description: "Use this to permanently remove a Rank Radar and all of its keyword ranking history. \u26A0\uFE0F Cannot be undone \u2014 there is no restore endpoint; set `confirm: true` only after the user approves. It does free the Daily Tracked Keywords quota those keywords held. Deleted Rank Radars are what `list_rank_radars` returns for `status: ARCHIVED`. If the user only wants to stop tracking for a while and keep the history \u2014 or asks to 'archive' the Rank Radar, which is what the DataDive API calls pausing \u2014 use `pause_rank_radar` instead: it frees the same quota and is reversible with `resume_rank_radar`.",
727
+ inputSchema: inputSchema15,
728
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
729
+ handler: async (args, ctx) => {
730
+ const pending = requireConfirmation(
731
+ args.confirm,
732
+ ctx,
733
+ "Deleting this Rank Radar removes its keyword ranking history permanently. It frees the Daily Tracked Keywords quota, but the history cannot be recovered \u2014 `pause_rank_radar` frees the same quota and is reversible."
734
+ );
735
+ if (pending) return pending;
736
+ await httpDelete(
737
+ { config: ctx.config, toolName: "delete_rank_radar" },
738
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}`
739
+ );
740
+ return { status: "deleted", rankRadarId: args.rankRadarId };
741
+ }
742
+ };
743
+
744
+ // src/tools/add-rank-radar-search-terms.ts
745
+ import { z as z16 } from "zod";
746
+ var inputSchema16 = {
747
+ rankRadarId: z16.string().uuid().describe("The Rank Radar UUID to add the search terms to (from `list_rank_radars`)."),
748
+ searchTerms: z16.array(z16.string().min(1)).min(1).max(ADD_SEARCH_TERMS_MAX).describe(
749
+ `The keywords to start tracking, 1\u2013${ADD_SEARCH_TERMS_MAX} per call. Must be unique. Amazon-ignored special characters (@, #, _, parentheses, \u2026) are rejected.`
750
+ )
751
+ };
752
+ var addRankRadarSearchTermsTool = {
753
+ name: "add_rank_radar_search_terms",
754
+ title: "Add Search Terms to a Rank Radar",
755
+ description: "Use this to start tracking extra keywords on an existing Rank Radar, instead of creating a new one with `create_rank_radar`. New keywords are added to the niche and tracked from now on; any matching keyword that was previously paused is resumed. Each newly tracked keyword takes one Daily Tracked Keywords slot, and the call fails if the quota is exhausted \u2014 check `get_quota` first. Reversible with `pause_rank_radar_search_terms`, which frees the slots again, so it needs no `confirm`. Returns `originBreakdown` (where each submitted term ended up) and `keywordToRankRadarKeywordIdMap`, whose ids are what the pause/resume search-term tools take.",
756
+ inputSchema: inputSchema16,
757
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
758
+ handler: async (args, ctx) => {
759
+ return await httpPost(
760
+ { config: ctx.config, toolName: "add_rank_radar_search_terms" },
761
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/search-terms`,
762
+ { searchTerms: args.searchTerms }
763
+ );
764
+ }
765
+ };
766
+
767
+ // src/tools/pause-rank-radar-search-terms.ts
768
+ import { z as z17 } from "zod";
769
+ var inputSchema17 = {
770
+ rankRadarId: z17.string().uuid().describe("The Rank Radar UUID the search terms belong to."),
771
+ rankRadarKeywordIds: z17.array(z17.string().uuid()).min(1).describe(
772
+ "The Rank Radar keyword ids to pause. These are the `id` values from `get_rank_radar_data`, or the values of `keywordToRankRadarKeywordIdMap` returned by `add_rank_radar_search_terms` \u2014 not the keyword text."
773
+ )
774
+ };
775
+ var pauseRankRadarSearchTermsTool = {
776
+ name: "pause_rank_radar_search_terms",
777
+ title: "Pause Search Terms of a Rank Radar",
778
+ description: "Use this to stop tracking individual keywords on a Rank Radar while keeping the Rank Radar itself active \u2014 the way to trim a keyword set the user finds too broad. The DataDive API calls this 'archiving' the search terms; nothing is lost. The paused keywords keep their history and their Daily Tracked Keywords slots are freed for other keywords. Reversible with `resume_rank_radar_search_terms`, so it needs no `confirm`. Takes keyword ids, not keyword text: get them from `get_rank_radar_data`. Safe to repeat: already-paused terms are left unchanged.",
779
+ inputSchema: inputSchema17,
780
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
781
+ handler: async (args, ctx) => {
782
+ await httpPost(
783
+ { config: ctx.config, toolName: "pause_rank_radar_search_terms" },
784
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/search-terms/archive`,
785
+ { rankRadarKeywordIds: args.rankRadarKeywordIds }
786
+ );
787
+ return {
788
+ status: "paused",
789
+ rankRadarId: args.rankRadarId,
790
+ rankRadarKeywordIds: args.rankRadarKeywordIds
791
+ };
792
+ }
793
+ };
794
+
795
+ // src/tools/resume-rank-radar-search-terms.ts
796
+ import { z as z18 } from "zod";
797
+ var inputSchema18 = {
798
+ rankRadarId: z18.string().uuid().describe("The Rank Radar UUID the search terms belong to."),
799
+ rankRadarKeywordIds: z18.array(z18.string().uuid()).min(1).describe(
800
+ "The Rank Radar keyword ids to resume. These are the `id` values from `get_rank_radar_data`, or the values of `keywordToRankRadarKeywordIdMap` returned by `add_rank_radar_search_terms` \u2014 not the keyword text."
801
+ )
802
+ };
803
+ var resumeRankRadarSearchTermsTool = {
804
+ name: "resume_rank_radar_search_terms",
805
+ title: "Resume Paused Search Terms of a Rank Radar",
806
+ description: "Use this to start tracking keywords again that were paused with `pause_rank_radar_search_terms`. Each resumed keyword takes back one Daily Tracked Keywords slot, and the call fails if the quota is exhausted \u2014 check `get_quota` first. Reversible with `pause_rank_radar_search_terms`, so it needs no `confirm`. Takes keyword ids, not keyword text: get them from `get_rank_radar_data`. Safe to repeat: already-active terms are left unchanged.",
807
+ inputSchema: inputSchema18,
808
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
809
+ handler: async (args, ctx) => {
810
+ await httpPost(
811
+ { config: ctx.config, toolName: "resume_rank_radar_search_terms" },
812
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/search-terms/resume`,
813
+ { rankRadarKeywordIds: args.rankRadarKeywordIds }
814
+ );
815
+ return {
816
+ status: "resumed",
817
+ rankRadarId: args.rankRadarId,
818
+ rankRadarKeywordIds: args.rankRadarKeywordIds
819
+ };
820
+ }
821
+ };
822
+
823
+ // src/tools/generate-listing-copy.ts
824
+ import { z as z19 } from "zod";
825
+ var inputSchema19 = {
826
+ nicheId: z19.string().min(1).describe("The niche whose keyword data the copy is written from. Get one from `list_niches`."),
827
+ strategy: z19.enum(LISTING_COPY_STRATEGIES).describe(
828
+ "Which generation strategy to use. `cosmo` targets Amazon's COSMO relevance model, `ranking-juice` optimises for DataDive's ranking-juice score, `nlp` writes for keyword coverage, and `cosmo-rufus` targets COSMO plus the Rufus shopping assistant. Ask the user if they have no preference."
829
+ ),
830
+ currentListing: z19.record(z19.union([z19.string(), z19.array(z19.string())])).describe(
831
+ 'The seller\'s existing listing to rewrite, as an object \u2014 e.g. `{ "title": "...", "description": "...", "bullets": ["...", "..."] }`. Pass what the user has; it is the starting point the generated copy builds on.'
832
+ ),
833
+ confirm: z19.boolean().optional().describe(
834
+ "Must be true to proceed \u2014 each generation spends one AI Copywriter prompt from the quota. Confirm the cost with the user first."
835
+ )
836
+ };
837
+ var generateListingCopyTool = {
838
+ name: "generate_listing_copy",
839
+ title: "Generate Listing Copy for a Niche",
840
+ description: "Use this to draft an optimised Amazon listing \u2014 title, bullets and description \u2014 from a niche's keyword research and the seller's current listing. It writes text only: nothing is published to Amazon, and the user still has to paste the result into Seller Central. \u26A0\uFE0F Spends one AI Copywriter prompt from the quota per call and cannot be undone \u2014 set `confirm: true` only after the user approves. Not safe to retry: each call spends another prompt, so if a call errors or times out, poll `get_listing_copy_generation_status` instead of re-calling. Runs asynchronously: returns a `generationId` \u2014 poll `get_listing_copy_generation_status` with it until the status is `complete`.",
841
+ inputSchema: inputSchema19,
842
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
843
+ handler: async (args, ctx) => {
844
+ const pending = requireConfirmation(
845
+ args.confirm,
846
+ ctx,
847
+ "Generating listing copy consumes one AI Copywriter prompt from the organization's quota. Check the remaining balance with `get_quota` if the user needs it."
848
+ );
849
+ if (pending) return pending;
850
+ return await httpPost(
851
+ { config: ctx.config, toolName: "generate_listing_copy" },
852
+ `/v1/niches/${encodeURIComponent(args.nicheId)}/ai-copywriter`,
853
+ { prompt: args.strategy, listingToInclude: args.currentListing }
854
+ );
855
+ }
856
+ };
857
+
858
+ // src/tools/get-listing-copy-generation-status.ts
859
+ import { z as z20 } from "zod";
860
+ var inputSchema20 = {
861
+ nicheId: z20.string().min(1).describe("The niche the generation was started for."),
862
+ generationId: z20.string().min(1).describe("The `generationId` returned by `generate_listing_copy`.")
863
+ };
864
+ var getListingCopyGenerationStatusTool = {
865
+ name: "get_listing_copy_generation_status",
866
+ title: "Get Listing Copy Generation Status",
867
+ description: "Use this to poll a listing-copy draft started with `generate_listing_copy` until it finishes. Returns one of three shapes keyed by `status`: `generating` (still running \u2014 poll again in a few seconds), `complete` (with `result`, carrying the generated `title`, `bullets`, `description`, `itemHighlights` and its `rankingJuice` score), or `failed` (with an `error` message). Polling is free \u2014 it does not spend another AI Copywriter prompt, so always poll rather than re-calling `generate_listing_copy`.",
868
+ inputSchema: inputSchema20,
869
+ annotations: { readOnlyHint: true },
870
+ handler: async (args, ctx) => {
871
+ return await httpGet(
872
+ { config: ctx.config, toolName: "get_listing_copy_generation_status" },
873
+ `/v1/niches/${encodeURIComponent(args.nicheId)}/ai-copywriter/${encodeURIComponent(args.generationId)}`
874
+ );
875
+ }
876
+ };
877
+
878
+ // src/tools/list-seller-profiles.ts
879
+ import { z as z21 } from "zod";
880
+ var inputSchema21 = {
881
+ currentPage: z21.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
882
+ pageSize: z21.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
584
883
  };
585
884
  var listSellerProfilesTool = {
586
885
  name: "list_seller_profiles",
587
886
  title: "List Connected Amazon Seller Profiles",
588
887
  description: 'Use this when the user asks which Amazon seller accounts are connected, or as the discovery step to find the `sellerId` and `marketplace` required by `get_asin_inventory_distribution`, `get_seller_catalog`, `get_seller_listing_changes`, and the alert tools. Returns a paginated list of the organization\'s connected seller profiles \u2014 each item has sellerId, sellerName, marketplace (e.g. "com", "co.uk"), hasAdApi (whether Advertising API credentials are connected), and createdAt \u2014 plus pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev).',
589
- inputSchema: inputSchema12,
888
+ inputSchema: inputSchema21,
590
889
  annotations: { readOnlyHint: true },
591
890
  handler: async (args, ctx) => {
592
891
  return await httpGet(
@@ -601,15 +900,15 @@ var listSellerProfilesTool = {
601
900
  };
602
901
 
603
902
  // src/tools/get-seller-catalog.ts
604
- import { z as z14 } from "zod";
903
+ import { z as z23 } from "zod";
605
904
 
606
905
  // src/tools/seller-scoped.ts
607
- import { z as z13 } from "zod";
906
+ import { z as z22 } from "zod";
608
907
  var sellerScopedInputSchema = {
609
- sellerId: z13.string().min(1).describe(
908
+ sellerId: z22.string().min(1).describe(
610
909
  "Amazon seller account ID. Get it from `list_seller_profiles`, or find it on the Connections page at https://2.datadive.tools."
611
910
  ),
612
- marketplace: z13.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.')
911
+ marketplace: z22.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.')
613
912
  };
614
913
  function sellerMarketplacePath(sellerId, marketplace, suffix) {
615
914
  return `/v1/seller_profiles/${encodeURIComponent(sellerId)}/marketplaces/${encodeURIComponent(
@@ -618,19 +917,19 @@ function sellerMarketplacePath(sellerId, marketplace, suffix) {
618
917
  }
619
918
 
620
919
  // src/tools/get-seller-catalog.ts
621
- var inputSchema13 = {
920
+ var inputSchema22 = {
622
921
  ...sellerScopedInputSchema,
623
- search: z14.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
624
- brand: z14.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
625
- status: z14.enum(CATALOG_STATUSES).optional().describe('Listing status filter. "Active" (default) or "all".'),
626
- currentPage: z14.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
627
- pageSize: z14.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
922
+ search: z23.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
923
+ brand: z23.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
924
+ status: z23.enum(CATALOG_STATUSES).optional().describe('Listing status filter. "Active" (default) or "all".'),
925
+ currentPage: z23.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
926
+ pageSize: z23.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
628
927
  };
629
928
  var getSellerCatalogTool = {
630
929
  name: "get_seller_catalog",
631
930
  title: "List Catalog ASINs for a Seller",
632
931
  description: "Use this when the user wants to browse or search a seller's own Amazon catalog \u2014 the products they sell on a given marketplace. Requires a `sellerId` + `marketplace` (use `list_seller_profiles` to discover them). Filter by `search` (title/brand), `brand`, and `status` (Active by default, or all). Returns a paginated list where each item has asin, title, parentAsin, brand, status, imageUrl, and hasVariations, plus pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev).",
633
- inputSchema: inputSchema13,
932
+ inputSchema: inputSchema22,
634
933
  annotations: { readOnlyHint: true },
635
934
  handler: async (args, ctx) => {
636
935
  return await httpGet(
@@ -648,28 +947,28 @@ var getSellerCatalogTool = {
648
947
  };
649
948
 
650
949
  // src/tools/get-seller-listing-changes.ts
651
- import { z as z15 } from "zod";
652
- var inputSchema14 = {
950
+ import { z as z24 } from "zod";
951
+ var inputSchema23 = {
653
952
  ...sellerScopedInputSchema,
654
- types: z15.array(z15.enum(LISTING_CHANGE_TYPES)).min(1).optional().describe('Filter to specific change types. Omit for all. Any of "Price", "Content", "Image".'),
655
- asin: z15.string().min(1).optional().describe("Filter to an exact ASIN or parent ASIN."),
656
- brand: z15.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
657
- search: z15.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
658
- startDate: z15.string().regex(ISO_8601, "startDate must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)").optional().describe("ISO-8601 date/timestamp; return only changes detected on or after this time."),
659
- endDate: z15.string().regex(ISO_8601, "endDate must be an ISO-8601 date or timestamp (e.g. 2026-05-31 or 2026-05-31T23:59:59Z)").optional().describe("ISO-8601 date/timestamp; return only changes detected on or before this time."),
660
- sortBy: z15.enum(LISTING_CHANGE_SORT_BY).optional().describe('Sort field. "date" (default) or "type".'),
661
- sortOrder: z15.enum(SORT_ORDER).optional().describe('Sort direction. "DESC" (default) or "ASC".'),
662
- includeCorrelations: z15.boolean().optional().describe(
953
+ types: z24.array(z24.enum(LISTING_CHANGE_TYPES)).min(1).optional().describe('Filter to specific change types. Omit for all. Any of "Price", "Content", "Image".'),
954
+ asin: z24.string().min(1).optional().describe("Filter to an exact ASIN or parent ASIN."),
955
+ brand: z24.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
956
+ search: z24.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
957
+ startDate: z24.string().regex(ISO_8601, "startDate must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)").optional().describe("ISO-8601 date/timestamp; return only changes detected on or after this time."),
958
+ endDate: z24.string().regex(ISO_8601, "endDate must be an ISO-8601 date or timestamp (e.g. 2026-05-31 or 2026-05-31T23:59:59Z)").optional().describe("ISO-8601 date/timestamp; return only changes detected on or before this time."),
959
+ sortBy: z24.enum(LISTING_CHANGE_SORT_BY).optional().describe('Sort field. "date" (default) or "type".'),
960
+ sortOrder: z24.enum(SORT_ORDER).optional().describe('Sort direction. "DESC" (default) or "ASC".'),
961
+ includeCorrelations: z24.boolean().optional().describe(
663
962
  "When true, include the ranking/conversion `correlation` object per change (CVR and search-term movement before vs after). Defaults to false."
664
963
  ),
665
- currentPage: z15.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
666
- pageSize: z15.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
964
+ currentPage: z24.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
965
+ pageSize: z24.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
667
966
  };
668
967
  var getSellerListingChangesTool = {
669
968
  name: "get_seller_listing_changes",
670
969
  title: "List Listing Changes for a Seller",
671
970
  description: "Use this when the user asks what changed on their Amazon listings \u2014 price, content (title/bullets/description), or image edits \u2014 for a seller account. Requires a `sellerId` + `marketplace` (use `list_seller_profiles` to discover them). Filter by `types`, `asin`/parent ASIN, `brand`, `search`, and a `startDate`/`endDate` range; sort with `sortBy`/`sortOrder`. Set `includeCorrelations: true` to attach the ranking/conversion impact per change. Returns a paginated list where each item has asin, title, imageUrl, date, type, contentType, description, previousValue, newValue, and (optionally) correlation, plus pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev).",
672
- inputSchema: inputSchema14,
971
+ inputSchema: inputSchema23,
673
972
  annotations: { readOnlyHint: true },
674
973
  handler: async (args, ctx) => {
675
974
  return await httpGet(
@@ -694,13 +993,13 @@ var getSellerListingChangesTool = {
694
993
  };
695
994
 
696
995
  // src/tools/get-asin-inventory-distribution.ts
697
- import { z as z16 } from "zod";
698
- var inputSchema15 = {
699
- sellerId: z16.string().min(1).describe(
996
+ import { z as z25 } from "zod";
997
+ var inputSchema24 = {
998
+ sellerId: z25.string().min(1).describe(
700
999
  "Amazon seller account ID as connected to DataDive. Get it from `list_seller_profiles`, or find it on the Connections page at https://2.datadive.tools."
701
1000
  ),
702
- marketplace: z16.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.'),
703
- asin: z16.string().regex(/^[A-Z0-9]{10}$/, "ASIN must be 10 uppercase alphanumeric characters (e.g. B08XYZ1234).").describe(
1001
+ marketplace: z25.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.'),
1002
+ asin: z25.string().regex(/^[A-Z0-9]{10}$/, "ASIN must be 10 uppercase alphanumeric characters (e.g. B08XYZ1234).").describe(
704
1003
  "Amazon Standard Identification Number (10 uppercase alphanumeric characters, e.g. B08XYZ1234)."
705
1004
  )
706
1005
  };
@@ -708,7 +1007,7 @@ var getAsinInventoryDistributionTool = {
708
1007
  name: "get_asin_inventory_distribution",
709
1008
  title: "Get Per-Fulfillment-Center Inventory Distribution for an ASIN",
710
1009
  description: "Use this when the user asks about inventory levels, stock by fulfillment center, or where their units are sitting across Amazon's fulfillment network for a specific ASIN. Requires the Amazon sellerId (from `list_seller_profiles` or the user's DataDive Connections page at https://2.datadive.tools), the marketplace code, and the ASIN. Returns totalSellableUnits and a per-FC `distribution` array (fc, state, availableStock, availableStockPercentage). `lastUpdatedAt` may be null when no successful inventory ingestion has occurred in the last 30 days.",
711
- inputSchema: inputSchema15,
1010
+ inputSchema: inputSchema24,
712
1011
  annotations: { readOnlyHint: true },
713
1012
  handler: async (args, ctx) => {
714
1013
  return await httpGet(
@@ -721,18 +1020,18 @@ var getAsinInventoryDistributionTool = {
721
1020
  };
722
1021
 
723
1022
  // src/tools/alert-query.ts
724
- import { z as z17 } from "zod";
1023
+ import { z as z26 } from "zod";
725
1024
  var alertsQueryInputSchema = {
726
- sellerId: z17.string().min(1).max(50).optional().describe('Filter to a single connected Amazon seller account ID, e.g. "A1B2C3D4E5".'),
727
- marketplace: z17.enum(SUPPORTED_MARKETPLACES).optional().describe('Filter to a single Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.'),
728
- status: z17.enum(ALERT_STATUSES).optional().describe(
1025
+ sellerId: z26.string().min(1).max(50).optional().describe('Filter to a single connected Amazon seller account ID, e.g. "A1B2C3D4E5".'),
1026
+ marketplace: z26.enum(SUPPORTED_MARKETPLACES).optional().describe('Filter to a single Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.'),
1027
+ status: z26.enum(ALERT_STATUSES).optional().describe(
729
1028
  "Lifecycle filter. `active` (default) returns unresolved alerts, `resolved` returns resolved alerts, `all` returns both. Dismissed alerts are never returned."
730
1029
  ),
731
- updatedSince: z17.string().regex(ISO_8601, "updatedSince must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)").optional().describe(
1030
+ updatedSince: z26.string().regex(ISO_8601, "updatedSince must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)").optional().describe(
732
1031
  "ISO-8601 timestamp; return only alerts surfaced at or after this time (filters on `lastAlertedAt`). Use it to incrementally sync since your last poll. Defaults to the last 30 days when omitted."
733
1032
  ),
734
- currentPage: z17.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
735
- pageSize: z17.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1033
+ currentPage: z26.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1034
+ pageSize: z26.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
736
1035
  };
737
1036
 
738
1037
  // src/tools/list-indexing-issue-alerts.ts
@@ -782,12 +1081,12 @@ var listBlindSpendAlertsTool = {
782
1081
  };
783
1082
 
784
1083
  // src/tools/get-quota.ts
785
- var inputSchema16 = {};
1084
+ var inputSchema25 = {};
786
1085
  var getQuotaTool = {
787
1086
  name: "get_quota",
788
1087
  title: "Get Quota Usage",
789
1088
  description: "Use this when the user asks how much quota or how many tokens they have left, or before creating a Niche Dive or Rank Radar to check remaining headroom. Returns current quota usage and capacity for each billable feature \u2014 DIVED_ASINS (Dive tokens), RANK_RADAR_KEYWORDS (tracked keywords), PRODUCT_BRIEF_ASINS, and AI_COPYWRITER_PROMPTS \u2014 each with `used` and `capacity` (null when unlimited / not applicable), plus `nextRefreshDate` (ISO-8601 timestamp of the next quota reset, or null). Takes no arguments.",
790
- inputSchema: inputSchema16,
1089
+ inputSchema: inputSchema25,
791
1090
  annotations: { readOnlyHint: true },
792
1091
  handler: async (_args, ctx) => {
793
1092
  return await httpGet({ config: ctx.config, toolName: "get_quota" }, "/v1/quota");
@@ -795,20 +1094,20 @@ var getQuotaTool = {
795
1094
  };
796
1095
 
797
1096
  // src/tools/list-usage.ts
798
- import { z as z18 } from "zod";
799
- var inputSchema17 = {
800
- type: z18.enum(BILLABLE_FEATURE_TYPES).optional().describe("Filter to a single billable feature type. Omit to return all types."),
801
- search: z18.string().min(1).optional().describe("Case-insensitive partial match on the user's name or email."),
802
- startDate: z18.string().regex(ISO_8601, "startDate must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)").optional().describe("ISO-8601 date/timestamp; return only usage logs recorded on or after this time."),
803
- endDate: z18.string().regex(ISO_8601, "endDate must be an ISO-8601 date or timestamp (e.g. 2026-05-31 or 2026-05-31T23:59:59Z)").optional().describe("ISO-8601 date/timestamp; return only usage logs recorded on or before this time."),
804
- currentPage: z18.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
805
- pageSize: z18.number().int().min(1).max(200).optional().describe("Items per page (max 200). Defaults to 50.")
1097
+ import { z as z27 } from "zod";
1098
+ var inputSchema26 = {
1099
+ type: z27.enum(BILLABLE_FEATURE_TYPES).optional().describe("Filter to a single billable feature type. Omit to return all types."),
1100
+ search: z27.string().min(1).optional().describe("Case-insensitive partial match on the user's name or email."),
1101
+ startDate: z27.string().regex(ISO_8601, "startDate must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)").optional().describe("ISO-8601 date/timestamp; return only usage logs recorded on or after this time."),
1102
+ endDate: z27.string().regex(ISO_8601, "endDate must be an ISO-8601 date or timestamp (e.g. 2026-05-31 or 2026-05-31T23:59:59Z)").optional().describe("ISO-8601 date/timestamp; return only usage logs recorded on or before this time."),
1103
+ currentPage: z27.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1104
+ pageSize: z27.number().int().min(1).max(200).optional().describe("Items per page (max 200). Defaults to 50.")
806
1105
  };
807
1106
  var listUsageTool = {
808
1107
  name: "list_usage",
809
1108
  title: "List Billable Usage Logs",
810
1109
  description: "Use this when the user asks who consumed tokens, how their quota was spent, or wants an audit of billable activity over a date range. Retrieves a paginated list of billable feature usage logs for the organization \u2014 each entry is a token-consumption event (a dive, rank-radar creation, AI copywriter prompt, etc.). Filter by `type` (billable feature), `search` (user name/email), and `startDate`/`endDate`. Each item includes name, email, qty (tokens consumed), type, action (specific operation), nicheId/nicheName, rankRadarId, and date, plus pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev).",
811
- inputSchema: inputSchema17,
1110
+ inputSchema: inputSchema26,
812
1111
  annotations: { readOnlyHint: true },
813
1112
  handler: async (args, ctx) => {
814
1113
  return await httpGet(
@@ -839,6 +1138,15 @@ var allTools = [
839
1138
  createNicheDiveTool,
840
1139
  rediveNicheTool,
841
1140
  getDiveStatusTool,
1141
+ addRankRadarSearchTermsTool,
1142
+ pauseRankRadarSearchTermsTool,
1143
+ resumeRankRadarSearchTermsTool,
1144
+ pauseRankRadarTool,
1145
+ resumeRankRadarTool,
1146
+ deleteRankRadarTool,
1147
+ deleteNicheTool,
1148
+ generateListingCopyTool,
1149
+ getListingCopyGenerationStatusTool,
842
1150
  listSellerProfilesTool,
843
1151
  getSellerCatalogTool,
844
1152
  getSellerListingChangesTool,