@carrierllc/mcp 0.13.58 → 0.13.60

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
@@ -82,7 +82,7 @@ import {
82
82
  verifyStorefront,
83
83
  withOcsListSummary,
84
84
  withTemplateResellerId
85
- } from "./chunk-VCNV4UHO.js";
85
+ } from "./chunk-6J2ZU3T5.js";
86
86
  import "./chunk-SHKKVIIA.js";
87
87
 
88
88
  // src/index.ts
@@ -6183,6 +6183,90 @@ function registerUiAgentAskTools(server2, ctx, runtime) {
6183
6183
  );
6184
6184
  }
6185
6185
 
6186
+ // src/carrier-api-tools.ts
6187
+ var CARRIER_API_TOOL_SCOPES = {
6188
+ list_connectivity_offering_templates: "read"
6189
+ };
6190
+ var DEFAULT_API_BASE_URL = "https://api.carrier.llc";
6191
+ var REQUEST_TIMEOUT_MS = 1e4;
6192
+ function jsonResult2(body2, isError = false) {
6193
+ return {
6194
+ ...isError ? { isError: true } : {},
6195
+ content: [{ type: "text", text: JSON.stringify(body2, null, 2) }]
6196
+ };
6197
+ }
6198
+ function apiError(code, message, detail = {}) {
6199
+ return jsonResult2({ ...detail, code, message }, true);
6200
+ }
6201
+ async function carrierApiRequest(ctx, extra, req) {
6202
+ const token2 = await ctx.getApiToken?.(extra);
6203
+ if (!token2) {
6204
+ return apiError(
6205
+ "CARRIER_API_AUTH_REQUIRED",
6206
+ "This tool needs the OAuth access token of your MCP session, and this connection did not present one. Reconnect with the OAuth flow instead of a ?TOKEN= reseller token. No request was made."
6207
+ );
6208
+ }
6209
+ const base = (ctx.env.CARRIER_API_BASE_URL ?? DEFAULT_API_BASE_URL).replace(/\/+$/, "");
6210
+ let response;
6211
+ try {
6212
+ response = await fetch(`${base}${req.path}`, {
6213
+ method: req.method,
6214
+ redirect: "error",
6215
+ headers: { Accept: "application/json", Authorization: `Bearer ${token2}` },
6216
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
6217
+ });
6218
+ } catch (err9) {
6219
+ return apiError("CARRIER_API_UNREACHABLE", `Carrier API request failed: ${err9 instanceof Error ? err9.name : "error"}.`);
6220
+ }
6221
+ let text;
6222
+ try {
6223
+ text = await response.text();
6224
+ } catch {
6225
+ return apiError("CARRIER_API_UNREADABLE", "Carrier API response could not be read.", { http_status: response.status });
6226
+ }
6227
+ let parsed;
6228
+ try {
6229
+ parsed = JSON.parse(text);
6230
+ } catch {
6231
+ parsed = void 0;
6232
+ }
6233
+ if (response.ok) {
6234
+ if (parsed === void 0) {
6235
+ return apiError("CARRIER_API_BAD_RESPONSE", "Carrier API returned a non-JSON success body.", { http_status: response.status });
6236
+ }
6237
+ return jsonResult2(parsed);
6238
+ }
6239
+ const body2 = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
6240
+ const nested = body2["error"];
6241
+ const source = nested && typeof nested === "object" && !Array.isArray(nested) ? nested : body2;
6242
+ const pick = (k) => typeof source[k] === "string" ? source[k].slice(0, 300) : void 0;
6243
+ const hint = response.status === 401 ? "The API did not accept your MCP access token. Reconnect to refresh it." : response.status === 403 ? "Your grant does not allow this operation. Re-authorize with a broader scope if you need it." : "The Carrier API returned an error.";
6244
+ return apiError("CARRIER_API_ERROR", hint, {
6245
+ http_status: response.status,
6246
+ api_code: pick("code"),
6247
+ api_error: pick("error") ?? pick("message")
6248
+ });
6249
+ }
6250
+ function registerCarrierApiTools(server2, ctx) {
6251
+ server2.registerTool(
6252
+ "list_connectivity_offering_templates",
6253
+ {
6254
+ title: "List connectivity offering templates",
6255
+ description: "List the versioned starter templates for a connectivity offering, for example travel-booking, own-brand and member-benefit. Calls GET /v1/connectivity/offerings/templates on api.carrier.llc with your own MCP access token, so the result is limited to what your organization may see. Use this before choosing a concept for a new offering. Params: none. Do NOT use this to list the offerings you already created, or OCS package templates \u2014 that is list_package_templates.",
6256
+ inputSchema: {},
6257
+ annotations: { readOnlyHint: true }
6258
+ },
6259
+ wrapHandler(
6260
+ "list_connectivity_offering_templates",
6261
+ "carrier-api.offering-templates",
6262
+ "read",
6263
+ ctx,
6264
+ (_args, _token, extra) => carrierApiRequest(ctx, extra, { method: "GET", path: "/v1/connectivity/offerings/templates" }),
6265
+ { skipUserToken: true }
6266
+ )
6267
+ );
6268
+ }
6269
+
6186
6270
  // src/tools-ui-agent-schedule.ts
