@carrierllc/mcp 0.13.12 → 0.13.13

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.
@@ -1820,7 +1820,7 @@ function storefrontScreen(input) {
1820
1820
  // package.json
1821
1821
  var package_default = {
1822
1822
  name: "@carrierllc/mcp",
1823
- version: "0.13.12",
1823
+ version: "0.13.13",
1824
1824
  description: "Carrier MCP \u2014 natural-language control of MVNO/eSIM fleets via eSIMVault OCS. Stdio mode for direct integration with Claude Desktop, Cursor, Windsurf, and MCP-compatible clients. Ships the `carrier` CLI (plugin install + white-label eSIM storefront scaffold).",
1825
1825
  license: "MIT",
1826
1826
  author: "Carrier (Lifecycle Innovations Limited)",
@@ -4133,6 +4133,113 @@ function applySubscriberFilters(raw, args) {
4133
4133
  }
4134
4134
  return rewrapSubscriberList(raw, envelope, rows, filtered, matched);
4135
4135
  }
4136
+ var OCS_SUBSCRIBER_SEARCH_KEYS = [
4137
+ "accountId",
4138
+ "iccid",
4139
+ "imsi",
4140
+ "msisdn",
4141
+ "activationCode",
4142
+ "iccidPrefix",
4143
+ "imsiPrefix",
4144
+ "msisdnPrefix"
4145
+ ];
4146
+ function hasSubscriberSearchKey(params) {
4147
+ return OCS_SUBSCRIBER_SEARCH_KEYS.some((key) => {
4148
+ const v = params[key];
4149
+ return v !== void 0 && v !== null && String(v).trim() !== "";
4150
+ });
4151
+ }
4152
+ function flattenResellerAccounts(raw) {
4153
+ const records = [];
4154
+ if (Array.isArray(raw)) {
4155
+ records.push(...raw);
4156
+ } else if (raw !== null && typeof raw === "object") {
4157
+ const obj = raw;
4158
+ if (Array.isArray(obj["reseller"])) {
4159
+ for (const entry of obj["reseller"]) {
4160
+ const accounts = entry?.["account"];
4161
+ if (Array.isArray(accounts)) records.push(...accounts);
4162
+ }
4163
+ }
4164
+ if (Array.isArray(obj["account"])) records.push(...obj["account"]);
4165
+ }
4166
+ const seen = /* @__PURE__ */ new Set();
4167
+ const out = [];
4168
+ for (const rec of records) {
4169
+ if (rec === null || typeof rec !== "object") continue;
4170
+ const r = rec;
4171
+ const id = Number(r["id"] ?? r["accountId"]);
4172
+ if (!Number.isFinite(id) || seen.has(id)) continue;
4173
+ seen.add(id);
4174
+ out.push(typeof r["name"] === "string" ? { id, name: r["name"] } : { id });
4175
+ }
4176
+ return out;
4177
+ }
4178
+ function pickDefaultAccount(accounts) {
4179
+ if (accounts.length === 0) return void 0;
4180
+ const first = [...accounts].sort((a, b) => a.id - b.id)[0];
4181
+ return {
4182
+ accountId: first.id,
4183
+ ...first.name !== void 0 ? { name: first.name } : {},
4184
+ accountCount: accounts.length
4185
+ };
4186
+ }
4187
+ var NO_ACCOUNTS_MESSAGE = "OCS requires a subscriber search key, and no default account could be chosen because this reseller has no accounts yet. Create an account in OCS, or pass accountId / set preferred_account_id once one exists.";
4188
+ function lookupFailedMessage(detail) {
4189
+ return `OCS requires a subscriber search key, and this organization's default account could not be looked up (${detail}). Pass accountId, or set preferred_account_id, or retry.`;
4190
+ }
4191
+ function errorText(err) {
4192
+ return err instanceof Error ? err.message : String(err);
4193
+ }
4194
+ async function resolveDefaultAccount(opts) {
4195
+ const cached = await opts.cache?.get().catch(() => null);
4196
+ if (cached && Number.isFinite(cached.accountId)) return { ok: true, ...cached };
4197
+ let resellerId;
4198
+ const given = Number(opts.resellerId);
4199
+ if (opts.resellerId !== void 0 && opts.resellerId !== "" && Number.isFinite(given)) {
4200
+ resellerId = given;
4201
+ } else {
4202
+ try {
4203
+ const info = await opts.call("getResellerInfo", {});
4204
+ const id = Number(info?.id);
4205
+ if (Number.isFinite(id)) resellerId = id;
4206
+ } catch {
4207
+ }
4208
+ }
4209
+ let raw;
4210
+ try {
4211
+ raw = await opts.call("listResellerAccount", resellerId !== void 0 ? { resellerId } : {});
4212
+ } catch (err) {
4213
+ return { ok: false, reason: "lookup_failed", message: lookupFailedMessage(errorText(err)) };
4214
+ }
4215
+ const pick = pickDefaultAccount(flattenResellerAccounts(raw));
4216
+ if (!pick) return { ok: false, reason: "no_accounts", message: NO_ACCOUNTS_MESSAGE };
4217
+ await opts.cache?.put(pick).catch(() => void 0);
4218
+ return { ok: true, ...pick };
4219
+ }
4220
+ function defaultAccountNote(pick) {
4221
+ const label = pick.name ? `${pick.accountId} (${pick.name})` : String(pick.accountId);
4222
+ return pick.accountCount > 1 ? `No account was specified, so this shows account ${label} only \u2014 the lowest of ${pick.accountCount} accounts under this reseller. Pass accountId to see another account.` : `No account was specified, so this shows account ${label}, the only account under this reseller.`;
4223
+ }
4224
+ async function scopeListSubscriberParams(opts) {
4225
+ if (opts.managed || hasSubscriberSearchKey(opts.params)) return { ok: true, params: opts.params };
4226
+ const preferred = Number(opts.preferredAccountId);
4227
+ if (opts.preferredAccountId !== void 0 && opts.preferredAccountId.trim() !== "" && Number.isFinite(preferred)) {
4228
+ return { ok: true, params: { ...opts.params, accountId: preferred } };
4229
+ }
4230
+ const resolved = await resolveDefaultAccount({
4231
+ call: opts.call,
4232
+ ...opts.resellerId !== void 0 ? { resellerId: opts.resellerId } : {},
4233
+ ...opts.cache ? { cache: opts.cache } : {}
4234
+ });
4235
+ if (!resolved.ok) return resolved;
4236
+ const { ok: _ok, ...pick } = resolved;
4237
+ return {
4238
+ ok: true,
4239
+ params: { ...opts.params, accountId: pick.accountId },
4240
+ defaultAccount: { ...pick, note: defaultAccountNote(pick) }
4241
+ };
4242
+ }
4136
4243
  var descriptions = /* @__PURE__ */ new Map();
4137
4244
  function recordToolDescription(name, description) {
4138
4245
  if (description) descriptions.set(name, description);
@@ -4786,6 +4893,7 @@ export {
4786
4893
  buildListSubscriberParams,
4787
4894
  extractSubscriberStatus,
4788
4895
  applySubscriberFilters,
4896
+ scopeListSubscriberParams,
4789
4897
  recordToolDescription,
4790
4898
  buildRouterCatalog,
4791
4899
  ROUTER_RULES,
@@ -4846,4 +4954,4 @@ export {
4846
4954
  storefrontScreen,
4847
4955
  CARRIER_VERSION
4848
4956
  };
4849
- //# sourceMappingURL=chunk-IQDAU7WA.js.map
4957
+ //# sourceMappingURL=chunk-OJITGTFO.js.map