@carrierllc/mcp 0.2.7 → 0.2.9

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/index.js CHANGED
@@ -438,9 +438,10 @@ function registerAllTools(server2, ctx) {
438
438
  "esim_status_per_account",
439
439
  {
440
440
  title: "eSIM Status Per Account",
441
- description: "Use this to get eSIM status counts broken down by account: active, suspended, inventory (not yet activated), and other states. Good for fleet health dashboards and capacity planning. Params: `accountId` (integer, optional \u2014 omit for all accounts under the reseller). Returns: array of per-account objects with `accountId`, `active`, `suspended`, `inventory`, `other`. Do NOT use this to check a single subscriber's status \u2014 use `get_subscriber` for that. Do NOT use this for billing or balance checks \u2014 use `list_reseller_accounts` for balances.",
441
+ description: "Use this to get eSIM status counts broken down by account: active, suspended, inventory (not yet activated), and other states. Good for fleet health dashboards and capacity planning. OCS requires either `accountId` OR `resellerId`. If both omitted, the token owner's reseller is resolved automatically. Params: `accountId` (integer, optional \u2014 for a single account), `resellerId` (integer, optional \u2014 for all accounts under a specific reseller). Returns: array of per-account objects with `accountId`, `active`, `suspended`, `inventory`, `other`. Do NOT use this to check a single subscriber's status \u2014 use `get_subscriber` for that. Do NOT use this for billing or balance checks \u2014 use `list_reseller_accounts` for balances.",
442
442
  inputSchema: {
443
- accountId: z.number().optional().describe("Filter to a specific account")
443
+ accountId: z.number().optional().describe("Filter to a specific account"),
444
+ resellerId: z.number().optional().describe("Reseller ID (omit to use the token owner's reseller)")
444
445
  },
445
446
  annotations: { readOnlyHint: true }
446
447
  },
@@ -449,9 +450,13 @@ function registerAllTools(server2, ctx) {
449
450
  "esimStatusPerAccount",
450
451
  TOOL_SCOPES["esim_status_per_account"],
451
452
  ctx,
452
- async ({ accountId }, token2) => {
453
+ async ({ accountId, resellerId }, token2) => {
453
454
  const params = {};
454
- if (accountId !== void 0) params.accountId = accountId;
455
+ if (accountId !== void 0) {
456
+ params.accountId = accountId;
457
+ } else {
458
+ params.resellerId = resellerId ?? await getDefaultResellerId(ctx.env, token2);
459
+ }
455
460
  return ocsCall(ctx.env, token2, "esimStatusPerAccount", params);
456
461
  }
457
462
  )
@@ -3144,15 +3149,42 @@ function registerIntelligenceTools(server2, ctx) {
3144
3149
  )
3145
3150
  ]);
3146
3151
  const sections = ["# Fleet Health Dashboard\n"];
3152
+ const statusRaw = statusResult.data;
3153
+ const statusAccounts = Array.isArray(statusRaw) ? statusRaw : statusRaw?.account ?? [];
3154
+ const statusOk = statusResult.data !== null && (statusAccounts.length > 0 || statusResult.error === null);
3155
+ const countByState = (account) => {
3156
+ const sponsors = account.sponsor ?? [];
3157
+ let active = 0, suspended = 0, inventory = 0, other = 0;
3158
+ for (const sp of sponsors) {
3159
+ const esim = sp.esim ?? {};
3160
+ const statuses = esim.status ?? [];
3161
+ for (const s of statuses) {
3162
+ const name = String(s.name ?? "").toUpperCase();
3163
+ const count = Number(s.count ?? 0);
3164
+ if (name === "ACTIVE" || name === "ACTIVATED") active += count;
3165
+ else if (name === "SUSPENDED") suspended += count;
3166
+ else if (name === "INVENTORY" || name === "NOT_ACTIVATED" || name === "AVAILABLE") inventory += count;
3167
+ else other += count;
3168
+ }
3169
+ }
3170
+ return { active, suspended, inventory, other };
3171
+ };
3147
3172
  let totalActive = 0, totalSuspended = 0, totalInventory = 0, totalOther = 0;
3148
- const statusOk = statusResult.data && Array.isArray(statusResult.data);
3149
- const statusAccounts = statusOk ? statusResult.data : [];
3150
3173
  if (statusOk) {
3151
3174
  for (const account of statusAccounts) {
3152
- totalActive += Number(account.active ?? 0);
3153
- totalSuspended += Number(account.suspended ?? 0);
3154
- totalInventory += Number(account.inventory ?? account.notActivated ?? 0);
3155
- totalOther += Number(account.other ?? account.terminated ?? 0);
3175
+ const hasSponsors = Array.isArray(account.sponsor);
3176
+ if (hasSponsors) {
3177
+ const c = countByState(account);
3178
+ totalActive += c.active;
3179
+ totalSuspended += c.suspended;
3180
+ totalInventory += c.inventory;
3181
+ totalOther += c.other;
3182
+ } else {
3183
+ totalActive += Number(account.active ?? 0);
3184
+ totalSuspended += Number(account.suspended ?? 0);
3185
+ totalInventory += Number(account.inventory ?? account.notActivated ?? 0);
3186
+ totalOther += Number(account.other ?? account.terminated ?? 0);
3187
+ }
3156
3188
  }
3157
3189
  const total = totalActive + totalSuspended + totalInventory + totalOther;
3158
3190
  const utilization = total > 0 ? (totalActive / total * 100).toFixed(1) : "0";
@@ -3178,8 +3210,9 @@ High suspension rate (${totalSuspended} suspended vs ${totalActive} active)`);
3178
3210
  sections.push(`## eSIM Fleet Status`);
3179
3211
  sections.push(`Unavailable: ${statusResult.error ?? "esimStatusPerAccount returned no data"}`);
3180
3212
  }
3181
- const accountsOk = accountsResult.data && Array.isArray(accountsResult.data);
3182
- const accounts = accountsOk ? accountsResult.data : [];
3213
+ const accountsRaw = accountsResult.data;
3214
+ const accounts = Array.isArray(accountsRaw) ? accountsRaw : (accountsRaw?.reseller ?? []).flatMap((r) => r.account ?? []);
3215
+ const accountsOk = accountsResult.data !== null && (accounts.length > 0 || accountsResult.error === null);
3183
3216
  if (accountsOk) {
3184
3217
  const lowBalance = accounts.filter(
3185
3218
  (a) => Number(a.balance ?? 0) < 10