@mcpcloud/cli 0.10.0-next-20260715004701 → 0.10.1-next-20260715014243

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.
Files changed (2) hide show
  1. package/dist/index.js +83 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3964,6 +3964,45 @@ function isTerminalEvent(event) {
3964
3964
  return true;
3965
3965
  return false;
3966
3966
  }
3967
+ var SUCCESS_STAGES = new Set(["active"]);
3968
+ var SUCCESS_LEVELS = new Set(["success"]);
3969
+ function isSuccessEvent(event) {
3970
+ if (SUCCESS_STAGES.has(event.stage))
3971
+ return true;
3972
+ if (SUCCESS_LEVELS.has(event.level))
3973
+ return true;
3974
+ const m = event.message.toLowerCase();
3975
+ if (m.includes("deployment active") || m.includes("deploy succeeded"))
3976
+ return true;
3977
+ return false;
3978
+ }
3979
+ function isFailureEvent(event) {
3980
+ return isTerminalEvent(event) && !isSuccessEvent(event);
3981
+ }
3982
+ function formatEventDetails(details) {
3983
+ if (details == null)
3984
+ return null;
3985
+ if (typeof details === "string") {
3986
+ const trimmed = details.trim();
3987
+ return trimmed.length > 0 ? trimmed : null;
3988
+ }
3989
+ if (typeof details === "object") {
3990
+ const record = details;
3991
+ for (const key of ["error", "message", "reason", "detail"]) {
3992
+ const value = record[key];
3993
+ if (typeof value === "string" && value.trim().length > 0) {
3994
+ return value.trim();
3995
+ }
3996
+ }
3997
+ try {
3998
+ const json = JSON.stringify(details);
3999
+ return json && json !== "{}" ? json : null;
4000
+ } catch {
4001
+ return null;
4002
+ }
4003
+ }
4004
+ return null;
4005
+ }
3967
4006
  async function followDeploymentEvents(args) {
3968
4007
  const isDone = args.isDone ?? isTerminalEvent;
3969
4008
  const totalTimeoutMs = args.totalTimeoutMs ?? 5 * 60000;
@@ -3999,7 +4038,9 @@ function formatEventLine(event) {
3999
4038
  const ts = new Date(event.timestamp).toISOString();
4000
4039
  const level = (event.level || "info").toUpperCase().padEnd(7);
4001
4040
  const stage = (event.stage || "").padEnd(12);
4002
- return `[${ts}] ${level} ${stage} ${event.message}`;
4041
+ const base = `[${ts}] ${level} ${stage} ${event.message}`;
4042
+ const details = formatEventDetails(event.details);
4043
+ return details && details !== event.message ? `${base} — ${details}` : base;
4003
4044
  }
4004
4045
  async function tailDeploymentLogs(args) {
4005
4046
  const params = {
@@ -4533,11 +4574,12 @@ function validateChoice(name, value, allowed) {
4533
4574
  }
4534
4575
  return v;
4535
4576
  }
4536
- function formatEventLine2(event) {
4537
- const ts = new Date(event.timestamp).toISOString();
4538
- const level = event.level.padEnd(7);
4539
- const stage = event.stage.padEnd(12);
4540
- return `[${ts}] ${level} ${stage} ${event.message}`;
4577
+ function reportDeployFailure(terminalEvent) {
4578
+ if (!terminalEvent || !isFailureEvent(terminalEvent))
4579
+ return false;
4580
+ const reason = formatEventDetails(terminalEvent.details);
4581
+ printError(`Deploy failed: ${reason ?? terminalEvent.message}`);
4582
+ return true;
4541
4583
  }
4542
4584
  function registerServerLifecycleCommands(servers) {
4543
4585
  servers.command("deploy <serverId>").description("Deploy a server's generated bundle to Cloudflare Workers (closes the spec → deploy loop)").option("--org <organizationId>", "Organization ID").option("--project <projectId>", "Project ID (defaults to the server's project)").option("--target <target>", `Deploy target: ${DEPLOY_TARGETS.join(" | ")}`, "workersDev").option("--access-mode <mode>", `Access mode: ${ACCESS_MODES.join(" | ")}`, "public").option("--upstream-base-url <url>", "Upstream API base URL bound into the worker").option("--upstream-api-key <key>", "Upstream API key (encrypted at rest server-side)").option("--upstream-api-key-header <header>", "Header name to inject the upstream API key on (default: Authorization)").option("--upstream-api-key-prefix <prefix>", 'Prefix for the upstream API key value (e.g. "Bearer ")').option("--wait", "Tail deployment events until the deploy reaches a terminal state").option("--wait-timeout <seconds>", "Maximum seconds to wait for terminal state (default 300)", "300").addHelpText("after", [
@@ -4603,7 +4645,7 @@ function registerServerLifecycleCommands(servers) {
4603
4645
  totalTimeoutMs,
4604
4646
  onEvent: (event) => {
4605
4647
  if (!isJsonMode()) {
4606
- printInfo(formatEventLine2(event));
4648
+ printInfo(formatEventLine(event));
4607
4649
  }
4608
4650
  }
4609
4651
  });
@@ -4614,9 +4656,10 @@ function registerServerLifecycleCommands(servers) {
4614
4656
  }
4615
4657
  }
4616
4658
  }
4659
+ const deployFailed = dep.status === "failed" || Boolean(terminalEvent && isFailureEvent(terminalEvent));
4617
4660
  if (isJsonMode()) {
4618
4661
  printJson({ deployment: dep, waitDone, terminalEvent });
4619
- if (opts.wait && !waitDone)
4662
+ if (opts.wait && (!waitDone || deployFailed))
4620
4663
  throw new CliExitError(1);
4621
4664
  return;
4622
4665
  }
@@ -4638,6 +4681,12 @@ function registerServerLifecycleCommands(servers) {
4638
4681
  }
4639
4682
  if (opts.wait && !waitDone)
4640
4683
  throw new CliExitError(1);
4684
+ if (deployFailed) {
4685
+ if (!reportDeployFailure(terminalEvent)) {
4686
+ printError("Deploy failed.");
4687
+ }
4688
+ throw new CliExitError(1);
4689
+ }
4641
4690
  }));
