@usethrottle/mcp 0.4.1 → 0.4.3

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.d.cts CHANGED
@@ -216,4 +216,72 @@ declare function createServer(options: CreateServerOptions): McpServer;
216
216
  declare function loadDocsIndex(): DocsIndex;
217
217
  declare function loadContractIndex(): ContractIndex;
218
218
 
219
- export { type ContractIndex, type CreateServerOptions, type DocsIndex, type HandlerContext, type Identity, type RegistrationPolicy, ThrottleClient, VERSION, buildInstructions, createServer, loadContractIndex, loadDocsIndex, registerableActions };
219
+ /** Every active ISO 4217 code in the snapshot; any other string is still accepted. */
220
+ type CurrencyCode = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UYW' | 'UZS' | 'VED' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAD' | 'XAF' | 'XCD' | 'XCG' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW' | 'ZWG' | (string & {});
221
+
222
+ /** Thrown by `minorUnitsOf` for a code that is not an active ISO 4217 code. */
223
+ declare class UnknownCurrencyError extends Error {
224
+ readonly code: "unknown_currency";
225
+ readonly currency: string;
226
+ constructor(currency: string);
227
+ }
228
+ /** Every active ISO 4217 code with its minor units and en-US symbol, sorted by code. */
229
+ declare const CURRENCIES: ReadonlyArray<{
230
+ code: string;
231
+ minorUnits: 0 | 2 | 3 | 4;
232
+ symbol: string;
233
+ }>;
234
+ /** Codes whose payment-provider exponent differs from ISO; slice 3 owns this set (MC2-R8). Read-only view. */
235
+ declare const UNCONFIRMED_EXPONENT_CODES: ReadonlySet<string>;
236
+ declare function isKnownCurrency(code: string): boolean;
237
+ declare function minorUnitsOf(code: string): 0 | 2 | 3 | 4;
238
+ /** Known, exponent 0/2/3, not a fund or non-transactional code, exponent confirmed (MC2-R8, MC2-R76). */
239
+ declare function isEnableableCurrency(code: string): boolean;
240
+
241
+ /**
242
+ * en-US money text: symbol first, `,` grouping, ISO fraction digits. Never throws:
243
+ * a non-finite amount prints `—`, an unknown code prints `12.34 XYZ`, no code prints `12.34`.
244
+ */
245
+ declare function formatMoney(minor: number, code: string, opts?: {
246
+ display?: 'symbol' | 'symbol-code';
247
+ }): string;
248
+ /** The en-US symbol of a known code, otherwise the trimmed upper-cased code. */
249
+ declare function currencySymbol(code: string): string;
250
+ /** Plain decimal text (`19.99`, `1999` for JPY, `-0.05`); `''` for a non-finite amount. */
251
+ declare function toDecimalString(minor: number, code: string): string;
252
+ type MoneyValue = {
253
+ amount: number;
254
+ currency: string;
255
+ display: string;
256
+ };
257
+ declare function moneyValue(amount: number, currency: string): MoneyValue;
258
+
259
+ /** `'19.99'` or `19.99` to minor units; null for anything else or an unsafe result. */
260
+ declare function toMinor(decimal: string | number, code: string): number | null;
261
+ /**
262
+ * Human money text to minor units: optional leading `-`, one optional marker
263
+ * (this currency's symbol or code) before or after the digits, `,` only as
264
+ * 3-digit grouping, `.` with 1..exponent fraction digits. Anything else is null.
265
+ */
266
+ declare function parseMoney(text: string, code: string): number | null;
267
+
268
+ declare const index_d_CURRENCIES: typeof CURRENCIES;
269
+ type index_d_CurrencyCode = CurrencyCode;
270
+ type index_d_MoneyValue = MoneyValue;
271
+ declare const index_d_UNCONFIRMED_EXPONENT_CODES: typeof UNCONFIRMED_EXPONENT_CODES;
272
+ type index_d_UnknownCurrencyError = UnknownCurrencyError;
273
+ declare const index_d_UnknownCurrencyError: typeof UnknownCurrencyError;
274
+ declare const index_d_currencySymbol: typeof currencySymbol;
275
+ declare const index_d_formatMoney: typeof formatMoney;
276
+ declare const index_d_isEnableableCurrency: typeof isEnableableCurrency;
277
+ declare const index_d_isKnownCurrency: typeof isKnownCurrency;
278
+ declare const index_d_minorUnitsOf: typeof minorUnitsOf;
279
+ declare const index_d_moneyValue: typeof moneyValue;
280
+ declare const index_d_parseMoney: typeof parseMoney;
281
+ declare const index_d_toDecimalString: typeof toDecimalString;
282
+ declare const index_d_toMinor: typeof toMinor;
283
+ declare namespace index_d {
284
+ export { index_d_CURRENCIES as CURRENCIES, type index_d_CurrencyCode as CurrencyCode, type index_d_MoneyValue as MoneyValue, index_d_UNCONFIRMED_EXPONENT_CODES as UNCONFIRMED_EXPONENT_CODES, index_d_UnknownCurrencyError as UnknownCurrencyError, index_d_currencySymbol as currencySymbol, index_d_formatMoney as formatMoney, index_d_isEnableableCurrency as isEnableableCurrency, index_d_isKnownCurrency as isKnownCurrency, index_d_minorUnitsOf as minorUnitsOf, index_d_moneyValue as moneyValue, index_d_parseMoney as parseMoney, index_d_toDecimalString as toDecimalString, index_d_toMinor as toMinor };
285
+ }
286
+
287
+ export { CURRENCIES, type ContractIndex, type CreateServerOptions, type CurrencyCode, type DocsIndex, type HandlerContext, type Identity, type MoneyValue, type RegistrationPolicy, ThrottleClient, UnknownCurrencyError, VERSION, buildInstructions, createServer, currencySymbol, formatMoney, isKnownCurrency, loadContractIndex, loadDocsIndex, minorUnitsOf, index_d as money, moneyValue, parseMoney, registerableActions, toDecimalString, toMinor };
package/dist/lib.d.ts CHANGED
@@ -216,4 +216,72 @@ declare function createServer(options: CreateServerOptions): McpServer;
216
216
  declare function loadDocsIndex(): DocsIndex;
