@carrierllc/mcp 0.13.47 → 0.13.51

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
@@ -16,6 +16,7 @@ import {
16
16
  configureClerkInstance,
17
17
  daysUntil,
18
18
  deploySite,
19
+ discoverSecrets,
19
20
  esimStatusPerAccountParams,
20
21
  extractDailyUsage,
21
22
  extractEsimStatusByAccount,
@@ -81,7 +82,7 @@ import {
81
82
  verifyStorefront,
82
83
  withOcsListSummary,
83
84
  withTemplateResellerId
84
- } from "./chunk-4XUAUQ3U.js";
85
+ } from "./chunk-NPAD6AA7.js";
85
86
  import "./chunk-SHKKVIIA.js";
86
87
 
87
88
  // src/index.ts
@@ -7730,18 +7731,66 @@ function registerStorefrontDeployTools(server2, props2) {
7730
7731
  ),
7731
7732
  skip_build: z10.boolean().optional().describe("Deploy the existing build without rebuilding"),
7732
7733
  push_secrets: z10.boolean().optional().describe("Stage runtime secrets on the host before deploy (default true)"),
7734
+ provision_clerk: z10.boolean().optional().default(true).describe("Provision and configure Clerk automatically (default true)"),
7733
7735
  verify: z10.boolean().optional().describe("Probe the deployed URL and report whether it actually serves (default true)"),
7734
7736
  domain: z10.boolean().optional().describe("Route the brand domain to the deployment (Cloudflare provisions DNS + cert)")
7735
7737
  },
7736
7738
  annotations: annotationsFor("deploy_storefront", "write")
7737
7739
  },
7738
- async ({ dir, target, name, force, skip_build, push_secrets, verify, domain }) => {
7740
+ async ({
7741
+ dir,
7742
+ target,
7743
+ name,
7744
+ force,
7745
+ skip_build,
7746
+ push_secrets,
7747
+ provision_clerk,
7748
+ verify,
7749
+ domain
7750
+ }) => {
7739
7751
  const denied = denyUnlessScoped(props2, "deploy_storefront", STOREFRONT_DEPLOY_TOOL_SCOPES);
7740
7752
  if (denied) return denied;
7741
7753
  try {
7742
7754
  if (target && !isTargetId(target)) return err4(`Unknown target "${target}".`);
7743
7755
  const brand = await loadStorefrontBrand(dir, name ? { name } : void 0);
7744
7756
  const preferred = target;
7757
+ let clerkProvisioned = false;
7758
+ let clerkTier = null;
7759
+ let clerkProvisionError;
7760
+ let clerkCredentials;
7761
+ let clerkEnvWritten = [];
7762
+ let clerkConfigured = [];
7763
+ let clerkConfigureFailures = [];
7764
+ if (provision_clerk !== false && !skip_build) {
7765
+ try {
7766
+ const provisioned = await provisionClerk({
7767
+ name: brand.name,
7768
+ domain: brand.domain,
7769
+ // A live deploy is a production deploy: when the platform tier
7770
+ // creates an application, request a production instance for it.
7771
+ production: true,
7772
+ // .env.local is not auto-loaded into process.env, so merge it in
7773
+ // explicitly: the discovered tier must see keys a previous
7774
+ // deploy wrote, or every redeploy would mint a fresh instance.
7775
+ env: { ...process.env, ...await discoverSecrets(dir, process.env) },
7776
+ storefront: dir,
7777
+ cli: clerkCliDeps()
7778
+ });
7779
+ clerkTier = provisioned.tier;
7780
+ if (provisioned.ok && provisioned.credentials) {
7781
+ clerkProvisioned = true;
7782
+ clerkCredentials = provisioned.credentials;
7783
+ clerkEnvWritten = await mergeEnvLocal(dir, {
7784
+ NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: provisioned.credentials.publishableKey,
7785
+ CLERK_SECRET_KEY: provisioned.credentials.secretKey
7786
+ });
7787
+ } else {
7788
+ clerkProvisionError = provisioned.reason ?? "Clerk provisioning did not return credentials.";
7789
+ }
7790
+ } catch (e) {
7791
+ clerkProvisionError = e instanceof Error ? e.message : String(e);
7792
+ }
7793
+ }
7745
7794
  if (!skip_build) {
7746
7795
  const ranked = rankTargets(await probeAll(dir));
7747
7796
  const buildFor = preferred ?? ranked[0]?.id ?? "cloudflare";
@@ -7762,7 +7811,19 @@ function registerStorefrontDeployTools(server2, props2) {
7762
7811
  if (!result2.ok) {
7763
7812
  return err4(result2.reason ?? "Deploy failed.");
7764
7813
  }
7814
+ if (provision_clerk !== false && result2.url) {
7815
+ const secretKey = clerkCredentials?.secretKey ?? (await discoverSecrets(dir, process.env)).CLERK_SECRET_KEY;
7816
+ if (secretKey) {
7817
+ const configured = await configureClerkInstance(
7818
+ secretKey,
7819
+ storefrontClerkUrls(result2.url, brand.domain)
7820
+ );
7821
+ clerkConfigured = configured.applied;
7822
+ clerkConfigureFailures = configured.failed;
7823
+ }
7824
+ }
7765
7825
  const verification = verify !== false && result2.url ? await verifyStorefront(result2.url, dir, process.env) : void 0;
7826
+ const repairHint = skip_build && clerkEnvWritten.includes("NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY") ? "Clerk keys were written to .env.local, but the publishable key is only inlined at build time; rebuild and redeploy to apply it." : verification && !verification.ok ? repairPlanFor(verification.diagnosis)?.note ?? verification.summary : void 0;
7766
7827
  return ok3({
7767
7828
  deployed: true,
7768
7829
  target: result2.target,
@@ -7770,10 +7831,15 @@ function registerStorefrontDeployTools(server2, props2) {
7770
7831
  url: result2.url ?? null,
7771
7832
  secrets_staged: result2.secrets?.pushed ?? [],
7772
7833
  secrets_failed: result2.secrets?.failed ?? [],
7834
+ clerk_provisioned: clerkProvisioned,
7835
+ clerk_tier: clerkTier,
7836
+ clerk_configured: clerkConfigured.length,
7837
+ clerk_configure_failures: clerkConfigureFailures,
7838
+ clerk_provision_error: clerkProvisionError,
7773
7839
  verified: verification ? verification.ok : null,
7774
7840
  diagnosis: verification?.ok === false ? verification.diagnosis : void 0,
7775
7841
  probes: verification ? formatProbes(verification.probes) : void 0,
7776
- repair_hint: verification && !verification.ok ? repairPlanFor(verification.diagnosis)?.note ?? verification.summary : void 0,
7842
+ repair_hint: repairHint,
7777
7843
  warning: result2.secrets?.pushed.includes("CARRIER_API_KEY") ? void 0 : "CARRIER_API_KEY was not staged \u2014 / and /shop will return 500 until it is set."
7778
7844
  });
7779
7845
  } catch (e) {