4642
4691
  servers.command("push-spec <serverId>").description("Push a local OpenAPI spec to the cloud (regenerates the bundle; optionally deploys)").option("--org <organizationId>", "Organization ID").option("--spec <path>", "Path to the OpenAPI/Swagger spec file", "./openapi.yaml").option("--enrich-on-change", "Preserve per-tool enrichment when the spec changes").option("--deploy", "Immediately deploy the regenerated bundle to Cloudflare Workers").option("--target <target>", `Deploy target (with --deploy): ${DEPLOY_TARGETS.join(" | ")}`, "workersDev").option("--access-mode <mode>", `Access mode (with --deploy): ${ACCESS_MODES.join(" | ")}`, "public").option("--wait", "With --deploy: tail deployment events until terminal state").option("--wait-timeout <seconds>", "Maximum seconds to wait for terminal state (default 300)", "300").addHelpText("after", [
4643
4692
  "",
@@ -4740,7 +4789,7 @@ function registerServerLifecycleCommands(servers) {
4740
4789
  totalTimeoutMs,
4741
4790
  onEvent: (event) => {
4742
4791
  if (!isJsonMode())
4743
- printInfo(formatEventLine2(event));
4792
+ printInfo(formatEventLine(event));
4744
4793
  }
4745
4794
  });
4746
4795
  terminalEvent = r.terminalEvent;
@@ -4750,6 +4799,7 @@ function registerServerLifecycleCommands(servers) {
4750
4799
  }
4751
4800
  }
4752
4801
  }
4802
+ const deployFailed = dep.status === "failed" || Boolean(terminalEvent && isFailureEvent(terminalEvent));
4753
4803
  if (isJsonMode()) {
4754
4804
  printJson({
4755
4805
  pushed: true,
@@ -4759,7 +4809,7 @@ function registerServerLifecycleCommands(servers) {
4759
4809
  waitDone,
4760
4810
  terminalEvent
4761
4811
  });
4762
- if (opts.wait && !waitDone)
4812
+ if (opts.wait && (!waitDone || deployFailed))
4763
4813
  throw new CliExitError(1);
4764
4814
  return;
4765
4815
  }
@@ -4781,6 +4831,12 @@ function registerServerLifecycleCommands(servers) {
4781
4831
  }
4782
4832
  if (opts.wait && !waitDone)
4783
4833
  throw new CliExitError(1);
4834
+ if (deployFailed) {
4835
+ if (!reportDeployFailure(terminalEvent)) {
4836
+ printError("Deploy failed.");
4837
+ }
4838
+ throw new CliExitError(1);
4839
+ }
4784
4840
  }));
