@usethrottle/mcp 0.2.2 → 0.4.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
@@ -1471,14 +1471,22 @@ var ACTIONS = [
1471
1471
  scopes: ["quotes:write"],
1472
1472
  input: [
1473
1473
  { name: "customerId", type: "string", required: true, description: "Customer the quote is for." },
1474
- { name: "items", type: "array", required: true, description: "Quote line items: { name, unitPrice, quantity }." },
1474
+ {
1475
+ name: "items",
1476
+ type: "array",
1477
+ required: true,
1478
+ description: "Quote line items: { name, unitPrice, quantity }. Add `recurring: { plan, interval | intervalUnit + intervalCount, totalPayments?, trialDays? }` to make a line a subscription (one per line when the quote is paid, quantity = seats; at most 10). unitPrice is then the per-period price; a free-trial line is charged nothing at acceptance."
1479
+ },
1475
1480
  { name: "expiresAt", type: "string", required: false, description: "ISO 8601 expiry." },
1476
- { name: "netN", type: "number", required: false, description: "Payment terms in days. Omit for pay-in-full." },
1481
+ { name: "netN", type: "number", required: false, description: "Payment terms in days. Omit for pay-in-full. Not allowed when any item is recurring." },
1477
1482
  { name: "notes", type: "string", required: false, description: "Buyer-visible notes." }
1478
1483
  ],
1479
1484
  requests: [{ method: "POST", path: "/api/v1/quotes" }],
1480
1485
  channels: ["mcp", "zapier", "make", "n8n"],
1481
- idempotent: true
1486
+ idempotent: true,
1487
+ guardrails: [
1488
+ "A quote with a recurring item must be pay-in-full: issuing it with net terms or a deposit fails with 422 recurring_terms_unsupported."
1489
+ ]
1482
1490
  },
