@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.cjs CHANGED
@@ -1503,14 +1503,22 @@ var ACTIONS = [
1503
1503
  scopes: ["quotes:write"],
1504
1504
  input: [
1505
1505
  { name: "customerId", type: "string", required: true, description: "Customer the quote is for." },
1506
- { name: "items", type: "array", required: true, description: "Quote line items: { name, unitPrice, quantity }." },
1506
+ {
1507
+ name: "items",
1508
+ type: "array",
1509
+ required: true,
1510
+ 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."
1511
+ },
1507
1512
  { name: "expiresAt", type: "string", required: false, description: "ISO 8601 expiry." },
1508
- { name: "netN", type: "number", required: false, description: "Payment terms in days. Omit for pay-in-full." },
1513
+ { name: "netN", type: "number", required: false, description: "Payment terms in days. Omit for pay-in-full. Not allowed when any item is recurring." },
1509
1514
  { name: "notes", type: "string", required: false, description: "Buyer-visible notes." }
1510
1515
  ],
1511
1516
  requests: [{ method: "POST", path: "/api/v1/quotes" }],
1512
1517
  channels: ["mcp", "zapier", "make", "n8n"],
1513
- idempotent: true
1518
+ idempotent: true,
1519
+ guardrails: [
1520
+ "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."
1521
+ ]
1514
1522
  },
