@yawlabs/lemonsqueezy-mcp 0.3.0 → 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.
Files changed (3) hide show
  1. package/README.md +51 -0
  2. package/dist/index.js +508 -197
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -21010,39 +21010,219 @@ var StdioServerTransport = class {
21010
21010
  }
21011
21011
  };
21012
21012
 
21013
- // src/api.ts
21014
- var BASE_URL = "https://api.lemonsqueezy.com/v1";
21013
+ // src/guardrails.ts
21014
+ var GuardrailError = class extends Error {
21015
+ constructor(message) {
21016
+ super(message);
21017
+ this.name = "GuardrailError";
21018
+ }
21019
+ };
21020
+ var cachedOptions = null;
21021
+ var destructiveTimestamps = [];
21022
+ function readNumber(name, raw) {
21023
+ if (raw === void 0 || raw.trim() === "") return null;
21024
+ const n = Number(raw);
21025
+ if (!Number.isFinite(n) || n < 0) {
21026
+ throw new Error(`${name} must be a non-negative number (got ${JSON.stringify(raw)})`);
21027
+ }
21028
+ return n;
21029
+ }
21030
+ function loadOptions() {
21031
+ if (cachedOptions) return cachedOptions;
21032
+ const allowed = process.env.LEMONSQUEEZY_ALLOWED_STORE_IDS;
21033
+ const allowedSet = allowed ? new Set(
21034
+ allowed.split(",").map((s) => s.trim()).filter(Boolean)
21035
+ ) : null;
21036
+ cachedOptions = {
21037
+ allowedStoreIds: allowedSet && allowedSet.size > 0 ? allowedSet : null,
21038
+ maxRefundAmountCents: readNumber(
21039
+ "LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS",
21040
+ process.env.LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS
21041
+ ),
21042
+ rateLimitPerMinute: readNumber(
21043
+ "LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT",
21044
+ process.env.LEMONSQUEEZY_DESTRUCTIVE_RATE_LIMIT
21045
+ )
21046
+ };
21047
+ return cachedOptions;
21048
+ }
21049
+ function checkStoreAllowed(storeId) {
21050
+ if (!storeId) return;
21051
+ const o = loadOptions();
21052
+ if (!o.allowedStoreIds) return;
21053
+ if (!o.allowedStoreIds.has(String(storeId))) {
21054
+ throw new GuardrailError(`Store ID ${storeId} is not in LEMONSQUEEZY_ALLOWED_STORE_IDS allowlist`);
21055
+ }
21056
+ }
21057
+ function checkRefundAmount(cents) {
21058
+ const o = loadOptions();
21059
+ if (o.maxRefundAmountCents === null) return;
21060
+ if (cents > o.maxRefundAmountCents) {
21061
+ throw new GuardrailError(
21062
+ `Refund amount ${cents} cents exceeds LEMONSQUEEZY_MAX_REFUND_AMOUNT_CENTS (${o.maxRefundAmountCents})`
21063
+ );
21064
+ }
21065
+ }
21066
+ function checkDestructiveRateLimit(now = Date.now()) {
21067
+ const o = loadOptions();
21068
+ if (o.rateLimitPerMinute === null) return;
21069
+ const cutoff = now - 6e4;
21070
+ destructiveTimestamps = destructiveTimestamps.filter((t) => t > cutoff);
21071
+ if (destructiveTimestamps.length >= o.rateLimitPerMinute) {
21072
+ throw new GuardrailError(`Destructive call rate limit exceeded (${o.rateLimitPerMinute}/min). Wait and retry.`);
21073
+ }
21074
+ destructiveTimestamps.push(now);
21075
+ }
21076
+
21077
+ // src/logger.ts
21078
+ function isEnabled() {
21079
+ return process.env.LEMONSQUEEZY_LOG === "json";
21080
+ }
21081
+ function logEvent(entry) {
21082
+ if (!isEnabled()) return;
21083
+ try {
21084
+ const line = JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry });
21085
+ process.stderr.write(`${line}
21086
+ `);
21087
+ } catch {
21088
+ }
21089
+ }
21090
+
21091
+ // src/retry.ts
21015
21092
  var REQUEST_TIMEOUT_MS = 3e4;
21016
21093
  var DEFAULT_RETRY_WAIT_MS = 1e3;
21017
21094
  var MAX_RETRY_WAIT_MS = 3e4;
21095
+ var DEFAULT_MAX_ATTEMPTS = 4;
21096
+ var BASE_BACKOFF_MS = 250;
21097
+ var JITTER_FRACTION = 0.25;
21018
21098
  function parseRetryAfterMs(header) {
21019
21099
  if (!header) return DEFAULT_RETRY_WAIT_MS;
21020
21100
  const trimmed = header.trim();
21021
21101
  const seconds = Number(trimmed);
21022
- if (Number.isFinite(seconds) && seconds >= 0) return seconds * 1e3;
21102
+ if (!Number.isNaN(seconds)) {
21103
+ return seconds >= 0 ? seconds * 1e3 : DEFAULT_RETRY_WAIT_MS;
21104
+ }
21023
21105
  const dateMs = Date.parse(trimmed);
21024
21106
  if (Number.isFinite(dateMs)) return Math.max(0, dateMs - Date.now());
21025
21107
  return DEFAULT_RETRY_WAIT_MS;
21026
21108
  }
