@carrierllc/mcp 0.2.5 → 0.2.6
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 +66 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3133,9 +3133,11 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3133
3133
|
safeCall(ctx.env, token2, "listResellerAccount", {})
|
|
3134
3134
|
]);
|
|
3135
3135
|
const sections = ["# Fleet Health Dashboard\n"];
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3136
|
+
let totalActive = 0, totalSuspended = 0, totalInventory = 0, totalOther = 0;
|
|
3137
|
+
const statusOk = statusResult.data && Array.isArray(statusResult.data);
|
|
3138
|
+
const statusAccounts = statusOk ? statusResult.data : [];
|
|
3139
|
+
if (statusOk) {
|
|
3140
|
+
for (const account of statusAccounts) {
|
|
3139
3141
|
totalActive += Number(account.active ?? 0);
|
|
3140
3142
|
totalSuspended += Number(account.suspended ?? 0);
|
|
3141
3143
|
totalInventory += Number(account.inventory ?? account.notActivated ?? 0);
|
|
@@ -3144,37 +3146,79 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3144
3146
|
const total = totalActive + totalSuspended + totalInventory + totalOther;
|
|
3145
3147
|
const utilization = total > 0 ? (totalActive / total * 100).toFixed(1) : "0";
|
|
3146
3148
|
sections.push(`## eSIM Fleet Status`);
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3149
|
+
if (total === 0) {
|
|
3150
|
+
sections.push(`No eSIMs provisioned across ${statusAccounts.length} account(s).`);
|
|
3151
|
+
} else {
|
|
3152
|
+
sections.push(`| Metric | Count | % |`);
|
|
3153
|
+
sections.push(`|--------|-------|---|`);
|
|
3154
|
+
sections.push(`| Active | ${totalActive} | ${(totalActive / total * 100).toFixed(1)}% |`);
|
|
3155
|
+
sections.push(`| Suspended | ${totalSuspended} | ${(totalSuspended / total * 100).toFixed(1)}% |`);
|
|
3156
|
+
sections.push(`| Inventory | ${totalInventory} | ${(totalInventory / total * 100).toFixed(1)}% |`);
|
|
3157
|
+
sections.push(`| Other | ${totalOther} | ${(totalOther / total * 100).toFixed(1)}% |`);
|
|
3158
|
+
sections.push(`| **Total** | **${total}** | |`);
|
|
3157
3159
|
sections.push(`
|
|
3158
|
-
|
|
3160
|
+
**Fleet Utilization: ${utilization}%**`);
|
|
3161
|
+
if (totalSuspended > totalActive * 0.1) {
|
|
3162
|
+
sections.push(`
|
|
3163
|
+
High suspension rate (${totalSuspended} suspended vs ${totalActive} active)`);
|
|
3164
|
+
}
|
|
3159
3165
|
}
|
|
3166
|
+
} else {
|
|
3167
|
+
sections.push(`## eSIM Fleet Status`);
|
|
3168
|
+
sections.push(`Unavailable: ${statusResult.error ?? "esimStatusPerAccount returned no data"}`);
|
|
3160
3169
|
}
|
|
3161
|
-
|
|
3162
|
-
|
|
3170
|
+
const accountsOk = accountsResult.data && Array.isArray(accountsResult.data);
|
|
3171
|
+
const accounts = accountsOk ? accountsResult.data : [];
|
|
3172
|
+
if (accountsOk) {
|
|
3173
|
+
const lowBalance = accounts.filter(
|
|
3163
3174
|
(a) => Number(a.balance ?? 0) < 10
|
|
3164
3175
|
);
|
|
3176
|
+
const packageOnlyZero = accounts.filter(
|
|
3177
|
+
(a) => Boolean(a.packageOnly) && Number(a.balance ?? 0) <= 0
|
|
3178
|
+
);
|
|
3179
|
+
sections.push(`
|
|
3180
|
+
## Account Summary`);
|
|
3181
|
+
sections.push(`- Total accounts: ${accounts.length}`);
|
|
3182
|
+
sections.push(`- Low balance (< 10): ${lowBalance.length}`);
|
|
3183
|
+
sections.push(`- Package-only with 0 balance: ${packageOnlyZero.length}`);
|
|
3165
3184
|
if (lowBalance.length > 0) {
|
|
3166
3185
|
sections.push(`
|
|
3167
|
-
|
|
3168
|
-
sections.push(`| Account | Balance |`);
|
|
3169
|
-
sections.push(
|
|
3186
|
+
### Low Balance Accounts (< 10)`);
|
|
3187
|
+
sections.push(`| Account | Balance | packageOnly |`);
|
|
3188
|
+
sections.push(`|---------|---------|-------------|`);
|
|
3170
3189
|
for (const a of lowBalance) {
|
|
3171
|
-
sections.push(`| ${a.name ?? a.accountId ?? "?"} | ${Number(a.balance ?? 0).toFixed(2)} |`);
|
|
3190
|
+
sections.push(`| ${a.name ?? a.accountId ?? "?"} | ${Number(a.balance ?? 0).toFixed(2)} | ${a.packageOnly ? "yes" : "no"} |`);
|
|
3172
3191
|
}
|
|
3173
3192
|
}
|
|
3193
|
+
const critical = packageOnlyZero.length;
|
|
3194
|
+
const warning = lowBalance.length - critical;
|
|
3195
|
+
const healthy = accounts.length - lowBalance.length;
|
|
3196
|
+
sections.push(`
|
|
3197
|
+
## Fleet Health Verdict`);
|
|
3198
|
+
sections.push(`- Healthy: ${healthy}`);
|
|
3199
|
+
sections.push(`- Warning (low balance, not package-only-zero): ${Math.max(warning, 0)}`);
|
|
3200
|
+
sections.push(`- Critical (package-only and 0 balance): ${critical}`);
|
|
3201
|
+
if (accounts.length === 0) {
|
|
3202
|
+
sections.push(`
|
|
3203
|
+
No accounts found under this reseller.`);
|
|
3204
|
+
} else if (critical > 0) {
|
|
3205
|
+
sections.push(`
|
|
3206
|
+
Action: top up package-only accounts at 0 balance to keep packages assignable.`);
|
|
3207
|
+
} else if (lowBalance.length === 0) {
|
|
3208
|
+
sections.push(`
|
|
3209
|
+
All accounts healthy.`);
|
|
3210
|
+
}
|
|
3211
|
+
} else {
|
|
3174
3212
|
sections.push(`
|
|
3175
3213
|
## Account Summary`);
|
|
3176
|
-
sections.push(
|
|
3177
|
-
|
|
3214
|
+
sections.push(`Unavailable: ${accountsResult.error ?? "listResellerAccount returned no data"}`);
|
|
3215
|
+
}
|
|
3216
|
+
if (!statusOk && !accountsOk) {
|
|
3217
|
+
sections.push(`
|
|
3218
|
+
## Errors`);
|
|
3219
|
+
if (statusResult.error) sections.push(`- esimStatusPerAccount: ${statusResult.error}`);
|
|
3220
|
+
if (accountsResult.error) sections.push(`- listResellerAccount: ${accountsResult.error}`);
|
|
3221
|
+
return result(sections.join("\n"), true);
|
|
3178
3222
|
}
|
|
3179
3223
|
return result(sections.join("\n"));
|
|
3180
3224
|
});
|