217
217
  declare function loadContractIndex(): ContractIndex;
218
218
 
219
- export { type ContractIndex, type CreateServerOptions, type DocsIndex, type HandlerContext, type Identity, type RegistrationPolicy, ThrottleClient, VERSION, buildInstructions, createServer, loadContractIndex, loadDocsIndex, registerableActions };
219
+ /** Every active ISO 4217 code in the snapshot; any other string is still accepted. */
220
+ type CurrencyCode = 'AED' | 'AFN' | 'ALL' | 'AMD' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLE' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UYW' | 'UZS' | 'VED' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAD' | 'XAF' | 'XCD' | 'XCG' | 'XOF' | 'XPF' | 'YER' | 'ZAR' | 'ZMW' | 'ZWG' | (string & {});
221
+
222
+ /** Thrown by `minorUnitsOf` for a code that is not an active ISO 4217 code. */
223
+ declare class UnknownCurrencyError extends Error {
224
+ readonly code: "unknown_currency";
225
+ readonly currency: string;
226
+ constructor(currency: string);
227
+ }
228
+ /** Every active ISO 4217 code with its minor units and en-US symbol, sorted by code. */
229
+ declare const CURRENCIES: ReadonlyArray<{
230
+ code: string;
231
+ minorUnits: 0 | 2 | 3 | 4;
232
+ symbol: string;
233
+ }>;
234
+ /** Codes whose payment-provider exponent differs from ISO; slice 3 owns this set (MC2-R8). Read-only view. */
235
+ declare const UNCONFIRMED_EXPONENT_CODES: ReadonlySet<string>;
236
+ declare function isKnownCurrency(code: string): boolean;
237
+ declare function minorUnitsOf(code: string): 0 | 2 | 3 | 4;
238
+ /** Known, exponent 0/2/3, not a fund or non-transactional code, exponent confirmed (MC2-R8, MC2-R76). */
239
+ declare function isEnableableCurrency(code: string): boolean;
240
+
241
+ /**
242
+ * en-US money text: symbol first, `,` grouping, ISO fraction digits. Never throws:
243
+ * a non-finite amount prints `—`, an unknown code prints `12.34 XYZ`, no code prints `12.34`.
244
+ */
245
+ declare function formatMoney(minor: number, code: string, opts?: {
246
+ display?: 'symbol' | 'symbol-code';
247
+ }): string;
248
+ /** The en-US symbol of a known code, otherwise the trimmed upper-cased code. */
249
+ declare function currencySymbol(code: string): string;
250
+ /** Plain decimal text (`19.99`, `1999` for JPY, `-0.05`); `''` for a non-finite amount. */
251
+ declare function toDecimalString(minor: number, code: string): string;
252
+ type MoneyValue = {
253
+ amount: number;
254
+ currency: string;
255
+ display: string;
256
+ };
257
+ declare function moneyValue(amount: number, currency: string): MoneyValue;
258
+
259
+ /** `'19.99'` or `19.99` to minor units; null for anything else or an unsafe result. */
260
+ declare function toMinor(decimal: string | number, code: string): number | null;
261
+ /**
262
+ * Human money text to minor units: optional leading `-`, one optional marker
263
+ * (this currency's symbol or code) before or after the digits, `,` only as
264
+ * 3-digit grouping, `.` with 1..exponent fraction digits. Anything else is null.
265
+ */
266
+ declare function parseMoney(text: string, code: string): number | null;
267
+
268
+ declare const index_d_CURRENCIES: typeof CURRENCIES;
269
+ type index_d_CurrencyCode = CurrencyCode;
270
+ type index_d_MoneyValue = MoneyValue;
271
+ declare const index_d_UNCONFIRMED_EXPONENT_CODES: typeof UNCONFIRMED_EXPONENT_CODES;
272
+ type index_d_UnknownCurrencyError = UnknownCurrencyError;
273
+ declare const index_d_UnknownCurrencyError: typeof UnknownCurrencyError;
274
+ declare const index_d_currencySymbol: typeof currencySymbol;
275
+ declare const index_d_formatMoney: typeof formatMoney;
276
+ declare const index_d_isEnableableCurrency: typeof isEnableableCurrency;
277
+ declare const index_d_isKnownCurrency: typeof isKnownCurrency;
278
+ declare const index_d_minorUnitsOf: typeof minorUnitsOf;
279
+ declare const index_d_moneyValue: typeof moneyValue;
280
+ declare const index_d_parseMoney: typeof parseMoney;
281
+ declare const index_d_toDecimalString: typeof toDecimalString;
282
+ declare const index_d_toMinor: typeof toMinor;
283
+ declare namespace index_d {
284
+ export { index_d_CURRENCIES as CURRENCIES, type index_d_CurrencyCode as CurrencyCode, type index_d_MoneyValue as MoneyValue, index_d_UNCONFIRMED_EXPONENT_CODES as UNCONFIRMED_EXPONENT_CODES, index_d_UnknownCurrencyError as UnknownCurrencyError, index_d_currencySymbol as currencySymbol, index_d_formatMoney as formatMoney, index_d_isEnableableCurrency as isEnableableCurrency, index_d_isKnownCurrency as isKnownCurrency, index_d_minorUnitsOf as minorUnitsOf, index_d_moneyValue as moneyValue, index_d_parseMoney as parseMoney, index_d_toDecimalString as toDecimalString, index_d_toMinor as toMinor };
285
+ }
286
+
287
+ export { CURRENCIES, type ContractIndex, type CreateServerOptions, type CurrencyCode, type DocsIndex, type HandlerContext, type Identity, type MoneyValue, type RegistrationPolicy, ThrottleClient, UnknownCurrencyError, VERSION, buildInstructions, createServer, currencySymbol, formatMoney, isKnownCurrency, loadContractIndex, loadDocsIndex, minorUnitsOf, index_d as money, moneyValue, parseMoney, registerableActions, toDecimalString, toMinor };
package/dist/lib.js CHANGED
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/server.ts
2
8
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
9
  import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
