@mcp-use/cli 3.5.3-canary.3 → 3.5.3-canary.5

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
@@ -5267,55 +5267,93 @@ async function getGitHubConnectionStatusWith401Retry(api, options, orgIdToRestor
5267
5267
  async function checkRepoAccess(api, owner, repo) {
5268
5268
  return api.checkGitHubRepoAccess(owner, repo);
5269
5269
  }
5270
+ function gitHubInstallUrl(appName) {
5271
+ return `https://github.com/apps/${appName}/installations/new`;
5272
+ }
5273
+ function resolveInstallFlowMode(opts) {
5274
+ if (opts.yes) return "auto";
5275
+ return opts.isTTY ? "interactive" : "non-interactive";
5276
+ }
5270
5277
  async function promptGitHubInstallation(api, reason, repoName, opts) {
5271
5278
  const yes = !!opts?.yes;
5272
5279
  const reauth = opts?.reauth;
5280
+ const noAccess = reason === "no_access";
5281
+ let client = api;
5282
+ let appName;
5283
+ for (; ; ) {
5284
+ try {
5285
+ appName = await client.getGitHubAppName();
5286
+ break;
5287
+ } catch (e) {
5288
+ if (e instanceof ApiUnauthorizedError && reauth) {
5289
+ client = await reauth();
5290
+ await client.testAuth();
5291
+ continue;
5292
+ }
5293
+ throw e;
5294
+ }
5295
+ }
5296
+ const installUrl = gitHubInstallUrl(appName);
5273
5297
  console.log();
5274
- if (reason === "not_connected") {
5275
- console.log(source_default.yellow("\u26A0\uFE0F GitHub account not connected"));
5276
- console.log(
5277
- source_default.white("Deployments require a connected GitHub account.\n")
5278
- );
5279
- } else {
5298
+ if (noAccess) {
5280
5299
  console.log(
5281
5300
  source_default.yellow("\u26A0\uFE0F GitHub App doesn't have access to this repository")
5282
5301
  );
5283
5302
  console.log(
5284
5303
  source_default.white(
5285
- `The GitHub App needs permission to access ${source_default.cyan(repoName || "this repository")}.
5286
- `
5304
+ `The GitHub App needs permission to access ${source_default.cyan(repoName || "this repository")}.`
5287
5305
  )
5288
5306
  );
5307
+ } else {
5308
+ console.log(source_default.yellow("\u26A0\uFE0F GitHub account not connected"));
5309
+ console.log(source_default.white("Deployments require a connected GitHub account."));
5289
5310
  }
5290
- const shouldInstall = yes ? true : await prompt(
5311
+ console.log(
5291
5312
  source_default.white(
5292
- `Would you like to ${reason === "not_connected" ? "connect" : "configure"} GitHub now? (Y/n): `
5293
- ),
5294
- "y"
5313
+ `
5314
+ Install${noAccess ? " / configure" : ""} the GitHub App to continue:`
5315
+ )
5295
5316
  );
5296
- if (!shouldInstall) return { ok: false, api };
5297
- let client = api;
5298
- try {
5299
- let appName;
5300
- for (; ; ) {
5301
- try {
5302
- appName = await client.getGitHubAppName();
5303
- break;
5304
- } catch (e) {
5305
- if (e instanceof ApiUnauthorizedError && reauth) {
5306
- client = await reauth();
5307
- await client.testAuth();
5308
- continue;
5309
- }
5310
- throw e;
5311
- }
5317
+ console.log(source_default.cyan.bold(` ${installUrl}`));
5318
+ if (noAccess) {
5319
+ console.log(
5320
+ source_default.gray(
5321
+ ` Grant access to ${repoName || "your repository"} on the app's settings page.`
5322
+ )
5323
+ );
5324
+ }
5325
+ const mode = resolveInstallFlowMode({ yes, isTTY: !!process.stdin.isTTY });
5326
+ if (mode === "non-interactive") {
5327
+ console.log(
5328
+ source_default.white(
5329
+ `
5330
+ Open the URL above to install the GitHub App, then re-run ${source_default.cyan("mcp-use deploy")}.`
5331
+ )
5332
+ );
5333
+ return { ok: false, api: client };
5334
+ }
5335
+ if (mode === "interactive") {
5336
+ const shouldInstall = await prompt(
5337
+ source_default.white(
5338
+ `
5339
+ Would you like to ${noAccess ? "configure" : "connect"} GitHub now? (Y/n): `
5340
+ ),
5341
+ "y"
5342
+ );
5343
+ if (!shouldInstall) {
5344
+ console.log(
5345
+ source_default.gray(
5346
+ `
5347
+ Open the URL above when ready, then re-run ${source_default.cyan("mcp-use deploy")}.`
5348
+ )
5349
+ );
5350
+ return { ok: false, api: client };
5312
5351
  }
5313
- const installUrl = `https://github.com/apps/${appName}/installations/new`;
5352
+ }
5353
+ try {
5314
5354
  console.log(source_default.cyan(`
5315
5355
  Opening browser...`));
5316
- console.log(source_default.gray(`URL: ${installUrl}
5317
- `));
5318
- if (reason === "no_access") {
5356
+ if (noAccess) {
5319
5357
  console.log(
5320
5358
  source_default.white("Please add ") + source_default.cyan.bold(repoName || "your repository") + source_default.white(" to the app's repository access, then return here.\n")
5321
5359
  );
@@ -5325,7 +5363,7 @@ Opening browser...`));
5325
5363
  );
5326
5364
  }
5327
5365
  await open_default(installUrl);
5328
- if (!yes) {
5366
+ if (mode === "interactive") {
5329
5367
  await prompt(source_default.white("Press Enter when done..."), "y");
5330
5368
  } else {
5331
5369
  console.log(source_default.gray("Waiting for GitHub configuration (polling)..."));
@@ -5358,7 +5396,7 @@ Opening browser...`));
5358
5396
  }
5359
5397
  console.log(source_default.yellow("\n\u26A0\uFE0F Unable to open browser automatically"));
5360
5398
  console.log(
5361
- source_default.white("Please visit: ") + source_default.cyan("https://manufact.com/cloud/settings")
5399
+ source_default.white("Please open the URL above: ") + source_default.cyan(installUrl)
5362
5400
  );
5363
5401
  return { ok: false, api: client };
5364
5402
  }
@@ -5944,12 +5982,8 @@ async function deployCommand(options) {
5944
5982
  \u2717 Repository ${source_default.cyan(repoFullName)} is still not accessible.`
5945
5983
  )
5946
5984
  );
5947
- console.log(
5948
- source_default.cyan(
5949
- ` https://github.com/apps/${appName}/installations/new
5950
- `
5951
- )
5952
- );
5985
+ console.log(source_default.cyan(` ${gitHubInstallUrl(appName)}
5986
+ `));
5953
5987
  process.exit(1);
5954
5988
  }
5955
5989
  }