4785
4841
  servers.command("regenerate <serverId>").description("Re-fetch a server's source spec and rebuild its tools with the current codegen (preserves customizations). Wraps POST /api/v1/server/regenerate.").option("--org <organizationId>", "Organization ID").option("--project <projectId>", "Project ID (defaults to the server's project)").option("--source-url <url>", "Override the stored spec source URL (needed for GraphQL servers whose introspection endpoint wasn't persisted)").addHelpText("after", [
4786
4842
  "",
@@ -30272,7 +30328,7 @@ async function runSpecInit(args) {
30272
30328
  opts
30273
30329
  });
30274
30330
  } catch (err) {
30275
- reportDeployFailure({
30331
+ reportDeployFailure2({
30276
30332
  serverId: server.id,
30277
30333
  projectId: project.id,
30278
30334
  project,
@@ -30293,12 +30349,19 @@ async function runSpecInit(args) {
30293
30349
  server,
30294
30350
  deploy: deployResult
30295
30351
  });
30352
+ if (deployResult?.terminalEvent && isFailureEvent(deployResult.terminalEvent))
30353
+ throw new CliExitError(1);
30296
30354
  if (deployResult && opts.wait && !deployResult.waitDone)
30297
30355
  throw new CliExitError(1);
30298
30356
  return;
30299
30357
  }
30300
30358
  if (deployResult) {
30301
- reportDeploySuccess({ serverId: server.id, result: deployResult, opts });
30359
+ reportDeploySuccess({
30360
+ serverId: server.id,
30361
+ projectId: project.id,
30362
+ result: deployResult,
30363
+ opts
30364
+ });
30302
30365
  return;
30303
30366
  }
30304
30367
  printInfo("");
@@ -30309,7 +30372,7 @@ async function runSpecInit(args) {
30309
30372
  function resumeDeployCommand(serverId, projectId) {
30310
30373
  return `mcp servers deploy ${serverId} --project ${projectId} --wait`;
30311
30374
  }
30312
- function reportDeployFailure(args) {
30375
+ function reportDeployFailure2(args) {
30313
30376
  const resume = resumeDeployCommand(args.serverId, args.projectId);
30314
30377
  if (isJsonMode()) {
30315
30378
  const message = args.err instanceof Error ? args.err.message : String(args.err);
@@ -30335,7 +30398,7 @@ function reportDeployFailure(args) {
30335
30398
  printInfo("");
30336
30399
  }
30337
30400
  function reportDeploySuccess(args) {
30338
- const { serverId, result, opts } = args;
30401
+ const { serverId, projectId, result, opts } = args;
30339
30402
  const dep = result.deployment;
30340
30403
  printSuccess(`Deployment ${c.bold(dep.deploymentId)} created.`);
30341
30404
  printKeyValue({
@@ -30346,6 +30409,12 @@ function reportDeploySuccess(args) {
30346
30409
  "access mode": dep.accessMode,
30347
30410
  status: dep.status
30348
30411
  });
30412
+ if (result.terminalEvent && isFailureEvent(result.terminalEvent)) {
30413
+ const reason = formatEventDetails(result.terminalEvent.details);
30414
+ printError(`Deploy failed: ${reason ?? result.terminalEvent.message}`);
30415
+ printStep(`Resume once the cause is cleared: \`mcp servers deploy ${serverId} --project ${projectId} --wait\``);
30416
+ throw new CliExitError(1);
30417
+ }
30349
30418
  if (opts.wait && !result.waitDone) {
30350
30419
  printError(`Deploy did not reach a terminal state in time. Check \`mcp deployments get ${dep.deploymentId}\` and \`mcp deployments health ${dep.deploymentId}\`, or tail \`mcp deployments logs ${dep.deploymentId} --follow\`.`);
30351
30420
  throw new CliExitError(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpcloud/cli",
3
- "version": "0.10.0-next-20260715004701",
3
+ "version": "0.10.1-next-20260715014243",
4
4
  "description": "The official CLI for MCPCloud — manage projects, servers, skills, and API keys from the terminal",
5
5
  "type": "module",
6
6
  "bin": {