21027
- async function fetchWithRetry(url, init) {
21028
- const makeCall = () => fetch(url, { ...init, signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
21029
- const res = await makeCall();
21030
- if (res.status !== 429) return res;
21031
- const waitMs = parseRetryAfterMs(res.headers.get("retry-after"));
21032
- if (waitMs > MAX_RETRY_WAIT_MS) return res;
21033
- await new Promise((resolve) => setTimeout(resolve, waitMs));
21034
- return makeCall();
21109
+ function isAbortTimeoutError(err) {
21110
+ if (!err || typeof err !== "object") return false;
21111
+ const e = err;
21112
+ return e.name === "TimeoutError" || e.name === "AbortError" || e.code === "ABORT_ERR";
21113
+ }
21114
+ function backoffDelay(attempt, rand = Math.random) {
21115
+ const base = BASE_BACKOFF_MS * 2 ** (attempt - 1);
21116
+ const jitter = rand() * base * JITTER_FRACTION;
21117
+ return Math.min(base + jitter, MAX_RETRY_WAIT_MS);
21118
+ }
21119
+ var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
21120
+ async function fetchWithRetry(url, init, opts) {
21121
+ const maxAttempts = opts.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
21122
+ const sleep = opts.sleep ?? defaultSleep;
21123
+ const fetchImpl = opts.fetchImpl ?? fetch;
21124
+ const rand = opts.rand ?? Math.random;
21125
+ let lastError;
21126
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
21127
+ try {
21128
+ const res = await fetchImpl(url, { ...init, signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
21129
+ if (res.status === 429) {
21130
+ if (attempt === maxAttempts) return res;
21131
+ const waitMs = parseRetryAfterMs(res.headers.get("retry-after"));
21132
+ if (waitMs > MAX_RETRY_WAIT_MS) return res;
21133
+ await sleep(waitMs);
21134
+ continue;
21135
+ }
21136
+ if (res.status >= 500 && res.status < 600 && opts.idempotent && attempt < maxAttempts) {
21137
+ await sleep(backoffDelay(attempt, rand));
21138
+ continue;
21139
+ }
21140
+ return res;
21141
+ } catch (err) {
21142
+ lastError = err;
21143
+ if (isAbortTimeoutError(err)) {
21144
+ if (!opts.idempotent || attempt === maxAttempts) throw err;
21145
+ await sleep(backoffDelay(attempt, rand));
21146
+ continue;
21147
+ }
21148
+ if (err instanceof TypeError && opts.idempotent && attempt < maxAttempts) {
21149
+ await sleep(backoffDelay(attempt, rand));
21150
+ continue;
21151
+ }
21152
+ throw err;
21153
+ }
21154
+ }
21155
+ throw lastError ?? new Error("fetchWithRetry exhausted attempts");
21156
+ }
21157
+
21158
+ // src/secret.ts
21159
+ import { execFile } from "node:child_process";
21160
+ import { promisify } from "node:util";
21161
+ var execFileAsync = promisify(execFile);
21162
+ var CACHE_TTL_MS = 60 * 60 * 1e3;
21163
+ var COMMAND_TIMEOUT_MS = 1e4;
21164
+ var COMMAND_MAX_BUFFER = 64 * 1024;
21165
+ var cached2 = null;
21166
+ function parseCommand(cmd) {
21167
+ const parts = [];
21168
+ let current = "";
21169
+ let quote = null;
21170
+ for (const ch of cmd) {
21171
+ if (quote) {
21172
+ if (ch === quote) {
21173
+ quote = null;
21174
+ continue;
21175
+ }
21176
+ current += ch;
21177
+ } else if (ch === '"' || ch === "'") {
21178
+ quote = ch;
21179
+ } else if (ch === " " || ch === " ") {
21180
+ if (current) {
21181
+ parts.push(current);
21182
+ current = "";
21183
+ }
21184
+ } else {
21185
+ current += ch;
21186
+ }
21187
+ }
21188
+ if (quote) throw new Error("LEMONSQUEEZY_API_KEY_COMMAND has an unterminated quote");
21189
+ if (current) parts.push(current);
21190
+ if (parts.length === 0) throw new Error("LEMONSQUEEZY_API_KEY_COMMAND is empty");
21191
+ return { command: parts[0], args: parts.slice(1) };
21035
21192
  }
21036
- function getApiKey() {
21193
+ async function loadApiKey() {
21194
+ if (cached2 && cached2.expiresAt > Date.now()) return cached2.key;
21195
+ const cmdStr = process.env.LEMONSQUEEZY_API_KEY_COMMAND;
21196
+ if (cmdStr && cmdStr.trim() !== "") {
21197
+ const { command, args } = parseCommand(cmdStr);
21198
+ let stdout;
21199
+ try {
21200
+ const result = await execFileAsync(command, args, {
21201
+ timeout: COMMAND_TIMEOUT_MS,
21202
+ maxBuffer: COMMAND_MAX_BUFFER
21203
+ });
21204
+ stdout = result.stdout;
21205
+ } catch (err) {
21206
+ const msg = err instanceof Error ? err.message : String(err);
21207
+ throw new Error(`LEMONSQUEEZY_API_KEY_COMMAND failed: ${msg}`);
21208
+ }
21209
+ const key2 = stdout.trim();
21210
+ if (!key2) throw new Error("LEMONSQUEEZY_API_KEY_COMMAND produced empty output");
21211
+ cached2 = { key: key2, expiresAt: Date.now() + CACHE_TTL_MS };
21212
+ return key2;
21213
+ }
21037
21214
  const key = process.env.LEMONSQUEEZY_API_KEY;
21038
21215
  if (!key) {
21039
- throw new Error("LEMONSQUEEZY_API_KEY environment variable is required.");
21216
+ throw new Error("LEMONSQUEEZY_API_KEY or LEMONSQUEEZY_API_KEY_COMMAND environment variable is required.");
21040
21217
  }
21041
21218
  if (key.trim() === "") {
21042
21219
  throw new Error("LEMONSQUEEZY_API_KEY is set but empty. Provide a valid API key.");
21043
21220
  }
21044
21221
  return key;
21045
21222
  }
21223
+
21224
+ // src/api.ts
21225
+ var BASE_URL = "https://api.lemonsqueezy.com/v1";
21046
21226
  function buildQuery(params) {
21047
21227
  if (!params) return "";
21048
21228
  const parts = [];
@@ -21064,9 +21244,14 @@ function buildQuery(params) {
21064
21244
  }
21065
21245
  return parts.length > 0 ? `?${parts.join("&")}` : "";
21066
21246
  }
21247
+ function decorateError(error2, requestId) {
21248
+ return requestId ? `${error2} (request_id: ${requestId})` : error2;
21249
+ }
21067
21250
  async function apiRequest(method, path, body) {
21251
+ const start = Date.now();
21252
+ const apiKey = await loadApiKey();
21068
21253
  const headers = {
21069
- Authorization: `Bearer ${getApiKey()}`,
21254
+ Authorization: `Bearer ${apiKey}`,
21070
21255
  Accept: "application/vnd.api+json"
21071
21256
  };
21072
21257
  let fetchBody;
@@ -21075,64 +21260,163 @@ async function apiRequest(method, path, body) {
21075
21260
  fetchBody = JSON.stringify(body);
21076
21261
  }
21077
21262
  const url = path.startsWith("http") ? path : `${BASE_URL}${path}`;
21263
+ const idempotent = method === "GET" || method === "DELETE";
21078
21264
  let res;
21079
21265
  try {
21080
- res = await fetchWithRetry(url, { method, headers, body: fetchBody });
21266
+ res = await fetchWithRetry(url, { method, headers, body: fetchBody }, { idempotent });
21081
21267
  } catch (err) {
21082
- if (err instanceof Error && err.name === "TimeoutError") {
21083
- return { ok: false, status: 0, error: `Request timed out after ${REQUEST_TIMEOUT_MS / 1e3}s` };
21084
- }
21268
+ const latency_ms2 = Date.now() - start;
21269
+ if (isAbortTimeoutError(err)) {
21270
+ const error2 = `Request timed out after ${REQUEST_TIMEOUT_MS / 1e3}s`;
21271
+ logEvent({ event: "http_call", method, path, status: "timeout", latency_ms: latency_ms2, error: error2 });
21272
+ return { ok: false, status: 0, error: error2 };
21273
+ }
21274
+ const message = err instanceof Error ? err.message : String(err);
21275
+ logEvent({ event: "http_call", method, path, status: "network_error", latency_ms: latency_ms2, error: message });
21085
21276
  throw err;
21086
21277
  }
21278
+ const latency_ms = Date.now() - start;
21279
+ const requestId = res.headers.get("x-request-id") ?? void 0;
21087
21280
  if (!res.ok) {
21088
21281
  const errorBody = await res.text();
21089
21282
  try {
21090
21283
  const parsed = JSON.parse(errorBody);
21091
- return { ok: false, status: res.status, data: parsed, error: parsed.errors?.[0]?.detail ?? errorBody };
21284
+ const detail = parsed.errors?.[0]?.detail ?? errorBody;
21285
+ logEvent({
21286
+ event: "http_call",
21287
+ method,
21288
+ path,
21289
+ status: res.status,
21290
+ latency_ms,
21291
+ request_id: requestId,
21292
+ error: detail
21293
+ });
21294
+ return {
21295
+ ok: false,
21296
+ status: res.status,
21297
+ data: parsed,
21298
+ error: decorateError(detail, requestId),
21299
+ requestId
21300
+ };
21092
21301
  } catch {
21093
- return { ok: false, status: res.status, error: errorBody };
21302
+ logEvent({
21303
+ event: "http_call",
21304
+ method,
21305
+ path,
21306
+ status: res.status,
21307
+ latency_ms,
21308
+ request_id: requestId,
21309
+ error: errorBody
21310
+ });
21311
+ return {
21312
+ ok: false,
21313
+ status: res.status,
21314
+ error: decorateError(errorBody, requestId),
21315
+ requestId
21316
+ };
21094
21317
  }
21095
21318
  }
21319
+ logEvent({
21320
+ event: "http_call",
21321
+ method,
21322
+ path,
21323
+ status: res.status,
21324
+ latency_ms,
21325
+ request_id: requestId
21326
+ });
21096
21327
  if (res.status === 204) {
21097
- return { ok: true, status: res.status };
21328
+ return { ok: true, status: res.status, requestId };
21098
21329
  }
21099
21330
  const data = await res.json();
21100
- return { ok: true, status: res.status, data };
21331
+ return { ok: true, status: res.status, data, requestId };
21101
21332
  }
21102
21333
  async function licenseRequest(path, body) {
21103
21334
  const url = `${BASE_URL}${path}`;
21335
+ const start = Date.now();
21104
21336
  let res;
21105
21337
  try {
21106
- res = await fetchWithRetry(url, {
21107
- method: "POST",
21108
- headers: {
21109
- Accept: "application/json",
21110
- "Content-Type": "application/x-www-form-urlencoded"
21338
+ res = await fetchWithRetry(
21339
+ url,
21340
+ {
21341
+ method: "POST",
21342
+ headers: {
21343
+ Accept: "application/json",
21344
+ "Content-Type": "application/x-www-form-urlencoded"
21345
+ },
21346
+ body: new URLSearchParams(body)
21111
21347
  },
21112
- body: new URLSearchParams(body)
21113
- });
21348
+ { idempotent: false }
21349
+ );
21114
21350
  } catch (err) {
21115
- if (err instanceof Error && err.name === "TimeoutError") {
21116
- return { ok: false, status: 0, error: `Request timed out after ${REQUEST_TIMEOUT_MS / 1e3}s` };
21117
- }
21351
+ const latency_ms2 = Date.now() - start;
21352
+ if (isAbortTimeoutError(err)) {
21353
+ const error2 = `Request timed out after ${REQUEST_TIMEOUT_MS / 1e3}s`;
21354
+ logEvent({ event: "http_call", method: "POST", path, status: "timeout", latency_ms: latency_ms2, error: error2 });
21355
+ return { ok: false, status: 0, error: error2 };
21356
+ }
21357
+ const message = err instanceof Error ? err.message : String(err);
21358
+ logEvent({
21359
+ event: "http_call",
21360
+ method: "POST",
21361
+ path,
21362
+ status: "network_error",
21363
+ latency_ms: latency_ms2,
21364
+ error: message
21365
+ });
21118
21366
  throw err;
21119
21367
  }
21368
+ const latency_ms = Date.now() - start;
21369
+ const requestId = res.headers.get("x-request-id") ?? void 0;
21120
21370
  if (!res.ok) {
21121
21371
  const errorBody = await res.text();
21122
21372
  try {
21123
21373
  const parsed = JSON.parse(errorBody);
21374
+ const p = parsed;
21375
+ const detail = p.errors?.[0]?.detail ?? p.error ?? errorBody;
21376
+ logEvent({
21377
+ event: "http_call",
21378
+ method: "POST",
21379
+ path,
21380
+ status: res.status,
21381
+ latency_ms,
21382
+ request_id: requestId,
21383
+ error: detail
21384
+ });
21124
21385
  return {
21125
21386
  ok: false,
21126
21387
  status: res.status,
21127
21388
  data: parsed,
21128
- error: parsed.errors?.[0]?.detail ?? parsed.error ?? errorBody
21389
+ error: decorateError(detail, requestId),
21390
+ requestId
21129
21391
  };
21130
21392
  } catch {
21131
- return { ok: false, status: res.status, error: errorBody };
21393
+ logEvent({
21394
+ event: "http_call",
21395
+ method: "POST",
21396
+ path,
21397
+ status: res.status,
21398
+ latency_ms,
21399
+ request_id: requestId,
21400
+ error: errorBody
21401
+ });
21402
+ return {
21403
+ ok: false,
21404
+ status: res.status,
21405
+ error: decorateError(errorBody, requestId),
21406
+ requestId
21407
+ };
21132
21408
  }
21133
21409
  }
21410
+ logEvent({
21411
+ event: "http_call",
21412
+ method: "POST",
21413
+ path,
21414
+ status: res.status,
21415
+ latency_ms,
21416
+ request_id: requestId
21417
+ });
21134
21418
  const data = await res.json();
21135
- return { ok: true, status: res.status, data };
21419
+ return { ok: true, status: res.status, data, requestId };
21136
21420
  }
21137
21421
  function getHandler(endpoint, idField) {
21138
21422
  return async (input) => {
@@ -21181,8 +21465,8 @@ var affiliateTools = [
21181
21465
  openWorldHint: true
21182
21466
  },
21183
21467
  inputSchema: external_exports.object({
21184
- affiliateId: external_exports.string().describe("The affiliate ID"),
21185
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,user')")
21468
+ affiliateId: external_exports.string().max(1e4).describe("The affiliate ID"),
21469
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,user')")
21186
21470
  }),
21187
21471
  handler: getHandler("/affiliates", "affiliateId")
21188
21472
  },
@@ -21197,8 +21481,8 @@ var affiliateTools = [
21197
21481
  openWorldHint: true
21198
21482
  },
21199
21483
  inputSchema: external_exports.object({
21200
- userEmail: external_exports.string().email().optional().describe("Filter by affiliate's user email"),
21201
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,user')"),
21484
+ userEmail: external_exports.string().email().max(320).optional().describe("Filter by affiliate's user email"),
21485
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,user')"),
21202
21486
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21203
21487
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21204
21488
  }),
@@ -21219,8 +21503,8 @@ var checkoutTools = [
21219
21503
  openWorldHint: true
21220
21504
  },
21221
21505
  inputSchema: external_exports.object({
21222
- checkoutId: external_exports.string().describe("The checkout ID"),
21223
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,variant')")
21506
+ checkoutId: external_exports.string().max(1e4).describe("The checkout ID"),
21507
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,variant')")
21224
21508
  }),
21225
21509
  handler: getHandler("/checkouts", "checkoutId")
21226
21510
  },
@@ -21235,9 +21519,9 @@ var checkoutTools = [
21235
21519
  openWorldHint: true
21236
21520
  },
21237
21521
  inputSchema: external_exports.object({
21238
- storeId: external_exports.string().optional().describe("Filter by store ID"),
21239
- variantId: external_exports.string().optional().describe("Filter by variant ID"),
21240
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,variant')"),
21522
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
21523
+ variantId: external_exports.string().max(1e4).optional().describe("Filter by variant ID"),
21524
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,variant')"),
21241
21525
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21242
21526
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21243
21527
  }),
@@ -21254,18 +21538,18 @@ var checkoutTools = [
21254
21538
  openWorldHint: true
21255
21539
  },
21256
21540
  inputSchema: external_exports.object({
21257
- storeId: external_exports.string().describe("The store ID"),
21258
- variantId: external_exports.string().describe("The variant ID for the product being purchased"),
21541
+ storeId: external_exports.string().max(1e4).describe("The store ID"),
21542
+ variantId: external_exports.string().max(1e4).describe("The variant ID for the product being purchased"),
21259
21543
  customPrice: external_exports.number().int().min(0).optional().describe("Custom price in cents (overrides the variant price)"),
21260
21544
  enabledVariants: external_exports.array(external_exports.string()).optional().describe("Array of variant IDs to show on the checkout (for products with multiple variants)"),
21261
- email: external_exports.string().optional().describe("Prefill customer email"),
21262
- name: external_exports.string().optional().describe("Prefill customer name"),
21263
- billingAddressCountry: external_exports.string().optional().describe("Prefill billing country (ISO 3166-1 alpha-2)"),
21264
- billingAddressZip: external_exports.string().optional().describe("Prefill billing ZIP/postal code"),
21265
- taxNumber: external_exports.string().optional().describe("Prefill tax/VAT number"),
21266
- discountCode: external_exports.string().optional().describe("Pre-apply a discount code"),
21545
+ email: external_exports.string().max(1e4).optional().describe("Prefill customer email"),
21546
+ name: external_exports.string().max(1e4).optional().describe("Prefill customer name"),
21547
+ billingAddressCountry: external_exports.string().max(1e4).optional().describe("Prefill billing country (ISO 3166-1 alpha-2)"),
21548
+ billingAddressZip: external_exports.string().max(1e4).optional().describe("Prefill billing ZIP/postal code"),
21549
+ taxNumber: external_exports.string().max(1e4).optional().describe("Prefill tax/VAT number"),
21550
+ discountCode: external_exports.string().max(1e4).optional().describe("Pre-apply a discount code"),
21267
21551
  customData: external_exports.record(external_exports.unknown()).optional().describe("Custom data object to attach to the order"),
21268
- expiresAt: external_exports.string().optional().describe("Checkout expiry date (ISO 8601 format)")
21552
+ expiresAt: external_exports.string().max(1e4).optional().describe("Checkout expiry date (ISO 8601 format)")
21269
21553
  }),
21270
21554
  handler: async (input) => {
21271
21555
  const attributes = {};
@@ -21316,8 +21600,8 @@ var customerTools = [
21316
21600
  openWorldHint: true
21317
21601
  },
21318
21602
  inputSchema: external_exports.object({
21319
- customerId: external_exports.string().describe("The customer ID"),
21320
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,orders,subscriptions,license-keys')")
21603
+ customerId: external_exports.string().max(1e4).describe("The customer ID"),
21604
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,orders,subscriptions,license-keys')")
21321
21605
  }),
21322
21606
  handler: getHandler("/customers", "customerId")
21323
21607
  },
@@ -21332,9 +21616,9 @@ var customerTools = [
21332
21616
  openWorldHint: true
21333
21617
  },
21334
21618
  inputSchema: external_exports.object({
21335
- storeId: external_exports.string().optional().describe("Filter by store ID"),
21336
- email: external_exports.string().optional().describe("Filter by customer email"),
21337
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,orders,subscriptions,license-keys')"),
21619
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
21620
+ email: external_exports.string().max(1e4).optional().describe("Filter by customer email"),
21621
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,orders,subscriptions,license-keys')"),
21338
21622
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21339
21623
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21340
21624
  }),
@@ -21351,12 +21635,12 @@ var customerTools = [
21351
21635
  openWorldHint: true
21352
21636
  },
21353
21637
  inputSchema: external_exports.object({
21354
- storeId: external_exports.string().describe("The store ID to create the customer in"),
21355
- name: external_exports.string().describe("Customer's full name"),
21356
- email: external_exports.string().describe("Customer's email address"),
21357
- city: external_exports.string().optional().describe("Customer's city"),
21358
- region: external_exports.string().optional().describe("Customer's region/state"),
21359
- country: external_exports.string().optional().describe("Customer's country (ISO 3166-1 alpha-2 code, e.g. 'US')")
21638
+ storeId: external_exports.string().max(1e4).describe("The store ID to create the customer in"),
21639
+ name: external_exports.string().max(1e4).describe("Customer's full name"),
21640
+ email: external_exports.string().max(1e4).describe("Customer's email address"),
21641
+ city: external_exports.string().max(1e4).optional().describe("Customer's city"),
21642
+ region: external_exports.string().max(1e4).optional().describe("Customer's region/state"),
21643
+ country: external_exports.string().max(1e4).optional().describe("Customer's country (ISO 3166-1 alpha-2 code, e.g. 'US')")
21360
21644
  }),
21361
21645
  handler: async (input) => {
21362
21646
  const attributes = {
@@ -21388,13 +21672,13 @@ var customerTools = [
21388
21672
  openWorldHint: true
21389
21673
  },
21390
21674
  inputSchema: external_exports.object({
21391
- customerId: external_exports.string().describe("The customer ID to update"),
21392
- name: external_exports.string().optional().describe("New name"),
21393
- email: external_exports.string().optional().describe("New email"),
21394
- city: external_exports.string().optional().describe("New city"),
21395
- region: external_exports.string().optional().describe("New region/state"),
21396
- country: external_exports.string().optional().describe("New country (ISO 3166-1 alpha-2 code)"),
21397
- status: external_exports.string().optional().describe("New status ('archived' to archive the customer)")
21675
+ customerId: external_exports.string().max(1e4).describe("The customer ID to update"),
21676
+ name: external_exports.string().max(1e4).optional().describe("New name"),
21677
+ email: external_exports.string().max(1e4).optional().describe("New email"),
21678
+ city: external_exports.string().max(1e4).optional().describe("New city"),
21679
+ region: external_exports.string().max(1e4).optional().describe("New region/state"),
21680
+ country: external_exports.string().max(1e4).optional().describe("New country (ISO 3166-1 alpha-2 code)"),
21681
+ status: external_exports.string().max(1e4).optional().describe("New status ('archived' to archive the customer)")
21398
21682
  }),
21399
21683
  handler: async (input) => {
21400
21684
  const attributes = {};
@@ -21424,7 +21708,7 @@ var customerTools = [
21424
21708
  openWorldHint: true
21425
21709
  },
21426
21710
  inputSchema: external_exports.object({
21427
- customerId: external_exports.string().describe("The customer ID to archive")
21711
+ customerId: external_exports.string().max(1e4).describe("The customer ID to archive")
21428
21712
  }),
21429
21713
  handler: async (input) => {
21430
21714
  return apiPatch(`/customers/${input.customerId}`, {
@@ -21451,8 +21735,8 @@ var discountRedemptionTools = [
21451
21735
  openWorldHint: true
21452
21736
  },
21453
21737
  inputSchema: external_exports.object({
21454
- discountRedemptionId: external_exports.string().describe("The discount redemption ID"),
21455
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'discount,order')")
21738
+ discountRedemptionId: external_exports.string().max(1e4).describe("The discount redemption ID"),
21739
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'discount,order')")
21456
21740
  }),
21457
21741
  handler: getHandler("/discount-redemptions", "discountRedemptionId")
21458
21742
  },
@@ -21467,9 +21751,9 @@ var discountRedemptionTools = [
21467
21751
  openWorldHint: true
21468
21752
  },
21469
21753
  inputSchema: external_exports.object({
21470
- discountId: external_exports.string().optional().describe("Filter by discount ID"),
21471
- orderId: external_exports.string().optional().describe("Filter by order ID"),
21472
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'discount,order')"),
21754
+ discountId: external_exports.string().max(1e4).optional().describe("Filter by discount ID"),
21755
+ orderId: external_exports.string().max(1e4).optional().describe("Filter by order ID"),
21756
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'discount,order')"),
21473
21757
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21474
21758
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21475
21759
  }),
@@ -21490,8 +21774,8 @@ var discountTools = [
21490
21774
  openWorldHint: true
21491
21775
  },
21492
21776
  inputSchema: external_exports.object({
21493
- discountId: external_exports.string().describe("The discount ID"),
21494
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,variants,discount-redemptions')")
21777
+ discountId: external_exports.string().max(1e4).describe("The discount ID"),
21778
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,variants,discount-redemptions')")
21495
21779
  }),
21496
21780
  handler: getHandler("/discounts", "discountId")
21497
21781
  },
@@ -21506,8 +21790,8 @@ var discountTools = [
21506
21790
  openWorldHint: true
21507
21791
  },
21508
21792
  inputSchema: external_exports.object({
21509
- storeId: external_exports.string().optional().describe("Filter by store ID"),
21510
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,variants,discount-redemptions')"),
21793
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
21794
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,variants,discount-redemptions')"),
21511
21795
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21512
21796
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21513
21797
  }),
@@ -21524,9 +21808,9 @@ var discountTools = [
21524
21808
  openWorldHint: true
21525
21809
  },
21526
21810
  inputSchema: external_exports.object({
21527
- storeId: external_exports.string().describe("The store ID to create the discount in"),
21528
- name: external_exports.string().describe("Internal name for the discount"),
21529
- code: external_exports.string().describe("The discount code customers will enter (e.g. 'SAVE20')"),
21811
+ storeId: external_exports.string().max(1e4).describe("The store ID to create the discount in"),
21812
+ name: external_exports.string().max(1e4).describe("Internal name for the discount"),
21813
+ code: external_exports.string().max(1e4).describe("The discount code customers will enter (e.g. 'SAVE20')"),
21530
21814
  amount: external_exports.number().int().min(1).describe(
21531
21815
  "Discount amount \u2014 in cents for 'fixed' type (e.g. 1000 = $10.00), or percentage for 'percent' type (e.g. 20 = 20%)"
21532
21816
  ),
@@ -21536,8 +21820,8 @@ var discountTools = [
21536
21820
  ),
21537
21821
  durationInMonths: external_exports.number().int().min(1).optional().describe("Number of months the discount applies (required when duration is 'repeating')"),
21538
21822
  maxRedemptions: external_exports.number().int().min(0).optional().describe("Maximum number of times this discount can be redeemed (0 = unlimited)"),
21539
- startsAt: external_exports.string().optional().describe("When the discount becomes active (ISO 8601 format)"),
21540
- expiresAt: external_exports.string().optional().describe("When the discount expires (ISO 8601 format)"),
21823
+ startsAt: external_exports.string().max(1e4).optional().describe("When the discount becomes active (ISO 8601 format)"),
21824
+ expiresAt: external_exports.string().max(1e4).optional().describe("When the discount expires (ISO 8601 format)"),
21541
21825
  isLimitedToProducts: external_exports.boolean().optional().describe("If true, the discount only applies to specific variants (set via variantIds)"),
21542
21826
  variantIds: external_exports.array(external_exports.string()).optional().describe("Array of variant IDs this discount applies to (requires isLimitedToProducts: true)")
21543
21827
  }),
@@ -21582,7 +21866,7 @@ var discountTools = [
21582
21866
  openWorldHint: true
21583
21867
  },
21584
21868
  inputSchema: external_exports.object({
21585
- discountId: external_exports.string().describe("The discount ID to delete")
21869
+ discountId: external_exports.string().max(1e4).describe("The discount ID to delete")
21586
21870
  }),
21587
21871
  handler: async (input) => {
21588
21872
  return apiDelete(`/discounts/${input.discountId}`);
@@ -21603,8 +21887,8 @@ var fileTools = [
21603
21887
  openWorldHint: true
21604
21888
  },
21605
21889
  inputSchema: external_exports.object({
21606
- fileId: external_exports.string().describe("The file ID"),
21607
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'variant')")
21890
+ fileId: external_exports.string().max(1e4).describe("The file ID"),
21891
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'variant')")
21608
21892
  }),
21609
21893
  handler: getHandler("/files", "fileId")
21610
21894
  },
@@ -21619,8 +21903,8 @@ var fileTools = [
21619
21903
  openWorldHint: true
21620
21904
  },
21621
21905
  inputSchema: external_exports.object({
21622
- variantId: external_exports.string().optional().describe("Filter by variant ID"),
21623
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'variant')"),
21906
+ variantId: external_exports.string().max(1e4).optional().describe("Filter by variant ID"),
21907
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'variant')"),
21624
21908
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21625
21909
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21626
21910
  }),
@@ -21641,8 +21925,8 @@ var licenseKeyInstanceTools = [
21641
21925
  openWorldHint: true
21642
21926
  },
21643
21927
  inputSchema: external_exports.object({
21644
- licenseKeyInstanceId: external_exports.string().describe("The license key instance ID"),
21645
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'license-key')")
21928
+ licenseKeyInstanceId: external_exports.string().max(1e4).describe("The license key instance ID"),
21929
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'license-key')")
21646
21930
  }),
