@mcp-use/cli 3.0.2-canary.5 → 3.0.2-canary.7
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/env.d.ts +3 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/index.cjs +188 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +187 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +26 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -503,7 +503,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
503
503
|
var source_default = chalk;
|
|
504
504
|
|
|
505
505
|
// src/index.ts
|
|
506
|
-
import { Command as
|
|
506
|
+
import { Command as Command6 } from "commander";
|
|
507
507
|
import "dotenv/config";
|
|
508
508
|
import { spawn } from "child_process";
|
|
509
509
|
import { readFileSync as readFileSync2 } from "fs";
|
|
@@ -1365,6 +1365,36 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
);
|
|
1367
1367
|
}
|
|
1368
|
+
// ── Env Variables ────────────────────────────────────────────────
|
|
1369
|
+
async listEnvVariables(serverId) {
|
|
1370
|
+
return this.request(
|
|
1371
|
+
`/servers/${encodeURIComponent(serverId)}/env-variables`
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
async createEnvVariable(serverId, body) {
|
|
1375
|
+
return this.request(
|
|
1376
|
+
`/servers/${encodeURIComponent(serverId)}/env-variables`,
|
|
1377
|
+
{
|
|
1378
|
+
method: "POST",
|
|
1379
|
+
body: JSON.stringify(body)
|
|
1380
|
+
}
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1383
|
+
async updateEnvVariable(serverId, varId, body) {
|
|
1384
|
+
return this.request(
|
|
1385
|
+
`/servers/${encodeURIComponent(serverId)}/env-variables/${encodeURIComponent(varId)}`,
|
|
1386
|
+
{
|
|
1387
|
+
method: "PATCH",
|
|
1388
|
+
body: JSON.stringify(body)
|
|
1389
|
+
}
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
async deleteEnvVariable(serverId, varId) {
|
|
1393
|
+
await this.request(
|
|
1394
|
+
`/servers/${encodeURIComponent(serverId)}/env-variables/${encodeURIComponent(varId)}`,
|
|
1395
|
+
{ method: "DELETE" }
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1368
1398
|
// ── Deployments ─────────────────────────────────────────────────
|
|
1369
1399
|
async createDeployment(input) {
|
|
1370
1400
|
return this.request("/deployments", {
|
|
@@ -4550,7 +4580,158 @@ function createDeploymentsCommand() {
|
|
|
4550
4580
|
}
|
|
4551
4581
|
|
|
4552
4582
|
// src/commands/servers.ts
|
|
4583
|
+
import { Command as Command4 } from "commander";
|
|
4584
|
+
|
|
4585
|
+
// src/commands/env.ts
|
|
4553
4586
|
import { Command as Command3 } from "commander";
|
|
4587
|
+
var ALL_ENVS = ["production", "preview", "development"];
|
|
4588
|
+
function parseEnvironments(raw) {
|
|
4589
|
+
const parts = raw.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
4590
|
+
const valid = [];
|
|
4591
|
+
for (const p of parts) {
|
|
4592
|
+
if (p === "production" || p === "preview" || p === "development") {
|
|
4593
|
+
valid.push(p);
|
|
4594
|
+
} else {
|
|
4595
|
+
console.error(
|
|
4596
|
+
source_default.red(
|
|
4597
|
+
`\u2717 Unknown environment "${p}". Valid values: production, preview, development`
|
|
4598
|
+
)
|
|
4599
|
+
);
|
|
4600
|
+
process.exit(1);
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
if (valid.length === 0) {
|
|
4604
|
+
console.error(source_default.red("\u2717 At least one environment must be specified."));
|
|
4605
|
+
process.exit(1);
|
|
4606
|
+
}
|
|
4607
|
+
return valid;
|
|
4608
|
+
}
|
|
4609
|
+
function envBadge(env2) {
|
|
4610
|
+
if (env2 === "production") return source_default.green("prod");
|
|
4611
|
+
if (env2 === "preview") return source_default.yellow("prev");
|
|
4612
|
+
return source_default.blue("dev");
|
|
4613
|
+
}
|
|
4614
|
+
function printEnvVar(v, showValue = false) {
|
|
4615
|
+
const envs = v.environments.map(envBadge).join(" ");
|
|
4616
|
+
const val = v.sensitive ? source_default.gray("<sensitive>") : showValue ? source_default.cyan(v.value) : source_default.gray("(hidden \u2014 use --show-values to reveal)");
|
|
4617
|
+
console.log(` ${source_default.white.bold(v.key.padEnd(32))} ${val}`);
|
|
4618
|
+
console.log(
|
|
4619
|
+
` ${source_default.gray("id:")} ${source_default.gray(v.id)} ${envs}${v.sensitive ? " " + source_default.yellow("\u{1F512} sensitive") : ""}`
|
|
4620
|
+
);
|
|
4621
|
+
}
|
|
4622
|
+
async function requireLogin() {
|
|
4623
|
+
if (!await isLoggedIn()) {
|
|
4624
|
+
console.log(source_default.red("\u2717 You are not logged in."));
|
|
4625
|
+
console.log(
|
|
4626
|
+
source_default.gray("Run " + source_default.white("npx mcp-use login") + " to get started.")
|
|
4627
|
+
);
|
|
4628
|
+
process.exit(1);
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
async function listEnvCommand(options) {
|
|
4632
|
+
await requireLogin();
|
|
4633
|
+
const api = await McpUseAPI.create();
|
|
4634
|
+
const vars = await api.listEnvVariables(options.server);
|
|
4635
|
+
if (vars.length === 0) {
|
|
4636
|
+
console.log(
|
|
4637
|
+
source_default.yellow("\nNo environment variables set for this server.\n")
|
|
4638
|
+
);
|
|
4639
|
+
return;
|
|
4640
|
+
}
|
|
4641
|
+
console.log(source_default.cyan.bold(`
|
|
4642
|
+
Environment Variables (${vars.length})
|
|
4643
|
+
`));
|
|
4644
|
+
for (const v of vars) {
|
|
4645
|
+
printEnvVar(v, options.showValues);
|
|
4646
|
+
console.log();
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4649
|
+
async function addEnvCommand(assignment, options) {
|
|
4650
|
+
await requireLogin();
|
|
4651
|
+
const eqIdx = assignment.indexOf("=");
|
|
4652
|
+
if (eqIdx === -1) {
|
|
4653
|
+
console.error(
|
|
4654
|
+
source_default.red(
|
|
4655
|
+
"\u2717 Expected KEY=VALUE format, e.g. mcp-use servers env add API_KEY=abc123"
|
|
4656
|
+
)
|
|
4657
|
+
);
|
|
4658
|
+
process.exit(1);
|
|
4659
|
+
}
|
|
4660
|
+
const key = assignment.substring(0, eqIdx).trim();
|
|
4661
|
+
const value = assignment.substring(eqIdx + 1);
|
|
4662
|
+
if (!key) {
|
|
4663
|
+
console.error(source_default.red("\u2717 Key must not be empty."));
|
|
4664
|
+
process.exit(1);
|
|
4665
|
+
}
|
|
4666
|
+
const environments = options.env ? parseEnvironments(options.env) : ALL_ENVS;
|
|
4667
|
+
const api = await McpUseAPI.create();
|
|
4668
|
+
const created = await api.createEnvVariable(options.server, {
|
|
4669
|
+
key,
|
|
4670
|
+
value,
|
|
4671
|
+
environments,
|
|
4672
|
+
sensitive: options.sensitive ?? false
|
|
4673
|
+
});
|
|
4674
|
+
console.log(
|
|
4675
|
+
source_default.green(`
|
|
4676
|
+
\u2713 Environment variable "${created.key}" added.
|
|
4677
|
+
`)
|
|
4678
|
+
);
|
|
4679
|
+
printEnvVar(created, true);
|
|
4680
|
+
console.log();
|
|
4681
|
+
}
|
|
4682
|
+
async function updateEnvCommand(varId, options) {
|
|
4683
|
+
await requireLogin();
|
|
4684
|
+
if (!options.value && !options.env && options.sensitive === void 0) {
|
|
4685
|
+
console.error(
|
|
4686
|
+
source_default.red(
|
|
4687
|
+
"\u2717 Nothing to update. Provide at least one of --value, --env, --sensitive."
|
|
4688
|
+
)
|
|
4689
|
+
);
|
|
4690
|
+
process.exit(1);
|
|
4691
|
+
}
|
|
4692
|
+
const body = {};
|
|
4693
|
+
if (options.value !== void 0) body.value = options.value;
|
|
4694
|
+
if (options.env) body.environments = parseEnvironments(options.env);
|
|
4695
|
+
if (options.sensitive !== void 0) body.sensitive = options.sensitive;
|
|
4696
|
+
const api = await McpUseAPI.create();
|
|
4697
|
+
const updated = await api.updateEnvVariable(options.server, varId, body);
|
|
4698
|
+
console.log(
|
|
4699
|
+
source_default.green(`
|
|
4700
|
+
\u2713 Environment variable "${updated.key}" updated.
|
|
4701
|
+
`)
|
|
4702
|
+
);
|
|
4703
|
+
printEnvVar(updated, !!options.value);
|
|
4704
|
+
console.log();
|
|
4705
|
+
}
|
|
4706
|
+
async function removeEnvCommand(varId, options) {
|
|
4707
|
+
await requireLogin();
|
|
4708
|
+
const api = await McpUseAPI.create();
|
|
4709
|
+
await api.deleteEnvVariable(options.server, varId);
|
|
4710
|
+
console.log(source_default.green(`
|
|
4711
|
+
\u2713 Environment variable ${varId} removed.
|
|
4712
|
+
`));
|
|
4713
|
+
}
|
|
4714
|
+
function createEnvCommand() {
|
|
4715
|
+
const envCommand = new Command3("env").description(
|
|
4716
|
+
"Manage environment variables for a server"
|
|
4717
|
+
);
|
|
4718
|
+
envCommand.command("list").alias("ls").description("List environment variables for a server").requiredOption("--server <id>", "Server UUID").option("--show-values", "Reveal non-sensitive values in output").action(listEnvCommand);
|
|
4719
|
+
envCommand.command("add").argument("<KEY=VALUE>", "Variable assignment, e.g. API_KEY=abc123").description("Add an environment variable to a server").requiredOption("--server <id>", "Server UUID").option(
|
|
4720
|
+
"--env <environments>",
|
|
4721
|
+
"Comma-separated environments: production,preview,development (default: all)"
|
|
4722
|
+
).option(
|
|
4723
|
+
"--sensitive",
|
|
4724
|
+
"Mark the variable as sensitive (value masked in UI)"
|
|
4725
|
+
).action(addEnvCommand);
|
|
4726
|
+
envCommand.command("update").argument("<var-id>", "Environment variable UUID").description("Update an existing environment variable").requiredOption("--server <id>", "Server UUID").option("--value <value>", "New value").option(
|
|
4727
|
+
"--env <environments>",
|
|
4728
|
+
"New environments (comma-separated: production,preview,development)"
|
|
4729
|
+
).option("--sensitive", "Mark as sensitive").option("--no-sensitive", "Unmark as sensitive").action(updateEnvCommand);
|
|
4730
|
+
envCommand.command("remove").alias("rm").argument("<var-id>", "Environment variable UUID").description("Remove an environment variable from a server").requiredOption("--server <id>", "Server UUID").action(removeEnvCommand);
|
|
4731
|
+
return envCommand;
|
|
4732
|
+
}
|
|
4733
|
+
|
|
4734
|
+
// src/commands/servers.ts
|
|
4554
4735
|
async function prompt3(question) {
|
|
4555
4736
|
const readline = await import("readline");
|
|
4556
4737
|
const rl = readline.createInterface({
|
|
@@ -4829,12 +5010,13 @@ async function deleteServerCommand(serverId, options) {
|
|
|
4829
5010
|
}
|
|
4830
5011
|
}
|
|
4831
5012
|
function createServersCommand() {
|
|
4832
|
-
const serversCommand = new
|
|
5013
|
+
const serversCommand = new Command4("servers").description(
|
|
4833
5014
|
"Manage cloud servers (Git-backed deploy targets)"
|
|
4834
5015
|
);
|
|
4835
5016
|
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 (1\u2013100, default 50)").option("--skip <n>", "Offset for pagination").option("--sort <field:asc|desc>", "Sort (e.g. updatedAt:desc)").action(listServersCommand);
|
|
4836
5017
|
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);
|
|
4837
5018
|
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);
|
|
5019
|
+
serversCommand.addCommand(createEnvCommand());
|
|
4838
5020
|
return serversCommand;
|
|
4839
5021
|
}
|
|
4840
5022
|
|
|
@@ -4958,7 +5140,7 @@ async function orgCurrentCommand() {
|
|
|
4958
5140
|
}
|
|
4959
5141
|
|
|
4960
5142
|
// src/commands/skills.ts
|
|
4961
|
-
import { Command as
|
|
5143
|
+
import { Command as Command5 } from "commander";
|
|
4962
5144
|
import { cpSync, existsSync as existsSync2, mkdtempSync, readdirSync, rmSync } from "fs";
|
|
4963
5145
|
import { tmpdir } from "os";
|
|
4964
5146
|
import { join as join2, resolve } from "path";
|
|
@@ -5028,7 +5210,7 @@ async function addSkillsToProject(projectPath) {
|
|
|
5028
5210
|
}
|
|
5029
5211
|
}
|
|
5030
5212
|
function createSkillsCommand() {
|
|
5031
|
-
const skills = new
|
|
5213
|
+
const skills = new Command5("skills").description(
|
|
5032
5214
|
"Manage mcp-use AI agent skills"
|
|
5033
5215
|
);
|
|
5034
5216
|
const installAction = async (options) => {
|
|
@@ -5204,7 +5386,7 @@ A new release of ${source_default.bold(PACKAGE_NAME)} is available: ${source_def
|
|
|
5204
5386
|
}
|
|
5205
5387
|
|
|
5206
5388
|
// src/index.ts
|
|
5207
|
-
var program = new
|
|
5389
|
+
var program = new Command6();
|
|
5208
5390
|
var packageContent = readFileSync2(
|
|
5209
5391
|
path7.join(__dirname, "../package.json"),
|
|
5210
5392
|
"utf-8"
|