@mcp-use/cli 3.4.2 → 3.5.0-canary.0
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 +76 -0
- package/dist/commands/deploy.d.ts +10 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deployments.d.ts.map +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/index.cjs +195 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +195 -26
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +24 -1
- package/dist/utils/api.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -147,6 +147,9 @@ mcp-use logout
|
|
|
147
147
|
- `--name <name>` - Custom deployment name
|
|
148
148
|
- `--port <port>` - Server port (default: 3000)
|
|
149
149
|
- `--runtime <runtime>` - Runtime environment: "node" or "python"
|
|
150
|
+
- `--branch <name>` - Deploy branch (default: current git branch). Also scopes `--env` / `--env-file` sync to that branch's preview env.
|
|
151
|
+
- `--env <key=value...>` - Set environment variable **values** (repeatable)
|
|
152
|
+
- `--env-file <path>` - Load environment variable values from a `.env` file
|
|
150
153
|
- `--open` - Open deployment in browser after success
|
|
151
154
|
|
|
152
155
|
**Example:**
|
|
@@ -160,10 +163,83 @@ mcp-use deploy --no-github
|
|
|
160
163
|
|
|
161
164
|
# Deploy with custom options
|
|
162
165
|
mcp-use deploy --name my-server --port 8000 --open
|
|
166
|
+
|
|
167
|
+
# Deploy a branch and scope env values to its preview env
|
|
168
|
+
mcp-use deploy --branch feature-x --env API_KEY=abc123
|
|
163
169
|
```
|
|
164
170
|
|
|
165
171
|
---
|
|
166
172
|
|
|
173
|
+
## ☁️ Managing cloud servers
|
|
174
|
+
|
|
175
|
+
After a server exists you can update its configuration and environment
|
|
176
|
+
variables without redeploying from scratch.
|
|
177
|
+
|
|
178
|
+
### `servers update`
|
|
179
|
+
|
|
180
|
+
Mutate server-level config in place (no delete/recreate, so the URL slug and
|
|
181
|
+
env vars are preserved):
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Change the production branch (which branch triggers production deploys)
|
|
185
|
+
mcp-use servers update my-server --branch main
|
|
186
|
+
|
|
187
|
+
# Override build / start commands or rename the server
|
|
188
|
+
mcp-use servers update my-server --build-command "npm run build" --start-command "npm start"
|
|
189
|
+
mcp-use servers update my-server --name "My Server" --description "…"
|
|
190
|
+
|
|
191
|
+
# Clear a build/start override (pass an empty string)
|
|
192
|
+
mcp-use servers update my-server --build-command "" --start-command ""
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Flags: `--branch` (production branch), `--name`, `--description`,
|
|
196
|
+
`--build-command`, `--start-command`, `--org`. At least one is required.
|
|
197
|
+
Pass an empty string to `--build-command` or `--start-command` to remove the
|
|
198
|
+
stored override.
|
|
199
|
+
|
|
200
|
+
### `servers env` — environment variables
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# List (production scope), or scope to a branch's preview env
|
|
204
|
+
mcp-use servers env list --server <id>
|
|
205
|
+
mcp-use servers env list --server <id> --branch feature-x
|
|
206
|
+
|
|
207
|
+
# Add a variable. --env selects which environment TAGS it applies to;
|
|
208
|
+
# --branch pins it to a branch's preview env (omit for production).
|
|
209
|
+
mcp-use servers env add API_KEY=abc123 --server <id> --env production,preview
|
|
210
|
+
mcp-use servers env add API_KEY=abc123 --server <id> --branch feature-x
|
|
211
|
+
|
|
212
|
+
# Update / remove by KEY (resolved within the branch scope) or by UUID
|
|
213
|
+
mcp-use servers env update API_KEY --server <id> --value newval --branch feature-x
|
|
214
|
+
mcp-use servers env rm API_KEY --server <id> --branch feature-x
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### `deployments restart`
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Restart reusing the deployment's branch, or target a different branch
|
|
221
|
+
mcp-use deployments restart <deployment-id>
|
|
222
|
+
mcp-use deployments restart <deployment-id> --branch feature-x
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Environment naming
|
|
226
|
+
|
|
227
|
+
The platform models environments as `production`, `preview`, and
|
|
228
|
+
`development` (the `--env` tag) plus an optional **branch** pin (`--branch`).
|
|
229
|
+
There is no literal `test` environment. Common aliases map as:
|
|
230
|
+
|
|
231
|
+
| You might say | Use |
|
|
232
|
+
| --- | --- |
|
|
233
|
+
| `prod` | `production` |
|
|
234
|
+
| `dev` | `development` |
|
|
235
|
+
| `staging` / per-branch | a `--branch <name>` preview (optionally tagged `preview`) |
|
|
236
|
+
|
|
237
|
+
Note the two different `--env` meanings: on `deploy` it sets variable
|
|
238
|
+
**values** (`KEY=VALUE`), while on `servers env` it selects the environment
|
|
239
|
+
**tags** a variable applies to (`production,preview,development`).
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
167
243
|
## 💡 Examples
|
|
168
244
|
|
|
169
245
|
### Basic Development Workflow
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EnvEnvironment } from "../utils/api.js";
|
|
1
2
|
import { McpUseAPI } from "../utils/api.js";
|
|
2
3
|
/**
|
|
3
4
|
* Upsert env vars onto an existing server via the env-variables API.
|
|
@@ -8,7 +9,10 @@ import { McpUseAPI } from "../utils/api.js";
|
|
|
8
9
|
* dropped. Existing keys are updated; new keys are created. Keys not in the
|
|
9
10
|
* supplied set are left alone — clearing requires `mcp-use servers env rm`.
|
|
10
11
|
*/
|
|
11
|
-
export declare function syncEnvVarsToServer(api: McpUseAPI, serverId: string, envVars: Record<string, string
|
|
12
|
+
export declare function syncEnvVarsToServer(api: McpUseAPI, serverId: string, envVars: Record<string, string>, opts?: {
|
|
13
|
+
branch?: string;
|
|
14
|
+
environments?: EnvEnvironment[];
|
|
15
|
+
}): Promise<{
|
|
12
16
|
created: number;
|
|
13
17
|
updated: number;
|
|
14
18
|
}>;
|
|
@@ -26,6 +30,11 @@ interface DeployOptions {
|
|
|
26
30
|
region?: "US" | "EU" | "APAC";
|
|
27
31
|
buildCommand?: string;
|
|
28
32
|
startCommand?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Deploy branch. Defaults to the current git branch (managed flow: "main").
|
|
35
|
+
* Also scopes env-var sync to that branch's preview env.
|
|
36
|
+
*/
|
|
37
|
+
branch?: string;
|
|
29
38
|
/**
|
|
30
39
|
* Upload local source without connecting the user's GitHub. Uses the
|
|
31
40
|
* platform-managed org and a tarball instead of pushing to a user repo.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAgGzB;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAA;CAAE,GAC1D,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAiC/C;AA0CD,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;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA8nBD,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA2xBzE"}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"deployments.d.ts","sourceRoot":"","sources":["../../src/commands/deployments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAklBpC,wBAAgB,wBAAwB,IAAI,OAAO,CAgElD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmRpC,wBAAgB,gBAAgB,IAAI,OAAO,CAmE1C"}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../src/commands/servers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsbpC,wBAAgB,oBAAoB,IAAI,OAAO,CAyD9C"}
|
package/dist/index.cjs
CHANGED
|
@@ -1471,6 +1471,15 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1471
1471
|
const path11 = encodeURIComponent(idOrSlug);
|
|
1472
1472
|
return this.request(`/servers/${path11}`);
|
|
1473
1473
|
}
|
|
1474
|
+
async updateServer(idOrSlug, body) {
|
|
1475
|
+
return this.request(
|
|
1476
|
+
`/servers/${encodeURIComponent(idOrSlug)}`,
|
|
1477
|
+
{
|
|
1478
|
+
method: "PATCH",
|
|
1479
|
+
body: JSON.stringify(body)
|
|
1480
|
+
}
|
|
1481
|
+
);
|
|
1482
|
+
}
|
|
1474
1483
|
async deleteServer(id) {
|
|
1475
1484
|
await this.request(
|
|
1476
1485
|
`/servers/${encodeURIComponent(id)}`,
|
|
@@ -1480,9 +1489,10 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1480
1489
|
);
|
|
1481
1490
|
}
|
|
1482
1491
|
// ── Env Variables ────────────────────────────────────────────────
|
|
1483
|
-
async listEnvVariables(serverId) {
|
|
1492
|
+
async listEnvVariables(serverId, opts) {
|
|
1493
|
+
const q = opts?.branch ? `?branch=${encodeURIComponent(opts.branch)}` : "";
|
|
1484
1494
|
return this.request(
|
|
1485
|
-
`/servers/${encodeURIComponent(serverId)}/env-variables`
|
|
1495
|
+
`/servers/${encodeURIComponent(serverId)}/env-variables${q}`
|
|
1486
1496
|
);
|
|
1487
1497
|
}
|
|
1488
1498
|
async createEnvVariable(serverId, body) {
|
|
@@ -4897,10 +4907,13 @@ function parseEnvVar(envStr) {
|
|
|
4897
4907
|
}
|
|
4898
4908
|
return { key, value };
|
|
4899
4909
|
}
|
|
4900
|
-
async function syncEnvVarsToServer(api, serverId, envVars) {
|
|
4910
|
+
async function syncEnvVarsToServer(api, serverId, envVars, opts) {
|
|
4901
4911
|
const entries = Object.entries(envVars);
|
|
4902
4912
|
if (entries.length === 0) return { created: 0, updated: 0 };
|
|
4903
|
-
const existing = await api.listEnvVariables(
|
|
4913
|
+
const existing = await api.listEnvVariables(
|
|
4914
|
+
serverId,
|
|
4915
|
+
opts?.branch ? { branch: opts.branch } : void 0
|
|
4916
|
+
);
|
|
4904
4917
|
const byKey = new Map(existing.map((v) => [v.key, v]));
|
|
4905
4918
|
const results = await Promise.all(
|
|
4906
4919
|
entries.map(async ([key, value]) => {
|
|
@@ -4909,7 +4922,12 @@ async function syncEnvVarsToServer(api, serverId, envVars) {
|
|
|
4909
4922
|
await api.updateEnvVariable(serverId, found.id, { value });
|
|
4910
4923
|
return "updated";
|
|
4911
4924
|
}
|
|
4912
|
-
await api.createEnvVariable(serverId, {
|
|
4925
|
+
await api.createEnvVariable(serverId, {
|
|
4926
|
+
key,
|
|
4927
|
+
value,
|
|
4928
|
+
...opts?.branch ? { branch: opts.branch } : {},
|
|
4929
|
+
...opts?.environments ? { environments: opts.environments } : {}
|
|
4930
|
+
});
|
|
4913
4931
|
return "created";
|
|
4914
4932
|
})
|
|
4915
4933
|
);
|
|
@@ -5357,7 +5375,7 @@ async function deployViaManagedUpload(api, options, ctx) {
|
|
|
5357
5375
|
console.log();
|
|
5358
5376
|
}
|
|
5359
5377
|
const envVars = await buildEnvVars(options);
|
|
5360
|
-
const branch = "main";
|
|
5378
|
+
const branch = options.branch || "main";
|
|
5361
5379
|
const projectName = options.name || await getProjectName(projectDir);
|
|
5362
5380
|
console.log(source_default.gray("Packaging project source..."));
|
|
5363
5381
|
const tarball = await packProjectTarball(projectDir);
|
|
@@ -5388,7 +5406,12 @@ async function deployViaManagedUpload(api, options, ctx) {
|
|
|
5388
5406
|
if (serverId) {
|
|
5389
5407
|
console.log(source_default.gray("Uploading source and redeploying..."));
|
|
5390
5408
|
if (Object.keys(envVars).length > 0) {
|
|
5391
|
-
await syncEnvVarsToServer(
|
|
5409
|
+
await syncEnvVarsToServer(
|
|
5410
|
+
api,
|
|
5411
|
+
serverId,
|
|
5412
|
+
envVars,
|
|
5413
|
+
options.branch ? { branch: options.branch } : void 0
|
|
5414
|
+
);
|
|
5392
5415
|
}
|
|
5393
5416
|
await api.pushSourceToServer(serverId, {
|
|
5394
5417
|
tarball,
|
|
@@ -5658,7 +5681,7 @@ async function deployCommand(options) {
|
|
|
5658
5681
|
}
|
|
5659
5682
|
let gitInfo = await getGitInfo(cwd);
|
|
5660
5683
|
let repoFullName;
|
|
5661
|
-
let branch = "main";
|
|
5684
|
+
let branch = options.branch || "main";
|
|
5662
5685
|
if (!gitInfo.isGitRepo || !gitInfo.remoteUrl) {
|
|
5663
5686
|
const projectName2 = options.name || await getProjectName(projectDir);
|
|
5664
5687
|
console.log(source_default.yellow("\u26A0\uFE0F No GitHub remote found.\n"));
|
|
@@ -5835,7 +5858,7 @@ async function deployCommand(options) {
|
|
|
5835
5858
|
console.log(source_default.green("\u2713 Code pushed to GitHub\n"));
|
|
5836
5859
|
gitInfo = await getGitInfo(cwd);
|
|
5837
5860
|
repoFullName = repoResult.fullName;
|
|
5838
|
-
branch = gitInfo.branch || "main";
|
|
5861
|
+
branch = options.branch || gitInfo.branch || "main";
|
|
5839
5862
|
} else if (!isGitHubUrl(gitInfo.remoteUrl)) {
|
|
5840
5863
|
console.log(source_default.red("\u2717 Remote is not a GitHub repository"));
|
|
5841
5864
|
console.log(source_default.yellow(` Current remote: ${gitInfo.remoteUrl}
|
|
@@ -5846,7 +5869,7 @@ async function deployCommand(options) {
|
|
|
5846
5869
|
process.exit(1);
|
|
5847
5870
|
} else {
|
|
5848
5871
|
repoFullName = `${gitInfo.owner}/${gitInfo.repo}`;
|
|
5849
|
-
branch = gitInfo.branch || "main";
|
|
5872
|
+
branch = options.branch || gitInfo.branch || "main";
|
|
5850
5873
|
const ownerLower = gitInfo.owner.toLowerCase();
|
|
5851
5874
|
const matchingInst = installations.find(
|
|
5852
5875
|
(i) => i.account_login.toLowerCase() === ownerLower
|
|
@@ -5994,7 +6017,12 @@ async function deployCommand(options) {
|
|
|
5994
6017
|
console.log(source_default.cyan(` URL: ${getMcpServerUrl(existingDep)}
|
|
5995
6018
|
`));
|
|
5996
6019
|
if (Object.keys(envVars).length > 0) {
|
|
5997
|
-
const synced = await syncEnvVarsToServer(
|
|
6020
|
+
const synced = await syncEnvVarsToServer(
|
|
6021
|
+
api,
|
|
6022
|
+
serverId,
|
|
6023
|
+
envVars,
|
|
6024
|
+
options.branch ? { branch: options.branch } : void 0
|
|
6025
|
+
);
|
|
5998
6026
|
console.log(
|
|
5999
6027
|
source_default.green(
|
|
6000
6028
|
`\u2713 Synced ${synced.created + synced.updated} environment variable(s)` + (synced.created || synced.updated ? source_default.gray(
|
|
@@ -6042,7 +6070,12 @@ async function deployCommand(options) {
|
|
|
6042
6070
|
let deploymentId;
|
|
6043
6071
|
if (serverId) {
|
|
6044
6072
|
if (Object.keys(envVars).length > 0) {
|
|
6045
|
-
const synced = await syncEnvVarsToServer(
|
|
6073
|
+
const synced = await syncEnvVarsToServer(
|
|
6074
|
+
api,
|
|
6075
|
+
serverId,
|
|
6076
|
+
envVars,
|
|
6077
|
+
options.branch ? { branch: options.branch } : void 0
|
|
6078
|
+
);
|
|
6046
6079
|
console.log(
|
|
6047
6080
|
source_default.green(
|
|
6048
6081
|
`\u2713 Synced ${synced.created + synced.updated} environment variable(s)` + (synced.created || synced.updated ? source_default.gray(
|
|
@@ -6384,8 +6417,10 @@ async function restartDeploymentCommand(deploymentId, options) {
|
|
|
6384
6417
|
\u{1F504} Restarting deployment: ${deployment.name}
|
|
6385
6418
|
`)
|
|
6386
6419
|
);
|
|
6420
|
+
const branch = options.branch ?? deployment.gitBranch ?? void 0;
|
|
6387
6421
|
const newDep = await api.createDeployment({
|
|
6388
6422
|
serverId: deployment.serverId,
|
|
6423
|
+
...branch ? { branch } : {},
|
|
6389
6424
|
trigger: "redeploy"
|
|
6390
6425
|
});
|
|
6391
6426
|
console.log(source_default.green("\u2713 Restart initiated: ") + source_default.gray(newDep.id));
|
|
@@ -6609,7 +6644,10 @@ function createDeploymentsCommand() {
|
|
|
6609
6644
|
);
|
|
6610
6645
|
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);
|
|
6611
6646
|
deploymentsCommand.command("get").argument("<deployment-id>", "Deployment ID").description("Get deployment details").action(getDeploymentCommand);
|
|
6612
|
-
deploymentsCommand.command("restart").argument("<deployment-id>", "Deployment ID").option("-f, --follow", "Follow build logs").
|
|
6647
|
+
deploymentsCommand.command("restart").argument("<deployment-id>", "Deployment ID").option("-f, --follow", "Follow build logs").option(
|
|
6648
|
+
"--branch <name>",
|
|
6649
|
+
"Target branch for the redeploy (default: the deployment's branch)"
|
|
6650
|
+
).description(
|
|
6613
6651
|
"Restart a deployment (triggers a new deployment on the same server)"
|
|
6614
6652
|
).action(restartDeploymentCommand);
|
|
6615
6653
|
deploymentsCommand.command("delete").alias("rm").argument("<deployment-id>", "Deployment ID").option("-y, --yes", "Skip confirmation prompt").description("Delete a deployment").action(deleteDeploymentCommand);
|
|
@@ -6651,12 +6689,45 @@ function envBadge(env2) {
|
|
|
6651
6689
|
if (env2 === "preview") return source_default.yellow("prev");
|
|
6652
6690
|
return source_default.blue("dev");
|
|
6653
6691
|
}
|
|
6692
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6693
|
+
async function resolveVarId(api, server, keyOrId, branch) {
|
|
6694
|
+
if (UUID_RE.test(keyOrId)) return keyOrId;
|
|
6695
|
+
const vars = await api.listEnvVariables(
|
|
6696
|
+
server,
|
|
6697
|
+
branch ? { branch } : void 0
|
|
6698
|
+
);
|
|
6699
|
+
const matches = vars.filter((v) => v.key === keyOrId);
|
|
6700
|
+
const scope = branch ? `branch "${branch}"` : "production";
|
|
6701
|
+
if (matches.length === 0) {
|
|
6702
|
+
console.error(
|
|
6703
|
+
source_default.red(
|
|
6704
|
+
`\u2717 No environment variable with key "${keyOrId}" in ${scope} scope.`
|
|
6705
|
+
)
|
|
6706
|
+
);
|
|
6707
|
+
console.error(
|
|
6708
|
+
source_default.gray(
|
|
6709
|
+
branch ? "Check the key, or omit --branch to target production scope." : "Check the key, or pass --branch <name> if it lives on a branch."
|
|
6710
|
+
)
|
|
6711
|
+
);
|
|
6712
|
+
process.exit(1);
|
|
6713
|
+
}
|
|
6714
|
+
if (matches.length > 1) {
|
|
6715
|
+
console.error(
|
|
6716
|
+
source_default.red(
|
|
6717
|
+
`\u2717 Multiple variables match key "${keyOrId}" in ${scope} scope. Pass the variable id instead.`
|
|
6718
|
+
)
|
|
6719
|
+
);
|
|
6720
|
+
process.exit(1);
|
|
6721
|
+
}
|
|
6722
|
+
return matches[0].id;
|
|
6723
|
+
}
|
|
6654
6724
|
function printEnvVar(v, showValue = false) {
|
|
6655
6725
|
const envs = v.environments.map(envBadge).join(" ");
|
|
6656
6726
|
const val = v.sensitive ? source_default.gray("<sensitive>") : showValue ? source_default.cyan(v.value) : source_default.gray("(hidden \u2014 use --show-values to reveal)");
|
|
6727
|
+
const branch = v.branch ? " " + source_default.magenta(`branch:${v.branch}`) : "";
|
|
6657
6728
|
console.log(` ${source_default.white.bold(v.key.padEnd(32))} ${val}`);
|
|
6658
6729
|
console.log(
|
|
6659
|
-
` ${source_default.gray("id:")} ${source_default.gray(v.id)} ${envs}${v.sensitive ? " " + source_default.yellow("\u{1F512} sensitive") : ""}`
|
|
6730
|
+
` ${source_default.gray("id:")} ${source_default.gray(v.id)} ${envs}${branch}${v.sensitive ? " " + source_default.yellow("\u{1F512} sensitive") : ""}`
|
|
6660
6731
|
);
|
|
6661
6732
|
}
|
|
6662
6733
|
async function requireLogin() {
|
|
@@ -6672,16 +6743,26 @@ async function listEnvCommand(options) {
|
|
|
6672
6743
|
try {
|
|
6673
6744
|
await requireLogin();
|
|
6674
6745
|
const api = await McpUseAPI.create();
|
|
6675
|
-
const vars = await api.listEnvVariables(
|
|
6746
|
+
const vars = await api.listEnvVariables(
|
|
6747
|
+
options.server,
|
|
6748
|
+
options.branch ? { branch: options.branch } : void 0
|
|
6749
|
+
);
|
|
6750
|
+
const scope = options.branch ? `branch "${options.branch}"` : "production";
|
|
6676
6751
|
if (vars.length === 0) {
|
|
6677
6752
|
console.log(
|
|
6678
|
-
source_default.yellow(
|
|
6753
|
+
source_default.yellow(
|
|
6754
|
+
`
|
|
6755
|
+
No environment variables set for this server (${scope} scope).
|
|
6756
|
+
`
|
|
6757
|
+
)
|
|
6679
6758
|
);
|
|
6680
6759
|
return;
|
|
6681
6760
|
}
|
|
6682
|
-
console.log(
|
|
6683
|
-
|
|
6684
|
-
|
|
6761
|
+
console.log(
|
|
6762
|
+
source_default.cyan.bold(`
|
|
6763
|
+
Environment Variables \u2014 ${scope} (${vars.length})
|
|
6764
|
+
`)
|
|
6765
|
+
);
|
|
6685
6766
|
for (const v of vars) {
|
|
6686
6767
|
printEnvVar(v, options.showValues);
|
|
6687
6768
|
console.log();
|
|
@@ -6714,6 +6795,7 @@ async function addEnvCommand(assignment, options) {
|
|
|
6714
6795
|
key,
|
|
6715
6796
|
value,
|
|
6716
6797
|
environments,
|
|
6798
|
+
...options.branch ? { branch: options.branch } : {},
|
|
6717
6799
|
sensitive: options.sensitive ?? false
|
|
6718
6800
|
});
|
|
6719
6801
|
console.log(
|
|
@@ -6727,7 +6809,7 @@ async function addEnvCommand(assignment, options) {
|
|
|
6727
6809
|
handleCommandError(error, "Failed to add environment variable");
|
|
6728
6810
|
}
|
|
6729
6811
|
}
|
|
6730
|
-
async function updateEnvCommand(
|
|
6812
|
+
async function updateEnvCommand(keyOrId, options) {
|
|
6731
6813
|
try {
|
|
6732
6814
|
await requireLogin();
|
|
6733
6815
|
if (!options.value && !options.env && options.sensitive === void 0) {
|
|
@@ -6743,6 +6825,12 @@ async function updateEnvCommand(varId, options) {
|
|
|
6743
6825
|
if (options.env) body.environments = parseEnvironments(options.env);
|
|
6744
6826
|
if (options.sensitive !== void 0) body.sensitive = options.sensitive;
|
|
6745
6827
|
const api = await McpUseAPI.create();
|
|
6828
|
+
const varId = await resolveVarId(
|
|
6829
|
+
api,
|
|
6830
|
+
options.server,
|
|
6831
|
+
keyOrId,
|
|
6832
|
+
options.branch
|
|
6833
|
+
);
|
|
6746
6834
|
const updated = await api.updateEnvVariable(options.server, varId, body);
|
|
6747
6835
|
console.log(
|
|
6748
6836
|
source_default.green(`
|
|
@@ -6755,13 +6843,19 @@ async function updateEnvCommand(varId, options) {
|
|
|
6755
6843
|
handleCommandError(error, "Failed to update environment variable");
|
|
6756
6844
|
}
|
|
6757
6845
|
}
|
|
6758
|
-
async function removeEnvCommand(
|
|
6846
|
+
async function removeEnvCommand(keyOrId, options) {
|
|
6759
6847
|
try {
|
|
6760
6848
|
await requireLogin();
|
|
6761
6849
|
const api = await McpUseAPI.create();
|
|
6850
|
+
const varId = await resolveVarId(
|
|
6851
|
+
api,
|
|
6852
|
+
options.server,
|
|
6853
|
+
keyOrId,
|
|
6854
|
+
options.branch
|
|
6855
|
+
);
|
|
6762
6856
|
await api.deleteEnvVariable(options.server, varId);
|
|
6763
6857
|
console.log(source_default.green(`
|
|
6764
|
-
\u2713 Environment variable ${
|
|
6858
|
+
\u2713 Environment variable ${keyOrId} removed.
|
|
6765
6859
|
`));
|
|
6766
6860
|
} catch (error) {
|
|
6767
6861
|
handleCommandError(error, "Failed to remove environment variable");
|
|
@@ -6769,19 +6863,31 @@ async function removeEnvCommand(varId, options) {
|
|
|
6769
6863
|
}
|
|
6770
6864
|
function createEnvCommand() {
|
|
6771
6865
|
const envCommand = new import_commander4.Command("env").description("Manage environment variables for a server").showHelpAfterError("(Run `mcp-use env --help` to see available commands)");
|
|
6772
|
-
envCommand.command("list").alias("ls").description("List environment variables for a server").requiredOption("--server <id>", "Server UUID").option(
|
|
6866
|
+
envCommand.command("list").alias("ls").description("List environment variables for a server").requiredOption("--server <id>", "Server UUID").option(
|
|
6867
|
+
"--branch <name>",
|
|
6868
|
+
"Scope to a branch's preview env (omit for production)"
|
|
6869
|
+
).option("--show-values", "Reveal non-sensitive values in output").action(listEnvCommand);
|
|
6773
6870
|
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(
|
|
6774
6871
|
"--env <environments>",
|
|
6775
6872
|
"Comma-separated environments: production,preview,development (default: all)"
|
|
6873
|
+
).option(
|
|
6874
|
+
"--branch <name>",
|
|
6875
|
+
"Pin the variable to a branch's preview env (omit for production)"
|
|
6776
6876
|
).option(
|
|
6777
6877
|
"--sensitive",
|
|
6778
6878
|
"Mark the variable as sensitive (value masked in UI)"
|
|
6779
6879
|
).action(addEnvCommand);
|
|
6780
|
-
envCommand.command("update").argument("<
|
|
6880
|
+
envCommand.command("update").argument("<key-or-id>", "Environment variable KEY or UUID").description("Update an existing environment variable").requiredOption("--server <id>", "Server UUID").option("--value <value>", "New value").option(
|
|
6781
6881
|
"--env <environments>",
|
|
6782
6882
|
"New environments (comma-separated: production,preview,development)"
|
|
6883
|
+
).option(
|
|
6884
|
+
"--branch <name>",
|
|
6885
|
+
"Branch scope used to resolve a KEY (omit for production)"
|
|
6783
6886
|
).option("--sensitive", "Mark as sensitive").option("--no-sensitive", "Unmark as sensitive").action(updateEnvCommand);
|
|
6784
|
-
envCommand.command("remove").alias("rm").argument("<
|
|
6887
|
+
envCommand.command("remove").alias("rm").argument("<key-or-id>", "Environment variable KEY or UUID").description("Remove an environment variable from a server").requiredOption("--server <id>", "Server UUID").option(
|
|
6888
|
+
"--branch <name>",
|
|
6889
|
+
"Branch scope used to resolve a KEY (omit for production)"
|
|
6890
|
+
).action(removeEnvCommand);
|
|
6785
6891
|
return envCommand;
|
|
6786
6892
|
}
|
|
6787
6893
|
|
|
@@ -7029,6 +7135,55 @@ async function getServerCommand(idOrSlug, options) {
|
|
|
7029
7135
|
handleCommandError(error, "Failed to get server");
|
|
7030
7136
|
}
|
|
7031
7137
|
}
|
|
7138
|
+
async function updateServerCommand(idOrSlug, options) {
|
|
7139
|
+
try {
|
|
7140
|
+
if (!await isLoggedIn()) {
|
|
7141
|
+
console.log(source_default.red("\u2717 You are not logged in."));
|
|
7142
|
+
console.log(
|
|
7143
|
+
source_default.gray(
|
|
7144
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
7145
|
+
)
|
|
7146
|
+
);
|
|
7147
|
+
process.exit(1);
|
|
7148
|
+
}
|
|
7149
|
+
const body = {};
|
|
7150
|
+
if (options.name !== void 0) body.name = options.name;
|
|
7151
|
+
if (options.description !== void 0)
|
|
7152
|
+
body.description = options.description;
|
|
7153
|
+
if (options.branch !== void 0) body.productionBranch = options.branch;
|
|
7154
|
+
const config = {};
|
|
7155
|
+
if (options.buildCommand !== void 0) {
|
|
7156
|
+
config.buildCommand = options.buildCommand === "" ? null : options.buildCommand;
|
|
7157
|
+
}
|
|
7158
|
+
if (options.startCommand !== void 0) {
|
|
7159
|
+
config.startCommand = options.startCommand === "" ? null : options.startCommand;
|
|
7160
|
+
}
|
|
7161
|
+
if (Object.keys(config).length > 0) body.config = config;
|
|
7162
|
+
if (Object.keys(body).length === 0) {
|
|
7163
|
+
console.error(
|
|
7164
|
+
source_default.red(
|
|
7165
|
+
"\u2717 Nothing to update. Provide at least one of: --branch, --name, --build-command, --start-command, --description."
|
|
7166
|
+
)
|
|
7167
|
+
);
|
|
7168
|
+
process.exit(1);
|
|
7169
|
+
}
|
|
7170
|
+
const api = await McpUseAPI.create();
|
|
7171
|
+
await applyOrgOption(api, options.org);
|
|
7172
|
+
if (options.org) console.log();
|
|
7173
|
+
const server = await api.updateServer(idOrSlug, body);
|
|
7174
|
+
const label = server.name || server.slug || server.id;
|
|
7175
|
+
console.log(source_default.green.bold(`
|
|
7176
|
+
\u2713 Server updated: ${label}`));
|
|
7177
|
+
if (server.connectedRepository) {
|
|
7178
|
+
console.log(
|
|
7179
|
+
source_default.gray(" Prod branch: ") + source_default.cyan(server.connectedRepository.productionBranch)
|
|
7180
|
+
);
|
|
7181
|
+
}
|
|
7182
|
+
console.log();
|
|
7183
|
+
} catch (error) {
|
|
7184
|
+
handleCommandError(error, "Failed to update server");
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
7032
7187
|
async function deleteServerCommand(serverId, options) {
|
|
7033
7188
|
try {
|
|
7034
7189
|
if (!await isLoggedIn()) {
|
|
@@ -7088,6 +7243,16 @@ function createServersCommand() {
|
|
|
7088
7243
|
);
|
|
7089
7244
|
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);
|
|
7090
7245
|
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);
|
|
7246
|
+
serversCommand.command("update").argument("<id-or-slug>", "Server UUID or slug").description("Update server configuration (branch, name, commands, \u2026)").option(
|
|
7247
|
+
"--branch <name>",
|
|
7248
|
+
"New production branch \u2014 controls which branch triggers production deploys"
|
|
7249
|
+
).option("--name <name>", "Rename the server").option(
|
|
7250
|
+
"--build-command <cmd>",
|
|
7251
|
+
"Override the build command (pass an empty string to clear)"
|
|
7252
|
+
).option(
|
|
7253
|
+
"--start-command <cmd>",
|
|
7254
|
+
"Override the start command (pass an empty string to clear)"
|
|
7255
|
+
).option("--description <text>", "Update the server description").option("--org <slug-or-id>", "Target organization").action(updateServerCommand);
|
|
7091
7256
|
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);
|
|
7092
7257
|
serversCommand.addCommand(createEnvCommand());
|
|
7093
7258
|
return serversCommand;
|
|
@@ -9692,8 +9857,11 @@ program.command("deploy").description("Deploy MCP server from GitHub to Manufact
|
|
|
9692
9857
|
"Force creation of new deployment instead of reusing linked deployment"
|
|
9693
9858
|
).option(
|
|
9694
9859
|
"--env <key=value...>",
|
|
9695
|
-
"Environment
|
|
9860
|
+
"Environment variable values as KEY=VALUE (repeatable). Note: this sets values, unlike `servers env --env` which selects environment tags."
|
|
9696
9861
|
).option("--env-file <path>", "Path to .env file with environment variables").option(
|
|
9862
|
+
"--branch <name>",
|
|
9863
|
+
"Deploy branch (default: current git branch). Also scopes --env/--env-file sync to that branch's preview env."
|
|
9864
|
+
).option(
|
|
9697
9865
|
"--root-dir <path>",
|
|
9698
9866
|
"Root directory within repo to deploy from (for monorepos)"
|
|
9699
9867
|
).option(
|
|
@@ -9717,6 +9885,7 @@ program.command("deploy").description("Deploy MCP server from GitHub to Manufact
|
|
|
9717
9885
|
new: options.new,
|
|
9718
9886
|
env: options.env,
|
|
9719
9887
|
envFile: options.envFile,
|
|
9888
|
+
branch: options.branch,
|
|
9720
9889
|
rootDir: options.rootDir,
|
|
9721
9890
|
org: options.org,
|
|
9722
9891
|
yes: options.yes,
|