1483
1491
  {
1484
1492
  id: "send_quote",
@@ -1585,12 +1593,12 @@ var ACTIONS = [
1585
1593
  {
1586
1594
  id: "send_test_webhook",
1587
1595
  title: "Send a test webhook",
1588
- description: "Send a synthetic signed event to a webhook endpoint to verify signature handling and reachability.",
1596
+ description: "Send a synthetic signed event to a webhook endpoint to verify signature handling and reachability. The event type must be one the endpoint is subscribed to (an endpoint subscribed to all events accepts any); otherwise the call fails with 400 validation_error naming the allowed types.",
1589
1597
  kind: "write",
1590
1598
  scopes: ["webhooks:write"],
1591
1599
  input: [
1592
1600
  { name: "id", type: "string", required: true, description: "Endpoint id." },
1593
- { name: "eventType", type: "string", required: false, description: "Event type to simulate." }
1601
+ { name: "eventType", type: "string", required: false, description: "Event type to simulate. Must be in the endpoint's subscribed events unless it subscribes to all." }
1594
1602
  ],
1595
1603
  requests: [{ method: "POST", path: "/api/v1/webhook-endpoints/:id/test" }],
1596
1604
  channels: ["mcp", "n8n"],
@@ -2386,14 +2394,14 @@ var HANDLERS = {
2386
2394
  idempotencyKey: `mcp-manage-subscription-${id}-${action}-${Date.now()}`
2387
2395
  });
2388
2396
  },
2389
- create_quote: async (ctx, args) => (
2390
- // The real route's body shape differs from this tool's flatter,
2391
- // model-facing input: line items are "items" (not "lineItems"), Net-N
2392
- // terms are nested under paymentTerms.netN with an explicit mode (not a
2393
- // flat "netN"), and the buyer-visible note field is "buyerNote" (not
2394
- // "notes"). Confirmed against packages/platform-api/src/validation/quotes.ts's
2395
- // actual zod schema after a live call 400'd with unrecognized_keys.
2396
- ctx.client.post("/api/v1/quotes", {
2397
+ create_quote: async (ctx, args) => {
2398
+ const items = Array.isArray(args.items) ? args.items : [];
2399
+ if (args.netN !== void 0 && items.some((item) => item && item.recurring)) {
2400
+ throw new Error(
2401
+ "create_quote: items with `recurring` need pay-in-full terms \u2014 omit netN. Net terms cannot start a subscription."
2402
+ );
2403
+ }
2404
+ return ctx.client.post("/api/v1/quotes", {
2397
2405
  body: {
2398
2406
  customerId: args.customerId,
2399
2407
  items: args.items,
@@ -2402,8 +2410,8 @@ var HANDLERS = {
2402
2410
  buyerNote: args.notes
2403
2411
  },
2404
2412
  idempotencyKey: `mcp-create-quote-${String(args.customerId)}-${Date.now()}`
2405
- })
2406
- ),
2413
+ });
2414
+ },
2407
2415
  get_sales_timeseries: async (ctx, args) => ctx.client.get(
2408
2416
  "/api/v1/analytics/orders-timeseries",
2409
2417
  {
@@ -2660,6 +2668,16 @@ var ORDER_DISPLAY_STATUSES = new Set(
2660
2668
  );
2661
2669
  var DISPLAY_STATUS = oneOf(ORDER_DISPLAY_STATUSES);
2662
2670
  var RANGE = { from: S, to: S, timezone: S, groupBy: S };
2671
+ var LINE_RECURRING = {
2672
+ plan: S,
2673
+ interval: S,
2674
+ intervalUnit: S,
2675
+ intervalCount: S,
2676
+ totalPayments: S,
2677
+ trialDays: S,
2678
+ // A custom installment schedule: amounts and gaps are numbers and unit tokens, no free text.
2679
+ schedule: [{ amount: S, intervalUnit: S, intervalCount: S }]
2680
+ };
2663
2681
  var LINE_ITEM = {
2664
2682
  id: S,
2665
2683
  type: S,
@@ -2669,7 +2687,9 @@ var LINE_ITEM = {
2669
2687
  discountAmount: S,
2670
2688
  taxAmount: S,
2671
2689
  total: S,
2672
- recurring: S
2690
+ // amount = renewal price on a trial line (whose unitPrice is 0); count = the old display mirror.
2691
+ recurring: { ...LINE_RECURRING, amount: S, count: S, scheduleUnitTotal: S },
2692
+ subscriptionId: S
2673
2693
  };
2674
2694
  var ORDER = {
2675
2695
  id: S,
@@ -2693,6 +2713,7 @@ var ORDER = {
2693
2713
  customerId: S,
2694
2714
  customer: CUSTOMER_REF,
2695
2715
  subscriptionId: S,
2716
+ subscriptionIds: [S],
2696
2717
  shippingAddress: ADDRESS,
2697
2718
  billingAddress: ADDRESS,
2698
2719
  fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
@@ -2774,6 +2795,18 @@ var SUBSCRIPTION = {
2774
2795
  pendingQuantity: S,
2775
2796
  pendingIntervalUnit: S,
2776
2797
  pendingIntervalCount: S,
2798
+ scheduleTotal: S,
2799
+ nextPaymentAmount: S,
2800
+ paymentSchedule: [{
2801
+ index: S,
2802
+ amount: S,
2803
+ discount: S,
2804
+ net: S,
2805
+ intervalUnit: S,
2806
+ intervalCount: S,
2807
+ status: S,
2808
+ dueAt: S
2809
+ }],
2777
2810
  createdAt: S
2778
2811
  };
2779
2812
  var QUOTE_SUMMARY = {
@@ -2815,7 +2848,8 @@ var QUOTE = {
2815
2848
  taxAmount: S,
2816
2849
  total: S,
2817
2850
  optional: S,
2818
- optionalSelected: S
2851
+ optionalSelected: S,
2852
+ recurring: LINE_RECURRING
2819
2853
  }]
2820
2854
  }],
2821
2855
  // Who commented and when, never what they wrote.
@@ -2981,7 +3015,24 @@ var OAUTH_PROJECTIONS = {
2981
3015
  trialDays: S,
2982
3016
  currency: S,
2983
3017
  firstChargeAmountMinor: S
2984
- }
3018
+ },
3019
+ hasSubscriptions: S,
3020
+ // One entry per subscription line. No `name`: it is the line's name.
3021
+ subscriptions: [{
3022
+ lineItemId: S,
3023
+ amount: S,
3024
+ quantity: S,
3025
+ interval: S,
3026
+ intervalUnit: S,
3027
+ intervalCount: S,
3028
+ totalPayments: S,
3029
+ trialDays: S,
3030
+ trialEndsAt: S,
3031
+ planChargedToday: S,
3032
+ taxApplies: S,
3033
+ scheduleGapUnits: [S],
3034
+ schedule: [{ net: S, dueAt: S }]
3035
+ }]
2985
3036
  },
2986
3037
  cart: section({
2987
3038
  id: S,
@@ -3122,7 +3173,7 @@ var OAUTH_PROJECTIONS = {
3122
3173
  };
3123
3174
 
3124
3175
  // src/server.ts
3125
- var VERSION = true ? "0.2.2" : "0.0.0-dev";
3176
+ var VERSION = true ? "0.4.0" : "0.0.0-dev";
3126
3177
  function registerableActions(policy) {
3127
3178
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3128
3179
  return actionsForChannel("mcp").filter((action) => {