1515
1523
  {
1516
1524
  id: "send_quote",
@@ -1617,12 +1625,12 @@ var ACTIONS = [
1617
1625
  {
1618
1626
  id: "send_test_webhook",
1619
1627
  title: "Send a test webhook",
1620
- description: "Send a synthetic signed event to a webhook endpoint to verify signature handling and reachability.",
1628
+ 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.",
1621
1629
  kind: "write",
1622
1630
  scopes: ["webhooks:write"],
1623
1631
  input: [
1624
1632
  { name: "id", type: "string", required: true, description: "Endpoint id." },
1625
- { name: "eventType", type: "string", required: false, description: "Event type to simulate." }
1633
+ { name: "eventType", type: "string", required: false, description: "Event type to simulate. Must be in the endpoint's subscribed events unless it subscribes to all." }
1626
1634
  ],
1627
1635
  requests: [{ method: "POST", path: "/api/v1/webhook-endpoints/:id/test" }],
1628
1636
  channels: ["mcp", "n8n"],
@@ -2418,14 +2426,14 @@ var HANDLERS = {
2418
2426
  idempotencyKey: `mcp-manage-subscription-${id}-${action}-${Date.now()}`
2419
2427
  });
2420
2428
  },
2421
- create_quote: async (ctx, args) => (
2422
- // The real route's body shape differs from this tool's flatter,
2423
- // model-facing input: line items are "items" (not "lineItems"), Net-N
2424
- // terms are nested under paymentTerms.netN with an explicit mode (not a
2425
- // flat "netN"), and the buyer-visible note field is "buyerNote" (not
2426
- // "notes"). Confirmed against packages/platform-api/src/validation/quotes.ts's
2427
- // actual zod schema after a live call 400'd with unrecognized_keys.
2428
- ctx.client.post("/api/v1/quotes", {
2429
+ create_quote: async (ctx, args) => {
2430
+ const items = Array.isArray(args.items) ? args.items : [];
2431
+ if (args.netN !== void 0 && items.some((item) => item && item.recurring)) {
2432
+ throw new Error(
2433
+ "create_quote: items with `recurring` need pay-in-full terms \u2014 omit netN. Net terms cannot start a subscription."
2434
+ );
2435
+ }
2436
+ return ctx.client.post("/api/v1/quotes", {
2429
2437
  body: {
2430
2438
  customerId: args.customerId,
2431
2439
  items: args.items,
@@ -2434,8 +2442,8 @@ var HANDLERS = {
2434
2442
  buyerNote: args.notes
2435
2443
  },
2436
2444
  idempotencyKey: `mcp-create-quote-${String(args.customerId)}-${Date.now()}`
2437
- })
2438
- ),
2445
+ });
2446
+ },
2439
2447
  get_sales_timeseries: async (ctx, args) => ctx.client.get(
2440
2448
  "/api/v1/analytics/orders-timeseries",
2441
2449
  {
@@ -2692,6 +2700,16 @@ var ORDER_DISPLAY_STATUSES = new Set(
2692
2700
  );
2693
2701
  var DISPLAY_STATUS = oneOf(ORDER_DISPLAY_STATUSES);
2694
2702
  var RANGE = { from: S, to: S, timezone: S, groupBy: S };
2703
+ var LINE_RECURRING = {
2704
+ plan: S,
2705
+ interval: S,
2706
+ intervalUnit: S,
2707
+ intervalCount: S,
2708
+ totalPayments: S,
2709
+ trialDays: S,
2710
+ // A custom installment schedule: amounts and gaps are numbers and unit tokens, no free text.
2711
+ schedule: [{ amount: S, intervalUnit: S, intervalCount: S }]
2712
+ };
2695
2713
  var LINE_ITEM = {
2696
2714
  id: S,
2697
2715
  type: S,
@@ -2701,7 +2719,9 @@ var LINE_ITEM = {
2701
2719
  discountAmount: S,
2702
2720
  taxAmount: S,
2703
2721
  total: S,
2704
- recurring: S
2722
+ // amount = renewal price on a trial line (whose unitPrice is 0); count = the old display mirror.
2723
+ recurring: { ...LINE_RECURRING, amount: S, count: S, scheduleUnitTotal: S },
2724
+ subscriptionId: S
2705
2725
  };
2706
2726
  var ORDER = {
2707
2727
  id: S,
@@ -2725,6 +2745,7 @@ var ORDER = {
2725
2745
  customerId: S,
2726
2746
  customer: CUSTOMER_REF,
2727
2747
  subscriptionId: S,
2748
+ subscriptionIds: [S],
2728
2749
  shippingAddress: ADDRESS,
2729
2750
  billingAddress: ADDRESS,
2730
2751
  fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
@@ -2806,6 +2827,18 @@ var SUBSCRIPTION = {
2806
2827
  pendingQuantity: S,
2807
2828
  pendingIntervalUnit: S,
2808
2829
  pendingIntervalCount: S,
2830
+ scheduleTotal: S,
2831
+ nextPaymentAmount: S,
2832
+ paymentSchedule: [{
2833
+ index: S,
2834
+ amount: S,
2835
+ discount: S,
2836
+ net: S,
2837
+ intervalUnit: S,
2838
+ intervalCount: S,
2839
+ status: S,
2840
+ dueAt: S
2841
+ }],
2809
2842
  createdAt: S
2810
2843
  };
2811
2844
  var QUOTE_SUMMARY = {
@@ -2847,7 +2880,8 @@ var QUOTE = {
2847
2880
  taxAmount: S,
2848
2881
  total: S,
2849
2882
  optional: S,
2850
- optionalSelected: S
2883
+ optionalSelected: S,
2884
+ recurring: LINE_RECURRING
2851
2885
  }]
2852
2886
  }],
2853
2887
  // Who commented and when, never what they wrote.
@@ -3013,7 +3047,24 @@ var OAUTH_PROJECTIONS = {
3013
3047
  trialDays: S,
3014
3048
  currency: S,
3015
3049
  firstChargeAmountMinor: S
3016
- }
3050
+ },
3051
+ hasSubscriptions: S,
3052
+ // One entry per subscription line. No `name`: it is the line's name.
3053
+ subscriptions: [{
3054
+ lineItemId: S,
3055
+ amount: S,
3056
+ quantity: S,
3057
+ interval: S,
3058
+ intervalUnit: S,
3059
+ intervalCount: S,
3060
+ totalPayments: S,
3061
+ trialDays: S,
3062
+ trialEndsAt: S,
3063
+ planChargedToday: S,
3064
+ taxApplies: S,
3065
+ scheduleGapUnits: [S],
3066
+ schedule: [{ net: S, dueAt: S }]
3067
+ }]
3017
3068
  },
3018
3069
  cart: section({
3019
3070
  id: S,
@@ -3154,7 +3205,7 @@ var OAUTH_PROJECTIONS = {
3154
3205
  };
3155
3206
 
3156
3207
  // src/server.ts
3157
- var VERSION = true ? "0.2.2" : "0.0.0-dev";
3208
+ var VERSION = true ? "0.4.0" : "0.0.0-dev";
3158
3209
  function registerableActions(policy) {
3159
3210
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3160
3211
  return actionsForChannel("mcp").filter((action) => {