@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/mcp.js CHANGED
@@ -1603,14 +1603,22 @@ var ACTIONS = [
1603
1603
  scopes: ["quotes:write"],
1604
1604
  input: [
1605
1605
  { name: "customerId", type: "string", required: true, description: "Customer the quote is for." },
1606
- { name: "items", type: "array", required: true, description: "Quote line items: { name, unitPrice, quantity }." },
1606
+ {
1607
+ name: "items",
1608
+ type: "array",
1609
+ required: true,
1610
+ 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."
1611
+ },
1607
1612
  { name: "expiresAt", type: "string", required: false, description: "ISO 8601 expiry." },
1608
- { name: "netN", type: "number", required: false, description: "Payment terms in days. Omit for pay-in-full." },
1613
+ { name: "netN", type: "number", required: false, description: "Payment terms in days. Omit for pay-in-full. Not allowed when any item is recurring." },
1609
1614
  { name: "notes", type: "string", required: false, description: "Buyer-visible notes." }
1610
1615
  ],
1611
1616
  requests: [{ method: "POST", path: "/api/v1/quotes" }],
1612
1617
  channels: ["mcp", "zapier", "make", "n8n"],
1613
- idempotent: true
1618
+ idempotent: true,
1619
+ guardrails: [
1620
+ "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."
1621
+ ]
1614
1622
  },
