@usethrottle/mcp 0.2.1 → 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/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"],
@@ -1728,6 +1736,7 @@ var ThrottleError = class extends Error {
1728
1736
  statusCode;
1729
1737
  details;
1730
1738
  body;
1739
+ requestId;
1731
1740
  constructor(args) {
1732
1741
  super(args.message);
1733
1742
  this.name = "ThrottleError";
@@ -1735,14 +1744,17 @@ var ThrottleError = class extends Error {
1735
1744
  this.statusCode = args.statusCode;
1736
1745
  this.details = args.details;
1737
1746
  this.body = args.body;
1747
+ const fromBody = args.body?.meta?.requestId;
1748
+ const fromHeader = typeof args.responseHeaders?.get === "function" ? args.responseHeaders.get("x-request-id") : args.responseHeaders?.["x-request-id"];
1749
+ this.requestId = args.requestId ?? (typeof fromBody === "string" ? fromBody : void 0) ?? (typeof fromHeader === "string" ? fromHeader : void 0);
1738
1750
  Object.setPrototypeOf(this, new.target.prototype);
1739
1751
  }
1740
1752
  };
1741
1753
 
1742
1754
  // src/client.ts
1743
1755
  var ThrottleApiError = class extends ThrottleError {
1744
- constructor(code, message, statusCode, details) {
1745
- super({ code, message, statusCode, details });
1756
+ constructor(code, message, statusCode, details, responseHeaders) {
1757
+ super({ code, message, statusCode, details, responseHeaders });
1746
1758
  this.name = "ThrottleApiError";
1747
1759
  }
1748
1760
  };
@@ -1808,7 +1820,8 @@ var ThrottleClient = class {
1808
1820
  err?.code ?? `http_${res.status}`,
1809
1821
  err?.message ?? `Request failed (${res.status}): ${text.slice(0, 200)}`,
1810
1822
  res.status,
1811
- err?.details
1823
+ err?.details,
1824
+ res.headers
1812
1825
  );
1813
1826
  }
1814
1827
  return parsed;
@@ -2413,14 +2426,14 @@ var HANDLERS = {
2413
2426
  idempotencyKey: `mcp-manage-subscription-${id}-${action}-${Date.now()}`
2414
2427
  });
2415
2428
  },
2416
- create_quote: async (ctx, args) => (
2417
- // The real route's body shape differs from this tool's flatter,
2418
- // model-facing input: line items are "items" (not "lineItems"), Net-N
2419
- // terms are nested under paymentTerms.netN with an explicit mode (not a
2420
- // flat "netN"), and the buyer-visible note field is "buyerNote" (not
2421
- // "notes"). Confirmed against packages/platform-api/src/validation/quotes.ts's
2422
- // actual zod schema after a live call 400'd with unrecognized_keys.
2423
- 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", {
2424
2437
  body: {
2425
2438
  customerId: args.customerId,
2426
2439
  items: args.items,
@@ -2429,8 +2442,8 @@ var HANDLERS = {
2429
2442
  buyerNote: args.notes
2430
2443
  },
2431
2444
  idempotencyKey: `mcp-create-quote-${String(args.customerId)}-${Date.now()}`
2432
- })
2433
- ),
2445
+ });
2446
+ },
2434
2447
  get_sales_timeseries: async (ctx, args) => ctx.client.get(
2435
2448
  "/api/v1/analytics/orders-timeseries",
2436
2449
  {
@@ -2687,6 +2700,14 @@ var ORDER_DISPLAY_STATUSES = new Set(
2687
2700
  );
2688
2701
  var DISPLAY_STATUS = oneOf(ORDER_DISPLAY_STATUSES);
2689
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
+ };
2690
2711
  var LINE_ITEM = {
2691
2712
  id: S,
2692
2713
  type: S,
@@ -2696,7 +2717,9 @@ var LINE_ITEM = {
2696
2717
  discountAmount: S,
2697
2718
  taxAmount: S,
2698
2719
  total: S,
2699
- recurring: S
2720
+ // amount = renewal price on a trial line (whose unitPrice is 0); count = the old display mirror.
2721
+ recurring: { ...LINE_RECURRING, amount: S, count: S },
2722
+ subscriptionId: S
2700
2723
  };
2701
2724
  var ORDER = {
2702
2725
  id: S,
@@ -2720,6 +2743,7 @@ var ORDER = {
2720
2743
  customerId: S,
2721
2744
  customer: CUSTOMER_REF,
2722
2745
  subscriptionId: S,
2746
+ subscriptionIds: [S],
2723
2747
  shippingAddress: ADDRESS,
2724
2748
  billingAddress: ADDRESS,
2725
2749
  fulfillmentSummary: { itemsFulfilled: S, itemsRemaining: S, itemsTotal: S },
@@ -2842,7 +2866,8 @@ var QUOTE = {
2842
2866
  taxAmount: S,
2843
2867
  total: S,
2844
2868
  optional: S,
2845
- optionalSelected: S
2869
+ optionalSelected: S,
2870
+ recurring: LINE_RECURRING
2846
2871
  }]
2847
2872
  }],
2848
2873
  // Who commented and when, never what they wrote.
@@ -3008,7 +3033,22 @@ var OAUTH_PROJECTIONS = {
3008
3033
  trialDays: S,
3009
3034
  currency: S,
3010
3035
  firstChargeAmountMinor: S
3011
- }
3036
+ },
3037
+ hasSubscriptions: S,
3038
+ // One entry per subscription line. No `name`: it is the line's name.
3039
+ subscriptions: [{
3040
+ lineItemId: S,
3041
+ amount: S,
3042
+ quantity: S,
3043
+ interval: S,
3044
+ intervalUnit: S,
3045
+ intervalCount: S,
3046
+ totalPayments: S,
3047
+ trialDays: S,
3048
+ trialEndsAt: S,
3049
+ planChargedToday: S,
3050
+ taxApplies: S
3051
+ }]
3012
3052
  },
3013
3053
  cart: section({
3014
3054
  id: S,
@@ -3149,7 +3189,7 @@ var OAUTH_PROJECTIONS = {
3149
3189
  };
3150
3190
 
3151
3191
  // src/server.ts
3152
- var VERSION = true ? "0.2.1" : "0.0.0-dev";
3192
+ var VERSION = true ? "0.3.0" : "0.0.0-dev";
3153
3193
  function registerableActions(policy) {
3154
3194
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3155
3195
  return actionsForChannel("mcp").filter((action) => {