@datadive-tools/mcp 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -139,7 +139,7 @@ function extractMessage(body) {
139
139
  }
140
140
 
141
141
  // package.json
142
- var version = "0.12.0";
142
+ var version = "0.13.0";
143
143
 
144
144
  // src/http/client.ts
145
145
  var PKG_VERSION = version;
@@ -481,16 +481,24 @@ var getRankRadarDataTool = {
481
481
  import { z as z8 } from "zod";
482
482
 
483
483
  // src/tools/confirm.ts
484
- function requireConfirmation(confirm, ctx, costNote) {
485
- if (confirm === true || ctx.config.autoConfirmWrites) return null;
484
+ function needsConfirmation(confirm, ctx) {
485
+ return !(confirm === true || ctx.config.autoConfirmWrites);
486
+ }
487
+ function confirmationRequired(costNote, warnings) {
486
488
  return {
487
489
  status: "confirmation_required",
488
490
  message: "This action spends billable tokens and cannot be undone. Confirm the cost with the user, then call again with `confirm: true` to proceed.",
489
- costNote
491
+ costNote,
492
+ ...warnings && warnings.length > 0 ? { warnings } : {}
490
493
  };
491
494
  }
495
+ function requireConfirmation(confirm, ctx, costNote) {
496
+ if (!needsConfirmation(confirm, ctx)) return null;
497
+ return confirmationRequired(costNote);
498
+ }
492
499
 
493
500
  // src/tools/create-rank-radar.ts
501
+ var PATH = "/v1/niches/rank-radars";
494
502
  var inputSchema8 = {
495
503
  asin: z8.string().min(1).describe("The ASIN to track keyword rankings for."),
496
504
  numberOfKeywords: z8.number().int().min(1).describe("How many keywords to track (minimum 1). More keywords = broader tracking but more Search Term tokens."),
@@ -502,28 +510,28 @@ var inputSchema8 = {
502
510
  var createRankRadarTool = {
503
511
  name: "create_rank_radar",
504
512
  title: "Create a Rank Radar",
505
- 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. Returns the new `rankRadarId`; read its data later with `get_rank_radar_data`. Requires `asin`, `numberOfKeywords` (min 1), and a `nicheId` from `list_niches`.",
513
+ 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`.",
506
514
  inputSchema: inputSchema8,
507
515
  // destructiveHint is technically "additive" here (this creates a new Rank Radar, it
508
516
  // doesn't destroy data), but we flag it destructive so clients prompt before the
509
517
  // irreversible token spend. The confirm gate enforces this server-side regardless.
510
518
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
511
519
  handler: async (args, ctx) => {
512
- const pending = requireConfirmation(
513
- args.confirm,
514
- ctx,
515
- `Creating this Rank Radar consumes Search Term tokens \u2014 one per keyword tracked (${args.numberOfKeywords} requested).`
516
- );
517
- if (pending) return pending;
518
- return await httpPost(
519
- { config: ctx.config, toolName: "create_rank_radar" },
520
- "/v1/niches/rank-radars",
521
- {
522
- asin: args.asin,
523
- numberOfKeywords: args.numberOfKeywords,
524
- nicheId: args.nicheId
525
- }
526
- );
520
+ const request = { config: ctx.config, toolName: "create_rank_radar" };
521
+ const body = {
522
+ asin: args.asin,
523
+ numberOfKeywords: args.numberOfKeywords,
524
+ nicheId: args.nicheId
525
+ };
526
+ if (needsConfirmation(args.confirm, ctx)) {
527
+ const preview = await httpPost(request, PATH, { ...body, dryRun: true });
528
+ if (preview.rankRadarId != null) return preview;
529
+ return confirmationRequired(
530
+ `Creating this Rank Radar consumes Search Term tokens \u2014 one per keyword tracked (${args.numberOfKeywords} requested).`,
531
+ preview.warnings
532
+ );
533
+ }
534
+ return await httpPost(request, PATH, body);
527
535
  }
528
536
  };
529
537