1615
1623
  {
1616
1624
  id: "send_quote",
@@ -1717,12 +1725,12 @@ var ACTIONS = [
1717
1725
  {
1718
1726
  id: "send_test_webhook",
1719
1727
  title: "Send a test webhook",
1720
- description: "Send a synthetic signed event to a webhook endpoint to verify signature handling and reachability.",
1728
+ 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.",
1721
1729
  kind: "write",
1722
1730
  scopes: ["webhooks:write"],
1723
1731
  input: [
1724
1732
  { name: "id", type: "string", required: true, description: "Endpoint id." },
1725
- { name: "eventType", type: "string", required: false, description: "Event type to simulate." }
1733
+ { name: "eventType", type: "string", required: false, description: "Event type to simulate. Must be in the endpoint's subscribed events unless it subscribes to all." }
1726
1734
  ],
1727
1735
  requests: [{ method: "POST", path: "/api/v1/webhook-endpoints/:id/test" }],
1728
1736
  channels: ["mcp", "n8n"],
@@ -2391,14 +2399,14 @@ var HANDLERS = {
2391
2399
  idempotencyKey: `mcp-manage-subscription-${id}-${action}-${Date.now()}`
2392
2400
  });
2393
2401
  },
2394
- create_quote: async (ctx, args) => (
2395
- // The real route's body shape differs from this tool's flatter,
2396
- // model-facing input: line items are "items" (not "lineItems"), Net-N
2397
- // terms are nested under paymentTerms.netN with an explicit mode (not a
2398
- // flat "netN"), and the buyer-visible note field is "buyerNote" (not
2399
- // "notes"). Confirmed against packages/platform-api/src/validation/quotes.ts's
2400
- // actual zod schema after a live call 400'd with unrecognized_keys.
2401
- ctx.client.post("/api/v1/quotes", {
2402
+ create_quote: async (ctx, args) => {
2403
+ const items = Array.isArray(args.items) ? args.items : [];
2404
+ if (args.netN !== void 0 && items.some((item) => item && item.recurring)) {
2405
+ throw new Error(
2406
+ "create_quote: items with `recurring` need pay-in-full terms \u2014 omit netN. Net terms cannot start a subscription."
2407
+ );
2408
+ }
2409
+ return ctx.client.post("/api/v1/quotes", {
2402
2410
  body: {
2403
2411
  customerId: args.customerId,
2404
2412
  items: args.items,
@@ -2407,8 +2415,8 @@ var HANDLERS = {
2407
2415
  buyerNote: args.notes
2408
2416
  },
2409
2417
  idempotencyKey: `mcp-create-quote-${String(args.customerId)}-${Date.now()}`
2410
- })
2411
- ),
2418
+ });
2419
+ },
2412
2420
  get_sales_timeseries: async (ctx, args) => ctx.client.get(
2413
2421
  "/api/v1/analytics/orders-timeseries",
2414
2422
  {
@@ -2665,6 +2673,16 @@ var ORDER_DISPLAY_STATUSES = new Set(
2665
2673
  );
2666
2674
  var DISPLAY_STATUS = oneOf(ORDER_DISPLAY_STATUSES);
2667
2675
  var RANGE = { from: S, to: S, timezone: S, groupBy: S };
2676
+ var LINE_RECURRING = {
2677
+ plan: S,
2678
+ interval: S,
2679
+ intervalUnit: S,
2680
+ intervalCount: S,
2681
+ totalPayments: S,
2682
+ trialDays: S,
2683
+ // A custom installment schedule: amounts and gaps are numbers and unit tokens, no free text.
2684
+ schedule: [{ amount: S, intervalUnit: S, intervalCount: S }]
2685
+ };
2668
2686
  var LINE_ITEM = {
2669
2687
  id: S,
2670
2688
  type: S,
@@ -2674,7 +2692,9 @@ var LINE_ITEM = {
2674
2692
  discountAmount: S,
2675
2693
  taxAmount: S,
2676
2694
  total: S,
2677
- recurring: S
2695
+ // amount = renewal price on a trial line (whose unitPrice is 0); count = the old display mirror.
2696
+ recurring: { ...LINE_RECURRING, amount: S, count: S, scheduleUnitTotal: S },
2697
+ subscriptionId: S
2678
2698
  };
2679
2699
  var ORDER = {
2680
2700
  id: S,
@@ -2698,6 +2718,7 @@ var ORDER = {
2698
2718
  customerId: S,
2699
2719
  customer: CUSTOMER_REF,
2700
2720
  subscriptionId: S,
2721
+ subscriptionIds: [S],
2701
2722
  shippingAddress: ADDRESS,
2702
2723
  billingAddress: ADDRESS,
2703
2724
  fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
@@ -2779,6 +2800,18 @@ var SUBSCRIPTION = {
2779
2800
  pendingQuantity: S,
2780
2801
  pendingIntervalUnit: S,
2781
2802
  pendingIntervalCount: S,
2803
+ scheduleTotal: S,
2804
+ nextPaymentAmount: S,
2805
+ paymentSchedule: [{
2806
+ index: S,
2807
+ amount: S,
2808
+ discount: S,
2809
+ net: S,
2810
+ intervalUnit: S,
2811
+ intervalCount: S,
2812
+ status: S,
2813
+ dueAt: S
2814
+ }],
2782
2815
  createdAt: S
2783
2816
  };
2784
2817
  var QUOTE_SUMMARY = {
@@ -2820,7 +2853,8 @@ var QUOTE = {
2820
2853
  taxAmount: S,
2821
2854
  total: S,
2822
2855
  optional: S,
2823
- optionalSelected: S
2856
+ optionalSelected: S,
2857
+ recurring: LINE_RECURRING
2824
2858
  }]
2825
2859
  }],
2826
2860
  // Who commented and when, never what they wrote.
@@ -2986,7 +3020,24 @@ var OAUTH_PROJECTIONS = {
2986
3020
  trialDays: S,
2987
3021
  currency: S,
2988
3022
  firstChargeAmountMinor: S
2989
- }
3023
+ },
3024
+ hasSubscriptions: S,
3025
+ // One entry per subscription line. No `name`: it is the line's name.
3026
+ subscriptions: [{
3027
+ lineItemId: S,
3028
+ amount: S,
3029
+ quantity: S,
3030
+ interval: S,
3031
+ intervalUnit: S,
3032
+ intervalCount: S,
3033
+ totalPayments: S,
3034
+ trialDays: S,
3035
+ trialEndsAt: S,
3036
+ planChargedToday: S,
3037
+ taxApplies: S,
3038
+ scheduleGapUnits: [S],
3039
+ schedule: [{ net: S, dueAt: S }]
3040
+ }]
2990
3041
  },
2991
3042
  cart: section({
2992
3043
  id: S,
@@ -3127,7 +3178,7 @@ var OAUTH_PROJECTIONS = {
3127
3178
  };
3128
3179
 
3129
3180
  // src/server.ts
3130
- var VERSION = true ? "0.2.2" : "0.0.0-dev";
3181
+ var VERSION = true ? "0.4.0" : "0.0.0-dev";
3131
3182
  function registerableActions(policy) {
3132
3183
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3133
3184
  return actionsForChannel("mcp").filter((action) => {