@carrierllc/mcp 0.2.9 → 0.2.11
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 +51 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2984,6 +2984,38 @@ async function safeCall(env, token2, method, params = {}) {
|
|
|
2984
2984
|
return { data: null, error: err2 instanceof Error ? err2.message : String(err2) };
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
2987
|
+
async function fetchActiveSubscribers(env, token2, accountId, resellerId) {
|
|
2988
|
+
let accountIds;
|
|
2989
|
+
if (accountId !== void 0) {
|
|
2990
|
+
accountIds = [accountId];
|
|
2991
|
+
} else {
|
|
2992
|
+
const accountsResult = await safeCall(
|
|
2993
|
+
env,
|
|
2994
|
+
token2,
|
|
2995
|
+
"listResellerAccount",
|
|
2996
|
+
{ resellerId }
|
|
2997
|
+
);
|
|
2998
|
+
if (accountsResult.error) return { data: null, error: accountsResult.error };
|
|
2999
|
+
const reseller = accountsResult.data?.reseller ?? [];
|
|
3000
|
+
accountIds = reseller.flatMap((r) => (r.account ?? []).map((a) => a.id));
|
|
3001
|
+
if (accountIds.length === 0) return { data: [], error: null };
|
|
3002
|
+
}
|
|
3003
|
+
const aggregated = [];
|
|
3004
|
+
for (const acctId of accountIds) {
|
|
3005
|
+
const subResult = await safeCall(
|
|
3006
|
+
env,
|
|
3007
|
+
token2,
|
|
3008
|
+
"listSubscriber",
|
|
3009
|
+
{ accountId: acctId }
|
|
3010
|
+
);
|
|
3011
|
+
if (subResult.error) return { data: null, error: subResult.error };
|
|
3012
|
+
const raw = subResult.data;
|
|
3013
|
+
const list = Array.isArray(raw) ? raw : raw?.subscriberList ?? [];
|
|
3014
|
+
aggregated.push(...list);
|
|
3015
|
+
}
|
|
3016
|
+
const active = aggregated.filter((s) => String(s.status ?? "").toUpperCase() === "ACTIVE");
|
|
3017
|
+
return { data: active, error: null };
|
|
3018
|
+
}
|
|
2987
3019
|
function formatBytes(bytes) {
|
|
2988
3020
|
if (bytes === 0) return "0 B";
|
|
2989
3021
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
@@ -3159,11 +3191,19 @@ function registerIntelligenceTools(server2, ctx) {
|
|
|
3159
3191
|
const esim = sp.esim ?? {};
|
|
3160
3192
|
const statuses = esim.status ?? [];
|
|
3161
3193
|
for (const s of statuses) {
|
|
3162
|
-
const name = String(s.name ?? "").toUpperCase();
|
|
3163
3194
|
const count = Number(s.count ?? 0);
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3195
|
+
const num = s.statusNum;
|
|
3196
|
+
if (typeof num === "number") {
|
|
3197
|
+
if (num === 1) active += count;
|
|
3198
|
+
else if (num === 2) suspended += count;
|
|
3199
|
+
else if (num === 0) inventory += count;
|
|
3200
|
+
else other += count;
|
|
3201
|
+
continue;
|
|
3202
|
+
}
|
|
3203
|
+
const str = String(s.statusStr ?? s.name ?? "").toUpperCase();
|
|
3204
|
+
if (str === "ACTIVATED" || str === "ACTIVE") active += count;
|
|
3205
|
+
else if (str === "SUSPENDED") suspended += count;
|
|
3206
|
+
else if (str === "FREE" || str === "INVENTORY" || str === "NOT_ACTIVATED" || str === "AVAILABLE") inventory += count;
|
|
3167
3207
|
else other += count;
|
|
3168
3208
|
}
|
|
3169
3209
|
}
|
|
@@ -3574,18 +3614,11 @@ All accounts healthy.`);
|
|
|
3574
3614
|
}, async ({ accountId, limit: sampleLimit }) => {
|
|
3575
3615
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
3576
3616
|
const maxSample = sampleLimit ?? 50;
|
|
3577
|
-
const
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
safeCall(ctx.env, token2, "
|
|
3581
|
-
getDefaultResellerId(ctx.env, token2)
|
|
3617
|
+
const resellerId = await getDefaultResellerId(ctx.env, token2);
|
|
3618
|
+
const [subsResult, steeringResult] = await Promise.all([
|
|
3619
|
+
fetchActiveSubscribers(ctx.env, token2, accountId, resellerId),
|
|
3620
|
+
safeCall(ctx.env, token2, "listSteeringList", resellerId)
|
|
3582
3621
|
]);
|
|
3583
|
-
const steeringResult = await safeCall(
|
|
3584
|
-
ctx.env,
|
|
3585
|
-
token2,
|
|
3586
|
-
"listSteeringList",
|
|
3587
|
-
resellerId
|
|
3588
|
-
);
|
|
3589
3622
|
if (subsResult.error) return result(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
3590
3623
|
const sections = [`# Network Coverage Audit
|
|
3591
3624
|
`];
|
|
@@ -3777,11 +3810,10 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
3777
3810
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
3778
3811
|
const sampleSize = maxLimit ?? 100;
|
|
3779
3812
|
const threshold = thresholdPct ?? 80;
|
|
3780
|
-
const
|
|
3781
|
-
|
|
3782
|
-
const subsResult = await safeCall(ctx.env, token2, "listSubscriber", subParams);
|
|
3813
|
+
const resellerId = await getDefaultResellerId(ctx.env, token2);
|
|
3814
|
+
const subsResult = await fetchActiveSubscribers(ctx.env, token2, accountId, resellerId);
|
|
3783
3815
|
if (subsResult.error) return result(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
3784
|
-
if (!subsResult.data ||
|
|
3816
|
+
if (!subsResult.data || subsResult.data.length === 0) return result("No subscribers found", true);
|
|
3785
3817
|
const sections = [`# High Cost Subscriber Report
|
|
3786
3818
|
`];
|
|
3787
3819
|
const now = /* @__PURE__ */ new Date();
|