@datadive-tools/mcp 0.16.1 → 0.18.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/index.js CHANGED
@@ -144,7 +144,7 @@ function extractMessage(body) {
144
144
  }
145
145
 
146
146
  // package.json
147
- var version = "0.16.1";
147
+ var version = "0.18.0";
148
148
 
149
149
  // src/http/client.ts
150
150
  var PKG_VERSION = version;
@@ -184,6 +184,7 @@ async function httpGet(ctx, path, query) {
184
184
  method: "GET",
185
185
  headers: {
186
186
  ...authHeaders(ctx.config),
187
+ ...forwardedForHeader(ctx.config),
187
188
  accept: "application/json",
188
189
  "user-agent": userAgent(ctx.toolName)
189
190
  }
@@ -201,6 +202,27 @@ async function httpPost(ctx, path, body) {
201
202
  method: "POST",
202
203
  headers: {
203
204
  ...authHeaders(ctx.config),
205
+ ...forwardedForHeader(ctx.config),
206
+ accept: "application/json",
207
+ "content-type": "application/json",
208
+ "user-agent": userAgent(ctx.toolName)
209
+ },
210
+ body: JSON.stringify(body)
211
+ });
212
+ } catch (e) {
213
+ throw networkError(url, e);
214
+ }
215
+ return handleResponse(res);
216
+ }
217
+ async function httpPatch(ctx, path, body) {
218
+ const url = buildUrl(ctx.config.baseUrl, path);
219
+ let res;
220
+ try {
221
+ res = await fetch(url, {
222
+ method: "PATCH",
223
+ headers: {
224
+ ...authHeaders(ctx.config),
225
+ ...forwardedForHeader(ctx.config),
204
226
  accept: "application/json",
205
227
  "content-type": "application/json",
206
228
  "user-agent": userAgent(ctx.toolName)
@@ -220,6 +242,7 @@ async function httpDelete(ctx, path) {
220
242
  method: "DELETE",
221
243
  headers: {
222
244
  ...authHeaders(ctx.config),
245
+ ...forwardedForHeader(ctx.config),
223
246
  accept: "application/json",
224
247
  "user-agent": userAgent(ctx.toolName)
225
248
  }
@@ -265,6 +288,9 @@ function authHeaders(config) {
265
288
  const c = config.credentials;
266
289
  return c.kind === "bearer" ? { authorization: `Bearer ${c.token}` } : { "x-api-key": c.apiKey };
267
290
  }
291
+ function forwardedForHeader(config) {
292
+ return config.forwardedFor ? { "x-forwarded-for": config.forwardedFor } : {};
293
+ }
268
294
  function unwrap(body) {
269
295
  if (!isObject(body)) return body;
270
296
  if (!("data" in body)) return body;
@@ -321,7 +347,7 @@ var inputSchema2 = {
321
347
  var getNicheKeywordsTool = {
322
348
  name: "get_niche_keywords",
323
349
  title: "Get Master Keyword List for a Niche",
324
- description: 'Use this when the user asks about keywords, search terms, or search volume for a niche. Retrieves the master keyword list for the specified Niche \u2014 the relevant search terms monitored for ranking and performance metrics. For each keyword, returns search volume, relevancy (numeric score or "Outlier"), and competitor ASIN organic ranks (asinRanks: { ASIN -> rank | null }). Also returns the latestResearchDate.',
350
+ description: 'Use this when the user asks about keywords, search terms, or search volume for a niche. Retrieves the master keyword list for the specified Niche \u2014 the relevant search terms monitored for ranking and performance metrics. For each keyword, returns search volume, relevancy (numeric score or "Outlier"), and competitor ASIN organic ranks (asinRanks: { ASIN -> rank | null }), plus `origin`: `mkl` (found by the dive), `manual` (added by hand with `add_niche_keywords`), `outlier` / `residue` (moved in from those lists). Only `manual`, `outlier` and `residue` keywords can be taken out with `remove_niche_keywords`. Keywords hidden by the niche\'s keyword exclusions are not listed; see `list_keyword_exclusions`. Also returns the latestResearchDate.',
325
351
  inputSchema: inputSchema2,
326
352
  annotations: { readOnlyHint: true },
327
353
  handler: async (args, ctx) => {
@@ -332,16 +358,35 @@ var getNicheKeywordsTool = {
332
358
  }
333
359
  };
334
360
 
335
- // src/tools/get-niche-roots.ts
361
+ // src/tools/list-keyword-exclusions.ts
336
362
  import { z as z3 } from "zod";
337
363
  var inputSchema3 = {
338
364
  nicheId: z3.string().min(1).describe("The unique identifier of the Niche (from `list_niches`).")
339
365
  };
366
+ var listKeywordExclusionsTool = {
367
+ name: "list_keyword_exclusions",
368
+ title: "List a Niche's Keyword Exclusions",
369
+ description: "Use this to see which keywords are hidden from a niche's Master Keyword List, e.g. when a keyword the user expects is missing from `get_niche_keywords`. Returns the same lists the DataDive web app shows, oldest first: `exact` \u2014 each entry hides the one keyword that matches it exactly, with that keyword's `searchVolume` (0 when the niche has no such keyword); `phrase` \u2014 each entry hides every keyword that contains the phrase, with `excludedKeywordsCount` and the total `searchVolume` of the keywords it hides (not counting ones already excluded exactly). Exclusions hide keywords wherever they come from: the dive, the Outliers and Residue lists, and hand-added ones. Change them with `add_keyword_exclusions` and `remove_keyword_exclusions`.",
370
+ inputSchema: inputSchema3,
371
+ annotations: { readOnlyHint: true },
372
+ handler: async (args, ctx) => {
373
+ return await httpGet(
374
+ { config: ctx.config, toolName: "list_keyword_exclusions" },
375
+ `/v1/niches/${encodeURIComponent(args.nicheId)}/keyword-exclusions`
376
+ );
377
+ }
378
+ };
379
+
380
+ // src/tools/get-niche-roots.ts
381
+ import { z as z4 } from "zod";
382
+ var inputSchema4 = {
383
+ nicheId: z4.string().min(1).describe("The unique identifier of the Niche (from `list_niches`).")
384
+ };
340
385
  var getNicheRootsTool = {
341
386
  name: "get_niche_roots",
342
387
  title: "Get Keyword Roots for a Niche",
343
388
  description: "Use this when the user wants to find the highest-impact words across a niche's keywords, asks about 'keyword roots', or wants to prioritize terms for a listing. Retrieves the keyword lexical roots for the Niche \u2014 individual words or word-combinations extracted from the Master Keyword List (e.g. 'bluetooth headphones' yields roots 'bluetooth', 'headphones', 'bluetooth headphones'). Returns `roots` and `normalizedRoots` tables, each item with root, frequency (how many keywords contain it), broadSearchVolume (summed search volume of those keywords), and broadSearchVolumeRatio (0-1, relative to the top root), plus the per-keyword breakdowns and latestResearchDate.",
344
- inputSchema: inputSchema3,
389
+ inputSchema: inputSchema4,
345
390
  annotations: { readOnlyHint: true },
346
391
  handler: async (args, ctx) => {
347
392
  return await httpGet(
@@ -352,15 +397,15 @@ var getNicheRootsTool = {
352
397
  };
353
398
 
354
399
  // src/tools/get-niche-competitors.ts
355
- import { z as z4 } from "zod";
356
- var inputSchema4 = {
357
- nicheId: z4.string().min(1).describe("The unique identifier of the Niche (from `list_niches`).")
400
+ import { z as z5 } from "zod";
401
+ var inputSchema5 = {
402
+ nicheId: z5.string().min(1).describe("The unique identifier of the Niche (from `list_niches`).")
358
403
  };
359
404
  var getNicheCompetitorsTool = {
360
405
  name: "get_niche_competitors",
361
406
  title: "Get Competitors and Niche Statistics",
362
407
  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`.",
363
- inputSchema: inputSchema4,
408
+ inputSchema: inputSchema5,
364
409
  annotations: { readOnlyHint: true },
365
410
  handler: async (args, ctx) => {
366
411
  return await httpGet(
@@ -371,15 +416,15 @@ var getNicheCompetitorsTool = {
371
416
  };
372
417
 
373
418
  // src/tools/get-ranking-juice.ts
374
- import { z as z5 } from "zod";
375
- var inputSchema5 = {
376
- nicheId: z5.string().min(1).describe("The unique identifier of the Niche (from `list_niches`).")
419
+ import { z as z6 } from "zod";
420
+ var inputSchema6 = {
421
+ nicheId: z6.string().min(1).describe("The unique identifier of the Niche (from `list_niches`).")
377
422
  };
378
423
  var getRankingJuiceTool = {
379
424
  name: "get_ranking_juice",
380
425
  title: "Get Ranking Juices for a Niche",
381
426
  description: "Use this when the user asks 'how do I rank higher', 'what's my ranking juice', or wants listing-optimization guidance. Retrieves the Ranking Juices for each Competitor within the specified Niche. Ranking Juice is DataDive's proprietary metric identifying the key factors driving search-ranking success for each Competitor's listing. Returns currentListing and optimizedListing breakdowns (rankingJuice + per-property contributions: title, bullets, description) plus per-competitor listing scores and the latestResearchDate.",
382
- inputSchema: inputSchema5,
427
+ inputSchema: inputSchema6,
383
428
  annotations: { readOnlyHint: true },
384
429
  handler: async (args, ctx) => {
385
430
  return await httpGet(
@@ -390,7 +435,7 @@ var getRankingJuiceTool = {
390
435
  };
391
436
 
392
437
  // src/tools/list-rank-radars.ts
393
- import { z as z6 } from "zod";
438
+ import { z as z7 } from "zod";
394
439
 
395
440
  // src/types/api.ts
396
441
  var ISO_8601 = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
@@ -406,8 +451,16 @@ var SUPPORTED_MARKETPLACES = [
406
451
  "it",
407
452
  "co.jp"
408
453
  ];
454
+ var NICHE_KEYWORDS_MAX_PER_CALL = 100;
455
+ var NICHE_KEYWORD_MAX_LENGTH = 255;
456
+ var KEYWORD_EXCLUSIONS_MAX_PER_CALL = 100;
457
+ var KEYWORD_EXCLUSIONS_MAX_PER_NICHE = 1e3;
409
458
  var RANK_RADAR_STATES = ["ACTIVE", "PAUSED", "ARCHIVED"];
410
459
  var RANK_RADAR_STATUSES = [...RANK_RADAR_STATES, "ALL"];
460
+ var TAG_TITLE_MAX_LENGTH = 100;
461
+ var TAG_KEYWORD_IDS_MAX = 1e3;
462
+ var TAG_RESERVED_COLOR = "#EB5757";
463
+ var TAG_HEX_COLOR_PATTERN = /^#[0-9A-Fa-f]{6}$/;
411
464
  var PPC_CAMPAIGN_BASE_SORT_BY = [
412
465
  "name",
413
466
  "state",
@@ -451,14 +504,14 @@ var LISTING_COPY_STRATEGIES = ["cosmo", "ranking-juice", "nlp", "cosmo-rufus"];
451
504
 
452
505
  // src/tools/list-rank-radars.ts
453
506
  var LIST_RANK_RADARS_MAX_PAGE_SIZE = 50;
454
- var inputSchema6 = {
455
- currentPage: z6.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
456
- 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.`),
457
- nicheId: z6.string().min(1).optional().describe("Filter Rank Radars by Niche identifier. Use after `list_niches`."),
458
- status: z6.enum(RANK_RADAR_STATUSES).optional().describe(
507
+ var inputSchema7 = {
508
+ currentPage: z7.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
509
+ pageSize: z7.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.`),
510
+ nicheId: z7.string().min(1).optional().describe("Filter Rank Radars by Niche identifier. Use after `list_niches`."),
511
+ status: z7.enum(RANK_RADAR_STATUSES).optional().describe(
459
512
  "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."
460
513
  ),
461
- searchText: z6.string().optional().describe("Filter Rank Radars by ASIN or product title.")
514
+ searchText: z7.string().optional().describe("Filter Rank Radars by ASIN or product title.")
462
515
  };
463
516
  function minimize(item) {
464
517
  const { asin, ...rest } = item;
@@ -468,7 +521,7 @@ var listRankRadarsTool = {
468
521
  name: "list_rank_radars",
469
522
  title: "List Rank Radars",
470
523
  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.`,
471
- inputSchema: inputSchema6,
524
+ inputSchema: inputSchema7,
472
525
  annotations: { readOnlyHint: true },
473
526
  handler: async (args, ctx) => {
474
527
  const page = await httpGet(
@@ -487,18 +540,18 @@ var listRankRadarsTool = {
487
540
  };
488
541
 
489
542
  // src/tools/rank-radar-keyword-query.ts
490
- import { z as z7 } from "zod";
543
+ import { z as z8 } from "zod";
491
544
  var ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
492
545
  var RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE = 100;
493
546
  var RANK_RADAR_MAX_DATE_RANGE_DAYS = 90;
494
547
  var rankRadarKeywordQueryInputSchema = {
495
- rankRadarId: z7.string().uuid().describe("The Rank Radar UUID (from `list_rank_radars`)."),
496
- startDate: z7.string().regex(ISO_DATE, "startDate must be in yyyy-mm-dd format").describe("Start date of the range, yyyy-mm-dd (e.g. 2024-03-26)."),
497
- endDate: z7.string().regex(ISO_DATE, "endDate must be in yyyy-mm-dd format").describe(
548
+ rankRadarId: z8.string().uuid().describe("The Rank Radar UUID (from `list_rank_radars`)."),
549
+ startDate: z8.string().regex(ISO_DATE, "startDate must be in yyyy-mm-dd format").describe("Start date of the range, yyyy-mm-dd (e.g. 2024-03-26)."),
550
+ endDate: z8.string().regex(ISO_DATE, "endDate must be in yyyy-mm-dd format").describe(
498
551
  `End date of the range, yyyy-mm-dd (e.g. 2024-04-26). Must be on or after startDate, and at most ${RANK_RADAR_MAX_DATE_RANGE_DAYS} days after it.`
499
552
  ),
500
- currentPage: z7.number().int().min(1).optional().describe("Page of keywords, 1-indexed. Defaults to 1."),
501
- pageSize: z7.number().int().min(1).max(RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE).optional().describe(`Keywords per page (max ${RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE}). Defaults to 20.`)
553
+ currentPage: z8.number().int().min(1).optional().describe("Page of keywords, 1-indexed. Defaults to 1."),
554
+ pageSize: z8.number().int().min(1).max(RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE).optional().describe(`Keywords per page (max ${RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE}). Defaults to 20.`)
502
555
  };
503
556
  var RANK_RADAR_KEYWORD_PAGING_NOTE = `Results are paged by keyword: \`data\` holds one page, and the response carries currentPage, pageSize, total, lastPage, hasNext and hasPrev. \`total\` is the Rank Radar's active keyword count; to read every keyword, call again with \`currentPage\` + 1 while \`hasNext\` is true, using \`pageSize\` ${RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE} for large Rank Radars. Paused keywords are not included.`;
504
557
  function rankRadarPath(rankRadarId, suffix = "") {
@@ -514,7 +567,7 @@ function rankRadarKeywordQuery(args) {
514
567
  }
515
568
 
516
569
  // src/tools/get-rank-radar-data.ts
517
- var inputSchema7 = rankRadarKeywordQueryInputSchema;
570
+ var inputSchema8 = rankRadarKeywordQueryInputSchema;
518
571
  async function readAllKeywords(args, ctx) {
519
572
  const request = { config: ctx.config, toolName: "get_rank_radar_data" };
520
573
  const path = rankRadarPath(args.rankRadarId);
@@ -543,8 +596,8 @@ async function readAllKeywords(args, ctx) {
543
596
  var getRankRadarDataTool = {
544
597
  name: "get_rank_radar_data",
545
598
  title: "Get Keyword Rankings for a Rank Radar",
546
- description: `Use this to analyze keyword ranking trends over time. Requires startDate and endDate (yyyy-mm-dd), at most ${RANK_RADAR_MAX_DATE_RANGE_DAYS} days apart. Retrieves historical keyword ranking data for the specified Rank Radar within the date range. Without \`currentPage\` and \`pageSize\` it returns every active keyword in one result. To read one page instead \u2014 faster for large Rank Radars \u2014 pass \`currentPage\` and/or \`pageSize\` (max ${RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE}) and continue with \`currentPage\` + 1 while \`hasNext\` is true. The response carries currentPage, pageSize, total, lastPage, hasNext and hasPrev; \`total\` is the Rank Radar's active keyword count. Paused keywords are not included. Each keyword has id, keyword, searchVolume, relevancy, ranks (per-day { date, organicRank, sponsoredRank, impressionRank }), and any highlight annotations. A rank of 101 means the product was not in the top 100 results that day. For PPC metrics use \`get_rank_radar_ppc_data\`; for Search Query Performance use \`get_rank_radar_sqp_data\`. Use after \`list_rank_radars\` to discover a \`rankRadarId\`.`,
547
- inputSchema: inputSchema7,
599
+ description: `Use this to analyze keyword ranking trends over time. Requires startDate and endDate (yyyy-mm-dd), at most ${RANK_RADAR_MAX_DATE_RANGE_DAYS} days apart. Retrieves historical keyword ranking data for the specified Rank Radar within the date range. Without \`currentPage\` and \`pageSize\` it returns every active keyword in one result. To read one page instead \u2014 faster for large Rank Radars \u2014 pass \`currentPage\` and/or \`pageSize\` (max ${RANK_RADAR_KEYWORDS_MAX_PAGE_SIZE}) and continue with \`currentPage\` + 1 while \`hasNext\` is true. The response carries currentPage, pageSize, total, lastPage, hasNext and hasPrev; \`total\` is the Rank Radar's active keyword count. Paused keywords are not included. Each keyword has id, keyword, searchVolume, relevancy, ranks (per-day { date, organicRank, sponsoredRank, impressionRank }), and \`highlights\` \u2014 the user tags on this keyword. Each \`highlights\` entry is the same object \`list_rank_radar_tags\` returns (id, title, color, description, startAt, endAt, type, krtId, krtKeywordId); its \`id\` is the \`tagId\` the tag-management tools take. A rank of 101 means the product was not in the top 100 results that day. For PPC metrics use \`get_rank_radar_ppc_data\`; for Search Query Performance use \`get_rank_radar_sqp_data\`. Use after \`list_rank_radars\` to discover a \`rankRadarId\`.`,
600
+ inputSchema: inputSchema8,
548
601
  annotations: { readOnlyHint: true },
549
602
  handler: async (args, ctx) => {
550
603
  if (args.currentPage === void 0 && args.pageSize === void 0) {
@@ -559,12 +612,12 @@ var getRankRadarDataTool = {
559
612
  };
560
613
 
561
614
  // src/tools/get-rank-radar-sqp-data.ts
562
- var inputSchema8 = rankRadarKeywordQueryInputSchema;
615
+ var inputSchema9 = rankRadarKeywordQueryInputSchema;
563
616
  var getRankRadarSqpDataTool = {
564
617
  name: "get_rank_radar_sqp_data",
565
618
  title: "Get Search Query Performance for a Rank Radar",
566
619
  description: `Use this when the user asks how shoppers search, click, add to cart and buy for the keywords of a Rank Radar \u2014 Amazon's Search Query Performance (SQP) data, from Brand Analytics. Requires startDate and endDate (yyyy-mm-dd), at most ${RANK_RADAR_MAX_DATE_RANGE_DAYS} days apart; 30 days or less keeps it fast. Each keyword's metrics are aggregated over the range: searchQueryVolume and searchQueryScore; impressions, clicks, cart adds and purchases, each as the total across all sellers (\`*TotalCount\`), this ASIN family's count (\`*AsinCount\`) and its share (\`*AsinShare\`); click, cart-add and purchase rates; and ctr/cvr for the market (\`*Total\`) and for this ASIN family (\`*Asin\`). \`numberOfDaysWithData\` says how many days of the range had SQP data; metrics are null when there is none, which is normal for low-volume keywords, recent dates (Amazon publishes SQP with a delay) and sellers without Brand Analytics. ${RANK_RADAR_KEYWORD_PAGING_NOTE} Each call counts toward API usage and is rate limited (about 60 requests/minute). Use after \`list_rank_radars\` to discover a \`rankRadarId\`.`,
567
- inputSchema: inputSchema8,
620
+ inputSchema: inputSchema9,
568
621
  annotations: { readOnlyHint: true },
569
622
  handler: async (args, ctx) => {
570
623
  return await httpGet(
@@ -576,10 +629,10 @@ var getRankRadarSqpDataTool = {
576
629
  };
577
630
 
578
631
  // src/tools/get-rank-radar-ppc-data.ts
579
- import { z as z8 } from "zod";
580
- var inputSchema9 = {
632
+ import { z as z9 } from "zod";
633
+ var inputSchema10 = {
581
634
  ...rankRadarKeywordQueryInputSchema,
582
- includeCampaigns: z8.boolean().optional().describe(
635
+ includeCampaigns: z9.boolean().optional().describe(
583
636
  "When true, each keyword also carries `campaigns`: the per-campaign/ad-group breakdown (campaign and ad group name, match type, targeting, spend, sales, clicks, impressions, orders, CPC, CTR, CVR, ACOS). Defaults to false; leave it off unless the user asks which campaigns drive a keyword."
584
637
  )
585
638
  };
@@ -587,7 +640,7 @@ var getRankRadarPpcDataTool = {
587
640
  name: "get_rank_radar_ppc_data",
588
641
  title: "Get PPC Data for a Rank Radar",
589
642
  description: `Use this when the user asks about advertising (Sponsored Products) performance for the keywords of a Rank Radar. Requires startDate and endDate (yyyy-mm-dd), at most ${RANK_RADAR_MAX_DATE_RANGE_DAYS} days apart; 30 days or less keeps it fast. Each keyword's metrics are aggregated over the range: sponsoredRank (median; 101 means not in the top 100 sponsored results), impressionRank and impressionRankShare; how many exact, phrase, broad and auto campaigns target it; organicSales, ppcSales, ppcSpend, costPerClicks, clickThroughRate, conversionRate, totalClicks, totalImpressions, totalOrders and acos. Metrics are null or 0 when the seller runs no ads on a keyword. Set \`includeCampaigns\` for the per-campaign breakdown. ${RANK_RADAR_KEYWORD_PAGING_NOTE} Each call counts toward API usage and is rate limited (about 60 requests/minute). For the seller's campaigns as a whole, use \`list_ppc_campaigns\`. Use after \`list_rank_radars\` to discover a \`rankRadarId\`.`,
590
- inputSchema: inputSchema9,
643
+ inputSchema: inputSchema10,
591
644
  annotations: { readOnlyHint: true },
592
645
  handler: async (args, ctx) => {
593
646
  return await httpGet(
@@ -599,7 +652,7 @@ var getRankRadarPpcDataTool = {
599
652
  };
600
653
 
601
654
  // src/tools/create-rank-radar.ts
602
- import { z as z9 } from "zod";
655
+ import { z as z10 } from "zod";
603
656
 
604
657
  // src/tools/confirm.ts
605
658
  function needsConfirmation(confirm, ctx) {
@@ -620,11 +673,11 @@ function requireConfirmation(confirm, ctx, costNote) {
620
673
 
621
674
  // src/tools/create-rank-radar.ts
622
675
  var PATH = "/v1/niches/rank-radars";
623
- var inputSchema10 = {
624
- asin: z9.string().min(1).describe("The ASIN to track keyword rankings for."),
625
- numberOfKeywords: z9.number().int().min(1).describe("How many keywords to track (minimum 1). More keywords = broader tracking but more Search Term tokens."),
626
- nicheId: z9.string().min(1).describe("The niche this Rank Radar belongs to. Get one from `list_niches`."),
627
- confirm: z9.boolean().optional().describe(
676
+ var inputSchema11 = {
677
+ asin: z10.string().min(1).describe("The ASIN to track keyword rankings for."),
678
+ numberOfKeywords: z10.number().int().min(1).describe("How many keywords to track (minimum 1). More keywords = broader tracking but more Search Term tokens."),
679
+ nicheId: z10.string().min(1).describe("The niche this Rank Radar belongs to. Get one from `list_niches`."),
680
+ confirm: z10.boolean().optional().describe(
628
681
  "Must be true to proceed \u2014 creating a Rank Radar spends Search Term tokens. Confirm the cost with the user first."
629
682
  )
630
683
  };
@@ -632,7 +685,7 @@ var createRankRadarTool = {
632
685
  name: "create_rank_radar",
633
686
  title: "Create a Rank Radar",
634
687
  description: "Use this to start tracking organic and sponsored keyword rankings for an ASIN within a niche. \u26A0\uFE0F Spends Search Term tokens (cost scales with `numberOfKeywords`) and cannot be undone \u2014 set `confirm: true` only after the user approves the cost. Not safe to retry: each call spends tokens again and creates a separate Rank Radar \u2014 if a call errors or times out, check `list_rank_radars` instead of re-calling. The first call previews the creation and may return `warnings` alongside the cost note \u2014 for example that this product family is already tracked by another Rank Radar. Show every warning `message` to the user verbatim, before asking them to confirm; do not summarise it or decide on their behalf. A warning never blocks creation. Returns the new `rankRadarId`; read its data later with `get_rank_radar_data`. Requires `asin`, `numberOfKeywords` (min 1), and a `nicheId` from `list_niches`.",
635
- inputSchema: inputSchema10,
688
+ inputSchema: inputSchema11,
636
689
  // destructiveHint is technically "additive" here (this creates a new Rank Radar, it
637
690
  // doesn't destroy data), but we flag it destructive so clients prompt before the
638
691
  // irreversible token spend. The confirm gate enforces this server-side regardless.
@@ -657,20 +710,20 @@ var createRankRadarTool = {
657
710
  };
658
711
 
659
712
  // src/tools/create-niche-dive.ts
660
- import { z as z10 } from "zod";
661
- var inputSchema11 = {
662
- marketplace: z10.enum(SUPPORTED_MARKETPLACES).describe(
713
+ import { z as z11 } from "zod";
714
+ var inputSchema12 = {
715
+ marketplace: z11.enum(SUPPORTED_MARKETPLACES).describe(
663
716
  "Amazon marketplace of the seed ASIN. Note these are full domain suffixes: com, ca, co.uk, com.mx, in, fr, de, es, it, co.jp (e.g. UK is `co.uk`, not `uk`)."
664
717
  ),
665
- asin: z10.string().min(1).describe("The seed ASIN to start the dive from (e.g. B08N5WRWNW). Competitors are built around it."),
666
- numberOfCompetitors: z10.number().int().min(2).describe("How many competitors to analyze (minimum 2). More competitors = deeper niche but more dive tokens."),
667
- confirm: z10.boolean().optional().describe("Must be true to proceed \u2014 creating a dive spends dive tokens. Confirm the cost with the user first.")
718
+ asin: z11.string().min(1).describe("The seed ASIN to start the dive from (e.g. B08N5WRWNW). Competitors are built around it."),
719
+ numberOfCompetitors: z11.number().int().min(2).describe("How many competitors to analyze (minimum 2). More competitors = deeper niche but more dive tokens."),
720
+ confirm: z11.boolean().optional().describe("Must be true to proceed \u2014 creating a dive spends dive tokens. Confirm the cost with the user first.")
668
721
  };
669
722
  var createNicheDiveTool = {
670
723
  name: "create_niche_dive",
671
724
  title: "Create a Niche Dive",
672
725
  description: "Use this to start new niche research from a seed ASIN. \u26A0\uFE0F Spends dive tokens (cost scales with `numberOfCompetitors`) and cannot be undone \u2014 set `confirm: true` only after the user approves the cost. Not safe to retry: each call spends tokens again and starts a separate dive \u2014 if a call errors or times out, poll `get_dive_status` (or check `list_niches`) instead of re-calling. The dive runs asynchronously: this returns immediately with a `diveId` and an `estimatedCompletionDate`. Poll `get_dive_status` with that `diveId` until it reports `success` (which carries the new `nicheId` for use with `list_niches`, `get_niche_keywords`, etc.). Requires `marketplace`, `asin`, and `numberOfCompetitors` (min 2).",
673
- inputSchema: inputSchema11,
726
+ inputSchema: inputSchema12,
674
727
  // destructiveHint is technically "additive" here (a dive creates a new niche, it
675
728
  // doesn't destroy data), but we flag it destructive so clients prompt before the
676
729
  // irreversible token spend. The confirm gate enforces this server-side regardless.
@@ -695,20 +748,20 @@ var createNicheDiveTool = {
695
748
  };
696
749
 
697
750
  // src/tools/create-niche-dive-from-competitors-list.ts
698
- import { z as z11 } from "zod";
751
+ import { z as z12 } from "zod";
699
752
  var DIVE_FROM_COMPETITORS_MIN_ASINS = 2;
700
753
  var DIVE_FROM_COMPETITORS_MAX_ASINS = 200;
701
- var normalizedAsins = z11.array(z11.string().trim().min(1).toUpperCase()).min(DIVE_FROM_COMPETITORS_MIN_ASINS).max(DIVE_FROM_COMPETITORS_MAX_ASINS).refine((asins) => new Set(asins).size === asins.length, {
754
+ var normalizedAsins = z12.array(z12.string().trim().min(1).toUpperCase()).min(DIVE_FROM_COMPETITORS_MIN_ASINS).max(DIVE_FROM_COMPETITORS_MAX_ASINS).refine((asins) => new Set(asins).size === asins.length, {
702
755
  message: "asins must not contain the same ASIN twice"
703
756
  });
704
- var inputSchema12 = {
705
- marketplace: z11.enum(SUPPORTED_MARKETPLACES).describe(
757
+ var inputSchema13 = {
758
+ marketplace: z12.enum(SUPPORTED_MARKETPLACES).describe(
706
759
  "Amazon marketplace where the ASINs are listed. Full domain suffixes: com, ca, co.uk, com.mx, in, fr, de, es, it, co.jp (e.g. UK is `co.uk`, not `uk`)."
707
760
  ),
708
761
  asins: normalizedAsins.describe(
709
762
  `The exact competitor ASINs to build the niche from, ${DIVE_FROM_COMPETITORS_MIN_ASINS} to ${DIVE_FROM_COMPETITORS_MAX_ASINS}, each once. No other competitors are added.`
710
763
  ),
711
- confirm: z11.boolean().optional().describe(
764
+ confirm: z12.boolean().optional().describe(
712
765
  "Must be true to proceed \u2014 this dive spends dive tokens for every ASIN. Confirm the cost with the user first."
713
766
  )
714
767
  };
@@ -716,7 +769,7 @@ var createNicheDiveFromCompetitorsListTool = {
716
769
  name: "create_niche_dive_from_competitors_list",
717
770
  title: "Create a Niche Dive from a Competitor List",
718
771
  description: `Use this when the user already knows which products belong in the niche \u2014 e.g. they list competitor ASINs, or picked them from search results \u2014 and wants niche research on exactly those. Unlike \`create_niche_dive\`, which discovers competitors around one seed ASIN, this builds the niche from the given ASINs only (${DIVE_FROM_COMPETITORS_MIN_ASINS}-${DIVE_FROM_COMPETITORS_MAX_ASINS}). \u26A0\uFE0F Spends dive tokens for every ASIN and cannot be undone \u2014 set \`confirm: true\` only after the user approves the cost. Not safe to retry: each call spends tokens again and starts a separate dive \u2014 if a call errors or times out, poll \`get_dive_status\` (or check \`list_niches\`) instead of re-calling. Fails without spending tokens when the ASIN count is over the plan's limit, when the account is at its niche limit, or when Amazon product data cannot be found for enough of the ASINs. The dive runs asynchronously: this returns a \`diveId\` and an \`estimatedCompletionDate\`; poll \`get_dive_status\` with the \`diveId\` until it reports \`success\`, which carries the new \`nicheId\`.`,
719
- inputSchema: inputSchema12,
772
+ inputSchema: inputSchema13,
720
773
  // Additive rather than destructive, but flagged destructive so clients prompt before the
721
774
  // irreversible token spend — same reasoning as create_niche_dive. The confirm gate enforces it.
722
775
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
@@ -736,23 +789,23 @@ var createNicheDiveFromCompetitorsListTool = {
736
789
  };
737
790
 
738
791
  // src/tools/redive-niche.ts
739
- import { z as z12 } from "zod";
740
- var inputSchema13 = {
741
- nicheId: z12.string().min(1).describe("The niche to re-dive. Get one from `list_niches`."),
742
- mode: z12.enum(["same_competitors", "discover"]).describe(
792
+ import { z as z13 } from "zod";
793
+ var inputSchema14 = {
794
+ nicheId: z13.string().min(1).describe("The niche to re-dive. Get one from `list_niches`."),
795
+ mode: z13.enum(["same_competitors", "discover"]).describe(
743
796
  "How to pick the competitors for the refreshed dive. `same_competitors` re-runs the niche's current competitor set and takes no other argument \u2014 use it to refresh stale data. `discover` searches for a fresh competitor set, which is what you want when the niche has changed."
744
797
  ),
745
- numberOfCompetitors: z12.number().int().min(2).optional().describe(
798
+ numberOfCompetitors: z13.number().int().min(2).optional().describe(
746
799
  "Total ASINs the refreshed dive should contain, including `lockedAsins`. Required in `discover` mode and rejected in `same_competitors` mode. Dive tokens are spent per ASIN."
747
800
  ),
748
- heroAsin: z12.string().min(1).optional().describe(
801
+ heroAsin: z13.string().min(1).optional().describe(
749
802
  "`discover` mode only. Seed product the competitor discovery starts from. Defaults to the niche's highest-selling competitor, preferring one the user's own connected seller account owns."
750
803
  ),
751
- lockedAsins: z12.array(z12.string().min(1)).optional().describe(
804
+ lockedAsins: z13.array(z13.string().min(1)).optional().describe(
752
805
  "`discover` mode only. ASINs that must stay in the competitor set regardless of what discovery finds. Cannot exceed `numberOfCompetitors`, and cannot overlap `excludedAsins`."
753
806
  ),
754
- excludedAsins: z12.array(z12.string().min(1)).optional().describe("`discover` mode only. ASINs discovery must never select."),
755
- confirm: z12.boolean().optional().describe(
807
+ excludedAsins: z13.array(z13.string().min(1)).optional().describe("`discover` mode only. ASINs discovery must never select."),
808
+ confirm: z13.boolean().optional().describe(
756
809
  "Must be true to proceed \u2014 a re-dive spends dive tokens. Confirm the cost with the user first."
757
810
  )
758
811
  };
@@ -760,7 +813,7 @@ var rediveNicheTool = {
760
813
  name: "redive_niche",
761
814
  title: "Re-dive an Existing Niche",
762
815
  description: "Use this to refresh an existing niche's research with current Amazon data, instead of creating a new niche with `create_niche_dive`. \u26A0\uFE0F Spends dive tokens (one batch per ASIN dived) and cannot be undone \u2014 set `confirm: true` only after the user approves the cost. Not safe to retry: each call spends tokens again and starts a separate re-dive \u2014 if a call errors or times out, poll `get_dive_status` instead of re-calling. Two modes: `same_competitors` re-dives the niche's current competitor set (no other argument needed) and `discover` finds a fresh set, sized by `numberOfCompetitors` and steerable with `heroAsin` / `lockedAsins` / `excludedAsins`. Runs asynchronously: returns a `diveId` and an `estimatedCompletionDate` \u2014 poll `get_dive_status` with that `diveId` until it reports `success`. The niche keeps its `nicheId`, so existing rank radars and reports follow the refreshed data.",
763
- inputSchema: inputSchema13,
816
+ inputSchema: inputSchema14,
764
817
  // Same reasoning as create_niche_dive: a re-dive is additive rather than destructive, but the
765
818
  // irreversible token spend is what clients need to prompt on. The confirm gate enforces it regardless.
766
819
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
@@ -793,17 +846,17 @@ var rediveNicheTool = {
793
846
  };
794
847
 
795
848
  // src/tools/get-dive-status.ts
796
- import { z as z13 } from "zod";
797
- var inputSchema14 = {
798
- diveId: z13.string().min(1).describe(
799
- "The dive identifier returned by `create_niche_dive`, `create_niche_dive_from_competitors_list` or `redive_niche`."
849
+ import { z as z14 } from "zod";
850
+ var inputSchema15 = {
851
+ diveId: z14.string().min(1).describe(
852
+ "The dive identifier returned by `create_niche_dive`, `create_niche_dive_from_competitors_list` or `redive_niche`, or the `refresh.diveId` returned by `add_niche_keywords`."
800
853
  )
801
854
  };
802
855
  var getDiveStatusTool = {
803
856
  name: "get_dive_status",
804
857
  title: "Get Niche Dive Status",
805
- description: "Use this to poll a niche dive started with `create_niche_dive`, `create_niche_dive_from_competitors_list` or `redive_niche` until it finishes. Returns one of three shapes keyed by `status`: `in_progress` (with `estimatedCompletionDate`), `success` (with the `nicheId` plus `tokensUsed`/`tokensLeft`), or `error` (with an `error` message). On `success`, use the `nicheId` with `list_niches`, `get_niche_keywords`, `get_niche_competitors`, etc. (for a re-dive it is the same niche you passed in, now carrying refreshed data). Re-poll periodically \u2014 dives can take minutes; the `estimatedCompletionDate` hints at when to check.",
806
- inputSchema: inputSchema14,
858
+ description: "Use this to poll a niche dive started with `create_niche_dive`, `create_niche_dive_from_competitors_list` or `redive_niche`, or the re-dive `add_niche_keywords` started on a stale niche, until it finishes. Returns one of three shapes keyed by `status`: `in_progress` (with `estimatedCompletionDate`), `success` (with the `nicheId` plus `tokensUsed`/`tokensLeft`), or `error` (with an `error` message). On `success`, use the `nicheId` with `list_niches`, `get_niche_keywords`, `get_niche_competitors`, etc. (for a re-dive it is the same niche you passed in, now carrying refreshed data). Re-poll periodically \u2014 dives can take minutes; the `estimatedCompletionDate` hints at when to check.",
859
+ inputSchema: inputSchema15,
807
860
  annotations: { readOnlyHint: true },
808
861
  handler: async (args, ctx) => {
809
862
  return await httpGet(
@@ -813,11 +866,166 @@ var getDiveStatusTool = {
813
866
  }
814
867
  };
815
868
 
869
+ // src/tools/add-niche-keywords.ts
870
+ import { z as z16 } from "zod";
871
+
872
+ // src/tools/niche-keyword-list.ts
873
+ import { z as z15 } from "zod";
874
+ var nicheKeyword = () => z15.string().trim().toLowerCase().min(1).max(NICHE_KEYWORD_MAX_LENGTH);
875
+ function uniqueKeywords(schema, field) {
876
+ return schema.refine((keywords) => new Set(keywords).size === keywords.length, {
877
+ message: `${field} must not contain the same keyword twice (compared lower-cased and trimmed)`
878
+ });
879
+ }
880
+ var nicheKeywordList = uniqueKeywords(
881
+ z15.array(nicheKeyword()).min(1).max(NICHE_KEYWORDS_MAX_PER_CALL),
882
+ "keywords"
883
+ );
884
+
885
+ // src/tools/add-niche-keywords.ts
886
+ var inputSchema16 = {
887
+ nicheId: z16.string().min(1).describe("The niche whose Master Keyword List to add to. Get one from `list_niches`."),
888
+ keywords: nicheKeywordList.describe(
889
+ `The keywords to add, 1\u2013${NICHE_KEYWORDS_MAX_PER_CALL} per call, at most 255 characters each. They are lower-cased and trimmed, and must be unique after that. Put every keyword in one call: this tool allows only 2 calls per minute per niche.`
890
+ ),
891
+ confirm: z16.boolean().optional().describe(
892
+ "Leave unset on the first call. Set to true only after the user approved the Dive token cost from a `confirmation_required` response \u2014 it lets the add re-dive a stale niche."
893
+ ),
894
+ maxTokensUsed: z16.number().int().min(0).optional().describe(
895
+ "With `confirm: true`: the `tokenCost` the user approved. The call then fails with nothing saved or charged rather than spend more. Ignored without `confirm`, where the tool never spends anything."
896
+ )
897
+ };
898
+ function isMaxTokensExceededBody(body) {
899
+ if (!body || typeof body !== "object") return false;
900
+ const b = body;
901
+ return b.error === "MAX_TOKENS_EXCEEDED" && typeof b.tokensUsed === "number";
902
+ }
903
+ var addNicheKeywordsTool = {
904
+ name: "add_niche_keywords",
905
+ title: "Add Keywords to a Niche's Master Keyword List",
906
+ description: "Use this to add keywords to a niche's Master Keyword List (MKL): the user's own search terms, or keywords from the niche's Outliers or Residue lists. Free while the niche is fresh (dived in the last 24 hours, or a dive is running): the first call adds the keywords at once and they are readable with `get_niche_keywords`. On a stale niche, any keyword new to the niche makes the add re-dive the whole niche with its current competitors, which spends one Dive token per competitor. The first call then saves and spends nothing and returns `confirmation_required` with `tokenCost`; after the user approves, call again with `confirm: true` and `maxTokensUsed` set to that `tokenCost`. Keywords moved in from Outliers or Residue never cost anything. Returns `originBreakdown` (`alreadyInMkl`, `takenFromOutliers`, `takenFromResidue`, `addedManually`) and `tokensUsed`. When `refresh` is present a re-dive is running: poll `get_dive_status` with `refresh.diveId`; the `addedManually` keywords show in the MKL once it succeeds. A confirmed call is not safe to retry: if it errors or times out, poll `get_dive_status` or re-read `get_niche_keywords` instead of re-calling. Limited to 2 calls per minute per niche, so batch keywords into one call. Undo with `remove_niche_keywords`. A keyword hidden by the niche's keyword exclusions stays hidden after an add: check `list_keyword_exclusions` and remove the exclusion with `remove_keyword_exclusions` first.",
907
+ inputSchema: inputSchema16,
908
+ // Like redive_niche: additive, but it can spend Dive tokens irreversibly, which is what clients
909
+ // need to prompt on. The confirm gate covers the paid path regardless.
910
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
911
+ handler: async (args, ctx) => {
912
+ const request = { config: ctx.config, toolName: "add_niche_keywords" };
913
+ const path = `/v1/niches/${encodeURIComponent(args.nicheId)}/keywords`;
914
+ if (needsConfirmation(args.confirm, ctx)) {
915
+ try {
916
+ return await httpPost(request, path, {
917
+ keywords: args.keywords,
918
+ maxTokensUsed: 0
919
+ });
920
+ } catch (err) {
921
+ if (err instanceof ApiError && isMaxTokensExceededBody(err.body)) {
922
+ const tokenCost = err.body.tokensUsed;
923
+ return {
924
+ ...confirmationRequired(
925
+ `This niche was last dived more than 24 hours ago, so adding keywords that are new to it re-dives the whole niche with its current competitors: up to ${tokenCost} Dive tokens, one per competitor (less if some can no longer be found). Nothing was added or charged yet.`
926
+ ),
927
+ tokenCost
928
+ };
929
+ }
930
+ throw err;
931
+ }
932
+ }
933
+ return await httpPost(request, path, {
934
+ keywords: args.keywords,
935
+ maxTokensUsed: args.maxTokensUsed
936
+ });
937
+ }
938
+ };
939
+
940
+ // src/tools/remove-niche-keywords.ts
941
+ import { z as z17 } from "zod";
942
+ var inputSchema17 = {
943
+ nicheId: z17.string().min(1).describe("The niche whose Master Keyword List to remove from. Get one from `list_niches`."),
944
+ keywords: nicheKeywordList.describe(
945
+ `The keywords to take out, 1\u2013${NICHE_KEYWORDS_MAX_PER_CALL} per call, at most 255 characters each. They are lower-cased and trimmed, and must be unique after that. Put every keyword in one call: this tool allows only 2 calls per minute per niche.`
946
+ )
947
+ };
948
+ var removeNicheKeywordsTool = {
949
+ name: "remove_niche_keywords",
950
+ title: "Remove Keywords from a Niche's Master Keyword List",
951
+ description: "Use this to undo `add_niche_keywords`: take keywords back out of a niche's Master Keyword List (MKL). Only keywords that were added to the MKL can be removed \u2014 `get_niche_keywords` shows each keyword's `origin`. What happens depends on that origin, and the response reports it per keyword: `removedManual` \u2014 added by hand (`manual`), deleted from the niche; `sentBackToOutliers` / `sentBackToResidue` \u2014 moved in from those lists (`outlier` / `residue`), listed there again with their data kept; `notRemovable` \u2014 found by the dive itself (`mkl`) or not in the niche, left unchanged. To hide a keyword the dive found, use `add_keyword_exclusions` instead. Free, and safe to repeat: a keyword already removed comes back under `notRemovable`. Adding a hand-added keyword back later re-dives the niche and costs Dive tokens if the niche is stale by then. Limited to 2 calls per minute per niche.",
952
+ inputSchema: inputSchema17,
953
+ // Deletes hand-added keywords, and putting them back can cost Dive tokens on a stale niche.
954
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
955
+ handler: async (args, ctx) => {
956
+ return await httpPost(
957
+ { config: ctx.config, toolName: "remove_niche_keywords" },
958
+ `/v1/niches/${encodeURIComponent(args.nicheId)}/keywords/remove`,
959
+ { keywords: args.keywords }
960
+ );
961
+ }
962
+ };
963
+
964
+ // src/tools/keyword-exclusions-input.ts
965
+ import { z as z18 } from "zod";
966
+ var entries = (field) => uniqueKeywords(z18.array(nicheKeyword()).max(KEYWORD_EXCLUSIONS_MAX_PER_CALL), field).optional();
967
+ var keywordExclusionsInputSchema = (verb) => ({
968
+ nicheId: z18.string().min(1).describe("The niche whose keyword exclusions to change. Get one from `list_niches`."),
969
+ exact: entries("exact").describe(
970
+ `Exact-match entries to ${verb}: each one hides the single keyword that matches it exactly. At most 255 characters each; lower-cased and trimmed, and must be unique after that.`
971
+ ),
972
+ phrase: entries("phrase").describe(
973
+ `Phrase-match entries to ${verb}: each one hides every keyword that contains the phrase (e.g. "puppy" hides "puppy hat" and "hat for puppy"). At most 255 characters each; lower-cased and trimmed, and must be unique after that.`
974
+ )
975
+ });
976
+ function assertExclusionCount(exact, phrase) {
977
+ const total = (exact?.length ?? 0) + (phrase?.length ?? 0);
978
+ if (total === 0 || total > KEYWORD_EXCLUSIONS_MAX_PER_CALL) {
979
+ throw new ApiError(
980
+ "bad_request",
981
+ 400,
982
+ `Send 1 to ${KEYWORD_EXCLUSIONS_MAX_PER_CALL} entries in total across \`exact\` and \`phrase\` (got ${total}). Split a longer list over several calls.`
983
+ );
984
+ }
985
+ }
986
+
987
+ // src/tools/add-keyword-exclusions.ts
988
+ var inputSchema18 = keywordExclusionsInputSchema("exclude");
989
+ var addKeywordExclusionsTool = {
990
+ name: "add_keyword_exclusions",
991
+ title: "Exclude Keywords from a Niche",
992
+ description: `Use this to hide irrelevant keywords from a niche's Master Keyword List \u2014 e.g. other brands, wrong product types. \`exact\` entries hide the one keyword that matches exactly; \`phrase\` entries hide every keyword containing the phrase, so prefer \`exact\` unless the user wants a whole family of keywords gone. The excluded keywords drop out of \`get_niche_keywords\` at once, wherever they come from: the dive, Outliers, Residue, or ones added with \`add_niche_keywords\`. Nothing is deleted: \`remove_keyword_exclusions\` brings them back. Only the exclusions change \u2014 every other niche setting is kept. Send 1\u2013${KEYWORD_EXCLUSIONS_MAX_PER_CALL} entries in total across \`exact\` and \`phrase\`; a niche can hold at most ${KEYWORD_EXCLUSIONS_MAX_PER_NICHE} exclusions. Free, no tokens, and safe to repeat: entries already excluded come back under \`unchanged\`. Returns \`added\`, \`unchanged\` and the full \`exact\` / \`phrase\` lists after the change. Limited to 30 calls per minute per niche, so batch entries into one call.`,
993
+ inputSchema: inputSchema18,
994
+ // Hides data from every MKL-based view until undone; reversible, but clients should prompt on it.
995
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
996
+ handler: async (args, ctx) => {
997
+ assertExclusionCount(args.exact, args.phrase);
998
+ return await httpPost(
999
+ { config: ctx.config, toolName: "add_keyword_exclusions" },
1000
+ `/v1/niches/${encodeURIComponent(args.nicheId)}/keyword-exclusions`,
1001
+ { exact: args.exact, phrase: args.phrase }
1002
+ );
1003
+ }
1004
+ };
1005
+
1006
+ // src/tools/remove-keyword-exclusions.ts
1007
+ var inputSchema19 = keywordExclusionsInputSchema("stop excluding");
1008
+ var removeKeywordExclusionsTool = {
1009
+ name: "remove_keyword_exclusions",
1010
+ title: "Remove Keyword Exclusions from a Niche",
1011
+ description: `Use this to undo \`add_keyword_exclusions\`, so the keywords an exclusion hid show in the niche's Master Keyword List (\`get_niche_keywords\`) again. Pass the entries exactly as \`list_keyword_exclusions\` shows them, \`exact\` and \`phrase\` separately: removing a phrase does not touch an exact entry for the same text, and a keyword also hidden by another remaining exclusion stays hidden. Only the exclusions change \u2014 every other niche setting is kept. Send 1\u2013${KEYWORD_EXCLUSIONS_MAX_PER_CALL} entries in total across \`exact\` and \`phrase\`. Free, and safe to repeat: entries that are not excluded come back under \`unchanged\`. Returns \`removed\`, \`unchanged\` and the full \`exact\` / \`phrase\` lists after the change. Limited to 30 calls per minute per niche.`,
1012
+ inputSchema: inputSchema19,
1013
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1014
+ handler: async (args, ctx) => {
1015
+ assertExclusionCount(args.exact, args.phrase);
1016
+ return await httpPost(
1017
+ { config: ctx.config, toolName: "remove_keyword_exclusions" },
1018
+ `/v1/niches/${encodeURIComponent(args.nicheId)}/keyword-exclusions/remove`,
1019
+ { exact: args.exact, phrase: args.phrase }
1020
+ );
1021
+ }
1022
+ };
1023
+
816
1024
  // src/tools/delete-niche.ts
817
- import { z as z14 } from "zod";
818
- var inputSchema15 = {
819
- nicheId: z14.string().min(1).describe("The niche to delete. Get one from `list_niches`."),
820
- confirm: z14.boolean().optional().describe(
1025
+ import { z as z19 } from "zod";
1026
+ var inputSchema20 = {
1027
+ nicheId: z19.string().min(1).describe("The niche to delete. Get one from `list_niches`."),
1028
+ confirm: z19.boolean().optional().describe(
821
1029
  "Must be true to proceed \u2014 deleting a niche destroys its keywords, competitors and dive history permanently. Confirm with the user first."
822
1030
  )
823
1031
  };
@@ -825,7 +1033,7 @@ var deleteNicheTool = {
825
1033
  name: "delete_niche",
826
1034
  title: "Delete a Niche",
827
1035
  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).",
828
- inputSchema: inputSchema15,
1036
+ inputSchema: inputSchema20,
829
1037
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
830
1038
  handler: async (args, ctx) => {
831
1039
  const pending = requireConfirmation(
@@ -843,15 +1051,15 @@ var deleteNicheTool = {
843
1051
  };
844
1052
 
845
1053
  // src/tools/pause-rank-radar.ts
846
- import { z as z15 } from "zod";
847
- var inputSchema16 = {
848
- rankRadarId: z15.string().uuid().describe("The Rank Radar UUID to pause (from `list_rank_radars`).")
1054
+ import { z as z20 } from "zod";
1055
+ var inputSchema21 = {
1056
+ rankRadarId: z20.string().uuid().describe("The Rank Radar UUID to pause (from `list_rank_radars`).")
849
1057
  };
850
1058
  var pauseRankRadarTool = {
851
1059
  name: "pause_rank_radar",
852
1060
  title: "Pause a Rank Radar",
853
1061
  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.",
854
- inputSchema: inputSchema16,
1062
+ inputSchema: inputSchema21,
855
1063
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
856
1064
  handler: async (args, ctx) => {
857
1065
  await httpPost(
@@ -864,15 +1072,15 @@ var pauseRankRadarTool = {
864
1072
  };
865
1073
 
866
1074
  // src/tools/resume-rank-radar.ts
867
- import { z as z16 } from "zod";
868
- var inputSchema17 = {
869
- rankRadarId: z16.string().uuid().describe("The Rank Radar UUID to resume (from `list_rank_radars`).")
1075
+ import { z as z21 } from "zod";
1076
+ var inputSchema22 = {
1077
+ rankRadarId: z21.string().uuid().describe("The Rank Radar UUID to resume (from `list_rank_radars`).")
870
1078
  };
871
1079
  var resumeRankRadarTool = {
872
1080
  name: "resume_rank_radar",
873
1081
  title: "Resume a Paused Rank Radar",
874
1082
  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.",
875
- inputSchema: inputSchema17,
1083
+ inputSchema: inputSchema22,
876
1084
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
877
1085
  handler: async (args, ctx) => {
878
1086
  await httpPost(
@@ -885,10 +1093,10 @@ var resumeRankRadarTool = {
885
1093
  };
886
1094
 
887
1095
  // src/tools/delete-rank-radar.ts
888
- import { z as z17 } from "zod";
889
- var inputSchema18 = {
890
- rankRadarId: z17.string().uuid().describe("The Rank Radar UUID to delete (from `list_rank_radars`)."),
891
- confirm: z17.boolean().optional().describe(
1096
+ import { z as z22 } from "zod";
1097
+ var inputSchema23 = {
1098
+ rankRadarId: z22.string().uuid().describe("The Rank Radar UUID to delete (from `list_rank_radars`)."),
1099
+ confirm: z22.boolean().optional().describe(
892
1100
  "Must be true to proceed \u2014 deleting a Rank Radar destroys its ranking history permanently. Confirm with the user first."
893
1101
  )
894
1102
  };
@@ -896,7 +1104,7 @@ var deleteRankRadarTool = {
896
1104
  name: "delete_rank_radar",
897
1105
  title: "Delete a Rank Radar",
898
1106
  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`.",
899
- inputSchema: inputSchema18,
1107
+ inputSchema: inputSchema23,
900
1108
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
901
1109
  handler: async (args, ctx) => {
902
1110
  const pending = requireConfirmation(
@@ -914,10 +1122,10 @@ var deleteRankRadarTool = {
914
1122
  };
915
1123
 
916
1124
  // src/tools/add-rank-radar-search-terms.ts
917
- import { z as z18 } from "zod";
918
- var inputSchema19 = {
919
- rankRadarId: z18.string().uuid().describe("The Rank Radar UUID to add the search terms to (from `list_rank_radars`)."),
920
- searchTerms: z18.array(z18.string().min(1)).min(1).max(ADD_SEARCH_TERMS_MAX).describe(
1125
+ import { z as z23 } from "zod";
1126
+ var inputSchema24 = {
1127
+ rankRadarId: z23.string().uuid().describe("The Rank Radar UUID to add the search terms to (from `list_rank_radars`)."),
1128
+ searchTerms: z23.array(z23.string().min(1)).min(1).max(ADD_SEARCH_TERMS_MAX).describe(
921
1129
  `The keywords to start tracking, 1\u2013${ADD_SEARCH_TERMS_MAX} per call. Must be unique. Amazon-ignored special characters (@, #, _, parentheses, \u2026) are rejected.`
922
1130
  )
923
1131
  };
@@ -925,7 +1133,7 @@ var addRankRadarSearchTermsTool = {
925
1133
  name: "add_rank_radar_search_terms",
926
1134
  title: "Add Search Terms to a Rank Radar",
927
1135
  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.",
928
- inputSchema: inputSchema19,
1136
+ inputSchema: inputSchema24,
929
1137
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
930
1138
  handler: async (args, ctx) => {
931
1139
  return await httpPost(
@@ -937,10 +1145,10 @@ var addRankRadarSearchTermsTool = {
937
1145
  };
938
1146
 
939
1147
  // src/tools/pause-rank-radar-search-terms.ts
940
- import { z as z19 } from "zod";
941
- var inputSchema20 = {
942
- rankRadarId: z19.string().uuid().describe("The Rank Radar UUID the search terms belong to."),
943
- rankRadarKeywordIds: z19.array(z19.string().uuid()).min(1).describe(
1148
+ import { z as z24 } from "zod";
1149
+ var inputSchema25 = {
1150
+ rankRadarId: z24.string().uuid().describe("The Rank Radar UUID the search terms belong to."),
1151
+ rankRadarKeywordIds: z24.array(z24.string().uuid()).min(1).describe(
944
1152
  "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."
945
1153
  )
946
1154
  };
@@ -948,7 +1156,7 @@ var pauseRankRadarSearchTermsTool = {
948
1156
  name: "pause_rank_radar_search_terms",
949
1157
  title: "Pause Search Terms of a Rank Radar",
950
1158
  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.",
951
- inputSchema: inputSchema20,
1159
+ inputSchema: inputSchema25,
952
1160
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
953
1161
  handler: async (args, ctx) => {
954
1162
  await httpPost(
@@ -965,10 +1173,10 @@ var pauseRankRadarSearchTermsTool = {
965
1173
  };
966
1174
 
967
1175
  // src/tools/resume-rank-radar-search-terms.ts
968
- import { z as z20 } from "zod";
969
- var inputSchema21 = {
970
- rankRadarId: z20.string().uuid().describe("The Rank Radar UUID the search terms belong to."),
971
- rankRadarKeywordIds: z20.array(z20.string().uuid()).min(1).describe(
1176
+ import { z as z25 } from "zod";
1177
+ var inputSchema26 = {
1178
+ rankRadarId: z25.string().uuid().describe("The Rank Radar UUID the search terms belong to."),
1179
+ rankRadarKeywordIds: z25.array(z25.string().uuid()).min(1).describe(
972
1180
  "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."
973
1181
  )
974
1182
  };
@@ -976,7 +1184,7 @@ var resumeRankRadarSearchTermsTool = {
976
1184
  name: "resume_rank_radar_search_terms",
977
1185
  title: "Resume Paused Search Terms of a Rank Radar",
978
1186
  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.",
979
- inputSchema: inputSchema21,
1187
+ inputSchema: inputSchema26,
980
1188
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
981
1189
  handler: async (args, ctx) => {
982
1190
  await httpPost(
@@ -992,17 +1200,193 @@ var resumeRankRadarSearchTermsTool = {
992
1200
  }
993
1201
  };
994
1202
 
1203
+ // src/tools/list-rank-radar-tags.ts
1204
+ import { z as z26 } from "zod";
1205
+ var LIST_RANK_RADAR_TAGS_MAX_PAGE_SIZE = 50;
1206
+ var inputSchema27 = {
1207
+ rankRadarId: z26.string().uuid().describe("The Rank Radar UUID whose tags to list (from `list_rank_radars`)."),
1208
+ currentPage: z26.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1209
+ pageSize: z26.number().int().min(1).max(LIST_RANK_RADAR_TAGS_MAX_PAGE_SIZE).optional().describe(`Items per page (max ${LIST_RANK_RADAR_TAGS_MAX_PAGE_SIZE}). Defaults to 20.`)
1210
+ };
1211
+ var listRankRadarTagsTool = {
1212
+ name: "list_rank_radar_tags",
1213
+ title: "List Tags of a Rank Radar",
1214
+ description: `Use this to find a \`tagId\` before calling \`update_rank_radar_tag\`, \`delete_rank_radar_tag\`, \`add_rank_radar_tag_search_terms\` or \`remove_rank_radar_tag_search_terms\`. Returns the user tags ("highlights") on the specified Rank Radar, ordered by title (case-insensitive, ascending). Each row carries \`id\`, \`title\`, \`color\`, \`description\`, \`startAt\`, \`endAt\`, \`createdAt\`, and \`keywordCount\` \u2014 the number of Rank Radar keywords this tag is applied to. The system "paused" tag (the one the quota pauser writes with a reserved colour) is not listed and cannot be addressed from these tools. Supports pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev); a page holds at most ${LIST_RANK_RADAR_TAGS_MAX_PAGE_SIZE} tags.`,
1215
+ inputSchema: inputSchema27,
1216
+ annotations: { readOnlyHint: true },
1217
+ handler: async (args, ctx) => {
1218
+ return await httpGet(
1219
+ { config: ctx.config, toolName: "list_rank_radar_tags" },
1220
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/tags`,
1221
+ {
1222
+ currentPage: args.currentPage,
1223
+ pageSize: args.pageSize
1224
+ }
1225
+ );
1226
+ }
1227
+ };
1228
+
1229
+ // src/tools/create-rank-radar-tag.ts
1230
+ import { z as z27 } from "zod";
1231
+ var inputSchema28 = {
1232
+ rankRadarId: z27.string().uuid().describe("The Rank Radar UUID to create the tag on (from `list_rank_radars`)."),
1233
+ title: z27.string().min(1).max(TAG_TITLE_MAX_LENGTH).describe(
1234
+ `Display title (1\u2013${TAG_TITLE_MAX_LENGTH} characters, trimmed on write). Must be unique on this Rank Radar, case-insensitive. A clash returns 409 with \`{ error: 'TAG_TITLE_EXISTS', existingTagId }\` \u2014 reuse that id instead of retrying.`
1235
+ ),
1236
+ color: z27.string().regex(TAG_HEX_COLOR_PATTERN, "color must be in #RRGGBB form").optional().describe(
1237
+ `Hex colour in \`#RRGGBB\` form. Defaults to the UI grey when omitted. The reserved colour \`${TAG_RESERVED_COLOR}\` (used by the system "paused" tag) is rejected with 400.`
1238
+ ),
1239
+ description: z27.string().optional().describe("Free-form description, e.g. 'Prime Day run-up'."),
1240
+ startAt: z27.string().optional().describe("ISO 8601 start date, e.g. '2026-07-01'. Required if `endAt` is set; `endAt >= startAt`."),
1241
+ endAt: z27.string().optional().describe("ISO 8601 end date, e.g. '2026-07-14'. Must be greater than or equal to `startAt`."),
1242
+ rankRadarKeywordIds: z27.array(z27.string().uuid()).min(1).max(TAG_KEYWORD_IDS_MAX).optional().describe(
1243
+ `Optional: Rank Radar keyword ids to tag on creation (1\u2013${TAG_KEYWORD_IDS_MAX}). These are the \`id\` values from \`get_rank_radar_data\`; the ids must all belong to this Rank Radar. To attach more later, use \`add_rank_radar_tag_search_terms\`.`
1244
+ )
1245
+ };
1246
+ var createRankRadarTagTool = {
1247
+ name: "create_rank_radar_tag",
1248
+ title: "Create a Rank Radar Tag",
1249
+ description: `Use this to create a new user tag ("highlight") on a Rank Radar \u2014 the way the UI marks a window on the ranking chart. Writing a tag costs nothing and is reversible with \`delete_rank_radar_tag\`, so no confirmation is required. Returns the new tag row (\`id\`, \`title\`, \`color\`, \`description\`, \`startAt\`, \`endAt\`, \`keywordCount\`, \`createdAt\`); the \`id\` is the \`tagId\` the other tag tools take. If the title clashes with an existing tag on this Rank Radar, the API answers 409 \`{ error: 'TAG_TITLE_EXISTS', existingTagId }\` so callers can reuse the existing tag without a follow-up \`list_rank_radar_tags\`. The reserved colour \`${TAG_RESERVED_COLOR}\` is rejected with 400. Pass \`rankRadarKeywordIds\` to tag a batch of keywords in the same call; otherwise create the tag and attach keywords later with \`add_rank_radar_tag_search_terms\`.`,
1250
+ inputSchema: inputSchema28,
1251
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1252
+ handler: async (args, ctx) => {
1253
+ const body = { title: args.title };
1254
+ if (args.color !== void 0) body.color = args.color;
1255
+ if (args.description !== void 0) body.description = args.description;
1256
+ if (args.startAt !== void 0) body.startAt = args.startAt;
1257
+ if (args.endAt !== void 0) body.endAt = args.endAt;
1258
+ if (args.rankRadarKeywordIds !== void 0) body.rankRadarKeywordIds = args.rankRadarKeywordIds;
1259
+ return await httpPost(
1260
+ { config: ctx.config, toolName: "create_rank_radar_tag" },
1261
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/tags`,
1262
+ body
1263
+ );
1264
+ }
1265
+ };
1266
+
1267
+ // src/tools/update-rank-radar-tag.ts
1268
+ import { z as z28 } from "zod";
1269
+ var inputSchema29 = {
1270
+ rankRadarId: z28.string().uuid().describe("The Rank Radar UUID the tag belongs to (from `list_rank_radars`)."),
1271
+ tagId: z28.string().uuid().describe("The tag UUID to update (the `id` from `list_rank_radar_tags` or `create_rank_radar_tag`)."),
1272
+ title: z28.string().min(1).max(TAG_TITLE_MAX_LENGTH).optional().describe(
1273
+ `New title (1\u2013${TAG_TITLE_MAX_LENGTH} characters, trimmed on write). Must be unique on this Rank Radar, case-insensitive. A clash returns 409 with \`{ error: 'TAG_TITLE_EXISTS', existingTagId }\`.`
1274
+ ),
1275
+ color: z28.string().regex(TAG_HEX_COLOR_PATTERN, "color must be in #RRGGBB form").optional().describe(`Hex colour in \`#RRGGBB\` form. The reserved colour \`${TAG_RESERVED_COLOR}\` is rejected with 400.`),
1276
+ description: z28.string().optional().describe("Free-form description. Pass an empty string to clear."),
1277
+ startAt: z28.string().optional().describe("ISO 8601 start date, e.g. '2026-07-01'. `endAt >= startAt`."),
1278
+ endAt: z28.string().optional().describe("ISO 8601 end date, e.g. '2026-07-14'. `endAt >= startAt`.")
1279
+ };
1280
+ var updateRankRadarTagTool = {
1281
+ name: "update_rank_radar_tag",
1282
+ title: "Update a Rank Radar Tag",
1283
+ description: "Use this to change a tag's title, colour, description, or date window. Partial update: only the fields you pass are modified, the rest are left as they are. The system \"paused\" tag (reserved colour, written by the quota pauser) cannot be addressed from here \u2014 the API answers 404. Writing a tag costs nothing and is reversible, so no confirmation is required. Returns the updated tag row. Title clashes return 409 `{ error: 'TAG_TITLE_EXISTS', existingTagId }`; the reserved colour returns 400; and `endAt < startAt` returns 400 (for whichever side the body omits, the comparison uses the stored value).",
1284
+ inputSchema: inputSchema29,
1285
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1286
+ handler: async (args, ctx) => {
1287
+ const body = {};
1288
+ if (args.title !== void 0) body.title = args.title;
1289
+ if (args.color !== void 0) body.color = args.color;
1290
+ if (args.description !== void 0) body.description = args.description;
1291
+ if (args.startAt !== void 0) body.startAt = args.startAt;
1292
+ if (args.endAt !== void 0) body.endAt = args.endAt;
1293
+ return await httpPatch(
1294
+ { config: ctx.config, toolName: "update_rank_radar_tag" },
1295
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/tags/${encodeURIComponent(args.tagId)}`,
1296
+ body
1297
+ );
1298
+ }
1299
+ };
1300
+
1301
+ // src/tools/delete-rank-radar-tag.ts
1302
+ import { z as z29 } from "zod";
1303
+ var inputSchema30 = {
1304
+ rankRadarId: z29.string().uuid().describe("The Rank Radar UUID the tag belongs to (from `list_rank_radars`)."),
1305
+ tagId: z29.string().uuid().describe("The tag UUID to delete (the `id` from `list_rank_radar_tags`)."),
1306
+ confirm: z29.boolean().optional().describe(
1307
+ "Must be true to proceed. Confirm with the user first \u2014 the tag's keyword assignments are removed too and the tag cannot be recovered."
1308
+ )
1309
+ };
1310
+ var deleteRankRadarTagTool = {
1311
+ name: "delete_rank_radar_tag",
1312
+ title: "Delete a Rank Radar Tag",
1313
+ description: 'Use this to permanently remove a tag from a Rank Radar. \u26A0\uFE0F The tag itself is gone and the assignments linking it to each tagged keyword are removed with it; the keywords themselves keep tracking. The deletion cannot be undone from this tool, so set `confirm: true` only after the user approves. The system "paused" tag (reserved colour, written by the quota pauser) cannot be addressed from here \u2014 the API answers 404. To remove just the assignments and keep the tag, use `remove_rank_radar_tag_search_terms` instead.',
1314
+ inputSchema: inputSchema30,
1315
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1316
+ handler: async (args, ctx) => {
1317
+ const pending = requireConfirmation(
1318
+ args.confirm,
1319
+ ctx,
1320
+ "Deleting this tag removes it from every keyword it was applied to. The tag cannot be recovered \u2014 if the user only wants to clear its keyword list, use `remove_rank_radar_tag_search_terms`."
1321
+ );
1322
+ if (pending) return pending;
1323
+ await httpDelete(
1324
+ { config: ctx.config, toolName: "delete_rank_radar_tag" },
1325
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/tags/${encodeURIComponent(args.tagId)}`
1326
+ );
1327
+ return { status: "deleted", rankRadarId: args.rankRadarId, tagId: args.tagId };
1328
+ }
1329
+ };
1330
+
1331
+ // src/tools/add-rank-radar-tag-search-terms.ts
1332
+ import { z as z30 } from "zod";
1333
+ var inputSchema31 = {
1334
+ rankRadarId: z30.string().uuid().describe("The Rank Radar UUID the tag belongs to (from `list_rank_radars`)."),
1335
+ tagId: z30.string().uuid().describe("The tag UUID to attach keywords to (the `id` from `list_rank_radar_tags`)."),
1336
+ rankRadarKeywordIds: z30.array(z30.string().uuid()).min(1).max(TAG_KEYWORD_IDS_MAX).describe(
1337
+ `Rank Radar keyword ids to attach to this tag (1\u2013${TAG_KEYWORD_IDS_MAX} per call, unique). These are the \`id\` values from \`get_rank_radar_data\`; all ids must belong to this Rank Radar. Safe to repeat: keywords already attached are left unchanged.`
1338
+ )
1339
+ };
1340
+ var addRankRadarTagSearchTermsTool = {
1341
+ name: "add_rank_radar_tag_search_terms",
1342
+ title: "Attach Search Terms to a Rank Radar Tag",
1343
+ description: `Use this to tag a batch of keywords on a Rank Radar \u2014 the same relation \`create_rank_radar_tag\` writes when \`rankRadarKeywordIds\` is passed on creation, so this is how you keep extending a tag's keyword set over time. Reversible with \`remove_rank_radar_tag_search_terms\`, so no confirmation is required. Idempotent: already-attached keywords are left unchanged, so re-sending the same ids after a timeout is safe. Up to ${TAG_KEYWORD_IDS_MAX} ids per call \u2014 split larger batches into multiple calls. The system "paused" tag (reserved colour, written by the quota pauser) is not addressable: the API answers 404.`,
1344
+ inputSchema: inputSchema31,
1345
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1346
+ handler: async (args, ctx) => {
1347
+ return await httpPost(
1348
+ { config: ctx.config, toolName: "add_rank_radar_tag_search_terms" },
1349
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/tags/${encodeURIComponent(args.tagId)}/search-terms`,
1350
+ { rankRadarKeywordIds: args.rankRadarKeywordIds }
1351
+ );
1352
+ }
1353
+ };
1354
+
1355
+ // src/tools/remove-rank-radar-tag-search-terms.ts
1356
+ import { z as z31 } from "zod";
1357
+ var inputSchema32 = {
1358
+ rankRadarId: z31.string().uuid().describe("The Rank Radar UUID the tag belongs to (from `list_rank_radars`)."),
1359
+ tagId: z31.string().uuid().describe("The tag UUID to detach keywords from (the `id` from `list_rank_radar_tags`)."),
1360
+ rankRadarKeywordIds: z31.array(z31.string().uuid()).min(1).max(TAG_KEYWORD_IDS_MAX).describe(
1361
+ `Rank Radar keyword ids to detach from this tag (1\u2013${TAG_KEYWORD_IDS_MAX} per call, unique). These are the \`id\` values from \`get_rank_radar_data\`. Safe to repeat: keywords that are not currently attached are left unchanged.`
1362
+ )
1363
+ };
1364
+ var removeRankRadarTagSearchTermsTool = {
1365
+ name: "remove_rank_radar_tag_search_terms",
1366
+ title: "Detach Search Terms from a Rank Radar Tag",
1367
+ description: `Use this to remove keywords from a tag without deleting the tag itself. The tag keeps its title, colour and date window; only the keyword assignments listed are cleared. Reversible with \`add_rank_radar_tag_search_terms\`, so no confirmation is required. Idempotent: ids that are not currently attached are left unchanged, so re-sending the same ids after a timeout is safe. Up to ${TAG_KEYWORD_IDS_MAX} ids per call \u2014 split larger batches into multiple calls. To remove the tag itself, use \`delete_rank_radar_tag\`. The system "paused" tag (reserved colour, written by the quota pauser) is not addressable: the API answers 404.`,
1368
+ inputSchema: inputSchema32,
1369
+ annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1370
+ handler: async (args, ctx) => {
1371
+ return await httpPost(
1372
+ { config: ctx.config, toolName: "remove_rank_radar_tag_search_terms" },
1373
+ `/v1/niches/rank-radars/${encodeURIComponent(args.rankRadarId)}/tags/${encodeURIComponent(args.tagId)}/search-terms/remove`,
1374
+ { rankRadarKeywordIds: args.rankRadarKeywordIds }
1375
+ );
1376
+ }
1377
+ };
1378
+
995
1379
  // src/tools/generate-listing-copy.ts
996
- import { z as z21 } from "zod";
997
- var inputSchema22 = {
998
- nicheId: z21.string().min(1).describe("The niche whose keyword data the copy is written from. Get one from `list_niches`."),
999
- strategy: z21.enum(LISTING_COPY_STRATEGIES).describe(
1380
+ import { z as z32 } from "zod";
1381
+ var inputSchema33 = {
1382
+ nicheId: z32.string().min(1).describe("The niche whose keyword data the copy is written from. Get one from `list_niches`."),
1383
+ strategy: z32.enum(LISTING_COPY_STRATEGIES).describe(
1000
1384
  "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."
1001
1385
  ),
1002
- currentListing: z21.record(z21.union([z21.string(), z21.array(z21.string())])).describe(
1386
+ currentListing: z32.record(z32.union([z32.string(), z32.array(z32.string())])).describe(
1003
1387
  '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.'
1004
1388
  ),
1005
- confirm: z21.boolean().optional().describe(
1389
+ confirm: z32.boolean().optional().describe(
1006
1390
  "Must be true to proceed \u2014 each generation spends one AI Copywriter prompt from the quota. Confirm the cost with the user first."
1007
1391
  )
1008
1392
  };
@@ -1010,7 +1394,7 @@ var generateListingCopyTool = {
1010
1394
  name: "generate_listing_copy",
1011
1395
  title: "Generate Listing Copy for a Niche",
1012
1396
  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`.",
1013
- inputSchema: inputSchema22,
1397
+ inputSchema: inputSchema33,
1014
1398
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
1015
1399
  handler: async (args, ctx) => {
1016
1400
  const pending = requireConfirmation(
@@ -1028,16 +1412,16 @@ var generateListingCopyTool = {
1028
1412
  };
1029
1413
 
1030
1414
  // src/tools/get-listing-copy-generation-status.ts
1031
- import { z as z22 } from "zod";
1032
- var inputSchema23 = {
1033
- nicheId: z22.string().min(1).describe("The niche the generation was started for."),
1034
- generationId: z22.string().min(1).describe("The `generationId` returned by `generate_listing_copy`.")
1415
+ import { z as z33 } from "zod";
1416
+ var inputSchema34 = {
1417
+ nicheId: z33.string().min(1).describe("The niche the generation was started for."),
1418
+ generationId: z33.string().min(1).describe("The `generationId` returned by `generate_listing_copy`.")
1035
1419
  };
1036
1420
  var getListingCopyGenerationStatusTool = {
1037
1421
  name: "get_listing_copy_generation_status",
1038
1422
  title: "Get Listing Copy Generation Status",
1039
1423
  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`.",
1040
- inputSchema: inputSchema23,
1424
+ inputSchema: inputSchema34,
1041
1425
  annotations: { readOnlyHint: true },
1042
1426
  handler: async (args, ctx) => {
1043
1427
  return await httpGet(
@@ -1048,16 +1432,16 @@ var getListingCopyGenerationStatusTool = {
1048
1432
  };
1049
1433
 
1050
1434
  // src/tools/list-seller-profiles.ts
1051
- import { z as z23 } from "zod";
1052
- var inputSchema24 = {
1053
- currentPage: z23.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1054
- pageSize: z23.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1435
+ import { z as z34 } from "zod";
1436
+ var inputSchema35 = {
1437
+ currentPage: z34.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1438
+ pageSize: z34.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1055
1439
  };
1056
1440
  var listSellerProfilesTool = {
1057
1441
  name: "list_seller_profiles",
1058
1442
  title: "List Connected Amazon Seller Profiles",
1059
1443
  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).',
1060
- inputSchema: inputSchema24,
1444
+ inputSchema: inputSchema35,
1061
1445
  annotations: { readOnlyHint: true },
1062
1446
  handler: async (args, ctx) => {
1063
1447
  return await httpGet(
@@ -1072,15 +1456,15 @@ var listSellerProfilesTool = {
1072
1456
  };
1073
1457
 
1074
1458
  // src/tools/get-seller-catalog.ts
1075
- import { z as z25 } from "zod";
1459
+ import { z as z36 } from "zod";
1076
1460
 
1077
1461
  // src/tools/seller-scoped.ts
1078
- import { z as z24 } from "zod";
1462
+ import { z as z35 } from "zod";
1079
1463
  var sellerScopedInputSchema = {
1080
- sellerId: z24.string().min(1).describe(
1464
+ sellerId: z35.string().min(1).describe(
1081
1465
  "Amazon seller account ID. Get it from `list_seller_profiles`, or find it on the Connections page at https://2.datadive.tools."
1082
1466
  ),
1083
- marketplace: z24.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.')
1467
+ marketplace: z35.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.')
1084
1468
  };
1085
1469
  function sellerMarketplacePath(sellerId, marketplace, suffix) {
1086
1470
  return `/v1/seller_profiles/${encodeURIComponent(sellerId)}/marketplaces/${encodeURIComponent(
@@ -1089,19 +1473,19 @@ function sellerMarketplacePath(sellerId, marketplace, suffix) {
1089
1473
  }
1090
1474
 
1091
1475
  // src/tools/get-seller-catalog.ts
1092
- var inputSchema25 = {
1476
+ var inputSchema36 = {
1093
1477
  ...sellerScopedInputSchema,
1094
- search: z25.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
1095
- brand: z25.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
1096
- status: z25.enum(CATALOG_STATUSES).optional().describe('Listing status filter. "Active" (default) or "all".'),
1097
- currentPage: z25.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1098
- pageSize: z25.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1478
+ search: z36.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
1479
+ brand: z36.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
1480
+ status: z36.enum(CATALOG_STATUSES).optional().describe('Listing status filter. "Active" (default) or "all".'),
1481
+ currentPage: z36.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1482
+ pageSize: z36.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1099
1483
  };
1100
1484
  var getSellerCatalogTool = {
1101
1485
  name: "get_seller_catalog",
1102
1486
  title: "List Catalog ASINs for a Seller",
1103
1487
  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).",
1104
- inputSchema: inputSchema25,
1488
+ inputSchema: inputSchema36,
1105
1489
  annotations: { readOnlyHint: true },
1106
1490
  handler: async (args, ctx) => {
1107
1491
  return await httpGet(
@@ -1119,28 +1503,28 @@ var getSellerCatalogTool = {
1119
1503
  };
1120
1504
 
1121
1505
  // src/tools/get-seller-listing-changes.ts
1122
- import { z as z26 } from "zod";
1123
- var inputSchema26 = {
1506
+ import { z as z37 } from "zod";
1507
+ var inputSchema37 = {
1124
1508
  ...sellerScopedInputSchema,
1125
- types: z26.array(z26.enum(LISTING_CHANGE_TYPES)).min(1).optional().describe('Filter to specific change types. Omit for all. Any of "Price", "Content", "Image".'),
1126
- asin: z26.string().min(1).optional().describe("Filter to an exact ASIN or parent ASIN."),
1127
- brand: z26.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
1128
- search: z26.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
1129
- startDate: z26.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."),
1130
- endDate: z26.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."),
1131
- sortBy: z26.enum(LISTING_CHANGE_SORT_BY).optional().describe('Sort field. "date" (default) or "type".'),
1132
- sortOrder: z26.enum(SORT_ORDER).optional().describe('Sort direction. "DESC" (default) or "ASC".'),
1133
- includeCorrelations: z26.boolean().optional().describe(
1509
+ types: z37.array(z37.enum(LISTING_CHANGE_TYPES)).min(1).optional().describe('Filter to specific change types. Omit for all. Any of "Price", "Content", "Image".'),
1510
+ asin: z37.string().min(1).optional().describe("Filter to an exact ASIN or parent ASIN."),
1511
+ brand: z37.string().min(1).optional().describe("Case-insensitive partial match on brand name."),
1512
+ search: z37.string().min(1).optional().describe("Case-insensitive partial match on product title or brand."),
1513
+ startDate: z37.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."),
1514
+ endDate: z37.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."),
1515
+ sortBy: z37.enum(LISTING_CHANGE_SORT_BY).optional().describe('Sort field. "date" (default) or "type".'),
1516
+ sortOrder: z37.enum(SORT_ORDER).optional().describe('Sort direction. "DESC" (default) or "ASC".'),
1517
+ includeCorrelations: z37.boolean().optional().describe(
1134
1518
  "When true, include the ranking/conversion `correlation` object per change (CVR and search-term movement before vs after). Defaults to false."
1135
1519
  ),
1136
- currentPage: z26.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1137
- pageSize: z26.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1520
+ currentPage: z37.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1521
+ pageSize: z37.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1138
1522
  };
1139
1523
  var getSellerListingChangesTool = {
1140
1524
  name: "get_seller_listing_changes",
1141
1525
  title: "List Listing Changes for a Seller",
1142
1526
  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).",
1143
- inputSchema: inputSchema26,
1527
+ inputSchema: inputSchema37,
1144
1528
  annotations: { readOnlyHint: true },
1145
1529
  handler: async (args, ctx) => {
1146
1530
  return await httpGet(
@@ -1165,40 +1549,40 @@ var getSellerListingChangesTool = {
1165
1549
  };
1166
1550
 
1167
1551
  // src/tools/list-ppc-campaigns.ts
1168
- import { z as z27 } from "zod";
1552
+ import { z as z38 } from "zod";
1169
1553
  var PPC_CAMPAIGNS_MAX_WINDOW_DAYS = 90;
1170
1554
  var PPC_CAMPAIGNS_MAX_PAGE_SIZE = 50;
1171
- var inputSchema27 = {
1555
+ var inputSchema38 = {
1172
1556
  ...sellerScopedInputSchema,
1173
- startDate: z27.string().regex(
1557
+ startDate: z38.string().regex(
1174
1558
  ISO_8601,
1175
1559
  "startDate must be an ISO-8601 date or timestamp (e.g. 2026-05-01 or 2026-05-01T00:00:00Z)"
1176
1560
  ).optional().describe("Start of the reporting window, ISO-8601. Defaults to 30 days before endDate."),
1177
- endDate: z27.string().regex(
1561
+ endDate: z38.string().regex(
1178
1562
  ISO_8601,
1179
1563
  "endDate must be an ISO-8601 date or timestamp (e.g. 2026-05-31 or 2026-05-31T23:59:59Z)"
1180
1564
  ).optional().describe(
1181
1565
  `End of the reporting window, ISO-8601. Defaults to now. At most ${PPC_CAMPAIGNS_MAX_WINDOW_DAYS} days after startDate.`
1182
1566
  ),
1183
- asin: z27.string().min(1).optional().describe("Only campaigns advertising this ASIN. Cannot be combined with parentAsin."),
1184
- parentAsin: z27.string().min(1).optional().describe("Only campaigns advertising any ASIN of this variation family. Cannot be combined with asin."),
1185
- search: z27.string().min(3).max(200).optional().describe("Partial match on campaign name or advertised ASIN. At least 3 characters."),
1186
- includePlacements: z27.boolean().optional().describe(
1567
+ asin: z38.string().min(1).optional().describe("Only campaigns advertising this ASIN. Cannot be combined with parentAsin."),
1568
+ parentAsin: z38.string().min(1).optional().describe("Only campaigns advertising any ASIN of this variation family. Cannot be combined with asin."),
1569
+ search: z38.string().min(3).max(200).optional().describe("Partial match on campaign name or advertised ASIN. At least 3 characters."),
1570
+ includePlacements: z38.boolean().optional().describe(
1187
1571
  "Include the per-placement breakdown (topOfSearch, restOfSearch, productPage, offAmazon, each with its bid adjustment). Defaults to true; set false for a smaller response when placements are not needed."
1188
1572
  ),
1189
- sortBy: z27.enum([...PPC_CAMPAIGN_BASE_SORT_BY, ...PPC_CAMPAIGN_PLACEMENT_SORT_BY]).optional().describe(
1573
+ sortBy: z38.enum([...PPC_CAMPAIGN_BASE_SORT_BY, ...PPC_CAMPAIGN_PLACEMENT_SORT_BY]).optional().describe(
1190
1574
  `Sort field. Defaults to "name". Any of ${PPC_CAMPAIGN_BASE_SORT_BY.join(", ")}. The placement fields (e.g. "tosSpend", "tosAcos", "ppBidAdjustment") are only accepted when includePlacements is not false.`
1191
1575
  ),
1192
- sortOrder: z27.enum(SORT_ORDER).optional().describe('Sort direction. "ASC" (default) or "DESC".'),
1193
- state: z27.enum(PPC_CAMPAIGN_STATES).optional().describe("Only ENABLED or only PAUSED campaigns. Omit for both."),
1194
- currentPage: z27.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1195
- pageSize: z27.number().int().min(1).max(PPC_CAMPAIGNS_MAX_PAGE_SIZE).optional().describe(`Campaigns per page (max ${PPC_CAMPAIGNS_MAX_PAGE_SIZE}). Defaults to 20.`)
1576
+ sortOrder: z38.enum(SORT_ORDER).optional().describe('Sort direction. "ASC" (default) or "DESC".'),
1577
+ state: z38.enum(PPC_CAMPAIGN_STATES).optional().describe("Only ENABLED or only PAUSED campaigns. Omit for both."),
1578
+ currentPage: z38.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1579
+ pageSize: z38.number().int().min(1).max(PPC_CAMPAIGNS_MAX_PAGE_SIZE).optional().describe(`Campaigns per page (max ${PPC_CAMPAIGNS_MAX_PAGE_SIZE}). Defaults to 20.`)
1196
1580
  };
1197
1581
  var listPpcCampaignsTool = {
1198
1582
  name: "list_ppc_campaigns",
1199
1583
  title: "List PPC Campaigns for a Seller",
1200
1584
  description: `Use this when the user asks about their Sponsored Products campaigns \u2014 which campaigns spend the most, which have a high ACOS, how placements (top of search, rest of search, product pages) perform, or which campaigns advertise a given product. Requires a \`sellerId\` + \`marketplace\` (use \`list_seller_profiles\` to discover them). Narrow to one product with \`asin\`, or to a variation family with \`parentAsin\` (not both). The reporting window defaults to the last 30 days and cannot exceed ${PPC_CAMPAIGNS_MAX_WINDOW_DAYS} days. Returns a paginated list where each campaign has campaignId, name, type, state, targetingType, bidStrategy, budget { type, amount, currencyCode }, window totals (impressions, clicks, ctr, cpc, cvr, spend, unitsSold, orders, sales, tosImpressionShare, acos, roas, tacos), asinCount and, unless includePlacements is false, \`placements\`; plus pagination metadata (currentPage, pageSize, total, lastPage, hasNext, hasPrev). To find the biggest spenders, sort with \`sortBy: "spend", sortOrder: "DESC"\` rather than paging through every campaign. Each call counts toward API usage and is rate limited (about 60 requests/minute). For per-keyword ad data of a Rank Radar, use \`get_rank_radar_ppc_data\`.`,
1201
- inputSchema: inputSchema27,
1585
+ inputSchema: inputSchema38,
1202
1586
  annotations: { readOnlyHint: true },
1203
1587
  handler: async (args, ctx) => {
1204
1588
  if (args.asin && args.parentAsin) {
@@ -1229,21 +1613,21 @@ var listPpcCampaignsTool = {
1229
1613
  };
1230
1614
 
1231
1615
  // src/tools/get-asin-inventory-distribution.ts
1232
- import { z as z28 } from "zod";
1233
- var inputSchema28 = {
1234
- sellerId: z28.string().min(1).describe(
1616
+ import { z as z39 } from "zod";
1617
+ var inputSchema39 = {
1618
+ sellerId: z39.string().min(1).describe(
1235
1619
  "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."
1236
1620
  ),
1237
- marketplace: z28.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.'),
1238
- asin: z28.string().regex(/^[A-Z0-9]{10}$/, "ASIN must be 10 uppercase alphanumeric characters (e.g. B08XYZ1234).").describe(
1621
+ marketplace: z39.enum(SUPPORTED_MARKETPLACES).describe('Amazon marketplace code, e.g. "com" for amazon.com or "co.uk" for amazon.co.uk.'),
1622
+ asin: z39.string().regex(/^[A-Z0-9]{10}$/, "ASIN must be 10 uppercase alphanumeric characters (e.g. B08XYZ1234).").describe(
1239
1623
  "Amazon Standard Identification Number (10 uppercase alphanumeric characters, e.g. B08XYZ1234)."
1240
1624
  )
1241
1625
  };
1242
1626
  var getAsinInventoryDistributionTool = {
1243
1627
  name: "get_asin_inventory_distribution",
1244
- title: "Get Per-Fulfillment-Center Inventory Distribution for an ASIN",
1245
- 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.",
1246
- inputSchema: inputSchema28,
1628
+ title: "Get Inventory Metrics and Fulfillment-Center Distribution for an ASIN",
1629
+ description: "Use this when the user asks about an ASIN's inventory: stock levels, days of stock or when it will run out, low-inventory or aged-inventory risk, low-inventory-level (LILF) or long-term storage (LTSF) fees, or where their units sit across Amazon's fulfillment network. 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 the metrics the DataDive Inventory page shows \u2014 fulfillableStock, totalStock, reservedStock, inboundStock, researchingStock, unfulfillableStock, daysOfStock (with daysOfStockSource AMAZON or ESTIMATE), daysOfStock30, daysOfStock90, inLowInventoryState, estWeeklyLilf, estLtsfNextAssessment, ltsfLastMonthActual, agedUnits, oldestUnitAgeDays, with fees in `currency` \u2014 plus totalSellableUnits and a per-FC `distribution` array (fc, state, availableStock, availableStockPercentage). A metric is null, never 0, when Amazon has no data (e.g. merchant-fulfilled); metrics the user's plan does not include are null and listed in `lockedFields` (say they need a plan upgrade, do not report them as zero). `lastUpdatedAt` dates the stock and metrics; `distributionLastUpdatedAt` dates the distribution, which is usually up to 2 days behind. Either may be null when no successful refresh happened in the last 30 days.",
1630
+ inputSchema: inputSchema39,
1247
1631
  annotations: { readOnlyHint: true },
1248
1632
  handler: async (args, ctx) => {
1249
1633
  return await httpGet(
@@ -1256,18 +1640,18 @@ var getAsinInventoryDistributionTool = {
1256
1640
  };
1257
1641
 
1258
1642
  // src/tools/alert-query.ts
1259
- import { z as z29 } from "zod";
1643
+ import { z as z40 } from "zod";
1260
1644
  var alertsQueryInputSchema = {
1261
- sellerId: z29.string().min(1).max(50).optional().describe('Filter to a single connected Amazon seller account ID, e.g. "A1B2C3D4E5".'),
1262
- marketplace: z29.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.'),
1263
- status: z29.enum(ALERT_STATUSES).optional().describe(
1645
+ sellerId: z40.string().min(1).max(50).optional().describe('Filter to a single connected Amazon seller account ID, e.g. "A1B2C3D4E5".'),
1646
+ marketplace: z40.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.'),
1647
+ status: z40.enum(ALERT_STATUSES).optional().describe(
1264
1648
  "Lifecycle filter. `active` (default) returns unresolved alerts, `resolved` returns resolved alerts, `all` returns both. Dismissed alerts are never returned."
1265
1649
  ),
1266
- updatedSince: z29.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(
1650
+ updatedSince: z40.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(
1267
1651
  "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."
1268
1652
  ),
1269
- currentPage: z29.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1270
- pageSize: z29.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1653
+ currentPage: z40.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1654
+ pageSize: z40.number().int().min(1).max(50).optional().describe("Items per page (max 50). Defaults to 20.")
1271
1655
  };
1272
1656
 
1273
1657
  // src/tools/list-indexing-issue-alerts.ts
@@ -1317,12 +1701,12 @@ var listBlindSpendAlertsTool = {
1317
1701
  };
1318
1702
 
1319
1703
  // src/tools/get-quota.ts
1320
- var inputSchema29 = {};
1704
+ var inputSchema40 = {};
1321
1705
  var getQuotaTool = {
1322
1706
  name: "get_quota",
1323
1707
  title: "Get Quota Usage",
1324
1708
  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.",
1325
- inputSchema: inputSchema29,
1709
+ inputSchema: inputSchema40,
1326
1710
  annotations: { readOnlyHint: true },
1327
1711
  handler: async (_args, ctx) => {
1328
1712
  return await httpGet({ config: ctx.config, toolName: "get_quota" }, "/v1/quota");
@@ -1330,20 +1714,20 @@ var getQuotaTool = {
1330
1714
  };
1331
1715
 
1332
1716
  // src/tools/list-usage.ts
1333
- import { z as z30 } from "zod";
1334
- var inputSchema30 = {
1335
- type: z30.enum(BILLABLE_FEATURE_TYPES).optional().describe("Filter to a single billable feature type. Omit to return all types."),
1336
- search: z30.string().min(1).optional().describe("Case-insensitive partial match on the user's name or email."),
1337
- startDate: z30.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."),
1338
- endDate: z30.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."),
1339
- currentPage: z30.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1340
- pageSize: z30.number().int().min(1).max(200).optional().describe("Items per page (max 200). Defaults to 50.")
1717
+ import { z as z41 } from "zod";
1718
+ var inputSchema41 = {
1719
+ type: z41.enum(BILLABLE_FEATURE_TYPES).optional().describe("Filter to a single billable feature type. Omit to return all types."),
1720
+ search: z41.string().min(1).optional().describe("Case-insensitive partial match on the user's name or email."),
1721
+ startDate: z41.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."),
1722
+ endDate: z41.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."),
1723
+ currentPage: z41.number().int().min(1).optional().describe("Page number, 1-indexed. Defaults to 1."),
1724
+ pageSize: z41.number().int().min(1).max(200).optional().describe("Items per page (max 200). Defaults to 50.")
1341
1725
  };
1342
1726
  var listUsageTool = {
1343
1727
  name: "list_usage",
1344
1728
  title: "List Billable Usage Logs",
1345
1729
  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).",
1346
- inputSchema: inputSchema30,
1730
+ inputSchema: inputSchema41,
1347
1731
  annotations: { readOnlyHint: true },
1348
1732
  handler: async (args, ctx) => {
1349
1733
  return await httpGet(
@@ -1365,6 +1749,7 @@ var listUsageTool = {
1365
1749
  var allTools = [
1366
1750
  listNichesTool,
1367
1751
  getNicheKeywordsTool,
1752
+ listKeywordExclusionsTool,
1368
1753
  getNicheRootsTool,
1369
1754
  getNicheCompetitorsTool,
1370
1755
  getRankingJuiceTool,
@@ -1372,14 +1757,24 @@ var allTools = [
1372
1757
  getRankRadarDataTool,
1373
1758
  getRankRadarSqpDataTool,
1374
1759
  getRankRadarPpcDataTool,
1760
+ listRankRadarTagsTool,
1375
1761
  createRankRadarTool,
1376
1762
  createNicheDiveTool,
1377
1763
  createNicheDiveFromCompetitorsListTool,
1378
1764
  rediveNicheTool,
1379
1765
  getDiveStatusTool,
1766
+ addNicheKeywordsTool,
1767
+ removeNicheKeywordsTool,
1768
+ addKeywordExclusionsTool,
1769
+ removeKeywordExclusionsTool,
1380
1770
  addRankRadarSearchTermsTool,
1381
1771
  pauseRankRadarSearchTermsTool,
1382
1772
  resumeRankRadarSearchTermsTool,
1773
+ createRankRadarTagTool,
1774
+ updateRankRadarTagTool,
1775
+ addRankRadarTagSearchTermsTool,
1776
+ removeRankRadarTagSearchTermsTool,
1777
+ deleteRankRadarTagTool,
1383
1778
  pauseRankRadarTool,
1384
1779
  resumeRankRadarTool,
1385
1780
  deleteRankRadarTool,
@@ -1399,6 +1794,21 @@ var allTools = [
1399
1794
 
1400
1795
  // src/whats-new.ts
1401
1796
  var WHATS_NEW = [
1797
+ {
1798
+ version: "0.17.1",
1799
+ released: "2026-10-13",
1800
+ items: [
1801
+ "Rank Radar tags end-to-end: list, create, update, delete tags, and attach or detach up to 1000 keywords per call (`list_rank_radar_tags`, `create_rank_radar_tag`, `update_rank_radar_tag`, `delete_rank_radar_tag`, `add_rank_radar_tag_search_terms`, `remove_rank_radar_tag_search_terms`). The highlights on each keyword in `get_rank_radar_data` are the same objects, so you can go from a ranking view to editing its tags without a round trip."
1802
+ ]
1803
+ },
1804
+ {
1805
+ version: "0.17.0",
1806
+ released: "2026-10-12",
1807
+ items: [
1808
+ "Add your own keywords to a niche's Master Keyword List, or take them back out (`add_niche_keywords`, `remove_niche_keywords`). Free while the niche is fresh; on an older niche you are asked to confirm the Dive tokens first. `get_niche_keywords` now shows where each keyword came from.",
1809
+ "See and change which keywords a niche hides (`list_keyword_exclusions`, `add_keyword_exclusions`, `remove_keyword_exclusions`): exclude one exact keyword, or every keyword containing a phrase. Free."
1810
+ ]
1811
+ },
1402
1812
  {
1403
1813
  version: "0.16.1",
1404
1814
  released: "2026-09-29",
@@ -1443,8 +1853,8 @@ var WHATS_NEW = [
1443
1853
  }
1444
1854
  ];
1445
1855
  var INSTRUCTIONS_RELEASES = 2;
1446
- function formatEntries(entries) {
1447
- return entries.map((e) => `${e.released} (v${e.version}):
1856
+ function formatEntries(entries2) {
1857
+ return entries2.map((e) => `${e.released} (v${e.version}):
1448
1858
  ${e.items.map((i) => `- ${i}`).join("\n")}`).join("\n\n");
1449
1859
  }
1450
1860
  var SERVER_INSTRUCTIONS = `DataDive tools for Amazon sellers: niche research (niches, keywords, roots, competitors, Ranking Juice), Rank Radar keyword rank tracking with SQP and PPC data, the seller's catalog, listing changes, inventory, PPC campaigns and alerts. Start with a discovery tool: \`list_niches\`, \`list_rank_radars\` or \`list_seller_profiles\`. Tools that spend tokens ask for confirmation first.