@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/README.md CHANGED
@@ -146,6 +146,14 @@ assistant to confirm the cost with you first:
146
146
 
147
147
  Check your remaining balance any time with `get_quota`.
148
148
 
149
+ `create_rank_radar` uses that first, unconfirmed call to preview the creation
150
+ against the API, so the note it comes back with can tell you something specific
151
+ rather than only the token cost — for instance that the product family you asked
152
+ for is already tracked by another of your Rank Radars, which would spend Tracked
153
+ Search Terms on it twice. The preview creates nothing and spends nothing, and a
154
+ warning never blocks the creation: two Rank Radars on one family is how you
155
+ track two different sets of search terms and keep separate statistics.
156
+
149
157
  The other write tools — `pause_rank_radar`, `resume_rank_radar` and the three
150
158
  `*_rank_radar_search_terms` tools — need no confirmation. They only move Daily
151
159
  Tracked Keywords capacity, which is freed again when you pause, and each is
package/dist/index.js CHANGED
@@ -144,7 +144,7 @@ function extractMessage(body) {
144
144
  }
145
145
 
146
146
  // package.json
147
- var version = "0.12.0";
147
+ var version = "0.13.0";
148
148
 
149
149
  // src/http/client.ts
150
150
  var PKG_VERSION = version;
@@ -486,16 +486,24 @@ var getRankRadarDataTool = {
486
486
  import { z as z8 } from "zod";
487
487
 
488
488
  // src/tools/confirm.ts
489
- function requireConfirmation(confirm, ctx, costNote) {
490
- if (confirm === true || ctx.config.autoConfirmWrites) return null;
489
+ function needsConfirmation(confirm, ctx) {
490
+ return !(confirm === true || ctx.config.autoConfirmWrites);
491
+ }
492
+ function confirmationRequired(costNote, warnings) {
491
493
  return {
492
494
  status: "confirmation_required",
493
495
  message: "This action spends billable tokens and cannot be undone. Confirm the cost with the user, then call again with `confirm: true` to proceed.",
494
- costNote
496
+ costNote,
497
+ ...warnings && warnings.length > 0 ? { warnings } : {}
495
498
  };
496
499
  }
500
+ function requireConfirmation(confirm, ctx, costNote) {
501
+ if (!needsConfirmation(confirm, ctx)) return null;
502
+ return confirmationRequired(costNote);
503
+ }
497
504
 
498
505
  // src/tools/create-rank-radar.ts
506
+ var PATH = "/v1/niches/rank-radars";
499
507
  var inputSchema8 = {
500
508
  asin: z8.string().min(1).describe("The ASIN to track keyword rankings for."),
501
509
  numberOfKeywords: z8.number().int().min(1).describe("How many keywords to track (minimum 1). More keywords = broader tracking but more Search Term tokens."),
@@ -507,28 +515,28 @@ var inputSchema8 = {
507
515
  var createRankRadarTool = {
508
516
  name: "create_rank_radar",
509
517
  title: "Create a Rank Radar",
510
- 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`.",
518
+ 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`.",
511
519
  inputSchema: inputSchema8,
512
520
  // destructiveHint is technically "additive" here (this creates a new Rank Radar, it
513
521
  // doesn't destroy data), but we flag it destructive so clients prompt before the
514
522
  // irreversible token spend. The confirm gate enforces this server-side regardless.
515
523
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
516
524
  handler: async (args, ctx) => {
517
- const pending = requireConfirmation(
518
- args.confirm,
519
- ctx,
520
- `Creating this Rank Radar consumes Search Term tokens \u2014 one per keyword tracked (${args.numberOfKeywords} requested).`
521
- );
522
- if (pending) return pending;
523
- return await httpPost(
524
- { config: ctx.config, toolName: "create_rank_radar" },
525
- "/v1/niches/rank-radars",
526
- {
527
- asin: args.asin,
528
- numberOfKeywords: args.numberOfKeywords,
529
- nicheId: args.nicheId
530
- }
531
- );
525
+ const request = { config: ctx.config, toolName: "create_rank_radar" };
526
+ const body = {
527
+ asin: args.asin,
528
+ numberOfKeywords: args.numberOfKeywords,
529
+ nicheId: args.nicheId
530
+ };
531
+ if (needsConfirmation(args.confirm, ctx)) {
532
+ const preview = await httpPost(request, PATH, { ...body, dryRun: true });
533
+ if (preview.rankRadarId != null) return preview;
534
+ return confirmationRequired(
535
+ `Creating this Rank Radar consumes Search Term tokens \u2014 one per keyword tracked (${args.numberOfKeywords} requested).`,
536
+ preview.warnings
537
+ );
538
+ }
539
+ return await httpPost(request, PATH, body);
532
540
  }
533
541
  };
534
542