@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 +3 -0
- package/dist/commands/auth.d.ts +6 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deployments.d.ts.map +1 -1
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/index.cjs +63 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -23
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1569,6 +1569,14 @@ async function pollForDeviceToken(authBaseUrl, deviceCode, intervalSeconds) {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
throw new Error("Login timed out. Please try again.");
|
|
1571
1571
|
}
|
|
1572
|
+
function resolveOrgFromOption(orgs, identifier) {
|
|
1573
|
+
const needle = identifier.trim();
|
|
1574
|
+
if (!needle) return null;
|
|
1575
|
+
const lower = needle.toLowerCase();
|
|
1576
|
+
return orgs.find(
|
|
1577
|
+
(o) => o.slug === needle || o.id === needle || o.name.toLowerCase() === lower
|
|
1578
|
+
) ?? null;
|
|
1579
|
+
}
|
|
1572
1580
|
async function promptOrgSelection(orgs, defaultOrgId) {
|
|
1573
1581
|
if (orgs.length === 0) return null;
|
|
1574
1582
|
if (orgs.length === 1) {
|
|
@@ -1615,8 +1623,8 @@ async function loginCommand(options) {
|
|
|
1615
1623
|
console.log(source_default.green.bold("\u2713 API key saved."));
|
|
1616
1624
|
try {
|
|
1617
1625
|
const api2 = await McpUseAPI.create();
|
|
1618
|
-
const
|
|
1619
|
-
console.log(source_default.gray(` Authenticated as ${
|
|
1626
|
+
const authInfo2 = await api2.testAuth();
|
|
1627
|
+
console.log(source_default.gray(` Authenticated as ${authInfo2.email}`));
|
|
1620
1628
|
} catch {
|
|
1621
1629
|
console.log(
|
|
1622
1630
|
source_default.gray(
|
|
@@ -1668,9 +1676,19 @@ async function loginCommand(options) {
|
|
|
1668
1676
|
const keyResp = await api.createApiKeyWithAccessToken(accessToken, "CLI");
|
|
1669
1677
|
await writeConfig({ apiKey: keyResp.key });
|
|
1670
1678
|
console.log(source_default.green.bold("\n\u2713 Successfully logged in!"));
|
|
1679
|
+
let authInfo = null;
|
|
1671
1680
|
try {
|
|
1672
1681
|
const freshApi = await McpUseAPI.create();
|
|
1673
|
-
|
|
1682
|
+
authInfo = await freshApi.testAuth();
|
|
1683
|
+
} catch {
|
|
1684
|
+
console.log(
|
|
1685
|
+
source_default.gray(
|
|
1686
|
+
`
|
|
1687
|
+
Your API key has been saved to ${source_default.white("~/.mcp-use/config.json")}`
|
|
1688
|
+
)
|
|
1689
|
+
);
|
|
1690
|
+
}
|
|
1691
|
+
if (authInfo) {
|
|
1674
1692
|
console.log(source_default.cyan.bold("\nCurrent user:\n"));
|
|
1675
1693
|
console.log(source_default.white(" Email: ") + source_default.cyan(authInfo.email));
|
|
1676
1694
|
console.log(source_default.white(" User ID: ") + source_default.gray(authInfo.user_id));
|
|
@@ -1682,8 +1700,19 @@ async function loginCommand(options) {
|
|
|
1682
1700
|
const orgs = authInfo.orgs ?? [];
|
|
1683
1701
|
if (orgs.length > 0) {
|
|
1684
1702
|
let selectedOrg = null;
|
|
1685
|
-
if (
|
|
1703
|
+
if (options?.org) {
|
|
1704
|
+
selectedOrg = resolveOrgFromOption(orgs, options.org);
|
|
1705
|
+
if (!selectedOrg) {
|
|
1706
|
+
throw new Error(
|
|
1707
|
+
`Organization "${options.org}" not found. Run 'npx mcp-use org list' after logging in to see available organizations.`
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1710
|
+
} else if (orgs.length === 1) {
|
|
1686
1711
|
selectedOrg = orgs[0];
|
|
1712
|
+
} else if (!process.stdin.isTTY) {
|
|
1713
|
+
throw new Error(
|
|
1714
|
+
"Multiple organizations available and no TTY for interactive selection. Re-run with --org <slug|id|name> to pick one non-interactively."
|
|
1715
|
+
);
|
|
1687
1716
|
} else {
|
|
1688
1717
|
selectedOrg = await promptOrgSelection(orgs, authInfo.default_org_id);
|
|
1689
1718
|
}
|
|
@@ -1701,13 +1730,6 @@ async function loginCommand(options) {
|
|
|
1701
1730
|
);
|
|
1702
1731
|
}
|
|
1703
1732
|
}
|
|
1704
|
-
} catch {
|
|
1705
|
-
console.log(
|
|
1706
|
-
source_default.gray(
|
|
1707
|
-
`
|
|
1708
|
-
Your API key has been saved to ${source_default.white("~/.mcp-use/config.json")}`
|
|
1709
|
-
)
|
|
1710
|
-
);
|
|
1711
1733
|
}
|
|
1712
1734
|
console.log(
|
|
1713
1735
|
source_default.gray(
|
|
@@ -3555,9 +3577,7 @@ async function deployCommand(options) {
|
|
|
3555
3577
|
let resolvedOrgId;
|
|
3556
3578
|
if (options.org) {
|
|
3557
3579
|
const authInfo = await api.testAuth();
|
|
3558
|
-
const match = (authInfo.orgs ?? [])
|
|
3559
|
-
(o) => o.slug === options.org || o.id === options.org || o.name.toLowerCase() === options.org.toLowerCase()
|
|
3560
|
-
);
|
|
3580
|
+
const match = resolveOrgFromOption(authInfo.orgs ?? [], options.org);
|
|
3561
3581
|
if (match) {
|
|
3562
3582
|
api.setOrgId(match.id);
|
|
3563
3583
|
resolvedOrgId = match.id;
|
|
@@ -4190,7 +4210,27 @@ async function listDeploymentsCommand() {
|
|
|
4190
4210
|
process.exit(1);
|
|
4191
4211
|
}
|
|
4192
4212
|
const api = await McpUseAPI.create();
|
|
4193
|
-
const deployments = await
|
|
4213
|
+
const [deployments, authResult] = await Promise.all([
|
|
4214
|
+
api.listDeployments(),
|
|
4215
|
+
api.testAuth()
|
|
4216
|
+
]);
|
|
4217
|
+
const orgMap = new Map(authResult.orgs.map((o) => [o.id, o.name]));
|
|
4218
|
+
const uniqueServerIds = [
|
|
4219
|
+
...new Set(
|
|
4220
|
+
deployments.map((d) => d.serverId).filter((id) => id != null)
|
|
4221
|
+
)
|
|
4222
|
+
];
|
|
4223
|
+
const serverResults = await Promise.allSettled(
|
|
4224
|
+
uniqueServerIds.map((id) => api.getServer(id))
|
|
4225
|
+
);
|
|
4226
|
+
const serverOrgMap = /* @__PURE__ */ new Map();
|
|
4227
|
+
for (let i = 0; i < uniqueServerIds.length; i++) {
|
|
4228
|
+
const result = serverResults[i];
|
|
4229
|
+
if (result.status === "fulfilled") {
|
|
4230
|
+
const orgName = orgMap.get(result.value.organizationId) ?? result.value.organizationId.substring(0, 19);
|
|
4231
|
+
serverOrgMap.set(uniqueServerIds[i], orgName);
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4194
4234
|
const sortedDeployments = [...deployments].sort(
|
|
4195
4235
|
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
4196
4236
|
);
|
|
@@ -4210,19 +4250,21 @@ async function listDeploymentsCommand() {
|
|
|
4210
4250
|
);
|
|
4211
4251
|
console.log(
|
|
4212
4252
|
source_default.white.bold(
|
|
4213
|
-
`${"ID".padEnd(40)} ${"NAME".padEnd(25)} ${"STATUS".padEnd(12)} ${"MCP URL".padEnd(45)} ${"CREATED"}`
|
|
4253
|
+
`${"ID".padEnd(40)} ${"NAME".padEnd(25)} ${"ORG".padEnd(20)} ${"STATUS".padEnd(12)} ${"MCP URL".padEnd(45)} ${"CREATED"}`
|
|
4214
4254
|
)
|
|
4215
4255
|
);
|
|
4216
|
-
console.log(source_default.gray("\u2500".repeat(
|
|
4256
|
+
console.log(source_default.gray("\u2500".repeat(155)));
|
|
4217
4257
|
for (const deployment of sortedDeployments) {
|
|
4218
4258
|
const id = formatId(deployment.id).padEnd(40);
|
|
4219
4259
|
const name = deployment.name.substring(0, 24).padEnd(25);
|
|
4260
|
+
const orgName = deployment.serverId ? serverOrgMap.get(deployment.serverId) ?? "-" : "-";
|
|
4261
|
+
const org = orgName.substring(0, 19).padEnd(20);
|
|
4220
4262
|
const statusColor = getStatusColor(deployment.status);
|
|
4221
4263
|
const status = statusColor(deployment.status.padEnd(12));
|
|
4222
4264
|
const mcpUrl = (deployment.mcpUrl || "-").substring(0, 44).padEnd(45);
|
|
4223
4265
|
const created = formatRelativeTime(deployment.createdAt);
|
|
4224
4266
|
console.log(
|
|
4225
|
-
`${source_default.gray(id)} ${name} ${status} ${source_default.cyan(mcpUrl)} ${source_default.gray(created)}`
|
|
4267
|
+
`${source_default.gray(id)} ${name} ${source_default.magenta(org)} ${status} ${source_default.cyan(mcpUrl)} ${source_default.gray(created)}`
|
|
4226
4268
|
);
|
|
4227
4269
|
}
|
|
4228
4270
|
console.log();
|
|
@@ -4759,9 +4801,7 @@ function pickStr(obj, key) {
|
|
|
4759
4801
|
async function applyOrgOption(api, org) {
|
|
4760
4802
|
if (!org) return;
|
|
4761
4803
|
const authInfo = await api.testAuth();
|
|
4762
|
-
const match = (authInfo.orgs ?? [])
|
|
4763
|
-
(o) => o.slug === org || o.id === org || o.name.toLowerCase() === org.toLowerCase()
|
|
4764
|
-
);
|
|
4804
|
+
const match = resolveOrgFromOption(authInfo.orgs ?? [], org);
|
|
4765
4805
|
if (!match) {
|
|
4766
4806
|
console.error(
|
|
4767
4807
|
source_default.red(
|
|
@@ -7180,9 +7220,9 @@ Looked for:
|
|
|
7180
7220
|
program.command("login").description("Login to mcp-use cloud").option(
|
|
7181
7221
|
"--api-key <key>",
|
|
7182
7222
|
"Login with an API key directly (non-interactive, for CI/CD)"
|
|
7183
|
-
).action(async (opts) => {
|
|
7223
|
+
).option("--org <slug|id|name>", "Select an organization non-interactively").action(async (opts) => {
|
|
7184
7224
|
try {
|
|
7185
|
-
await loginCommand({ apiKey: opts.apiKey });
|
|
7225
|
+
await loginCommand({ apiKey: opts.apiKey, org: opts.org });
|
|
7186
7226
|
process.exit(0);
|
|
7187
7227
|
} catch (error) {
|
|
7188
7228
|
console.error(
|