21647
21931
  handler: getHandler("/license-key-instances", "licenseKeyInstanceId")
21648
21932
  },
@@ -21657,8 +21941,8 @@ var licenseKeyInstanceTools = [
21657
21941
  openWorldHint: true
21658
21942
  },
21659
21943
  inputSchema: external_exports.object({
21660
- licenseKeyId: external_exports.string().optional().describe("Filter by license key ID"),
21661
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'license-key')"),
21944
+ licenseKeyId: external_exports.string().max(1e4).optional().describe("Filter by license key ID"),
21945
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'license-key')"),
21662
21946
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21663
21947
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21664
21948
  }),
@@ -21679,8 +21963,8 @@ var licenseKeyTools = [
21679
21963
  openWorldHint: true
21680
21964
  },
21681
21965
  inputSchema: external_exports.object({
21682
- licenseKeyId: external_exports.string().describe("The license key ID"),
21683
- include: external_exports.string().optional().describe(
21966
+ licenseKeyId: external_exports.string().max(1e4).describe("The license key ID"),
21967
+ include: external_exports.string().max(1e4).optional().describe(
21684
21968
  "Comma-separated related resources to include (e.g. 'store,customer,order,order-item,product,license-key-instances')"
21685
21969
  )
21686
21970
  }),
@@ -21697,11 +21981,11 @@ var licenseKeyTools = [
21697
21981
  openWorldHint: true
21698
21982
  },
21699
21983
  inputSchema: external_exports.object({
21700
- storeId: external_exports.string().optional().describe("Filter by store ID"),
21701
- orderId: external_exports.string().optional().describe("Filter by order ID"),
21702
- orderItemId: external_exports.string().optional().describe("Filter by order item ID"),
21703
- productId: external_exports.string().optional().describe("Filter by product ID"),
21704
- include: external_exports.string().optional().describe(
21984
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
21985
+ orderId: external_exports.string().max(1e4).optional().describe("Filter by order ID"),
21986
+ orderItemId: external_exports.string().max(1e4).optional().describe("Filter by order item ID"),
21987
+ productId: external_exports.string().max(1e4).optional().describe("Filter by product ID"),
21988
+ include: external_exports.string().max(1e4).optional().describe(
21705
21989
  "Comma-separated related resources to include (e.g. 'store,customer,order,order-item,product,license-key-instances')"
21706
21990
  ),
21707
21991
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
@@ -21725,10 +22009,10 @@ var licenseKeyTools = [
21725
22009
  openWorldHint: true
21726
22010
  },
21727
22011
  inputSchema: external_exports.object({
21728
- licenseKeyId: external_exports.string().describe("The license key ID to update"),
22012
+ licenseKeyId: external_exports.string().max(1e4).describe("The license key ID to update"),
21729
22013
  activationLimit: external_exports.number().int().min(0).optional().describe("Maximum number of activations allowed (0 = unlimited)"),
21730
22014
  disabled: external_exports.boolean().optional().describe("Set to true to disable this license key"),
21731
- expiresAt: external_exports.string().optional().describe("Expiry date (ISO 8601 format). Set to null to remove expiry.")
22015
+ expiresAt: external_exports.string().max(1e4).optional().describe("Expiry date (ISO 8601 format). Set to null to remove expiry.")
21732
22016
  }),
21733
22017
  handler: async (input) => {
21734
22018
  const attributes = {};
@@ -21759,8 +22043,8 @@ var licenseTools = [
21759
22043
  openWorldHint: true
21760
22044
  },
21761
22045
  inputSchema: external_exports.object({
21762
- licenseKey: external_exports.string().describe("The license key to activate"),
21763
- instanceName: external_exports.string().describe("A name for this activation instance (e.g. machine name, user identifier)")
22046
+ licenseKey: external_exports.string().max(1e4).describe("The license key to activate"),
22047
+ instanceName: external_exports.string().max(1e4).describe("A name for this activation instance (e.g. machine name, user identifier)")
21764
22048
  }),
21765
22049
  handler: async (input) => {
21766
22050
  return licenseRequest("/licenses/activate", {
@@ -21780,8 +22064,8 @@ var licenseTools = [
21780
22064
  openWorldHint: true
21781
22065
  },
21782
22066
  inputSchema: external_exports.object({
21783
- licenseKey: external_exports.string().describe("The license key to validate"),
21784
- instanceId: external_exports.string().optional().describe("Optional instance ID to validate a specific activation")
22067
+ licenseKey: external_exports.string().max(1e4).describe("The license key to validate"),
22068
+ instanceId: external_exports.string().max(1e4).optional().describe("Optional instance ID to validate a specific activation")
21785
22069
  }),
21786
22070
  handler: async (input) => {
21787
22071
  const body = { license_key: input.licenseKey };
@@ -21800,8 +22084,8 @@ var licenseTools = [
21800
22084
  openWorldHint: true
21801
22085
  },
21802
22086
  inputSchema: external_exports.object({
21803
- licenseKey: external_exports.string().describe("The license key"),
21804
- instanceId: external_exports.string().describe("The instance ID to deactivate")
22087
+ licenseKey: external_exports.string().max(1e4).describe("The license key"),
22088
+ instanceId: external_exports.string().max(1e4).describe("The instance ID to deactivate")
21805
22089
  }),
21806
22090
  handler: async (input) => {
21807
22091
  return licenseRequest("/licenses/deactivate", {
@@ -21825,8 +22109,8 @@ var orderItemTools = [
21825
22109
  openWorldHint: true
21826
22110
  },
21827
22111
  inputSchema: external_exports.object({
21828
- orderItemId: external_exports.string().describe("The order item ID"),
21829
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'order,product,variant')")
22112
+ orderItemId: external_exports.string().max(1e4).describe("The order item ID"),
22113
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'order,product,variant')")
21830
22114
  }),
21831
22115
  handler: getHandler("/order-items", "orderItemId")
21832
22116
  },
@@ -21841,10 +22125,10 @@ var orderItemTools = [
21841
22125
  openWorldHint: true
21842
22126
  },
21843
22127
  inputSchema: external_exports.object({
21844
- orderId: external_exports.string().optional().describe("Filter by order ID"),
21845
- productId: external_exports.string().optional().describe("Filter by product ID"),
21846
- variantId: external_exports.string().optional().describe("Filter by variant ID"),
21847
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'order,product,variant')"),
22128
+ orderId: external_exports.string().max(1e4).optional().describe("Filter by order ID"),
22129
+ productId: external_exports.string().max(1e4).optional().describe("Filter by product ID"),
22130
+ variantId: external_exports.string().max(1e4).optional().describe("Filter by variant ID"),
22131
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'order,product,variant')"),
21848
22132
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21849
22133
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21850
22134
  }),
@@ -21865,8 +22149,8 @@ var orderTools = [
21865
22149
  openWorldHint: true
21866
22150
  },
21867
22151
  inputSchema: external_exports.object({
21868
- orderId: external_exports.string().describe("The order ID"),
21869
- include: external_exports.string().optional().describe(
22152
+ orderId: external_exports.string().max(1e4).describe("The order ID"),
22153
+ include: external_exports.string().max(1e4).optional().describe(
21870
22154
  "Comma-separated related resources to include (e.g. 'store,customer,order-items,subscriptions,license-keys,discount-redemptions')"
21871
22155
  )
21872
22156
  }),
@@ -21883,9 +22167,9 @@ var orderTools = [
21883
22167
  openWorldHint: true
21884
22168
  },
21885
22169
  inputSchema: external_exports.object({
21886
- storeId: external_exports.string().optional().describe("Filter by store ID"),
21887
- userEmail: external_exports.string().optional().describe("Filter by user email"),
21888
- include: external_exports.string().optional().describe(
22170
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
22171
+ userEmail: external_exports.string().max(1e4).optional().describe("Filter by user email"),
22172
+ include: external_exports.string().max(1e4).optional().describe(
21889
22173
  "Comma-separated related resources to include (e.g. 'store,customer,order-items,subscriptions,license-keys,discount-redemptions')"
21890
22174
  ),
21891
22175
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
@@ -21904,15 +22188,15 @@ var orderTools = [
21904
22188
  openWorldHint: true
21905
22189
  },
21906
22190
  inputSchema: external_exports.object({
21907
- orderId: external_exports.string().describe("The order ID"),
21908
- name: external_exports.string().optional().describe("Customer name on the invoice"),
21909
- address: external_exports.string().optional().describe("Customer address on the invoice"),
21910
- city: external_exports.string().optional().describe("Customer city"),
21911
- state: external_exports.string().optional().describe("Customer state/region"),
21912
- zipCode: external_exports.string().optional().describe("Customer ZIP/postal code"),
21913
- country: external_exports.string().optional().describe("Customer country"),
21914
- notes: external_exports.string().optional().describe("Additional notes to include on the invoice"),
21915
- locale: external_exports.string().optional().describe("Invoice language locale (e.g. 'en', 'fr', 'de')")
22191
+ orderId: external_exports.string().max(1e4).describe("The order ID"),
22192
+ name: external_exports.string().max(1e4).optional().describe("Customer name on the invoice"),
22193
+ address: external_exports.string().max(1e4).optional().describe("Customer address on the invoice"),
22194
+ city: external_exports.string().max(1e4).optional().describe("Customer city"),
22195
+ state: external_exports.string().max(1e4).optional().describe("Customer state/region"),
22196
+ zipCode: external_exports.string().max(1e4).optional().describe("Customer ZIP/postal code"),
22197
+ country: external_exports.string().max(1e4).optional().describe("Customer country"),
22198
+ notes: external_exports.string().max(1e4).optional().describe("Additional notes to include on the invoice"),
22199
+ locale: external_exports.string().max(1e4).optional().describe("Invoice language locale (e.g. 'en', 'fr', 'de')")
21916
22200
  }),
21917
22201
  handler: async (input) => {
21918
22202
  const params = new URLSearchParams();
@@ -21939,10 +22223,11 @@ var orderTools = [
21939
22223
  openWorldHint: true
21940
22224
  },
21941
22225
  inputSchema: external_exports.object({
21942
- orderId: external_exports.string().describe("The order ID to refund"),
22226
+ orderId: external_exports.string().max(1e4).describe("The order ID to refund"),
21943
22227
  amount: external_exports.number().int().min(1).describe("Refund amount in cents (e.g. 1000 = $10.00)")
21944
22228
  }),
21945
22229
  handler: async (input) => {
22230
+ checkRefundAmount(input.amount);
21946
22231
  return apiPost(`/orders/${input.orderId}/refund`, {
21947
22232
  data: { type: "orders", id: input.orderId, attributes: { amount: input.amount } }
21948
22233
  });
@@ -21963,8 +22248,8 @@ var priceTools = [
21963
22248
  openWorldHint: true
21964
22249
  },
21965
22250
  inputSchema: external_exports.object({
21966
- priceId: external_exports.string().describe("The price ID"),
21967
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'variant')")
22251
+ priceId: external_exports.string().max(1e4).describe("The price ID"),
22252
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'variant')")
21968
22253
  }),
21969
22254
  handler: getHandler("/prices", "priceId")
21970
22255
  },
@@ -21979,8 +22264,8 @@ var priceTools = [
21979
22264
  openWorldHint: true
21980
22265
  },
21981
22266
  inputSchema: external_exports.object({
21982
- variantId: external_exports.string().optional().describe("Filter by variant ID"),
21983
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'variant')"),
22267
+ variantId: external_exports.string().max(1e4).optional().describe("Filter by variant ID"),
22268
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'variant')"),
21984
22269
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
21985
22270
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
21986
22271
  }),
@@ -22001,8 +22286,8 @@ var productTools = [
22001
22286
  openWorldHint: true
22002
22287
  },
22003
22288
  inputSchema: external_exports.object({
22004
- productId: external_exports.string().describe("The product ID"),
22005
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,variants')")
22289
+ productId: external_exports.string().max(1e4).describe("The product ID"),
22290
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,variants')")
22006
22291
  }),
22007
22292
  handler: getHandler("/products", "productId")
22008
22293
  },
@@ -22017,8 +22302,8 @@ var productTools = [
22017
22302
  openWorldHint: true
22018
22303
  },
22019
22304
  inputSchema: external_exports.object({
22020
- storeId: external_exports.string().optional().describe("Filter by store ID"),
22021
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,variants')"),
22305
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
22306
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,variants')"),
22022
22307
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
22023
22308
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
22024
22309
  }),
@@ -22039,8 +22324,8 @@ var storeTools = [
22039
22324
  openWorldHint: true
22040
22325
  },
22041
22326
  inputSchema: external_exports.object({
22042
- storeId: external_exports.string().describe("The store ID"),
22043
- include: external_exports.string().optional().describe(
22327
+ storeId: external_exports.string().max(1e4).describe("The store ID"),
22328
+ include: external_exports.string().max(1e4).optional().describe(
22044
22329
  "Comma-separated related resources to include (e.g. 'products,discounts,license-keys,subscriptions,webhooks')"
22045
22330
  )
22046
22331
  }),
@@ -22057,7 +22342,7 @@ var storeTools = [
22057
22342
  openWorldHint: true
22058
22343
  },
22059
22344
  inputSchema: external_exports.object({
22060
- include: external_exports.string().optional().describe(
22345
+ include: external_exports.string().max(1e4).optional().describe(
22061
22346
  "Comma-separated related resources to include (e.g. 'products,discounts,license-keys,subscriptions,webhooks')"
22062
22347
  ),
22063
22348
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
@@ -22080,8 +22365,8 @@ var subscriptionInvoiceTools = [
22080
22365
  openWorldHint: true
22081
22366
  },
22082
22367
  inputSchema: external_exports.object({
22083
- subscriptionInvoiceId: external_exports.string().describe("The subscription invoice ID"),
22084
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,subscription')")
22368
+ subscriptionInvoiceId: external_exports.string().max(1e4).describe("The subscription invoice ID"),
22369
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,subscription')")
22085
22370
  }),
22086
22371
  handler: getHandler("/subscription-invoices", "subscriptionInvoiceId")
22087
22372
  },
@@ -22096,11 +22381,11 @@ var subscriptionInvoiceTools = [
22096
22381
  openWorldHint: true
22097
22382
  },
22098
22383
  inputSchema: external_exports.object({
22099
- storeId: external_exports.string().optional().describe("Filter by store ID"),
22100
- subscriptionId: external_exports.string().optional().describe("Filter by subscription ID"),
22384
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
22385
+ subscriptionId: external_exports.string().max(1e4).optional().describe("Filter by subscription ID"),
22101
22386
  status: external_exports.enum(["pending", "paid", "void", "refunded"]).optional().describe("Filter by invoice status"),
22102
22387
  refunded: external_exports.boolean().optional().describe("Filter by refunded status"),
22103
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store,subscription')"),
22388
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store,subscription')"),
22104
22389
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
22105
22390
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
22106
22391
  }),
@@ -22122,15 +22407,15 @@ var subscriptionInvoiceTools = [
22122
22407
  openWorldHint: true
22123
22408
  },
22124
22409
  inputSchema: external_exports.object({
22125
- subscriptionInvoiceId: external_exports.string().describe("The subscription invoice ID"),
22126
- name: external_exports.string().optional().describe("Customer name on the invoice"),
22127
- address: external_exports.string().optional().describe("Customer address on the invoice"),
22128
- city: external_exports.string().optional().describe("Customer city"),
22129
- state: external_exports.string().optional().describe("Customer state/region"),
22130
- zipCode: external_exports.string().optional().describe("Customer ZIP/postal code"),
22131
- country: external_exports.string().optional().describe("Customer country"),
22132
- notes: external_exports.string().optional().describe("Additional notes to include on the invoice"),
22133
- locale: external_exports.string().optional().describe("Invoice language locale (e.g. 'en', 'fr', 'de')")
22410
+ subscriptionInvoiceId: external_exports.string().max(1e4).describe("The subscription invoice ID"),
22411
+ name: external_exports.string().max(1e4).optional().describe("Customer name on the invoice"),
22412
+ address: external_exports.string().max(1e4).optional().describe("Customer address on the invoice"),
22413
+ city: external_exports.string().max(1e4).optional().describe("Customer city"),
22414
+ state: external_exports.string().max(1e4).optional().describe("Customer state/region"),
22415
+ zipCode: external_exports.string().max(1e4).optional().describe("Customer ZIP/postal code"),
22416
+ country: external_exports.string().max(1e4).optional().describe("Customer country"),
22417
+ notes: external_exports.string().max(1e4).optional().describe("Additional notes to include on the invoice"),
22418
+ locale: external_exports.string().max(1e4).optional().describe("Invoice language locale (e.g. 'en', 'fr', 'de')")
22134
22419
  }),
22135
22420
  handler: async (input) => {
22136
22421
  const params = new URLSearchParams();
@@ -22157,7 +22442,7 @@ var subscriptionInvoiceTools = [
22157
22442
  openWorldHint: true
22158
22443
  },
22159
22444
  inputSchema: external_exports.object({
22160
- subscriptionInvoiceId: external_exports.string().describe("The subscription invoice ID to refund"),
22445
+ subscriptionInvoiceId: external_exports.string().max(1e4).describe("The subscription invoice ID to refund"),
22161
22446
  amount: external_exports.number().int().min(1).describe("Refund amount in cents (e.g. 1000 = $10.00)")
22162
22447
  }),
22163
22448
  handler: async (input) => {
@@ -22185,8 +22470,8 @@ var subscriptionItemTools = [
22185
22470
  openWorldHint: true
22186
22471
  },
22187
22472
  inputSchema: external_exports.object({
22188
- subscriptionItemId: external_exports.string().describe("The subscription item ID"),
22189
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'subscription,price,usage-records')")
22473
+ subscriptionItemId: external_exports.string().max(1e4).describe("The subscription item ID"),
22474
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'subscription,price,usage-records')")
22190
22475
  }),
22191
22476
  handler: getHandler("/subscription-items", "subscriptionItemId")
22192
22477
  },
@@ -22201,9 +22486,9 @@ var subscriptionItemTools = [
22201
22486
  openWorldHint: true
22202
22487
  },
22203
22488
  inputSchema: external_exports.object({
22204
- subscriptionId: external_exports.string().optional().describe("Filter by subscription ID"),
22205
- priceId: external_exports.string().optional().describe("Filter by price ID"),
22206
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'subscription,price,usage-records')"),
22489
+ subscriptionId: external_exports.string().max(1e4).optional().describe("Filter by subscription ID"),
22490
+ priceId: external_exports.string().max(1e4).optional().describe("Filter by price ID"),
22491
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'subscription,price,usage-records')"),
22207
22492
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
22208
22493
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
22209
22494
  }),
@@ -22220,7 +22505,7 @@ var subscriptionItemTools = [
22220
22505
  openWorldHint: true
22221
22506
  },
22222
22507
  inputSchema: external_exports.object({
22223
- subscriptionItemId: external_exports.string().describe("The subscription item ID to update"),
22508
+ subscriptionItemId: external_exports.string().max(1e4).describe("The subscription item ID to update"),
22224
22509
  quantity: external_exports.number().int().min(1).describe("New quantity for the subscription item")
22225
22510
  }),
22226
22511
  handler: async (input) => {
@@ -22244,7 +22529,7 @@ var subscriptionItemTools = [
22244
22529
  openWorldHint: true
22245
22530
  },
22246
22531
  inputSchema: external_exports.object({
22247
- subscriptionItemId: external_exports.string().describe("The subscription item ID")
22532
+ subscriptionItemId: external_exports.string().max(1e4).describe("The subscription item ID")
22248
22533
  }),
22249
22534
  handler: async (input) => {
22250
22535
  return apiGet(`/subscription-items/${input.subscriptionItemId}/current-usage`);
@@ -22265,8 +22550,8 @@ var subscriptionTools = [
22265
22550
  openWorldHint: true
22266
22551
  },
22267
22552
  inputSchema: external_exports.object({
22268
- subscriptionId: external_exports.string().describe("The subscription ID"),
22269
- include: external_exports.string().optional().describe(
22553
+ subscriptionId: external_exports.string().max(1e4).describe("The subscription ID"),
22554
+ include: external_exports.string().max(1e4).optional().describe(
22270
22555
  "Comma-separated related resources to include (e.g. 'store,customer,order,order-item,product,variant,subscription-items,subscription-invoices')"
22271
22556
  )
22272
22557
  }),
@@ -22283,14 +22568,14 @@ var subscriptionTools = [
22283
22568
  openWorldHint: true
22284
22569
  },
22285
22570
  inputSchema: external_exports.object({
22286
- storeId: external_exports.string().optional().describe("Filter by store ID"),
22287
- orderId: external_exports.string().optional().describe("Filter by order ID"),
22288
- orderItemId: external_exports.string().optional().describe("Filter by order item ID"),
22289
- productId: external_exports.string().optional().describe("Filter by product ID"),
22290
- variantId: external_exports.string().optional().describe("Filter by variant ID"),
22291
- userEmail: external_exports.string().optional().describe("Filter by user email"),
22571
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
22572
+ orderId: external_exports.string().max(1e4).optional().describe("Filter by order ID"),
22573
+ orderItemId: external_exports.string().max(1e4).optional().describe("Filter by order item ID"),
22574
+ productId: external_exports.string().max(1e4).optional().describe("Filter by product ID"),
22575
+ variantId: external_exports.string().max(1e4).optional().describe("Filter by variant ID"),
22576
+ userEmail: external_exports.string().max(1e4).optional().describe("Filter by user email"),
22292
22577
  status: external_exports.enum(["on_trial", "active", "paused", "past_due", "unpaid", "cancelled", "expired"]).optional().describe("Filter by subscription status"),
22293
- include: external_exports.string().optional().describe(
22578
+ include: external_exports.string().max(1e4).optional().describe(
22294
22579
  "Comma-separated related resources to include (e.g. 'store,customer,order,order-item,product,variant')"
22295
22580
  ),
22296
22581
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
@@ -22317,8 +22602,8 @@ var subscriptionTools = [
22317
22602
  openWorldHint: true
22318
22603
  },
22319
22604
  inputSchema: external_exports.object({
22320
- subscriptionId: external_exports.string().describe("The subscription ID to update"),
22321
- variantId: external_exports.string().optional().describe("New variant ID for plan switching"),
22605
+ subscriptionId: external_exports.string().max(1e4).describe("The subscription ID to update"),
22606
+ variantId: external_exports.string().max(1e4).optional().describe("New variant ID for plan switching"),
22322
22607
  pause: external_exports.enum(["void", "free", "resume"]).optional().describe("Pause mode: 'void' (pause, skip billing), 'free' (pause, keep access free), or 'resume' to unpause"),
22323
22608
  cancelled: external_exports.literal(false).optional().describe(
22324
22609
  "Set to false to un-cancel a subscription before it expires. To cancel, use ls_cancel_subscription instead."
@@ -22326,7 +22611,7 @@ var subscriptionTools = [
22326
22611
  billingAnchor: external_exports.number().int().min(1).max(28).optional().describe("Day of month (1-28) to anchor billing to"),
22327
22612
  invoiceImmediately: external_exports.boolean().optional().describe("If true, invoice immediately when updating (default false for prorated changes)"),
22328
22613
  disableProrations: external_exports.boolean().optional().describe("If true, disable prorations when changing plans"),
22329
- trialEndsAt: external_exports.string().optional().describe("Set trial end date (ISO 8601 format). Set to null to end trial immediately.")
22614
+ trialEndsAt: external_exports.string().max(1e4).optional().describe("Set trial end date (ISO 8601 format). Set to null to end trial immediately.")
22330
22615
  }),
22331
22616
  handler: async (input) => {
22332
22617
  const attributes = {};
@@ -22357,7 +22642,7 @@ var subscriptionTools = [
22357
22642
  openWorldHint: true
22358
22643
  },
22359
22644
  inputSchema: external_exports.object({
22360
- subscriptionId: external_exports.string().describe("The subscription ID to cancel")
22645
+ subscriptionId: external_exports.string().max(1e4).describe("The subscription ID to cancel")
22361
22646
  }),
22362
22647
  handler: async (input) => {
22363
22648
  return apiDelete(`/subscriptions/${input.subscriptionId}`);
@@ -22378,8 +22663,8 @@ var usageRecordTools = [
22378
22663
  openWorldHint: true
22379
22664
  },
22380
22665
  inputSchema: external_exports.object({
22381
- usageRecordId: external_exports.string().describe("The usage record ID"),
22382
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'subscription-item')")
22666
+ usageRecordId: external_exports.string().max(1e4).describe("The usage record ID"),
22667
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'subscription-item')")
22383
22668
  }),
22384
22669
  handler: getHandler("/usage-records", "usageRecordId")
22385
22670
  },
@@ -22394,8 +22679,8 @@ var usageRecordTools = [
22394
22679
  openWorldHint: true
22395
22680
  },
22396
22681
  inputSchema: external_exports.object({
22397
- subscriptionItemId: external_exports.string().optional().describe("Filter by subscription item ID"),
22398
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'subscription-item')"),
22682
+ subscriptionItemId: external_exports.string().max(1e4).optional().describe("Filter by subscription item ID"),
22683
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'subscription-item')"),
22399
22684
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
22400
22685
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
22401
22686
  }),
@@ -22412,7 +22697,7 @@ var usageRecordTools = [
22412
22697
  openWorldHint: true
22413
22698
  },
22414
22699
  inputSchema: external_exports.object({
22415
- subscriptionItemId: external_exports.string().describe("The subscription item ID to report usage for"),
22700
+ subscriptionItemId: external_exports.string().max(1e4).describe("The subscription item ID to report usage for"),
22416
22701
  quantity: external_exports.number().int().min(0).describe("The usage quantity to report"),
22417
22702
  action: external_exports.enum(["increment", "set"]).optional().describe("How to apply the quantity: 'increment' (add to current, default) or 'set' (replace current)")
22418
22703
  }),
@@ -22468,8 +22753,8 @@ var variantTools = [
22468
22753
  openWorldHint: true
22469
22754
  },
22470
22755
  inputSchema: external_exports.object({
22471
- variantId: external_exports.string().describe("The variant ID"),
22472
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'product,files')")
22756
+ variantId: external_exports.string().max(1e4).describe("The variant ID"),
22757
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'product,files')")
22473
22758
  }),
22474
22759
  handler: getHandler("/variants", "variantId")
22475
22760
  },
@@ -22484,8 +22769,8 @@ var variantTools = [
22484
22769
  openWorldHint: true
22485
22770
  },
22486
22771
  inputSchema: external_exports.object({
22487
- productId: external_exports.string().optional().describe("Filter by product ID"),
22488
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'product,files')"),
22772
+ productId: external_exports.string().max(1e4).optional().describe("Filter by product ID"),
22773
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'product,files')"),
22489
22774
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
22490
22775
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
22491
22776
  }),
@@ -22506,8 +22791,8 @@ var webhookTools = [
22506
22791
  openWorldHint: true
22507
22792
  },
22508
22793
  inputSchema: external_exports.object({
22509
- webhookId: external_exports.string().describe("The webhook ID"),
22510
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store')")
22794
+ webhookId: external_exports.string().max(1e4).describe("The webhook ID"),
22795
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store')")
22511
22796
  }),
22512
22797
  handler: getHandler("/webhooks", "webhookId")
22513
22798
  },
@@ -22522,8 +22807,8 @@ var webhookTools = [
22522
22807
  openWorldHint: true
22523
22808
  },
22524
22809
  inputSchema: external_exports.object({
22525
- storeId: external_exports.string().optional().describe("Filter by store ID"),
22526
- include: external_exports.string().optional().describe("Comma-separated related resources to include (e.g. 'store')"),
22810
+ storeId: external_exports.string().max(1e4).optional().describe("Filter by store ID"),
22811
+ include: external_exports.string().max(1e4).optional().describe("Comma-separated related resources to include (e.g. 'store')"),
22527
22812
  pageNumber: external_exports.number().int().min(1).optional().describe("Page number (1-indexed)"),
22528
22813
  pageSize: external_exports.number().int().min(1).max(100).optional().describe("Results per page (1-100)")
22529
22814
  }),
@@ -22540,8 +22825,8 @@ var webhookTools = [
22540
22825
  openWorldHint: true
22541
22826
  },
22542
22827
  inputSchema: external_exports.object({
22543
- storeId: external_exports.string().describe("The store ID"),
22544
- url: external_exports.string().describe("The URL to send webhook events to"),
22828
+ storeId: external_exports.string().max(1e4).describe("The store ID"),
22829
+ url: external_exports.string().max(1e4).describe("The URL to send webhook events to"),
22545
22830
  events: external_exports.array(external_exports.string()).describe(
22546
22831
  "Event types to subscribe to (e.g. ['order_created', 'subscription_created', 'subscription_updated', 'subscription_cancelled', 'subscription_payment_success', 'subscription_payment_failed', 'license_key_created'])"
22547
22832
  ),
@@ -22574,10 +22859,10 @@ var webhookTools = [
22574
22859
  openWorldHint: true
22575
22860
  },
22576
22861
  inputSchema: external_exports.object({
22577
- webhookId: external_exports.string().describe("The webhook ID to update"),
22578
- url: external_exports.string().optional().describe("New URL to send webhook events to"),
22862
+ webhookId: external_exports.string().max(1e4).describe("The webhook ID to update"),
22863
+ url: external_exports.string().max(1e4).optional().describe("New URL to send webhook events to"),
22579
22864
  events: external_exports.array(external_exports.string()).optional().describe("Updated list of event types to subscribe to"),
22580
- secret: external_exports.string().optional().describe("New signing secret")
22865
+ secret: external_exports.string().max(1e4).optional().describe("New signing secret")
22581
22866
  }),
22582
22867
  handler: async (input) => {
22583
22868
  const attributes = {};
@@ -22604,7 +22889,7 @@ var webhookTools = [
22604
22889
  openWorldHint: true
22605
22890
  },
22606
22891
  inputSchema: external_exports.object({
22607
- webhookId: external_exports.string().describe("The webhook ID to delete")
22892
+ webhookId: external_exports.string().max(1e4).describe("The webhook ID to delete")
22608
22893
  }),
22609
22894
  handler: async (input) => {
22610
22895
  return apiDelete(`/webhooks/${input.webhookId}`);
@@ -22613,7 +22898,7 @@ var webhookTools = [
22613
22898
  ];
22614
22899
 
22615
22900
  // src/index.ts
22616
- var version2 = true ? "0.3.0" : (await null).createRequire(import.meta.url)("../package.json").version;
22901
+ var version2 = true ? "0.4.0" : (await null).createRequire(import.meta.url)("../package.json").version;
22617
22902
  var subcommand = process.argv[2];
22618
22903
  if (subcommand === "version" || subcommand === "--version") {
22619
22904
  console.log(version2);
@@ -22647,15 +22932,31 @@ var server = new McpServer({
22647
22932
  version: version2
22648
22933
  });
22649
22934
  for (const tool of allTools) {
22935
+ const isDestructive = tool.annotations?.destructiveHint === true;
22650
22936
  server.tool(
22651
22937
  tool.name,
22652
22938
  tool.description,
22653
22939
  tool.inputSchema.shape,
22654
22940
  tool.annotations,
22655
22941
  async (input) => {
22942
+ const start = Date.now();
22656
22943
  try {
22944
+ if (isDestructive) checkDestructiveRateLimit();
22945
+ const storeId = input.storeId;
22946
+ if (typeof storeId === "string") checkStoreAllowed(storeId);
22657
22947
  const result = await tool.handler(input);
22658
22948
  const response = result;
22949
+ const latency_ms = Date.now() - start;
22950
+ logEvent({
22951
+ event: "tool_call",
22952
+ tool: tool.name,
22953
+ status: response.ok ? "ok" : "error",
22954
+ latency_ms,
22955
+ request_id: response.requestId,
22956
+ error: response.ok ? void 0 : response.error,
22957
+ audit: isDestructive ? true : void 0,
22958
+ inputs: isDestructive ? input : void 0
22959
+ });
22659
22960
  if (!response.ok) {
22660
22961
  return {
22661
22962
  content: [
@@ -22673,6 +22974,16 @@ for (const tool of allTools) {
22673
22974
  };
22674
22975
  } catch (err) {
22675
22976
  const message = err instanceof Error ? err.message : String(err);
22977
+ const latency_ms = Date.now() - start;
22978
+ logEvent({
22979
+ event: "tool_call",
22980
+ tool: tool.name,
22981
+ status: err instanceof GuardrailError ? "guardrail_block" : "exception",
22982
+ latency_ms,
22983
+ error: message,
22984
+ audit: isDestructive ? true : void 0,
22985
+ inputs: isDestructive ? input : void 0
22986
+ });
22676
22987
  return {
22677
22988
  content: [{ type: "text", text: `Error: ${message}` }],
22678
22989
  isError: true