@mcp-use/cli 3.3.2-canary.2 → 3.3.2-canary.4
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/commands/deployments.d.ts.map +1 -1
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/index.cjs +142 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +142 -42
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +15 -2
- package/dist/utils/api.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1209,6 +1209,39 @@ var ApiUnauthorizedError = class extends Error {
|
|
|
1209
1209
|
this.name = "ApiUnauthorizedError";
|
|
1210
1210
|
}
|
|
1211
1211
|
};
|
|
1212
|
+
function normalizePaginatedResponse(response, params) {
|
|
1213
|
+
if (Array.isArray(response)) {
|
|
1214
|
+
return {
|
|
1215
|
+
items: response,
|
|
1216
|
+
total: response.length,
|
|
1217
|
+
limit: params?.limit ?? response.length,
|
|
1218
|
+
skip: params?.skip ?? 0
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
return {
|
|
1222
|
+
items: response.items,
|
|
1223
|
+
total: response.total,
|
|
1224
|
+
limit: response.limit,
|
|
1225
|
+
skip: response.skip
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
function buildPaginationQuery(params) {
|
|
1229
|
+
const search = new URLSearchParams();
|
|
1230
|
+
if (params?.organizationId) {
|
|
1231
|
+
search.set("organizationId", params.organizationId);
|
|
1232
|
+
}
|
|
1233
|
+
if (params?.limit != null) {
|
|
1234
|
+
search.set("limit", String(params.limit));
|
|
1235
|
+
}
|
|
1236
|
+
if (params?.skip != null) {
|
|
1237
|
+
search.set("skip", String(params.skip));
|
|
1238
|
+
}
|
|
1239
|
+
if (params?.sort) {
|
|
1240
|
+
search.set("sort", params.sort);
|
|
1241
|
+
}
|
|
1242
|
+
const q = search.toString();
|
|
1243
|
+
return q ? `?${q}` : "";
|
|
1244
|
+
}
|
|
1212
1245
|
var McpUseAPI = class _McpUseAPI {
|
|
1213
1246
|
baseUrl;
|
|
1214
1247
|
apiKey;
|
|
@@ -1337,21 +1370,8 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1337
1370
|
});
|
|
1338
1371
|
}
|
|
1339
1372
|
async listServers(params) {
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
search.set("organizationId", params.organizationId);
|
|
1343
|
-
}
|
|
1344
|
-
if (params?.limit != null) {
|
|
1345
|
-
search.set("limit", String(params.limit));
|
|
1346
|
-
}
|
|
1347
|
-
if (params?.skip != null) {
|
|
1348
|
-
search.set("skip", String(params.skip));
|
|
1349
|
-
}
|
|
1350
|
-
if (params?.sort) {
|
|
1351
|
-
search.set("sort", params.sort);
|
|
1352
|
-
}
|
|
1353
|
-
const q = search.toString();
|
|
1354
|
-
return this.request(`/servers${q ? `?${q}` : ""}`);
|
|
1373
|
+
const response = await this.request(`/servers${buildPaginationQuery(params)}`);
|
|
1374
|
+
return normalizePaginatedResponse(response, params);
|
|
1355
1375
|
}
|
|
1356
1376
|
async getServer(idOrSlug) {
|
|
1357
1377
|
const path12 = encodeURIComponent(idOrSlug);
|
|
@@ -1405,8 +1425,9 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1405
1425
|
async getDeployment(deploymentId) {
|
|
1406
1426
|
return this.request(`/deployments/${deploymentId}`);
|
|
1407
1427
|
}
|
|
1408
|
-
async listDeployments() {
|
|
1409
|
-
|
|
1428
|
+
async listDeployments(params) {
|
|
1429
|
+
const response = await this.request(`/deployments${buildPaginationQuery(params)}`);
|
|
1430
|
+
return normalizePaginatedResponse(response, params);
|
|
1410
1431
|
}
|
|
1411
1432
|
async deleteDeployment(deploymentId) {
|
|
1412
1433
|
await this.request(`/deployments/${deploymentId}`, {
|
|
@@ -5848,6 +5869,7 @@ async function deployCommand(options) {
|
|
|
5848
5869
|
|
|
5849
5870
|
// src/commands/deployments.ts
|
|
5850
5871
|
import { Command as Command3 } from "commander";
|
|
5872
|
+
var DEFAULT_LIST_LIMIT = 30;
|
|
5851
5873
|
async function prompt2(question) {
|
|
5852
5874
|
const readline = await import("readline");
|
|
5853
5875
|
const rl = readline.createInterface({
|
|
@@ -5879,7 +5901,23 @@ function getStatusColor(status) {
|
|
|
5879
5901
|
function formatId(id) {
|
|
5880
5902
|
return id;
|
|
5881
5903
|
}
|
|
5882
|
-
|
|
5904
|
+
function formatPageHeader(label, count, total) {
|
|
5905
|
+
return count === total ? `${label} (${total})` : `${label} (${count} of ${total})`;
|
|
5906
|
+
}
|
|
5907
|
+
function printNextPageHint(command, page, extraArgs = []) {
|
|
5908
|
+
const nextSkip = page.skip + page.items.length;
|
|
5909
|
+
if (nextSkip >= page.total) return;
|
|
5910
|
+
const args = [
|
|
5911
|
+
command,
|
|
5912
|
+
"--limit",
|
|
5913
|
+
String(page.limit),
|
|
5914
|
+
"--skip",
|
|
5915
|
+
String(nextSkip),
|
|
5916
|
+
...extraArgs
|
|
5917
|
+
];
|
|
5918
|
+
console.log(source_default.gray(`Next page: ${args.join(" ")}`));
|
|
5919
|
+
}
|
|
5920
|
+
async function listDeploymentsCommand(options) {
|
|
5883
5921
|
try {
|
|
5884
5922
|
if (!await isLoggedIn()) {
|
|
5885
5923
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
@@ -5890,11 +5928,26 @@ async function listDeploymentsCommand() {
|
|
|
5890
5928
|
);
|
|
5891
5929
|
process.exit(1);
|
|
5892
5930
|
}
|
|
5931
|
+
const limit = options.limit ? parseInt(options.limit, 10) : DEFAULT_LIST_LIMIT;
|
|
5932
|
+
const skip = options.skip ? parseInt(options.skip, 10) : void 0;
|
|
5933
|
+
if (limit !== void 0 && (Number.isNaN(limit) || limit < 1)) {
|
|
5934
|
+
console.log(source_default.red("\u2717 Invalid --limit"));
|
|
5935
|
+
process.exit(1);
|
|
5936
|
+
}
|
|
5937
|
+
if (skip !== void 0 && (Number.isNaN(skip) || skip < 0)) {
|
|
5938
|
+
console.log(source_default.red("\u2717 Invalid --skip"));
|
|
5939
|
+
process.exit(1);
|
|
5940
|
+
}
|
|
5893
5941
|
const api = await McpUseAPI.create();
|
|
5894
|
-
const [
|
|
5895
|
-
api.listDeployments(
|
|
5942
|
+
const [page, authResult] = await Promise.all([
|
|
5943
|
+
api.listDeployments({
|
|
5944
|
+
limit,
|
|
5945
|
+
skip,
|
|
5946
|
+
sort: options.sort ?? "createdAt:desc"
|
|
5947
|
+
}),
|
|
5896
5948
|
api.testAuth()
|
|
5897
5949
|
]);
|
|
5950
|
+
const deployments = page.items;
|
|
5898
5951
|
const orgMap = new Map(authResult.orgs.map((o) => [o.id, o.name]));
|
|
5899
5952
|
const uniqueServerIds = [
|
|
5900
5953
|
...new Set(
|
|
@@ -5916,18 +5969,31 @@ async function listDeploymentsCommand() {
|
|
|
5916
5969
|
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
5917
5970
|
);
|
|
5918
5971
|
if (sortedDeployments.length === 0) {
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5972
|
+
if (page.total === 0) {
|
|
5973
|
+
console.log(source_default.yellow("No deployments found."));
|
|
5974
|
+
console.log(
|
|
5975
|
+
source_default.gray(
|
|
5976
|
+
"\nDeploy your first MCP server with " + source_default.white("mcp-use deploy")
|
|
5977
|
+
)
|
|
5978
|
+
);
|
|
5979
|
+
} else {
|
|
5980
|
+
console.log(
|
|
5981
|
+
source_default.yellow(`No deployments found at --skip ${page.skip}.`)
|
|
5982
|
+
);
|
|
5983
|
+
console.log(source_default.gray(`Total deployments: ${page.total}`));
|
|
5984
|
+
}
|
|
5925
5985
|
return;
|
|
5926
5986
|
}
|
|
5927
5987
|
console.log(
|
|
5928
|
-
source_default.cyan.bold(
|
|
5929
|
-
|
|
5930
|
-
|
|
5988
|
+
source_default.cyan.bold(
|
|
5989
|
+
`
|
|
5990
|
+
\u{1F4E6} ${formatPageHeader(
|
|
5991
|
+
"Deployments",
|
|
5992
|
+
sortedDeployments.length,
|
|
5993
|
+
page.total
|
|
5994
|
+
)}
|
|
5995
|
+
`
|
|
5996
|
+
)
|
|
5931
5997
|
);
|
|
5932
5998
|
console.log(
|
|
5933
5999
|
source_default.white.bold(
|
|
@@ -5948,6 +6014,9 @@ async function listDeploymentsCommand() {
|
|
|
5948
6014
|
`${source_default.gray(id)} ${name} ${source_default.magenta(org)} ${status} ${source_default.cyan(mcpUrl)} ${source_default.gray(created)}`
|
|
5949
6015
|
);
|
|
5950
6016
|
}
|
|
6017
|
+
const extraArgs = [];
|
|
6018
|
+
if (options.sort) extraArgs.push("--sort", options.sort);
|
|
6019
|
+
printNextPageHint("mcp-use deployments list", page, extraArgs);
|
|
5951
6020
|
console.log();
|
|
5952
6021
|
} catch (error) {
|
|
5953
6022
|
handleCommandError(error, "Failed to list deployments");
|
|
@@ -6262,7 +6331,7 @@ function createDeploymentsCommand() {
|
|
|
6262
6331
|
const deploymentsCommand = new Command3("deployments").description("Manage cloud deployments").showHelpAfterError(
|
|
6263
6332
|
"(Run `mcp-use deployments --help` to see available commands)"
|
|
6264
6333
|
);
|
|
6265
|
-
deploymentsCommand.command("list").alias("ls").description("List
|
|
6334
|
+
deploymentsCommand.command("list").alias("ls").description("List deployments").option("--limit <n>", "Page size (default 30)").option("--skip <n>", "Offset for pagination").option("--sort <field:asc|desc>", "Sort (e.g. createdAt:desc)").action(listDeploymentsCommand);
|
|
6266
6335
|
deploymentsCommand.command("get").argument("<deployment-id>", "Deployment ID").description("Get deployment details").action(getDeploymentCommand);
|
|
6267
6336
|
deploymentsCommand.command("restart").argument("<deployment-id>", "Deployment ID").option("-f, --follow", "Follow build logs").description(
|
|
6268
6337
|
"Restart a deployment (triggers a new deployment on the same server)"
|
|
@@ -6441,6 +6510,7 @@ function createEnvCommand() {
|
|
|
6441
6510
|
}
|
|
6442
6511
|
|
|
6443
6512
|
// src/commands/servers.ts
|
|
6513
|
+
var DEFAULT_LIST_LIMIT2 = 30;
|
|
6444
6514
|
async function prompt3(question) {
|
|
6445
6515
|
const readline = await import("readline");
|
|
6446
6516
|
const rl = readline.createInterface({
|
|
@@ -6488,6 +6558,22 @@ function getStatusColor2(status) {
|
|
|
6488
6558
|
if (s.includes("build") || s.includes("pend")) return source_default.yellow;
|
|
6489
6559
|
return source_default.gray;
|
|
6490
6560
|
}
|
|
6561
|
+
function formatPageHeader2(label, count, total) {
|
|
6562
|
+
return count === total ? `${label} (${total})` : `${label} (${count} of ${total})`;
|
|
6563
|
+
}
|
|
6564
|
+
function printNextPageHint2(command, page, extraArgs = []) {
|
|
6565
|
+
const nextSkip = page.skip + page.items.length;
|
|
6566
|
+
if (nextSkip >= page.total) return;
|
|
6567
|
+
const args = [
|
|
6568
|
+
command,
|
|
6569
|
+
"--limit",
|
|
6570
|
+
String(page.limit),
|
|
6571
|
+
"--skip",
|
|
6572
|
+
String(nextSkip),
|
|
6573
|
+
...extraArgs
|
|
6574
|
+
];
|
|
6575
|
+
console.log(source_default.gray(`Next page: ${args.join(" ")}`));
|
|
6576
|
+
}
|
|
6491
6577
|
async function listServersCommand(options) {
|
|
6492
6578
|
try {
|
|
6493
6579
|
if (!await isLoggedIn()) {
|
|
@@ -6502,7 +6588,7 @@ async function listServersCommand(options) {
|
|
|
6502
6588
|
const api = await McpUseAPI.create();
|
|
6503
6589
|
await applyOrgOption(api, options.org);
|
|
6504
6590
|
if (options.org) console.log();
|
|
6505
|
-
const limit = options.limit ? parseInt(options.limit, 10) :
|
|
6591
|
+
const limit = options.limit ? parseInt(options.limit, 10) : DEFAULT_LIST_LIMIT2;
|
|
6506
6592
|
const skip = options.skip ? parseInt(options.skip, 10) : void 0;
|
|
6507
6593
|
if (limit !== void 0 && (Number.isNaN(limit) || limit < 1)) {
|
|
6508
6594
|
console.log(source_default.red("\u2717 Invalid --limit"));
|
|
@@ -6512,23 +6598,33 @@ async function listServersCommand(options) {
|
|
|
6512
6598
|
console.log(source_default.red("\u2717 Invalid --skip"));
|
|
6513
6599
|
process.exit(1);
|
|
6514
6600
|
}
|
|
6515
|
-
const
|
|
6601
|
+
const page = await api.listServers({
|
|
6516
6602
|
limit,
|
|
6517
6603
|
skip,
|
|
6518
6604
|
sort: options.sort
|
|
6519
6605
|
});
|
|
6606
|
+
const servers = page.items;
|
|
6520
6607
|
if (servers.length === 0) {
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6608
|
+
if (page.total === 0) {
|
|
6609
|
+
console.log(source_default.yellow("No servers found."));
|
|
6610
|
+
console.log(
|
|
6611
|
+
source_default.gray(
|
|
6612
|
+
"\nCreate one by deploying with " + source_default.white("mcp-use deploy")
|
|
6613
|
+
)
|
|
6614
|
+
);
|
|
6615
|
+
} else {
|
|
6616
|
+
console.log(source_default.yellow(`No servers found at --skip ${page.skip}.`));
|
|
6617
|
+
console.log(source_default.gray(`Total servers: ${page.total}`));
|
|
6618
|
+
}
|
|
6527
6619
|
return;
|
|
6528
6620
|
}
|
|
6529
|
-
console.log(
|
|
6530
|
-
|
|
6531
|
-
`
|
|
6621
|
+
console.log(
|
|
6622
|
+
source_default.cyan.bold(
|
|
6623
|
+
`
|
|
6624
|
+
\u{1F5A5} ${formatPageHeader2("Servers", servers.length, page.total)}
|
|
6625
|
+
`
|
|
6626
|
+
)
|
|
6627
|
+
);
|
|
6532
6628
|
console.log(
|
|
6533
6629
|
source_default.white.bold(
|
|
6534
6630
|
`${"ID".padEnd(38)} ${"NAME".padEnd(22)} ${"STATUS".padEnd(14)} ${"REPO".padEnd(32)} ${"MCP URL".padEnd(52)}`
|
|
@@ -6546,6 +6642,10 @@ async function listServersCommand(options) {
|
|
|
6546
6642
|
`${source_default.gray(id)} ${name} ${status} ${source_default.gray(repo)} ${source_default.cyan(mcp)}`
|
|
6547
6643
|
);
|
|
6548
6644
|
}
|
|
6645
|
+
const extraArgs = [];
|
|
6646
|
+
if (options.sort) extraArgs.push("--sort", options.sort);
|
|
6647
|
+
if (options.org) extraArgs.push("--org", options.org);
|
|
6648
|
+
printNextPageHint2("mcp-use servers list", page, extraArgs);
|
|
6549
6649
|
console.log();
|
|
6550
6650
|
} catch (error) {
|
|
6551
6651
|
handleCommandError(error, "Failed to list servers");
|
|
@@ -6708,7 +6808,7 @@ function createServersCommand() {
|
|
|
6708
6808
|
const serversCommand = new Command5("servers").description("Manage cloud servers (Git-backed deploy targets)").showHelpAfterError(
|
|
6709
6809
|
"(Run `mcp-use servers --help` to see available commands)"
|
|
6710
6810
|
);
|
|
6711
|
-
serversCommand.command("list").alias("ls").description("List servers for the current organization").option("--org <slug-or-id>", "Target organization (slug, id, or name)").option("--limit <n>", "Page size (
|
|
6811
|
+
serversCommand.command("list").alias("ls").description("List servers for the current organization").option("--org <slug-or-id>", "Target organization (slug, id, or name)").option("--limit <n>", "Page size (default 30)").option("--skip <n>", "Offset for pagination").option("--sort <field:asc|desc>", "Sort (e.g. updatedAt:desc)").action(listServersCommand);
|
|
6712
6812
|
serversCommand.command("get").argument("<id-or-slug>", "Server UUID or slug").option("--org <slug-or-id>", "Resolve org context before fetch").description("Show server details and recent deployments").action(getServerCommand);
|
|
6713
6813
|
serversCommand.command("delete").alias("rm").argument("<server-id>", "Server UUID (or slug if API accepts it)").option("-y, --yes", "Skip confirmation prompt").option("--org <slug-or-id>", "Target organization").description("Delete a server and all its deployments").action(deleteServerCommand);
|
|
6714
6814
|
serversCommand.addCommand(createEnvCommand());
|