@mcp-use/cli 2.9.1 → 2.10.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/dist/commands/auth.d.ts +3 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/deploy.d.ts +0 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deployments.d.ts.map +1 -1
- package/dist/index.cjs +264 -338
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +260 -334
- package/dist/index.js.map +1 -1
- package/dist/utils/git.d.ts +5 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -525,7 +525,7 @@ var source_default = chalk;
|
|
|
525
525
|
// src/index.ts
|
|
526
526
|
var import_commander3 = require("commander");
|
|
527
527
|
var import_config5 = require("dotenv/config");
|
|
528
|
-
var
|
|
528
|
+
var import_node_child_process9 = require("child_process");
|
|
529
529
|
var import_node_fs8 = require("fs");
|
|
530
530
|
var import_promises5 = require("fs/promises");
|
|
531
531
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
@@ -1686,14 +1686,16 @@ async function startCallbackServer(port) {
|
|
|
1686
1686
|
server.on("error", reject);
|
|
1687
1687
|
});
|
|
1688
1688
|
}
|
|
1689
|
-
async function loginCommand() {
|
|
1689
|
+
async function loginCommand(options) {
|
|
1690
1690
|
try {
|
|
1691
1691
|
if (await isLoggedIn()) {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1692
|
+
if (!options?.silent) {
|
|
1693
|
+
console.log(
|
|
1694
|
+
source_default.yellow(
|
|
1695
|
+
"\u26A0\uFE0F You are already logged in. Run 'npx mcp-use logout' first if you want to login with a different account."
|
|
1696
|
+
)
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1697
1699
|
return;
|
|
1698
1700
|
}
|
|
1699
1701
|
console.log(source_default.cyan.bold("\u{1F510} Logging in to mcp-use cloud...\n"));
|
|
@@ -1733,24 +1735,37 @@ async function loginCommand() {
|
|
|
1733
1735
|
apiKey: apiKeyResponse.api_key
|
|
1734
1736
|
});
|
|
1735
1737
|
console.log(source_default.green.bold("\n\u2713 Successfully logged in!"));
|
|
1738
|
+
try {
|
|
1739
|
+
const api2 = await McpUseAPI.create();
|
|
1740
|
+
const authInfo = await api2.testAuth();
|
|
1741
|
+
console.log(source_default.cyan.bold("\n\u{1F464} Current user:\n"));
|
|
1742
|
+
console.log(source_default.white("Email: ") + source_default.cyan(authInfo.email));
|
|
1743
|
+
console.log(source_default.white("User ID: ") + source_default.gray(authInfo.user_id));
|
|
1744
|
+
const apiKey = await getApiKey();
|
|
1745
|
+
if (apiKey) {
|
|
1746
|
+
const masked = apiKey.substring(0, 6) + "...";
|
|
1747
|
+
console.log(source_default.white("API Key: ") + source_default.gray(masked));
|
|
1748
|
+
}
|
|
1749
|
+
} catch (error) {
|
|
1750
|
+
console.log(
|
|
1751
|
+
source_default.gray(
|
|
1752
|
+
`
|
|
1753
|
+
Your API key has been saved to ${source_default.white("~/.mcp-use/config.json")}`
|
|
1754
|
+
)
|
|
1755
|
+
);
|
|
1756
|
+
}
|
|
1736
1757
|
console.log(
|
|
1737
1758
|
source_default.gray(
|
|
1738
|
-
|
|
1739
|
-
Your API key has been saved to ${source_default.white("~/.mcp-use/config.json")}`
|
|
1759
|
+
"\nYou can now deploy your MCP servers with " + source_default.white("npx mcp-use deploy")
|
|
1740
1760
|
)
|
|
1741
1761
|
);
|
|
1742
1762
|
console.log(
|
|
1743
|
-
source_default.gray(
|
|
1744
|
-
"You can now deploy your MCP servers with " + source_default.white("mcp-use deploy")
|
|
1745
|
-
)
|
|
1763
|
+
source_default.gray("To logout later, run " + source_default.white("npx mcp-use logout"))
|
|
1746
1764
|
);
|
|
1747
|
-
process.exit(0);
|
|
1748
1765
|
} catch (error) {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
source_default.red(error instanceof Error ? error.message : "Unknown error")
|
|
1766
|
+
throw new Error(
|
|
1767
|
+
`Login failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1752
1768
|
);
|
|
1753
|
-
process.exit(1);
|
|
1754
1769
|
}
|
|
1755
1770
|
}
|
|
1756
1771
|
async function logoutCommand() {
|
|
@@ -1780,7 +1795,9 @@ async function whoamiCommand() {
|
|
|
1780
1795
|
if (!await isLoggedIn()) {
|
|
1781
1796
|
console.log(source_default.yellow("\u26A0\uFE0F You are not logged in."));
|
|
1782
1797
|
console.log(
|
|
1783
|
-
source_default.gray(
|
|
1798
|
+
source_default.gray(
|
|
1799
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
1800
|
+
)
|
|
1784
1801
|
);
|
|
1785
1802
|
return;
|
|
1786
1803
|
}
|
|
@@ -2829,11 +2846,8 @@ function createClientCommand() {
|
|
|
2829
2846
|
}
|
|
2830
2847
|
|
|
2831
2848
|
// src/commands/deploy.ts
|
|
2832
|
-
var import_node_child_process9 = require("child_process");
|
|
2833
2849
|
var import_node_fs7 = require("fs");
|
|
2834
|
-
var import_node_os5 = __toESM(require("os"), 1);
|
|
2835
2850
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
2836
|
-
var import_node_util8 = require("util");
|
|
2837
2851
|
|
|
2838
2852
|
// src/utils/git.ts
|
|
2839
2853
|
var import_node_child_process8 = require("child_process");
|
|
@@ -2875,6 +2889,10 @@ async function getCommitSha(cwd = process.cwd()) {
|
|
|
2875
2889
|
async function getCommitMessage(cwd = process.cwd()) {
|
|
2876
2890
|
return gitCommand("git log -1 --pretty=%B", cwd);
|
|
2877
2891
|
}
|
|
2892
|
+
async function hasUncommittedChanges(cwd = process.cwd()) {
|
|
2893
|
+
const result = await gitCommand("git status --porcelain", cwd);
|
|
2894
|
+
return result !== null && result.length > 0;
|
|
2895
|
+
}
|
|
2878
2896
|
async function getGitInfo(cwd = process.cwd()) {
|
|
2879
2897
|
const isRepo = await isGitRepo(cwd);
|
|
2880
2898
|
if (!isRepo) {
|
|
@@ -2884,6 +2902,7 @@ async function getGitInfo(cwd = process.cwd()) {
|
|
|
2884
2902
|
const branch = await getCurrentBranch(cwd);
|
|
2885
2903
|
const commitSha = await getCommitSha(cwd);
|
|
2886
2904
|
const commitMessage = await getCommitMessage(cwd);
|
|
2905
|
+
const uncommittedChanges = await hasUncommittedChanges(cwd);
|
|
2887
2906
|
let owner;
|
|
2888
2907
|
let repo;
|
|
2889
2908
|
if (remoteUrl) {
|
|
@@ -2900,7 +2919,8 @@ async function getGitInfo(cwd = process.cwd()) {
|
|
|
2900
2919
|
repo,
|
|
2901
2920
|
branch: branch || void 0,
|
|
2902
2921
|
commitSha: commitSha || void 0,
|
|
2903
|
-
commitMessage: commitMessage || void 0
|
|
2922
|
+
commitMessage: commitMessage || void 0,
|
|
2923
|
+
hasUncommittedChanges: uncommittedChanges
|
|
2904
2924
|
};
|
|
2905
2925
|
}
|
|
2906
2926
|
function isGitHubUrl(url) {
|
|
@@ -2963,7 +2983,6 @@ ${MCP_USE_DIR}
|
|
|
2963
2983
|
}
|
|
2964
2984
|
|
|
2965
2985
|
// src/commands/deploy.ts
|
|
2966
|
-
var execAsync2 = (0, import_node_util8.promisify)(import_node_child_process9.exec);
|
|
2967
2986
|
async function parseEnvFile(filePath) {
|
|
2968
2987
|
try {
|
|
2969
2988
|
const content = await import_node_fs7.promises.readFile(filePath, "utf-8");
|
|
@@ -3167,45 +3186,6 @@ async function prompt(question, defaultValue = "n") {
|
|
|
3167
3186
|
});
|
|
3168
3187
|
});
|
|
3169
3188
|
}
|
|
3170
|
-
async function createTarball(cwd) {
|
|
3171
|
-
const tmpDir = import_node_os5.default.tmpdir();
|
|
3172
|
-
const tarballPath = import_node_path5.default.join(tmpDir, `mcp-deploy-${Date.now()}.tar.gz`);
|
|
3173
|
-
const excludePatterns = [
|
|
3174
|
-
"node_modules",
|
|
3175
|
-
".git",
|
|
3176
|
-
"dist",
|
|
3177
|
-
"build",
|
|
3178
|
-
".next",
|
|
3179
|
-
".venv",
|
|
3180
|
-
"__pycache__",
|
|
3181
|
-
"*.pyc",
|
|
3182
|
-
".DS_Store",
|
|
3183
|
-
"._*",
|
|
3184
|
-
// macOS resource fork files
|
|
3185
|
-
".mcp-use",
|
|
3186
|
-
// Build artifacts directory
|
|
3187
|
-
".env",
|
|
3188
|
-
".env.local",
|
|
3189
|
-
"*.log"
|
|
3190
|
-
];
|
|
3191
|
-
const excludeFlags = excludePatterns.map((pattern) => `--exclude=${pattern}`).join(" ");
|
|
3192
|
-
const command = `tar ${excludeFlags} -czf "${tarballPath}" -C "${cwd}" . 2>&1 || true`;
|
|
3193
|
-
try {
|
|
3194
|
-
await execAsync2(command);
|
|
3195
|
-
return tarballPath;
|
|
3196
|
-
} catch (error) {
|
|
3197
|
-
throw new Error(
|
|
3198
|
-
`Failed to create tarball: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
3199
|
-
);
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
function formatFileSize(bytes) {
|
|
3203
|
-
if (bytes === 0) return "0 B";
|
|
3204
|
-
const k = 1024;
|
|
3205
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
3206
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
3207
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
3208
|
-
}
|
|
3209
3189
|
async function displayDeploymentProgress(api, deployment) {
|
|
3210
3190
|
const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
3211
3191
|
let frameIndex = 0;
|
|
@@ -3358,10 +3338,36 @@ async function deployCommand(options) {
|
|
|
3358
3338
|
const cwd = process.cwd();
|
|
3359
3339
|
if (!await isLoggedIn()) {
|
|
3360
3340
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3361
|
-
|
|
3362
|
-
source_default.
|
|
3341
|
+
const shouldLogin = await prompt(
|
|
3342
|
+
source_default.white("Would you like to login now? (Y/n): "),
|
|
3343
|
+
"y"
|
|
3363
3344
|
);
|
|
3364
|
-
|
|
3345
|
+
if (shouldLogin) {
|
|
3346
|
+
try {
|
|
3347
|
+
await loginCommand({ silent: false });
|
|
3348
|
+
if (!await isLoggedIn()) {
|
|
3349
|
+
console.log(
|
|
3350
|
+
source_default.red("\u2717 Login verification failed. Please try again.")
|
|
3351
|
+
);
|
|
3352
|
+
process.exit(1);
|
|
3353
|
+
}
|
|
3354
|
+
console.log(source_default.gray("\nContinuing with deployment...\n"));
|
|
3355
|
+
} catch (error) {
|
|
3356
|
+
console.error(
|
|
3357
|
+
source_default.red.bold("\u2717 Login failed:"),
|
|
3358
|
+
source_default.red(error instanceof Error ? error.message : "Unknown error")
|
|
3359
|
+
);
|
|
3360
|
+
process.exit(1);
|
|
3361
|
+
}
|
|
3362
|
+
} else {
|
|
3363
|
+
console.log(
|
|
3364
|
+
source_default.gray(
|
|
3365
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3366
|
+
)
|
|
3367
|
+
);
|
|
3368
|
+
console.log(source_default.gray("Deployment cancelled."));
|
|
3369
|
+
process.exit(0);
|
|
3370
|
+
}
|
|
3365
3371
|
}
|
|
3366
3372
|
console.log(source_default.cyan.bold("\u{1F680} Deploying to mcp-use cloud...\n"));
|
|
3367
3373
|
const isMcp = await isMcpProject(cwd);
|
|
@@ -3381,282 +3387,177 @@ async function deployCommand(options) {
|
|
|
3381
3387
|
console.log();
|
|
3382
3388
|
}
|
|
3383
3389
|
const gitInfo = await getGitInfo(cwd);
|
|
3384
|
-
if (!
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
console.log(source_default.
|
|
3394
|
-
console.log(
|
|
3395
|
-
|
|
3396
|
-
);
|
|
3390
|
+
if (!gitInfo.isGitRepo) {
|
|
3391
|
+
console.log(source_default.red("\u2717 Not a git repository\n"));
|
|
3392
|
+
console.log(source_default.white("To deploy, initialize git and push to GitHub:"));
|
|
3393
|
+
console.log(source_default.gray(" 1. Initialize git:"));
|
|
3394
|
+
console.log(source_default.cyan(" git init\n"));
|
|
3395
|
+
console.log(source_default.gray(" 2. Create a GitHub repository at:"));
|
|
3396
|
+
console.log(source_default.cyan(" https://github.com/new\n"));
|
|
3397
|
+
console.log(source_default.gray(" 3. Add the remote and push:"));
|
|
3398
|
+
console.log(source_default.cyan(" git remote add origin <your-github-url>"));
|
|
3399
|
+
console.log(source_default.cyan(" git add ."));
|
|
3400
|
+
console.log(source_default.cyan(" git commit -m 'Initial commit'"));
|
|
3401
|
+
console.log(source_default.cyan(" git push -u origin main\n"));
|
|
3402
|
+
process.exit(1);
|
|
3403
|
+
}
|
|
3404
|
+
if (!gitInfo.remoteUrl) {
|
|
3405
|
+
console.log(source_default.red("\u2717 No git remote configured\n"));
|
|
3406
|
+
console.log(source_default.white("Add a GitHub remote:"));
|
|
3407
|
+
console.log(source_default.cyan(" git remote add origin <your-github-url>\n"));
|
|
3408
|
+
process.exit(1);
|
|
3409
|
+
}
|
|
3410
|
+
if (!isGitHubUrl(gitInfo.remoteUrl)) {
|
|
3411
|
+
console.log(source_default.red("\u2717 Remote is not a GitHub repository"));
|
|
3412
|
+
console.log(source_default.yellow(` Current remote: ${gitInfo.remoteUrl}
|
|
3413
|
+
`));
|
|
3414
|
+
console.log(source_default.white("Please add a GitHub remote to deploy."));
|
|
3415
|
+
process.exit(1);
|
|
3416
|
+
}
|
|
3417
|
+
if (!gitInfo.owner || !gitInfo.repo) {
|
|
3418
|
+
console.log(source_default.red("\u2717 Could not parse GitHub repository information"));
|
|
3419
|
+
process.exit(1);
|
|
3420
|
+
}
|
|
3421
|
+
if (gitInfo.hasUncommittedChanges) {
|
|
3422
|
+
console.log(source_default.yellow("\u26A0\uFE0F You have uncommitted changes\n"));
|
|
3423
|
+
console.log(source_default.white("Deployments use the code pushed to GitHub."));
|
|
3397
3424
|
console.log(
|
|
3398
|
-
source_default.gray(` Branch: `) + source_default.cyan(gitInfo.branch || "main")
|
|
3399
|
-
);
|
|
3400
|
-
if (gitInfo.commitSha) {
|
|
3401
|
-
console.log(
|
|
3402
|
-
source_default.gray(` Commit: `) + source_default.gray(gitInfo.commitSha.substring(0, 7))
|
|
3403
|
-
);
|
|
3404
|
-
}
|
|
3405
|
-
if (gitInfo.commitMessage) {
|
|
3406
|
-
console.log(
|
|
3407
|
-
source_default.gray(` Message: `) + source_default.gray(gitInfo.commitMessage.split("\n")[0])
|
|
3408
|
-
);
|
|
3409
|
-
}
|
|
3410
|
-
console.log();
|
|
3411
|
-
const shouldDeploy = await prompt(
|
|
3412
3425
|
source_default.white(
|
|
3413
|
-
|
|
3426
|
+
"Local changes will not be included until you commit and push.\n"
|
|
3414
3427
|
)
|
|
3415
3428
|
);
|
|
3416
|
-
|
|
3429
|
+
const shouldContinue = await prompt(
|
|
3430
|
+
source_default.white("Continue with deployment from GitHub? (y/n): ")
|
|
3431
|
+
);
|
|
3432
|
+
if (!shouldContinue) {
|
|
3417
3433
|
console.log(source_default.gray("Deployment cancelled."));
|
|
3418
3434
|
process.exit(0);
|
|
3419
3435
|
}
|
|
3420
|
-
const projectName = options.name || await getProjectName(cwd);
|
|
3421
|
-
const runtime = options.runtime || await detectRuntime(cwd);
|
|
3422
|
-
const port = options.port || 3e3;
|
|
3423
|
-
const buildCommand = await detectBuildCommand(cwd);
|
|
3424
|
-
const startCommand = await detectStartCommand(cwd);
|
|
3425
|
-
const envVars = await buildEnvVars(options);
|
|
3426
3436
|
console.log();
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
}
|
|
3437
|
-
if (envVars && Object.keys(envVars).length > 0) {
|
|
3438
|
-
console.log(
|
|
3439
|
-
source_default.gray(` Environment: `) + source_default.cyan(`${Object.keys(envVars).length} variable(s)`)
|
|
3440
|
-
);
|
|
3441
|
-
console.log(
|
|
3442
|
-
source_default.gray(` `) + source_default.gray(Object.keys(envVars).join(", "))
|
|
3443
|
-
);
|
|
3444
|
-
}
|
|
3445
|
-
console.log();
|
|
3446
|
-
const api = await McpUseAPI.create();
|
|
3447
|
-
const existingLink = !options.new ? await getProjectLink(cwd) : null;
|
|
3448
|
-
if (existingLink) {
|
|
3449
|
-
try {
|
|
3450
|
-
const existingDeployment = await api.getDeployment(
|
|
3451
|
-
existingLink.deploymentId
|
|
3452
|
-
);
|
|
3453
|
-
if (existingDeployment && existingDeployment.status !== "failed") {
|
|
3454
|
-
console.log(source_default.green(`\u2713 Found linked deployment`));
|
|
3455
|
-
console.log(
|
|
3456
|
-
source_default.gray(` Redeploying to maintain the same URL...`)
|
|
3457
|
-
);
|
|
3458
|
-
console.log(
|
|
3459
|
-
source_default.cyan(` URL: https://${existingDeployment.domain}/mcp
|
|
3460
|
-
`)
|
|
3461
|
-
);
|
|
3462
|
-
const deployment2 = await api.redeployDeployment(
|
|
3463
|
-
existingLink.deploymentId
|
|
3464
|
-
);
|
|
3465
|
-
await saveProjectLink(cwd, {
|
|
3466
|
-
...existingLink,
|
|
3467
|
-
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3468
|
-
});
|
|
3469
|
-
await displayDeploymentProgress(api, deployment2);
|
|
3470
|
-
if (options.open && deployment2.domain) {
|
|
3471
|
-
console.log();
|
|
3472
|
-
console.log(source_default.gray("Opening deployment in browser..."));
|
|
3473
|
-
await open_default(`https://${deployment2.domain}`);
|
|
3474
|
-
}
|
|
3475
|
-
return;
|
|
3476
|
-
}
|
|
3477
|
-
} catch (error) {
|
|
3478
|
-
console.log(
|
|
3479
|
-
source_default.yellow(`\u26A0\uFE0F Linked deployment not found, creating new one...`)
|
|
3480
|
-
);
|
|
3481
|
-
}
|
|
3482
|
-
}
|
|
3483
|
-
const deploymentRequest = {
|
|
3484
|
-
name: projectName,
|
|
3485
|
-
source: {
|
|
3486
|
-
type: "github",
|
|
3487
|
-
repo: `${gitInfo.owner}/${gitInfo.repo}`,
|
|
3488
|
-
branch: gitInfo.branch || "main",
|
|
3489
|
-
runtime,
|
|
3490
|
-
port,
|
|
3491
|
-
buildCommand,
|
|
3492
|
-
startCommand,
|
|
3493
|
-
env: Object.keys(envVars).length > 0 ? envVars : void 0
|
|
3494
|
-
},
|
|
3495
|
-
healthCheckPath: "/healthz"
|
|
3496
|
-
};
|
|
3497
|
-
console.log(source_default.gray("Creating deployment..."));
|
|
3498
|
-
const deployment = await api.createDeployment(deploymentRequest);
|
|
3437
|
+
}
|
|
3438
|
+
console.log(source_default.white("GitHub repository detected:"));
|
|
3439
|
+
console.log(
|
|
3440
|
+
source_default.gray(` Repository: `) + source_default.cyan(`${gitInfo.owner}/${gitInfo.repo}`)
|
|
3441
|
+
);
|
|
3442
|
+
console.log(
|
|
3443
|
+
source_default.gray(` Branch: `) + source_default.cyan(gitInfo.branch || "main")
|
|
3444
|
+
);
|
|
3445
|
+
if (gitInfo.commitSha) {
|
|
3499
3446
|
console.log(
|
|
3500
|
-
source_default.
|
|
3447
|
+
source_default.gray(` Commit: `) + source_default.gray(gitInfo.commitSha.substring(0, 7))
|
|
3501
3448
|
);
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
deploymentName: projectName,
|
|
3505
|
-
deploymentUrl: deployment.domain,
|
|
3506
|
-
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3507
|
-
});
|
|
3449
|
+
}
|
|
3450
|
+
if (gitInfo.commitMessage) {
|
|
3508
3451
|
console.log(
|
|
3509
|
-
source_default.gray(`
|
|
3452
|
+
source_default.gray(` Message: `) + source_default.gray(gitInfo.commitMessage.split("\n")[0])
|
|
3510
3453
|
);
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
console.log(
|
|
3541
|
-
|
|
3542
|
-
console.log(source_default.gray(` Port: `) + source_default.cyan(port));
|
|
3543
|
-
if (buildCommand) {
|
|
3544
|
-
console.log(source_default.gray(` Build command: `) + source_default.cyan(buildCommand));
|
|
3545
|
-
}
|
|
3546
|
-
if (startCommand) {
|
|
3547
|
-
console.log(source_default.gray(` Start command: `) + source_default.cyan(startCommand));
|
|
3548
|
-
}
|
|
3549
|
-
if (envVars && Object.keys(envVars).length > 0) {
|
|
3550
|
-
console.log(
|
|
3551
|
-
source_default.gray(` Environment: `) + source_default.cyan(`${Object.keys(envVars).length} variable(s)`)
|
|
3552
|
-
);
|
|
3553
|
-
console.log(
|
|
3554
|
-
source_default.gray(` `) + source_default.gray(Object.keys(envVars).join(", "))
|
|
3555
|
-
);
|
|
3556
|
-
}
|
|
3557
|
-
console.log();
|
|
3558
|
-
const shouldDeploy = await prompt(
|
|
3559
|
-
source_default.white("Deploy from local source? (y/n): "),
|
|
3560
|
-
"y"
|
|
3454
|
+
}
|
|
3455
|
+
console.log();
|
|
3456
|
+
const shouldDeploy = await prompt(
|
|
3457
|
+
source_default.white(
|
|
3458
|
+
`Deploy from GitHub repository ${gitInfo.owner}/${gitInfo.repo}? (y/n): `
|
|
3459
|
+
)
|
|
3460
|
+
);
|
|
3461
|
+
if (!shouldDeploy) {
|
|
3462
|
+
console.log(source_default.gray("Deployment cancelled."));
|
|
3463
|
+
process.exit(0);
|
|
3464
|
+
}
|
|
3465
|
+
const projectName = options.name || await getProjectName(cwd);
|
|
3466
|
+
const runtime = options.runtime || await detectRuntime(cwd);
|
|
3467
|
+
const port = options.port || 3e3;
|
|
3468
|
+
const buildCommand = await detectBuildCommand(cwd);
|
|
3469
|
+
const startCommand = await detectStartCommand(cwd);
|
|
3470
|
+
const envVars = await buildEnvVars(options);
|
|
3471
|
+
console.log();
|
|
3472
|
+
console.log(source_default.white("Deployment configuration:"));
|
|
3473
|
+
console.log(source_default.gray(` Name: `) + source_default.cyan(projectName));
|
|
3474
|
+
console.log(source_default.gray(` Runtime: `) + source_default.cyan(runtime));
|
|
3475
|
+
console.log(source_default.gray(` Port: `) + source_default.cyan(port));
|
|
3476
|
+
if (buildCommand) {
|
|
3477
|
+
console.log(source_default.gray(` Build command: `) + source_default.cyan(buildCommand));
|
|
3478
|
+
}
|
|
3479
|
+
if (startCommand) {
|
|
3480
|
+
console.log(source_default.gray(` Start command: `) + source_default.cyan(startCommand));
|
|
3481
|
+
}
|
|
3482
|
+
if (envVars && Object.keys(envVars).length > 0) {
|
|
3483
|
+
console.log(
|
|
3484
|
+
source_default.gray(` Environment: `) + source_default.cyan(`${Object.keys(envVars).length} variable(s)`)
|
|
3561
3485
|
);
|
|
3562
|
-
if (!shouldDeploy) {
|
|
3563
|
-
console.log(source_default.gray("Deployment cancelled."));
|
|
3564
|
-
process.exit(0);
|
|
3565
|
-
}
|
|
3566
|
-
console.log();
|
|
3567
|
-
console.log(source_default.gray("Packaging source code..."));
|
|
3568
|
-
const tarballPath = await createTarball(cwd);
|
|
3569
|
-
const stats = await import_node_fs7.promises.stat(tarballPath);
|
|
3570
3486
|
console.log(
|
|
3571
|
-
source_default.
|
|
3487
|
+
source_default.gray(` `) + source_default.gray(Object.keys(envVars).join(", "))
|
|
3572
3488
|
);
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3489
|
+
}
|
|
3490
|
+
console.log();
|
|
3491
|
+
const api = await McpUseAPI.create();
|
|
3492
|
+
const existingLink = !options.new ? await getProjectLink(cwd) : null;
|
|
3493
|
+
if (existingLink) {
|
|
3494
|
+
try {
|
|
3495
|
+
const existingDeployment = await api.getDeployment(
|
|
3496
|
+
existingLink.deploymentId
|
|
3579
3497
|
);
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
const
|
|
3498
|
+
if (existingDeployment && existingDeployment.status !== "failed") {
|
|
3499
|
+
console.log(source_default.green(`\u2713 Found linked deployment`));
|
|
3500
|
+
console.log(source_default.gray(` Redeploying to maintain the same URL...`));
|
|
3501
|
+
console.log(
|
|
3502
|
+
source_default.cyan(` URL: https://${existingDeployment.domain}/mcp
|
|
3503
|
+
`)
|
|
3504
|
+
);
|
|
3505
|
+
const deployment2 = await api.redeployDeployment(
|
|
3588
3506
|
existingLink.deploymentId
|
|
3589
3507
|
);
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
);
|
|
3599
|
-
const deployment2 = await api.redeployDeployment(
|
|
3600
|
-
existingLink.deploymentId,
|
|
3601
|
-
tarballPath
|
|
3602
|
-
);
|
|
3603
|
-
await import_node_fs7.promises.unlink(tarballPath);
|
|
3604
|
-
await saveProjectLink(cwd, {
|
|
3605
|
-
...existingLink,
|
|
3606
|
-
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3607
|
-
});
|
|
3608
|
-
await displayDeploymentProgress(api, deployment2);
|
|
3609
|
-
if (options.open && deployment2.domain) {
|
|
3610
|
-
console.log();
|
|
3611
|
-
console.log(source_default.gray("Opening deployment in browser..."));
|
|
3612
|
-
await open_default(`https://${deployment2.domain}`);
|
|
3613
|
-
}
|
|
3614
|
-
return;
|
|
3508
|
+
await saveProjectLink(cwd, {
|
|
3509
|
+
...existingLink,
|
|
3510
|
+
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3511
|
+
});
|
|
3512
|
+
await displayDeploymentProgress(api, deployment2);
|
|
3513
|
+
if (options.open && deployment2.domain) {
|
|
3514
|
+
console.log();
|
|
3515
|
+
console.log(source_default.gray("Opening deployment in browser..."));
|
|
3516
|
+
await open_default(`https://${deployment2.domain}`);
|
|
3615
3517
|
}
|
|
3616
|
-
|
|
3617
|
-
console.log(
|
|
3618
|
-
source_default.yellow(`\u26A0\uFE0F Linked deployment not found, creating new one...`)
|
|
3619
|
-
);
|
|
3518
|
+
return;
|
|
3620
3519
|
}
|
|
3520
|
+
} catch (error) {
|
|
3521
|
+
console.log(
|
|
3522
|
+
source_default.yellow(`\u26A0\uFE0F Linked deployment not found, creating new one...`)
|
|
3523
|
+
);
|
|
3621
3524
|
}
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
console.log(source_default.gray(` Future deploys will reuse the same URL
|
|
3525
|
+
}
|
|
3526
|
+
const deploymentRequest = {
|
|
3527
|
+
name: projectName,
|
|
3528
|
+
source: {
|
|
3529
|
+
type: "github",
|
|
3530
|
+
repo: `${gitInfo.owner}/${gitInfo.repo}`,
|
|
3531
|
+
branch: gitInfo.branch || "main",
|
|
3532
|
+
runtime,
|
|
3533
|
+
port,
|
|
3534
|
+
buildCommand,
|
|
3535
|
+
startCommand,
|
|
3536
|
+
env: Object.keys(envVars).length > 0 ? envVars : void 0
|
|
3537
|
+
},
|
|
3538
|
+
healthCheckPath: "/healthz"
|
|
3539
|
+
};
|
|
3540
|
+
console.log(source_default.gray("Creating deployment..."));
|
|
3541
|
+
const deployment = await api.createDeployment(deploymentRequest);
|
|
3542
|
+
console.log(
|
|
3543
|
+
source_default.green("\u2713 Deployment created: ") + source_default.gray(deployment.id)
|
|
3544
|
+
);
|
|
3545
|
+
await saveProjectLink(cwd, {
|
|
3546
|
+
deploymentId: deployment.id,
|
|
3547
|
+
deploymentName: projectName,
|
|
3548
|
+
deploymentUrl: deployment.domain,
|
|
3549
|
+
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3550
|
+
});
|
|
3551
|
+
console.log(
|
|
3552
|
+
source_default.gray(` Linked to this project (stored in .mcp-use/project.json)`)
|
|
3553
|
+
);
|
|
3554
|
+
console.log(source_default.gray(` Future deploys will reuse the same URL
|
|
3653
3555
|
`));
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
}
|
|
3556
|
+
await displayDeploymentProgress(api, deployment);
|
|
3557
|
+
if (options.open && deployment.domain) {
|
|
3558
|
+
console.log();
|
|
3559
|
+
console.log(source_default.gray("Opening deployment in browser..."));
|
|
3560
|
+
await open_default(`https://${deployment.domain}`);
|
|
3660
3561
|
}
|
|
3661
3562
|
} catch (error) {
|
|
3662
3563
|
console.error(
|
|
@@ -3705,7 +3606,9 @@ async function listDeploymentsCommand() {
|
|
|
3705
3606
|
if (!await isLoggedIn()) {
|
|
3706
3607
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3707
3608
|
console.log(
|
|
3708
|
-
source_default.gray(
|
|
3609
|
+
source_default.gray(
|
|
3610
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3611
|
+
)
|
|
3709
3612
|
);
|
|
3710
3613
|
process.exit(1);
|
|
3711
3614
|
}
|
|
@@ -3759,7 +3662,9 @@ async function getDeploymentCommand(deploymentId) {
|
|
|
3759
3662
|
if (!await isLoggedIn()) {
|
|
3760
3663
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3761
3664
|
console.log(
|
|
3762
|
-
source_default.gray(
|
|
3665
|
+
source_default.gray(
|
|
3666
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3667
|
+
)
|
|
3763
3668
|
);
|
|
3764
3669
|
process.exit(1);
|
|
3765
3670
|
}
|
|
@@ -3833,7 +3738,9 @@ async function restartDeploymentCommand(deploymentId, options) {
|
|
|
3833
3738
|
if (!await isLoggedIn()) {
|
|
3834
3739
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3835
3740
|
console.log(
|
|
3836
|
-
source_default.gray(
|
|
3741
|
+
source_default.gray(
|
|
3742
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3743
|
+
)
|
|
3837
3744
|
);
|
|
3838
3745
|
process.exit(1);
|
|
3839
3746
|
}
|
|
@@ -3893,7 +3800,9 @@ async function deleteDeploymentCommand(deploymentId, options) {
|
|
|
3893
3800
|
if (!await isLoggedIn()) {
|
|
3894
3801
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3895
3802
|
console.log(
|
|
3896
|
-
source_default.gray(
|
|
3803
|
+
source_default.gray(
|
|
3804
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3805
|
+
)
|
|
3897
3806
|
);
|
|
3898
3807
|
process.exit(1);
|
|
3899
3808
|
}
|
|
@@ -3936,7 +3845,9 @@ async function logsCommand(deploymentId, options) {
|
|
|
3936
3845
|
if (!await isLoggedIn()) {
|
|
3937
3846
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3938
3847
|
console.log(
|
|
3939
|
-
source_default.gray(
|
|
3848
|
+
source_default.gray(
|
|
3849
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3850
|
+
)
|
|
3940
3851
|
);
|
|
3941
3852
|
process.exit(1);
|
|
3942
3853
|
}
|
|
@@ -3997,7 +3908,9 @@ async function listEnvCommand(deploymentId) {
|
|
|
3997
3908
|
if (!await isLoggedIn()) {
|
|
3998
3909
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
3999
3910
|
console.log(
|
|
4000
|
-
source_default.gray(
|
|
3911
|
+
source_default.gray(
|
|
3912
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3913
|
+
)
|
|
4001
3914
|
);
|
|
4002
3915
|
process.exit(1);
|
|
4003
3916
|
}
|
|
@@ -4033,7 +3946,9 @@ async function setEnvCommand(deploymentId, envPairs) {
|
|
|
4033
3946
|
if (!await isLoggedIn()) {
|
|
4034
3947
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
4035
3948
|
console.log(
|
|
4036
|
-
source_default.gray(
|
|
3949
|
+
source_default.gray(
|
|
3950
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3951
|
+
)
|
|
4037
3952
|
);
|
|
4038
3953
|
process.exit(1);
|
|
4039
3954
|
}
|
|
@@ -4078,7 +3993,9 @@ async function unsetEnvCommand(deploymentId, keys) {
|
|
|
4078
3993
|
if (!await isLoggedIn()) {
|
|
4079
3994
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
4080
3995
|
console.log(
|
|
4081
|
-
source_default.gray(
|
|
3996
|
+
source_default.gray(
|
|
3997
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
3998
|
+
)
|
|
4082
3999
|
);
|
|
4083
4000
|
process.exit(1);
|
|
4084
4001
|
}
|
|
@@ -4113,7 +4030,9 @@ async function stopDeploymentCommand(deploymentId) {
|
|
|
4113
4030
|
if (!await isLoggedIn()) {
|
|
4114
4031
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
4115
4032
|
console.log(
|
|
4116
|
-
source_default.gray(
|
|
4033
|
+
source_default.gray(
|
|
4034
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
4035
|
+
)
|
|
4117
4036
|
);
|
|
4118
4037
|
process.exit(1);
|
|
4119
4038
|
}
|
|
@@ -4137,7 +4056,9 @@ async function startDeploymentCommand(deploymentId) {
|
|
|
4137
4056
|
if (!await isLoggedIn()) {
|
|
4138
4057
|
console.log(source_default.red("\u2717 You are not logged in."));
|
|
4139
4058
|
console.log(
|
|
4140
|
-
source_default.gray(
|
|
4059
|
+
source_default.gray(
|
|
4060
|
+
"Run " + source_default.white("npx mcp-use login") + " to get started."
|
|
4061
|
+
)
|
|
4141
4062
|
);
|
|
4142
4063
|
process.exit(1);
|
|
4143
4064
|
}
|
|
@@ -4218,7 +4139,7 @@ async function waitForServer(port, host = "localhost", maxAttempts = 30) {
|
|
|
4218
4139
|
return false;
|
|
4219
4140
|
}
|
|
4220
4141
|
function runCommand(command, args, cwd, env2, filterStderr = false) {
|
|
4221
|
-
const proc = (0,
|
|
4142
|
+
const proc = (0, import_node_child_process9.spawn)(command, args, {
|
|
4222
4143
|
cwd,
|
|
4223
4144
|
stdio: filterStderr ? ["inherit", "inherit", "pipe"] : "inherit",
|
|
4224
4145
|
shell: process.platform === "win32",
|
|
@@ -4251,7 +4172,7 @@ async function startTunnel(port, subdomain) {
|
|
|
4251
4172
|
if (subdomain) {
|
|
4252
4173
|
tunnelArgs.push("--subdomain", subdomain);
|
|
4253
4174
|
}
|
|
4254
|
-
const proc = (0,
|
|
4175
|
+
const proc = (0, import_node_child_process9.spawn)("npx", tunnelArgs, {
|
|
4255
4176
|
stdio: ["ignore", "pipe", "pipe"],
|
|
4256
4177
|
shell: process.platform === "win32"
|
|
4257
4178
|
});
|
|
@@ -5145,7 +5066,7 @@ program.command("start").description("Start production server").option("-p, --pa
|
|
|
5145
5066
|
env2.MCP_URL = mcpUrl;
|
|
5146
5067
|
console.log(source_default.whiteBright(`Tunnel: ${mcpUrl}/mcp`));
|
|
5147
5068
|
}
|
|
5148
|
-
const serverProc = (0,
|
|
5069
|
+
const serverProc = (0, import_node_child_process9.spawn)("node", [serverFile], {
|
|
5149
5070
|
cwd: projectPath,
|
|
5150
5071
|
stdio: "inherit",
|
|
5151
5072
|
env: env2
|
|
@@ -5206,7 +5127,16 @@ program.command("start").description("Start production server").option("-p, --pa
|
|
|
5206
5127
|
}
|
|
5207
5128
|
});
|
|
5208
5129
|
program.command("login").description("Login to mcp-use cloud").action(async () => {
|
|
5209
|
-
|
|
5130
|
+
try {
|
|
5131
|
+
await loginCommand();
|
|
5132
|
+
process.exit(0);
|
|
5133
|
+
} catch (error) {
|
|
5134
|
+
console.error(
|
|
5135
|
+
source_default.red.bold("\n\u2717 Login failed:"),
|
|
5136
|
+
source_default.red(error instanceof Error ? error.message : "Unknown error")
|
|
5137
|
+
);
|
|
5138
|
+
process.exit(1);
|
|
5139
|
+
}
|
|
5210
5140
|
});
|
|
5211
5141
|
program.command("logout").description("Logout from mcp-use cloud").action(async () => {
|
|
5212
5142
|
await logoutCommand();
|
|
@@ -5214,10 +5144,7 @@ program.command("logout").description("Logout from mcp-use cloud").action(async
|
|
|
5214
5144
|
program.command("whoami").description("Show current user information").action(async () => {
|
|
5215
5145
|
await whoamiCommand();
|
|
5216
5146
|
});
|
|
5217
|
-
program.command("deploy").description("Deploy MCP server to mcp-use cloud").option("--open", "Open deployment in browser after successful deploy").option("--name <name>", "Custom deployment name").option("--port <port>", "Server port", "3000").option("--runtime <runtime>", "Runtime (node or python)").option(
|
|
5218
|
-
"--from-source",
|
|
5219
|
-
"Deploy from local source code (even for GitHub repos)"
|
|
5220
|
-
).option(
|
|
5147
|
+
program.command("deploy").description("Deploy MCP server from GitHub to mcp-use cloud").option("--open", "Open deployment in browser after successful deploy").option("--name <name>", "Custom deployment name").option("--port <port>", "Server port", "3000").option("--runtime <runtime>", "Runtime (node or python)").option(
|
|
5221
5148
|
"--new",
|
|
5222
5149
|
"Force creation of new deployment instead of reusing linked deployment"
|
|
5223
5150
|
).option(
|
|
@@ -5229,7 +5156,6 @@ program.command("deploy").description("Deploy MCP server to mcp-use cloud").opti
|
|
|
5229
5156
|
name: options.name,
|
|
5230
5157
|
port: options.port ? parseInt(options.port, 10) : void 0,
|
|
5231
5158
|
runtime: options.runtime,
|
|
5232
|
-
fromSource: options.fromSource,
|
|
5233
5159
|
new: options.new,
|
|
5234
5160
|
env: options.env,
|
|
5235
5161
|
envFile: options.envFile
|