6187
6271
  import { z as z6 } from "zod";
6188
6272
  var UI_AGENT_SCHEDULE_TOOL_SCOPES = {
@@ -8157,7 +8241,7 @@ var networkSchema = {
8157
8241
  mcc: z12.string().regex(/^\d{3}$/, "mcc must be 3 digits").describe("Mobile Country Code"),
8158
8242
  mnc: z12.string().regex(/^\d{2,3}$/, "mnc must be 2 or 3 digits").describe("Mobile Network Code")
8159
8243
  };
8160
- function jsonResult2(body2) {
8244
+ function jsonResult3(body2) {
8161
8245
  return {
8162
8246
  content: [{ type: "text", text: JSON.stringify(body2, null, 2) }]
8163
8247
  };
@@ -8183,7 +8267,7 @@ function registerAtlasTools(server2, ctx) {
8183
8267
  technology: args.technology
8184
8268
  });
8185
8269
  const body2 = await atlasPublicGet(atlasBaseUrl(ctx.env), path);
8186
- return jsonResult2(body2);
8270
+ return jsonResult3(body2);
8187
8271
  }
8188
8272
  )
8189
8273
  );
@@ -8203,7 +8287,7 @@ function registerAtlasTools(server2, ctx) {
8203
8287
  async (args, _token) => {
8204
8288
  const path = atlasNetworkPath(args.mcc, args.mnc);
8205
8289
  const body2 = await atlasPublicGet(atlasBaseUrl(ctx.env), path);
8206
- return jsonResult2(body2);
8290
+ return jsonResult3(body2);
8207
8291
  }
8208
8292
  )
8209
8293
  );
@@ -9868,7 +9952,8 @@ var ALL_TOOL_SCOPES = Object.freeze({
9868
9952
  ...STOREFRONT_PLAN_TOOL_SCOPES,
9869
9953
  ...ATLAS_TOOL_SCOPES,
9870
9954
  ...NETWORK_DEFAULT_TOOL_SCOPES,
9871
- ...AFFILIATE_TOOL_SCOPES
9955
+ ...AFFILIATE_TOOL_SCOPES,
9956
+ ...CARRIER_API_TOOL_SCOPES
9872
9957
  });
9873
9958
  var TOOL_REGISTRY = new Set(Object.keys(ALL_TOOL_SCOPES));
9874
9959
  var UNREGISTERED_TOOLS = /* @__PURE__ */ new Set(["stripe_proxy_call"]);
@@ -13195,6 +13280,7 @@ registerAllUiAgentTools(server, toolCtx, uiAgentRuntime, portalOptIn);
13195
13280
  registerUiAgentAskTools(server, toolCtx, uiAgentRuntime);
13196
13281
  registerStripeConnectTools(server, { env: stdioEnv, props });
13197
13282
  registerAffiliateTools(server, { env: stdioEnv, props });
13283
+ registerCarrierApiTools(server, toolCtx);
13198
13284
  registerWalletTools(server, { env: stdioEnv, props });
13199
13285
  registerGreenzoneTools(server, toolCtx);
13200
13286
  registerUiAgentGenericTools(server, toolCtx, uiAgentRuntime);