@@ -62,6 +68,8 @@ add("Customers", "customers", ["read", "write"], { read: "View customers", write
62
68
  add("Customers", "customer_pii", ["read"], { read: "View customer PII" }, { sensitive: true });
63
69
  add("Customers", "customer_addresses", ["read", "write"], { read: "View addresses", write: "Manage addresses" });
64
70
  add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
71
+ add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
72
+ add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
65
73
  add(
66
74
  "Customer accounts",
67
75
  "customer_accounts",
@@ -194,6 +202,7 @@ var EVENT_SCOPE_OVERRIDES = {
194
202
  "subscription.invoice_refunded": "payment_refunds:read",
195
203
  "payment.disputed": "payment_disputes:read",
196
204
  "payment.dispute_cleared": "payment_disputes:read",
205
+ "payment.dispute_lost": "payment_disputes:read",
197
206
  "fulfillment.digital.delivered": "fulfillment_digital:read"
198
207
  };
199
208
  var PREFIX_RULES = [
@@ -502,7 +511,7 @@ var ACTIONS = [
502
511
  {
503
512
  id: "search_customers",
504
513
  title: "Search customers",
505
- description: "Find customers by name, email or external id, or list them by creation date. Over an OAuth connection (ChatGPT, Claude) text search is not available \u2014 list by date instead \u2014 because every field it could match is withheld there.",
514
+ description: "Find customers by name, company, email or external id, or list them by creation date. Over an OAuth connection (ChatGPT, Claude) text search is not available \u2014 list by date instead \u2014 because every field it could match is withheld there.",
506
515
  kind: "read",
507
516
  scopes: ["customers:read"],
508
517
  input: [
@@ -1347,7 +1356,7 @@ var ACTIONS = [
1347
1356
  {
1348
1357
  id: "create_customer",
1349
1358
  title: "Create a customer",
1350
- description: "Create a customer record. Use search_customers first if the buyer may already exist \u2014 this does not de-duplicate by email.",
1359
+ description: "Create a customer record. Email and externalId are each unique per application: a value that already belongs to a customer fails with 409 customer_already_exists rather than returning the existing record, so use search_customers first if the buyer may already exist.",
1351
1360
  kind: "write",
1352
1361
  scopes: ["customers:write"],
1353
1362
  input: [
@@ -1425,7 +1434,7 @@ var ACTIONS = [
1425
1434
  {
1426
1435
  id: "create_checkout_link",
1427
1436
  title: "Create a checkout link",
1428
- description: "Build a cart from line items and return a hosted checkout URL the buyer can pay at. Prices are in minor units (2500 = $25.00).",
1437
+ description: "Build a cart from line items and return a hosted checkout URL the buyer can pay at. Prices are integers in the minor units of the cart currency (2500 = 25.00 in a two-decimal currency).",
1429
1438
  kind: "write",
1430
1439
  scopes: ["carts:write", "cart_items:write", "checkout_sessions:write"],
1431
1440
  input: [
@@ -1579,6 +1588,29 @@ var ACTIONS = [
1579
1588
  channels: ["mcp", "zapier", "make", "n8n"],
1580
1589
  idempotent: true
1581
1590
  },
1591
+ {
1592
+ id: "set_subscription_payment_method",
1593
+ title: "Change a subscription's card",
1594
+ description: "Set the saved card one subscription renews on. Only that subscription moves; the customer's default card and their other subscriptions stay as they are. Nothing is charged now.",
1595
+ kind: "write",
1596
+ scopes: ["subscriptions:write"],
1597
+ input: [
1598
+ { name: "id", type: "string", required: true, description: "Subscription id." },
1599
+ {
1600
+ name: "paymentMethodId",
1601
+ type: "string",
1602
+ required: true,
1603
+ description: "One of the subscription customer's saved cards (GET /api/v1/customers/:id/payment-methods): active and in date."
1604
+ }
1605
+ ],
1606
+ requests: [{ method: "PATCH", path: "/api/v1/subscriptions/:id/payment-method" }],
1607
+ channels: ["mcp", "zapier", "make", "n8n"],
1608
+ idempotent: true,
1609
+ guardrails: [
1610
+ "Changes which card future renewals charge. Confirm the subscription and the card (brand, last four) with the user first.",
1611
+ "409 payment_method_unusable: the card is not this customer's active, in-date saved card. 409 invalid_state: the subscription is cancelled or completed."
1612
+ ]
1613
+ },
1582
1614
  {
1583
1615
  id: "cancel_subscription",
1584
1616
  title: "Cancel a subscription",
@@ -2417,6 +2449,14 @@ var HANDLERS = {
2417
2449
  idempotencyKey: `mcp-manage-subscription-${id}-${action}-${Date.now()}`
2418
2450
  });
2419
2451
  },
2452
+ set_subscription_payment_method: async (ctx, args) => {
2453
+ const id = String(args.id);
2454
+ return ctx.client.patch(`/api/v1/subscriptions/${id}/payment-method`, {
2455
+ // `id` is the path parameter; the body is `.strict()`.
2456
+ body: { paymentMethodId: args.paymentMethodId },
2457
+ idempotencyKey: `mcp-set-subscription-card-${id}-${String(args.paymentMethodId)}-${Date.now()}`
2458
+ });
2459
+ },
2420
2460
  create_quote: async (ctx, args) => {
2421
2461
  const items = Array.isArray(args.items) ? args.items : [];
2422
2462
  if (args.netN !== void 0 && items.some((item) => item && item.recurring)) {
@@ -2681,6 +2721,7 @@ var DISPLAY_QUALIFIERS = [
2681
2721
  "Payment processing",
2682
2722
  "Disputed",
2683
2723
  "Authorization expired",
2724
+ "Chargeback lost",
2684
2725
  "Returned",
2685
2726
  "Partially returned",
2686
2727
  "Delivered",
@@ -2758,6 +2799,8 @@ var PAYMENT = {
2758
2799
  cardBrand: S,
2759
2800
  disputed: S,
2760
2801
  disputeOpenedAt: S,
2802
+ disputeOutcome: S,
2803
+ disputeClosedAt: S,
2761
2804
  errorCode: S,
2762
2805
  netN: S,
2763
2806
  netNSource: S,
@@ -2820,6 +2863,10 @@ var SUBSCRIPTION = {
2820
2863
  pendingIntervalCount: S,
2821
2864
  scheduleTotal: S,
2822
2865
  nextPaymentAmount: S,
2866
+ // A physical subscription (0236): the method is an enum, and the ship-to is
2867
+ // kept to its country like every other address here.
2868
+ deliveryMethod: S,
2869
+ shippingAddress: ADDRESS,
2823
2870
  paymentSchedule: [{
2824
2871
  index: S,
2825
2872
  amount: S,
@@ -3196,7 +3243,7 @@ var OAUTH_PROJECTIONS = {
3196
3243
  };
3197
3244
 
3198
3245
  // src/server.ts
3199
- var VERSION = true ? "0.4.1" : "0.0.0-dev";
3246
+ var VERSION = true ? "0.4.3" : "0.0.0-dev";
3200
3247
  function registerableActions(policy) {
3201
3248
  const isProduction = policy.identity.environment.providerEnvironment === "production";
3202
3249
  return actionsForChannel("mcp").filter((action) => {
@@ -3225,7 +3272,7 @@ function buildInstructions(identity, actions, policy) {
3225
3272
  '- The application can vary per call: pass "applicationId" on a read or analytics tool to reach a different application in this workspace, and call list_applications to see which ones this connection can reach. Omitting applicationId uses the application this connection was authorized for.',
3226
3273
  "- Every analytics result covers exactly ONE application and names it in `application`. Say which application a figure describes. If the user asks about their business as a whole and this connection reaches more than one application, do not answer from the default alone \u2014 call list_applications, then query each and add them up, or ask which application they mean.",
3227
3274
  '- List tools return { data, pagination }. When pagination.hasMore is true, pass pagination.cursor back as "cursor" rather than raising "limit".',
3228
- "- Amounts are integer minor units (2500 = $25.00).",
3275
+ "- Amounts are integer minor units of the record's currency (2500 = 25.00 in a two-decimal currency; JPY has none, KWD has three).",
3229
3276
  "- Throttle rejects snake_case on public request bodies. Before writing integration code, confirm shapes with describe_endpoint and check bodies with validate_payload instead of guessing field names.",
3230
3277
  "- API errors come back as text with a stable code. On insufficient_scopes, tell the user which scope to add \u2014 do not retry.",
3231
3278
  "- Analytics results may mark a section `omitted`. That means UNKNOWN, never zero. When `grantable` is false the data cannot be read over this connection at all \u2014 say so rather than reporting an absence."
@@ -3361,13 +3408,331 @@ function loadDocsIndex() {
3361
3408
  function loadContractIndex() {
3362
3409
  return loadIndex("contract-index.json", { generatedAt: "", operations: [] }, "contract");
3363
3410
  }
3411
+
3412
+ // ../money/dist/index.js
3413
+ var dist_exports = {};
3414
+ __export(dist_exports, {
3415
+ CURRENCIES: () => CURRENCIES,
3416
+ UNCONFIRMED_EXPONENT_CODES: () => UNCONFIRMED_EXPONENT_CODES,
3417
+ UnknownCurrencyError: () => UnknownCurrencyError,
3418
+ currencySymbol: () => currencySymbol,
3419
+ formatMoney: () => formatMoney,
3420
+ isEnableableCurrency: () => isEnableableCurrency,
3421
+ isKnownCurrency: () => isKnownCurrency,
3422
+ minorUnitsOf: () => minorUnitsOf,
3423
+ moneyValue: () => moneyValue,
3424
+ parseMoney: () => parseMoney,
3425
+ toDecimalString: () => toDecimalString,
3426
+ toMinor: () => toMinor
3427
+ });
3428
+ var CURRENCY_ROWS = [
3429
+ ["AED", 2, "AED", false],
3430
+ ["AFN", 2, "AFN", false],
3431
+ ["ALL", 2, "ALL", false],
3432
+ ["AMD", 2, "AMD", false],
3433
+ ["AOA", 2, "AOA", false],
3434
+ ["ARS", 2, "ARS", false],
3435
+ ["AUD", 2, "A$", false],
3436
+ ["AWG", 2, "AWG", false],
3437
+ ["AZN", 2, "AZN", false],
3438
+ ["BAM", 2, "BAM", false],
3439
+ ["BBD", 2, "BBD", false],
3440
+ ["BDT", 2, "BDT", false],
3441
+ ["BHD", 3, "BHD", false],
3442
+ ["BIF", 0, "BIF", false],
3443
+ ["BMD", 2, "BMD", false],
3444
+ ["BND", 2, "BND", false],
3445
+ ["BOB", 2, "BOB", false],
3446
+ ["BOV", 2, "BOV", true],
3447
+ ["BRL", 2, "R$", false],
3448
+ ["BSD", 2, "BSD", false],
3449
+ ["BTN", 2, "BTN", false],
3450
+ ["BWP", 2, "BWP", false],
3451
+ ["BYN", 2, "BYN", false],
3452
+ ["BZD", 2, "BZD", false],
3453
+ ["CAD", 2, "CA$", false],
3454
+ ["CDF", 2, "CDF", false],
3455
+ ["CHE", 2, "CHE", true],
3456
+ ["CHF", 2, "CHF", false],
3457
+ ["CHW", 2, "CHW", true],
3458
+ ["CLF", 4, "CLF", true],
3459
+ ["CLP", 0, "CLP", false],
3460
+ ["CNY", 2, "CN\xA5", false],
3461
+ ["COP", 2, "COP", false],
3462
+ ["COU", 2, "COU", true],
3463
+ ["CRC", 2, "CRC", false],
3464
+ ["CUP", 2, "CUP", false],
3465
+ ["CVE", 2, "CVE", false],
3466
+ ["CZK", 2, "CZK", false],
3467
+ ["DJF", 0, "DJF", false],
3468
+ ["DKK", 2, "DKK", false],
3469
+ ["DOP", 2, "DOP", false],
3470
+ ["DZD", 2, "DZD", false],
3471
+ ["EGP", 2, "EGP", false],
3472
+ ["ERN", 2, "ERN", false],
3473
+ ["ETB", 2, "ETB", false],
3474
+ ["EUR", 2, "\u20AC", false],
3475
+ ["FJD", 2, "FJD", false],
3476
+ ["FKP", 2, "FKP", false],
3477
+ ["GBP", 2, "\xA3", false],
3478
+ ["GEL", 2, "GEL", false],
3479
+ ["GHS", 2, "GHS", false],
3480
+ ["GIP", 2, "GIP", false],
3481
+ ["GMD", 2, "GMD", false],
3482
+ ["GNF", 0, "GNF", false],
3483
+ ["GTQ", 2, "GTQ", false],
3484
+ ["GYD", 2, "GYD", false],
3485
+ ["HKD", 2, "HK$", false],
3486
+ ["HNL", 2, "HNL", false],
3487
+ ["HTG", 2, "HTG", false],
3488
+ ["HUF", 2, "HUF", false],
3489
+ ["IDR", 2, "IDR", false],
3490
+ ["ILS", 2, "\u20AA", false],
3491
+ ["INR", 2, "\u20B9", false],
3492
+ ["IQD", 3, "IQD", false],
3493
+ ["IRR", 2, "IRR", false],
3494
+ ["ISK", 0, "ISK", false],
3495
+ ["JMD", 2, "JMD", false],
3496
+ ["JOD", 3, "JOD", false],
3497
+ ["JPY", 0, "\xA5", false],
3498
+ ["KES", 2, "KES", false],
3499
+ ["KGS", 2, "KGS", false],
3500
+ ["KHR", 2, "KHR", false],
3501
+ ["KMF", 0, "KMF", false],
3502
+ ["KPW", 2, "KPW", false],
3503
+ ["KRW", 0, "\u20A9", false],
3504
+ ["KWD", 3, "KWD", false],
3505
+ ["KYD", 2, "KYD", false],
3506
+ ["KZT", 2, "KZT", false],
3507
+ ["LAK", 2, "LAK", false],
3508
+ ["LBP", 2, "LBP", false],
3509
+ ["LKR", 2, "LKR", false],
3510
+ ["LRD", 2, "LRD", false],
3511
+ ["LSL", 2, "LSL", false],
3512
+ ["LYD", 3, "LYD", false],
3513
+ ["MAD", 2, "MAD", false],
3514
+ ["MDL", 2, "MDL", false],
3515
+ ["MGA", 2, "MGA", false],
3516
+ ["MKD", 2, "MKD", false],
3517
+ ["MMK", 2, "MMK", false],
3518
+ ["MNT", 2, "MNT", false],
3519
+ ["MOP", 2, "MOP", false],
3520
+ ["MRU", 2, "MRU", false],
3521
+ ["MUR", 2, "MUR", false],
3522
+ ["MVR", 2, "MVR", false],
3523
+ ["MWK", 2, "MWK", false],
3524
+ ["MXN", 2, "MX$", false],
3525
+ ["MXV", 2, "MXV", true],
3526
+ ["MYR", 2, "MYR", false],
3527
+ ["MZN", 2, "MZN", false],
3528
+ ["NAD", 2, "NAD", false],
3529
+ ["NGN", 2, "NGN", false],
3530
+ ["NIO", 2, "NIO", false],
3531
+ ["NOK", 2, "NOK", false],
3532
+ ["NPR", 2, "NPR", false],
3533
+ ["NZD", 2, "NZ$", false],
3534
+ ["OMR", 3, "OMR", false],
3535
+ ["PAB", 2, "PAB", false],
3536
+ ["PEN", 2, "PEN", false],
3537
+ ["PGK", 2, "PGK", false],
3538
+ ["PHP", 2, "\u20B1", false],
3539
+ ["PKR", 2, "PKR", false],
3540
+ ["PLN", 2, "PLN", false],
3541
+ ["PYG", 0, "PYG", false],
3542
+ ["QAR", 2, "QAR", false],
3543
+ ["RON", 2, "RON", false],
3544
+ ["RSD", 2, "RSD", false],
3545
+ ["RUB", 2, "RUB", false],
3546
+ ["RWF", 0, "RWF", false],
3547
+ ["SAR", 2, "SAR", false],
3548
+ ["SBD", 2, "SBD", false],
3549
+ ["SCR", 2, "SCR", false],
3550
+ ["SDG", 2, "SDG", false],
3551
+ ["SEK", 2, "SEK", false],
3552
+ ["SGD", 2, "SGD", false],
3553
+ ["SHP", 2, "SHP", false],
3554
+ ["SLE", 2, "SLE", false],
3555
+ ["SOS", 2, "SOS", false],
3556
+ ["SRD", 2, "SRD", false],
3557
+ ["SSP", 2, "SSP", false],
3558
+ ["STN", 2, "STN", false],
3559
+ ["SVC", 2, "SVC", false],
3560
+ ["SYP", 2, "SYP", false],
3561
+ ["SZL", 2, "SZL", false],
3562
+ ["THB", 2, "THB", false],
3563
+ ["TJS", 2, "TJS", false],
3564
+ ["TMT", 2, "TMT", false],
3565
+ ["TND", 3, "TND", false],
3566
+ ["TOP", 2, "TOP", false],
3567
+ ["TRY", 2, "TRY", false],
3568
+ ["TTD", 2, "TTD", false],
3569
+ ["TWD", 2, "NT$", false],
3570
+ ["TZS", 2, "TZS", false],
3571
+ ["UAH", 2, "UAH", false],
3572
+ ["UGX", 0, "UGX", false],
3573
+ ["USD", 2, "$", false],
3574
+ ["USN", 2, "USN", true],
3575
+ ["UYI", 0, "UYI", true],
3576
+ ["UYU", 2, "UYU", false],
3577
+ ["UYW", 4, "UYW", true],
3578
+ ["UZS", 2, "UZS", false],
3579
+ ["VED", 2, "VED", false],
3580
+ ["VES", 2, "VES", false],
3581
+ ["VND", 0, "\u20AB", false],
3582
+ ["VUV", 0, "VUV", false],
3583
+ ["WST", 2, "WST", false],
3584
+ ["XAD", 2, "XAD", true],
3585
+ ["XAF", 0, "FCFA", false],
3586
+ ["XCD", 2, "EC$", false],
3587
+ ["XCG", 2, "Cg.", false],
3588
+ ["XOF", 0, "F\u202FCFA", false],
3589
+ ["XPF", 0, "CFPF", false],
3590
+ ["YER", 2, "YER", false],
3591
+ ["ZAR", 2, "ZAR", false],
3592
+ ["ZMW", 2, "ZMW", false],
3593
+ ["ZWG", 2, "ZWG", false]
3594
+ ];
3595
+ var UnknownCurrencyError = class extends Error {
3596
+ constructor(currency) {
3597
+ super(`Unknown currency code: ${currency}`);
3598
+ this.code = "unknown_currency";
3599
+ this.name = "UnknownCurrencyError";
3600
+ this.currency = currency;
3601
+ }
3602
+ };
3603
+ var BY_CODE = new Map(
3604
+ CURRENCY_ROWS.map(([code, minorUnits, symbol, fund]) => [code, { minorUnits, symbol, fund }])
3605
+ );
3606
+ var CURRENCIES = Object.freeze(
3607
+ CURRENCY_ROWS.map(([code, minorUnits, symbol]) => Object.freeze({ code, minorUnits, symbol }))
3608
+ );
3609
+ var UNCONFIRMED = /* @__PURE__ */ new Set(["COP", "HUF", "IDR", "ISK", "TWD", "UGX"]);
3610
+ var UNCONFIRMED_EXPONENT_CODES = Object.freeze({
3611
+ has: (code) => UNCONFIRMED.has(code),
3612
+ get size() {
3613
+ return UNCONFIRMED.size;
3614
+ },
3615
+ forEach: (fn, thisArg) => UNCONFIRMED.forEach((v) => fn.call(thisArg, v, v, UNCONFIRMED_EXPONENT_CODES)),
3616
+ keys: () => UNCONFIRMED.keys(),
3617
+ values: () => UNCONFIRMED.values(),
3618
+ entries: () => UNCONFIRMED.entries(),
3619
+ [Symbol.iterator]: () => UNCONFIRMED.values()
3620
+ });
3621
+ function currencyRow(code) {
3622
+ return BY_CODE.get(code);
3623
+ }
3624
+ function isKnownCurrency(code) {
3625
+ return BY_CODE.has(code);
3626
+ }
3627
+ function minorUnitsOf(code) {
3628
+ const row = BY_CODE.get(code);
3629
+ if (row === void 0) throw new UnknownCurrencyError(code);
3630
+ return row.minorUnits;
3631
+ }
3632
+ function isEnableableCurrency(code) {
3633
+ const row = BY_CODE.get(code);
3634
+ return row !== void 0 && row.minorUnits !== 4 && !row.fund && !UNCONFIRMED.has(code);
3635
+ }
3636
+ var NBSP = "\xA0";
3637
+ function normalizeCode(code) {
3638
+ return typeof code === "string" ? code.trim().toUpperCase() : "";
3639
+ }
3640
+ function displayExponent(normalizedCode) {
3641
+ return currencyRow(normalizedCode)?.minorUnits ?? 2;
3642
+ }
3643
+ function roundHalfAwayFromZero(n) {
3644
+ return n < 0 ? -Math.round(-n) : Math.round(n);
3645
+ }
3646
+ function decimalDigits(abs, exponent, grouped) {
3647
+ const raw = Number.isSafeInteger(abs) ? String(abs) : BigInt(abs).toString();
3648
+ const padded = raw.padStart(exponent + 1, "0");
3649
+ const cut = padded.length - exponent;
3650
+ let integer = padded.slice(0, cut);
3651
+ if (grouped) integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3652
+ return exponent === 0 ? integer : `${integer}.${padded.slice(cut)}`;
3653
+ }
3654
+ function formatMoney(minor, code, opts) {
3655
+ if (typeof minor !== "number" || !Number.isFinite(minor)) return "\u2014";
3656
+ const c = normalizeCode(code);
3657
+ const row = currencyRow(c);
3658
+ const n = roundHalfAwayFromZero(minor);
3659
+ const sign = n < 0 ? "-" : "";
3660
+ const digits = decimalDigits(Math.abs(n), row?.minorUnits ?? 2, true);
3661
+ if (c === "") return sign + digits;
3662
+ if (row === void 0) return `${sign}${digits}${NBSP}${c}`;
3663
+ const separator = new RegExp("\\p{Sc}$", "u").test(row.symbol) ? "" : NBSP;
3664
+ const text = `${sign}${row.symbol}${separator}${digits}`;
3665
+ return opts?.display === "symbol-code" && row.symbol !== c ? `${text}${NBSP}${c}` : text;
3666
+ }
3667
+ function currencySymbol(code) {
3668
+ const c = normalizeCode(code);
3669
+ return currencyRow(c)?.symbol ?? c;
3670
+ }
3671
+ function toDecimalString(minor, code) {
3672
+ if (typeof minor !== "number" || !Number.isFinite(minor)) return "";
3673
+ const n = roundHalfAwayFromZero(minor);
3674
+ const sign = n < 0 ? "-" : "";
3675
+ return sign + decimalDigits(Math.abs(n), displayExponent(normalizeCode(code)), false);
3676
+ }
3677
+ function moneyValue(amount, currency) {
3678
+ return { amount, currency: normalizeCode(currency), display: formatMoney(amount, currency) };
3679
+ }
3680
+ function toMinorUnits(negative, integer, fraction, exponent) {
3681
+ if (fraction.length > exponent) return null;
3682
+ const n = Number(integer + fraction.padEnd(exponent, "0"));
3683
+ if (!Number.isSafeInteger(n)) return null;
3684
+ return negative && n !== 0 ? -n : n;
3685
+ }
3686
+ function toMinor(decimal, code) {
3687
+ const text = typeof decimal === "number" ? String(decimal) : typeof decimal === "string" ? decimal : "";
3688
+ const m = /^(-?)(\d+)(?:\.(\d+))?$/.exec(text);
3689
+ if (m === null) return null;
3690
+ return toMinorUnits(m[1] === "-", m[2], m[3] ?? "", displayExponent(normalizeCode(code)));
3691
+ }
3692
+ var SPACE = /^[ \u00A0]/;
3693
+ var TRAILING_SPACE = /[ \u00A0]$/;
3694
+ var AMOUNT = /^([1-9]\d{0,2}(?:,\d{3})+|\d+)(?:\.(\d+))?$/;
3695
+ function withoutMarker(text, markers) {
3696
+ for (const marker of markers) {
3697
+ if (text.startsWith(marker)) return text.slice(marker.length).replace(SPACE, "");
3698
+ }
3699
+ for (const marker of markers) {
3700
+ if (text.endsWith(marker)) return text.slice(0, text.length - marker.length).replace(TRAILING_SPACE, "");
3701
+ }
3702
+ return text;
3703
+ }
3704
+ function parseMoney(text, code) {
3705
+ if (typeof text !== "string") return null;
3706
+ const c = normalizeCode(code);
3707
+ let rest = text.trim();
3708
+ const negative = rest.startsWith("-");
3709
+ if (negative) rest = rest.slice(1);
3710
+ if (c !== "") {
3711
+ const symbol = currencySymbol(c);
3712
+ rest = withoutMarker(rest, symbol === c ? [c] : [symbol, c]);
3713
+ }
3714
+ const m = AMOUNT.exec(rest);
3715
+ if (m === null) return null;
3716
+ return toMinorUnits(negative, m[1].replace(/,/g, ""), m[2] ?? "", displayExponent(c));
3717
+ }
3364
3718
  export {
3719
+ CURRENCIES,
3365
3720
  ThrottleClient,
3721
+ UnknownCurrencyError,
3366
3722
  VERSION,
3367
3723
  buildInstructions,
3368
3724
  createServer,
3725
+ currencySymbol,
3726
+ formatMoney,
3727
+ isKnownCurrency,
3369
3728
  loadContractIndex,
3370
3729
  loadDocsIndex,
3371
- registerableActions
3730
+ minorUnitsOf,
3731
+ dist_exports as money,
3732
+ moneyValue,
3733
+ parseMoney,
3734
+ registerableActions,
3735
+ toDecimalString,
3736
+ toMinor
3372
3737
  };
3373
3738
  //# sourceMappingURL=lib.js.map