@mcp-use/cli 3.0.3-canary.0 → 3.1.0-canary.2

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/README.md CHANGED
@@ -125,6 +125,9 @@ Deploy your MCP server to production via [manufact.com](https://manufact.com):
125
125
  # Login to Manufact cloud
126
126
  mcp-use login
127
127
 
128
+ # Non-interactive login (for agents / CI) — picks an org without prompting
129
+ mcp-use login --org <slug|id|name>
130
+
128
131
  # Check authentication status
129
132
  mcp-use whoami
130
133
 
@@ -1,4 +1,9 @@
1
1
  import type { OrgInfo } from "../utils/api.js";
2
+ /**
3
+ * Resolve an org identifier (slug, id, or case-insensitive name) against a list.
4
+ * Returns null if no match.
5
+ */
6
+ export declare function resolveOrgFromOption(orgs: OrgInfo[], identifier: string): OrgInfo | null;
2
7
  /**
3
8
  * Prompt user to pick an organization from a numbered list.
4
9
  */
@@ -9,6 +14,7 @@ export declare function promptOrgSelection(orgs: OrgInfo[], defaultOrgId?: strin
9
14
  export declare function loginCommand(options?: {
10
15
  silent?: boolean;
11
16
  apiKey?: string;
17
+ org?: string;
12
18
  }): Promise<void>;
13
19
  /**
14
20
  * Logout command - revokes API key and deletes config
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AA8F/C;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EAAE,EACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAC3B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CA2CzB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4IhB;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAwBnD;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAkEnD"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAoB,OAAO,EAAE,MAAM,iBAAiB,CAAC;AA8FjE;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,EAAE,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,GAAG,IAAI,CAUhB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EAAE,EACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAC3B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CA2CzB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,IAAI,CAAC,CA0JhB;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAwBnD;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAkEnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AA4IA,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAueD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAwsBzE"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAgJA,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAueD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAmsBzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"deployments.d.ts","sourceRoot":"","sources":["../../src/commands/deployments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAugBpC,wBAAgB,wBAAwB,IAAI,OAAO,CAuDlD"}
1
+ {"version":3,"file":"deployments.d.ts","sourceRoot":"","sources":["../../src/commands/deployments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuiBpC,wBAAgB,wBAAwB,IAAI,OAAO,CAuDlD"}
@@ -1 +1 @@
1
- {"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../src/commands/servers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6UpC,wBAAgB,oBAAoB,IAAI,OAAO,CAkC9C"}
1
+ {"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../src/commands/servers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyUpC,wBAAgB,oBAAoB,IAAI,OAAO,CAkC9C"}
package/dist/index.cjs CHANGED
@@ -1589,6 +1589,14 @@ async function pollForDeviceToken(authBaseUrl, deviceCode, intervalSeconds) {
1589
1589
  }
1590
1590
  throw new Error("Login timed out. Please try again.");
1591
1591
  }
1592
+ function resolveOrgFromOption(orgs, identifier) {
1593
+ const needle = identifier.trim();
1594
+ if (!needle) return null;
1595
+ const lower = needle.toLowerCase();
1596
+ return orgs.find(
1597
+ (o) => o.slug === needle || o.id === needle || o.name.toLowerCase() === lower
1598
+ ) ?? null;
1599
+ }
1592
1600
  async function promptOrgSelection(orgs, defaultOrgId) {
1593
1601
  if (orgs.length === 0) return null;
1594
1602
  if (orgs.length === 1) {
@@ -1635,8 +1643,8 @@ async function loginCommand(options) {
1635
1643
  console.log(source_default.green.bold("\u2713 API key saved."));
1636
1644
  try {
1637
1645
  const api2 = await McpUseAPI.create();
1638
- const authInfo = await api2.testAuth();
1639
- console.log(source_default.gray(` Authenticated as ${authInfo.email}`));
1646
+ const authInfo2 = await api2.testAuth();
1647
+ console.log(source_default.gray(` Authenticated as ${authInfo2.email}`));
1640
1648
  } catch {
1641
1649
  console.log(
1642
1650
  source_default.gray(
@@ -1688,9 +1696,19 @@ async function loginCommand(options) {
1688
1696
  const keyResp = await api.createApiKeyWithAccessToken(accessToken, "CLI");
1689
1697
  await writeConfig({ apiKey: keyResp.key });
1690
1698
  console.log(source_default.green.bold("\n\u2713 Successfully logged in!"));
1699
+ let authInfo = null;
1691
1700
  try {
1692
1701
  const freshApi = await McpUseAPI.create();
1693
- const authInfo = await freshApi.testAuth();
1702
+ authInfo = await freshApi.testAuth();
1703
+ } catch {
1704
+ console.log(
1705
+ source_default.gray(
1706
+ `
1707
+ Your API key has been saved to ${source_default.white("~/.mcp-use/config.json")}`
1708
+ )
1709
+ );
1710
+ }
1711
+ if (authInfo) {
1694
1712
  console.log(source_default.cyan.bold("\nCurrent user:\n"));
1695
1713
  console.log(source_default.white(" Email: ") + source_default.cyan(authInfo.email));
1696
1714
  console.log(source_default.white(" User ID: ") + source_default.gray(authInfo.user_id));
@@ -1702,8 +1720,19 @@ async function loginCommand(options) {
1702
1720
  const orgs = authInfo.orgs ?? [];
1703
1721
  if (orgs.length > 0) {
1704
1722
  let selectedOrg = null;
1705
- if (orgs.length === 1) {
1723
+ if (options?.org) {
1724
+ selectedOrg = resolveOrgFromOption(orgs, options.org);
1725
+ if (!selectedOrg) {
1726
+ throw new Error(
1727
+ `Organization "${options.org}" not found. Run 'npx mcp-use org list' after logging in to see available organizations.`
1728
+ );
1729
+ }
1730
+ } else if (orgs.length === 1) {
1706
1731
  selectedOrg = orgs[0];
1732
+ } else if (!process.stdin.isTTY) {
1733
+ throw new Error(
1734
+ "Multiple organizations available and no TTY for interactive selection. Re-run with --org <slug|id|name> to pick one non-interactively."
1735
+ );
1707
1736
  } else {
1708
1737
  selectedOrg = await promptOrgSelection(orgs, authInfo.default_org_id);
1709
1738
  }
@@ -1721,13 +1750,6 @@ async function loginCommand(options) {
1721
1750
  );
1722
1751
  }
1723
1752
  }
1724
- } catch {
1725
- console.log(
1726
- source_default.gray(
1727
- `
1728
- Your API key has been saved to ${source_default.white("~/.mcp-use/config.json")}`
1729
- )
1730
- );
1731
1753
  }
1732
1754
  console.log(
1733
1755
  source_default.gray(
@@ -3575,9 +3597,7 @@ async function deployCommand(options) {
3575
3597
  let resolvedOrgId;
3576
3598
  if (options.org) {
3577
3599
  const authInfo = await api.testAuth();
3578
- const match = (authInfo.orgs ?? []).find(
3579
- (o) => o.slug === options.org || o.id === options.org || o.name.toLowerCase() === options.org.toLowerCase()
3580
- );
3600
+ const match = resolveOrgFromOption(authInfo.orgs ?? [], options.org);
3581
3601
  if (match) {
3582
3602
  api.setOrgId(match.id);
3583
3603
  resolvedOrgId = match.id;
@@ -4210,7 +4230,27 @@ async function listDeploymentsCommand() {
4210
4230
  process.exit(1);
4211
4231
  }
4212
4232
  const api = await McpUseAPI.create();
4213
- const deployments = await api.listDeployments();
4233
+ const [deployments, authResult] = await Promise.all([
4234
+ api.listDeployments(),
4235
+ api.testAuth()
4236
+ ]);
4237
+ const orgMap = new Map(authResult.orgs.map((o) => [o.id, o.name]));
4238
+ const uniqueServerIds = [
4239
+ ...new Set(
4240
+ deployments.map((d) => d.serverId).filter((id) => id != null)
4241
+ )
4242
+ ];
4243
+ const serverResults = await Promise.allSettled(
4244
+ uniqueServerIds.map((id) => api.getServer(id))
4245
+ );
4246
+ const serverOrgMap = /* @__PURE__ */ new Map();
4247
+ for (let i = 0; i < uniqueServerIds.length; i++) {
4248
+ const result = serverResults[i];
4249
+ if (result.status === "fulfilled") {
4250
+ const orgName = orgMap.get(result.value.organizationId) ?? result.value.organizationId.substring(0, 19);
4251
+ serverOrgMap.set(uniqueServerIds[i], orgName);
4252
+ }
4253
+ }
4214
4254
  const sortedDeployments = [...deployments].sort(
4215
4255
  (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
4216
4256
  );
@@ -4230,19 +4270,21 @@ async function listDeploymentsCommand() {
4230
4270
  );
4231
4271
  console.log(
4232
4272
  source_default.white.bold(
4233
- `${"ID".padEnd(40)} ${"NAME".padEnd(25)} ${"STATUS".padEnd(12)} ${"MCP URL".padEnd(45)} ${"CREATED"}`
4273
+ `${"ID".padEnd(40)} ${"NAME".padEnd(25)} ${"ORG".padEnd(20)} ${"STATUS".padEnd(12)} ${"MCP URL".padEnd(45)} ${"CREATED"}`
4234
4274
  )
4235
4275
  );
4236
- console.log(source_default.gray("\u2500".repeat(140)));
4276
+ console.log(source_default.gray("\u2500".repeat(155)));
4237
4277
  for (const deployment of sortedDeployments) {
4238
4278
  const id = formatId(deployment.id).padEnd(40);
4239
4279
  const name = deployment.name.substring(0, 24).padEnd(25);
4280
+ const orgName = deployment.serverId ? serverOrgMap.get(deployment.serverId) ?? "-" : "-";
4281
+ const org = orgName.substring(0, 19).padEnd(20);
4240
4282
  const statusColor = getStatusColor(deployment.status);
4241
4283
  const status = statusColor(deployment.status.padEnd(12));
4242
4284
  const mcpUrl = (deployment.mcpUrl || "-").substring(0, 44).padEnd(45);
4243
4285
  const created = formatRelativeTime(deployment.createdAt);
4244
4286
  console.log(
4245
- `${source_default.gray(id)} ${name} ${status} ${source_default.cyan(mcpUrl)} ${source_default.gray(created)}`
4287
+ `${source_default.gray(id)} ${name} ${source_default.magenta(org)} ${status} ${source_default.cyan(mcpUrl)} ${source_default.gray(created)}`
4246
4288
  );
4247
4289
  }
4248
4290
  console.log();
@@ -4779,9 +4821,7 @@ function pickStr(obj, key) {
4779
4821
  async function applyOrgOption(api, org) {
4780
4822
  if (!org) return;
4781
4823
  const authInfo = await api.testAuth();
4782
- const match = (authInfo.orgs ?? []).find(
4783
- (o) => o.slug === org || o.id === org || o.name.toLowerCase() === org.toLowerCase()
4784
- );
4824
+ const match = resolveOrgFromOption(authInfo.orgs ?? [], org);
4785
4825
  if (!match) {
4786
4826
  console.error(
4787
4827
  source_default.red(
@@ -7200,9 +7240,9 @@ Looked for:
7200
7240
  program.command("login").description("Login to mcp-use cloud").option(
7201
7241
  "--api-key <key>",
7202
7242
  "Login with an API key directly (non-interactive, for CI/CD)"
7203
- ).action(async (opts) => {
7243
+ ).option("--org <slug|id|name>", "Select an organization non-interactively").action(async (opts) => {
7204
7244
  try {
7205
- await loginCommand({ apiKey: opts.apiKey });
7245
+ await loginCommand({ apiKey: opts.apiKey, org: opts.org });
7206
7246
  process.exit(0);
7207
7247
  } catch (error) {
7208
7248
  console.error(