@usethrottle/mcp 0.2.2 → 0.3.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,14 @@ 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
+ };
2668
2684
  var LINE_ITEM = {
2669
2685
  id: S,
2670
2686
  type: S,
@@ -2674,7 +2690,9 @@ var LINE_ITEM = {
2674
2690
  discountAmount: S,
2675
2691
  taxAmount: S,
2676
2692
  total: S,
2677
- recurring: S
2693
+ // amount = renewal price on a trial line (whose unitPrice is 0); count = the old display mirror.
2694
+ recurring: { ...LINE_RECURRING, amount: S, count: S },
2695
+ subscriptionId: S
2678
2696
  };
2679
2697
  var ORDER = {
2680
2698
  id: S,
@@ -2698,6 +2716,7 @@ var ORDER = {
2698
2716
  customerId: S,
2699
2717
  customer: CUSTOMER_REF,
2700
2718
  subscriptionId: S,
2719
+ subscriptionIds: [S],
2701
2720
  shippingAddress: ADDRESS,
2702
2721
  billingAddress: ADDRESS,
2703
2722
  fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
@@ -2820,7 +2839,8 @@ var QUOTE = {
2820
2839
  taxAmount: S,
2821
2840
  total: S,
2822
2841
  optional: S,
2823
- optionalSelected: S
2842
+ optionalSelected: S,
2843
+ recurring: LINE_RECURRING
2824
2844
  }]
2825
2845
  }],
2826
2846
  // Who commented and when, never what they wrote.
@@ -2986,7 +3006,22 @@ var OAUTH_PROJECTIONS = {
2986
3006
  trialDays: S,
2987
3007
  currency: S,
2988
3008
  firstChargeAmountMinor: S
2989
- }
3009
+ },
3010
+ hasSubscriptions: S,
3011
+ // One entry per subscription line. No `name`: it is the line's name.
3012
+ subscriptions: [{
3013
+ lineItemId: S,
3014
+ amount: S,
3015
+ quantity: S,
3016
+ interval: S,
3017
+ intervalUnit: S,
3018
+ intervalCount: S,
3019
+ totalPayments: S,
3020
+ trialDays: S,
3021
+ trialEndsAt: S,
3022
+ planChargedToday: S,
3023
+ taxApplies: S
3024
+ }]
2990
3025
  },
2991
3026
  cart: section({
2992
3027
  id: S,
@@ -3127,7 +3162,7 @@ var OAUTH_PROJECTIONS = {
3127
3162
  };
3128
3163
 
3129
3164
  // src/server.ts
3130
- var VERSION = true ? "0.2.2" : "0.0.0-dev";
3165
+ var VERSION = true ? "0.3.0" : "0.0.0-dev";
3131
3166
  function registerableActions(policy) {
3132
3167
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3133
3168
  return actionsForChannel("mcp").filter((action) => {