@mcp-use/cli 2.2.2 → 2.2.3-canary.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -24,14 +24,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/index.ts
27
- var import_config4 = require("dotenv/config");
27
+ var import_chalk3 = __toESM(require("chalk"));
28
28
  var import_commander = require("commander");
29
+ var import_config4 = require("dotenv/config");
29
30
  var import_node_child_process3 = require("child_process");
30
31
  var import_node_fs3 = require("fs");
31
32
  var import_promises = require("fs/promises");
32
33
  var import_node_path3 = __toESM(require("path"));
33
34
  var import_open3 = __toESM(require("open"));
34
- var import_chalk3 = __toESM(require("chalk"));
35
35
 
36
36
  // src/commands/auth.ts
37
37
  var import_chalk = __toESM(require("chalk"));
@@ -213,7 +213,7 @@ var McpUseAPI = class _McpUseAPI {
213
213
  * Create deployment with source code upload
214
214
  */
215
215
  async createDeploymentWithUpload(request, filePath) {
216
- const { readFile } = await import("fs/promises");
216
+ const { readFile: readFile2 } = await import("fs/promises");
217
217
  const { basename } = await import("path");
218
218
  const { stat } = await import("fs/promises");
219
219
  const stats = await stat(filePath);
@@ -223,7 +223,7 @@ var McpUseAPI = class _McpUseAPI {
223
223
  `File size (${(stats.size / 1024 / 1024).toFixed(2)}MB) exceeds maximum of 2MB`
224
224
  );
225
225
  }
226
- const fileBuffer = await readFile(filePath);
226
+ const fileBuffer = await readFile2(filePath);
227
227
  const filename = basename(filePath);
228
228
  const formData = new FormData();
229
229
  const blob = new Blob([fileBuffer], { type: "application/gzip" });
@@ -1215,10 +1215,14 @@ function runCommand(command, args, cwd, env, filterStderr = false) {
1215
1215
  });
1216
1216
  return { promise, process: proc };
1217
1217
  }
1218
- async function startTunnel(port) {
1218
+ async function startTunnel(port, subdomain) {
1219
1219
  return new Promise((resolve, reject) => {
1220
1220
  console.log(import_chalk3.default.gray(`Starting tunnel for port ${port}...`));
1221
- const proc = (0, import_node_child_process3.spawn)("npx", ["--yes", "@mcp-use/tunnel", String(port)], {
1221
+ const tunnelArgs = ["--yes", "@mcp-use/tunnel", String(port)];
1222
+ if (subdomain) {
1223
+ tunnelArgs.push("--", "--subdomain", subdomain);
1224
+ }
1225
+ const proc = (0, import_node_child_process3.spawn)("npx", tunnelArgs, {
1222
1226
  stdio: ["ignore", "pipe", "pipe"],
1223
1227
  shell: false
1224
1228
  });
@@ -1229,11 +1233,13 @@ async function startTunnel(port) {
1229
1233
  const urlMatch = text.match(/https?:\/\/([a-z0-9-]+\.[a-z0-9.-]+)/i);
1230
1234
  if (urlMatch && !resolved) {
1231
1235
  const url = urlMatch[0];
1232
- const subdomain = url;
1236
+ const fullDomain = urlMatch[1];
1237
+ const subdomainMatch = fullDomain.match(/^([a-z0-9-]+)\./);
1238
+ const extractedSubdomain = subdomainMatch ? subdomainMatch[1] : fullDomain.split(".")[0];
1233
1239
  resolved = true;
1234
1240
  clearTimeout(setupTimeout);
1235
1241
  console.log(import_chalk3.default.green.bold(`\u2713 Tunnel established: ${url}/mcp`));
1236
- resolve({ url, subdomain, process: proc });
1242
+ resolve({ url, subdomain: extractedSubdomain, process: proc });
1237
1243
  }
1238
1244
  });
1239
1245
  proc.stderr?.on("data", (data) => {
@@ -1512,7 +1518,6 @@ program.command("dev").description("Run development server with auto-reload and
1512
1518
  console.log(import_chalk3.default.green.bold(`\u2713 Using port ${availablePort} instead`));
1513
1519
  port = availablePort;
1514
1520
  }
1515
- let mcpUrl;
1516
1521
  const serverFile = await findServerFile(projectPath);
1517
1522
  const processes = [];
1518
1523
  const env = {
@@ -1520,9 +1525,6 @@ program.command("dev").description("Run development server with auto-reload and
1520
1525
  HOST: host,
1521
1526
  NODE_ENV: "development"
1522
1527
  };
1523
- if (mcpUrl) {
1524
- env.MCP_URL = mcpUrl;
1525
- }
1526
1528
  const serverCommand = runCommand(
1527
1529
  "npx",
1528
1530
  ["tsx", "watch", serverFile],
@@ -1536,17 +1538,11 @@ program.command("dev").description("Run development server with auto-reload and
1536
1538
  const ready = await waitForServer(port, host);
1537
1539
  if (ready) {
1538
1540
  const mcpEndpoint = `http://${host}:${port}/mcp`;
1539
- let inspectorUrl = `http://${host}:${port}/inspector?autoConnect=${encodeURIComponent(mcpEndpoint)}`;
1540
- if (mcpUrl) {
1541
- inspectorUrl += `&tunnelUrl=${encodeURIComponent(mcpUrl)}`;
1542
- }
1541
+ const inspectorUrl = `http://${host}:${port}/inspector?autoConnect=${encodeURIComponent(mcpEndpoint)}`;
1543
1542
  const readyTime = Date.now() - startTime;
1544
1543
  console.log(import_chalk3.default.green.bold(`\u2713 Ready in ${readyTime}ms`));
1545
1544
  console.log(import_chalk3.default.whiteBright(`Local: http://${host}:${port}`));
1546
1545
  console.log(import_chalk3.default.whiteBright(`Network: http://${host}:${port}`));
1547
- if (mcpUrl) {
1548
- console.log(import_chalk3.default.whiteBright(`Tunnel: ${mcpUrl}`));
1549
- }
1550
1546
  console.log(import_chalk3.default.whiteBright(`MCP: ${mcpEndpoint}`));
1551
1547
  console.log(import_chalk3.default.whiteBright(`Inspector: ${inspectorUrl}
1552
1548
  `));
@@ -1601,9 +1597,50 @@ program.command("start").description("Start production server").option("-p, --pa
1601
1597
  let tunnelProcess = void 0;
1602
1598
  if (options.tunnel) {
1603
1599
  try {
1604
- const tunnelInfo = await startTunnel(port);
1605
- mcpUrl = tunnelInfo.subdomain;
1600
+ const manifestPath = import_node_path3.default.join(projectPath, "dist", "mcp-use.json");
1601
+ let existingSubdomain;
1602
+ try {
1603
+ const manifestContent = await (0, import_promises.readFile)(manifestPath, "utf-8");
1604
+ const manifest = JSON.parse(manifestContent);
1605
+ existingSubdomain = manifest.tunnel?.subdomain;
1606
+ if (existingSubdomain) {
1607
+ console.log(
1608
+ import_chalk3.default.gray(`Found existing subdomain: ${existingSubdomain}`)
1609
+ );
1610
+ }
1611
+ } catch {
1612
+ }
1613
+ const tunnelInfo = await startTunnel(port, existingSubdomain);
1614
+ mcpUrl = tunnelInfo.url;
1606
1615
  tunnelProcess = tunnelInfo.process;
1616
+ const subdomain = tunnelInfo.subdomain;
1617
+ try {
1618
+ let manifest = {};
1619
+ try {
1620
+ const manifestContent = await (0, import_promises.readFile)(manifestPath, "utf-8");
1621
+ manifest = JSON.parse(manifestContent);
1622
+ } catch {
1623
+ }
1624
+ if (!manifest.tunnel) {
1625
+ manifest.tunnel = {};
1626
+ }
1627
+ manifest.tunnel.subdomain = subdomain;
1628
+ await (0, import_promises.mkdir)(import_node_path3.default.dirname(manifestPath), { recursive: true });
1629
+ await (0, import_promises.writeFile)(
1630
+ manifestPath,
1631
+ JSON.stringify(manifest, null, 2),
1632
+ "utf-8"
1633
+ );
1634
+ console.log(
1635
+ import_chalk3.default.green(`\u2713 Subdomain saved to mcp-use.json: ${subdomain}`)
1636
+ );
1637
+ } catch (error) {
1638
+ console.warn(
1639
+ import_chalk3.default.yellow(
1640
+ `\u26A0\uFE0F Failed to save subdomain to mcp-use.json: ${error instanceof Error ? error.message : "Unknown error"}`
1641
+ )
1642
+ );
1643
+ }
1607
1644
  } catch (error) {
1608
1645
  console.error(import_chalk3.default.red("Failed to start tunnel:"), error);
1609
1646
  process.exit(1);
@@ -1623,7 +1660,7 @@ program.command("start").description("Start production server").option("-p, --pa
1623
1660
  };
1624
1661
  if (mcpUrl) {
1625
1662
  env.MCP_URL = mcpUrl;
1626
- console.log(import_chalk3.default.whiteBright(`Tunnel: ${mcpUrl}`));
1663
+ console.log(import_chalk3.default.whiteBright(`Tunnel: ${mcpUrl}/mcp`));
1627
1664
  }
1628
1665
  const serverProc = (0, import_node_child_process3.spawn)("node", [serverFile], {
1629
1666
  cwd: projectPath,
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import "dotenv/config";
4
+ import chalk3 from "chalk";
5
5
  import { Command } from "commander";
6
+ import "dotenv/config";
6
7
  import { spawn } from "child_process";
7
8
  import { readFileSync } from "fs";
8
- import { access } from "fs/promises";
9
+ import { access, mkdir, readFile, writeFile } from "fs/promises";
9
10
  import path3 from "path";
10
11
  import open3 from "open";
11
- import chalk3 from "chalk";
12
12
 
13
13
  // src/commands/auth.ts
14
14
  import chalk from "chalk";
@@ -192,7 +192,7 @@ var McpUseAPI = class _McpUseAPI {
192
192
  * Create deployment with source code upload
193
193
  */
194
194
  async createDeploymentWithUpload(request, filePath) {
195
- const { readFile } = await import("fs/promises");
195
+ const { readFile: readFile2 } = await import("fs/promises");
196
196
  const { basename } = await import("path");
197
197
  const { stat } = await import("fs/promises");
198
198
  const stats = await stat(filePath);
@@ -202,7 +202,7 @@ var McpUseAPI = class _McpUseAPI {
202
202
  `File size (${(stats.size / 1024 / 1024).toFixed(2)}MB) exceeds maximum of 2MB`
203
203
  );
204
204
  }
205
- const fileBuffer = await readFile(filePath);
205
+ const fileBuffer = await readFile2(filePath);
206
206
  const filename = basename(filePath);
207
207
  const formData = new FormData();
208
208
  const blob = new Blob([fileBuffer], { type: "application/gzip" });
@@ -1194,10 +1194,14 @@ function runCommand(command, args, cwd, env, filterStderr = false) {
1194
1194
  });
1195
1195
  return { promise, process: proc };
1196
1196
  }
1197
- async function startTunnel(port) {
1197
+ async function startTunnel(port, subdomain) {
1198
1198
  return new Promise((resolve, reject) => {
1199
1199
  console.log(chalk3.gray(`Starting tunnel for port ${port}...`));
1200
- const proc = spawn("npx", ["--yes", "@mcp-use/tunnel", String(port)], {
1200
+ const tunnelArgs = ["--yes", "@mcp-use/tunnel", String(port)];
1201
+ if (subdomain) {
1202
+ tunnelArgs.push("--", "--subdomain", subdomain);
1203
+ }
1204
+ const proc = spawn("npx", tunnelArgs, {
1201
1205
  stdio: ["ignore", "pipe", "pipe"],
1202
1206
  shell: false
1203
1207
  });
@@ -1208,11 +1212,13 @@ async function startTunnel(port) {
1208
1212
  const urlMatch = text.match(/https?:\/\/([a-z0-9-]+\.[a-z0-9.-]+)/i);
1209
1213
  if (urlMatch && !resolved) {
1210
1214
  const url = urlMatch[0];
1211
- const subdomain = url;
1215
+ const fullDomain = urlMatch[1];
1216
+ const subdomainMatch = fullDomain.match(/^([a-z0-9-]+)\./);
1217
+ const extractedSubdomain = subdomainMatch ? subdomainMatch[1] : fullDomain.split(".")[0];
1212
1218
  resolved = true;
1213
1219
  clearTimeout(setupTimeout);
1214
1220
  console.log(chalk3.green.bold(`\u2713 Tunnel established: ${url}/mcp`));
1215
- resolve({ url, subdomain, process: proc });
1221
+ resolve({ url, subdomain: extractedSubdomain, process: proc });
1216
1222
  }
1217
1223
  });
1218
1224
  proc.stderr?.on("data", (data) => {
@@ -1491,7 +1497,6 @@ program.command("dev").description("Run development server with auto-reload and
1491
1497
  console.log(chalk3.green.bold(`\u2713 Using port ${availablePort} instead`));
1492
1498
  port = availablePort;
1493
1499
  }
1494
- let mcpUrl;
1495
1500
  const serverFile = await findServerFile(projectPath);
1496
1501
  const processes = [];
1497
1502
  const env = {
@@ -1499,9 +1504,6 @@ program.command("dev").description("Run development server with auto-reload and
1499
1504
  HOST: host,
1500
1505
  NODE_ENV: "development"
1501
1506
  };
1502
- if (mcpUrl) {
1503
- env.MCP_URL = mcpUrl;
1504
- }
1505
1507
  const serverCommand = runCommand(
1506
1508
  "npx",
1507
1509
  ["tsx", "watch", serverFile],
@@ -1515,17 +1517,11 @@ program.command("dev").description("Run development server with auto-reload and
1515
1517
  const ready = await waitForServer(port, host);
1516
1518
  if (ready) {
1517
1519
  const mcpEndpoint = `http://${host}:${port}/mcp`;
1518
- let inspectorUrl = `http://${host}:${port}/inspector?autoConnect=${encodeURIComponent(mcpEndpoint)}`;
1519
- if (mcpUrl) {
1520
- inspectorUrl += `&tunnelUrl=${encodeURIComponent(mcpUrl)}`;
1521
- }
1520
+ const inspectorUrl = `http://${host}:${port}/inspector?autoConnect=${encodeURIComponent(mcpEndpoint)}`;
1522
1521
  const readyTime = Date.now() - startTime;
1523
1522
  console.log(chalk3.green.bold(`\u2713 Ready in ${readyTime}ms`));
1524
1523
  console.log(chalk3.whiteBright(`Local: http://${host}:${port}`));
1525
1524
  console.log(chalk3.whiteBright(`Network: http://${host}:${port}`));
1526
- if (mcpUrl) {
1527
- console.log(chalk3.whiteBright(`Tunnel: ${mcpUrl}`));
1528
- }
1529
1525
  console.log(chalk3.whiteBright(`MCP: ${mcpEndpoint}`));
1530
1526
  console.log(chalk3.whiteBright(`Inspector: ${inspectorUrl}
1531
1527
  `));
@@ -1580,9 +1576,50 @@ program.command("start").description("Start production server").option("-p, --pa
1580
1576
  let tunnelProcess = void 0;
1581
1577
  if (options.tunnel) {
1582
1578
  try {
1583
- const tunnelInfo = await startTunnel(port);
1584
- mcpUrl = tunnelInfo.subdomain;
1579
+ const manifestPath = path3.join(projectPath, "dist", "mcp-use.json");
1580
+ let existingSubdomain;
1581
+ try {
1582
+ const manifestContent = await readFile(manifestPath, "utf-8");
1583
+ const manifest = JSON.parse(manifestContent);
1584
+ existingSubdomain = manifest.tunnel?.subdomain;
1585
+ if (existingSubdomain) {
1586
+ console.log(
1587
+ chalk3.gray(`Found existing subdomain: ${existingSubdomain}`)
1588
+ );
1589
+ }
1590
+ } catch {
1591
+ }
1592
+ const tunnelInfo = await startTunnel(port, existingSubdomain);
1593
+ mcpUrl = tunnelInfo.url;
1585
1594
  tunnelProcess = tunnelInfo.process;
1595
+ const subdomain = tunnelInfo.subdomain;
1596
+ try {
1597
+ let manifest = {};
1598
+ try {
1599
+ const manifestContent = await readFile(manifestPath, "utf-8");
1600
+ manifest = JSON.parse(manifestContent);
1601
+ } catch {
1602
+ }
1603
+ if (!manifest.tunnel) {
1604
+ manifest.tunnel = {};
1605
+ }
1606
+ manifest.tunnel.subdomain = subdomain;
1607
+ await mkdir(path3.dirname(manifestPath), { recursive: true });
1608
+ await writeFile(
1609
+ manifestPath,
1610
+ JSON.stringify(manifest, null, 2),
1611
+ "utf-8"
1612
+ );
1613
+ console.log(
1614
+ chalk3.green(`\u2713 Subdomain saved to mcp-use.json: ${subdomain}`)
1615
+ );
1616
+ } catch (error) {
1617
+ console.warn(
1618
+ chalk3.yellow(
1619
+ `\u26A0\uFE0F Failed to save subdomain to mcp-use.json: ${error instanceof Error ? error.message : "Unknown error"}`
1620
+ )
1621
+ );
1622
+ }
1586
1623
  } catch (error) {
1587
1624
  console.error(chalk3.red("Failed to start tunnel:"), error);
1588
1625
  process.exit(1);
@@ -1602,7 +1639,7 @@ program.command("start").description("Start production server").option("-p, --pa
1602
1639
  };
1603
1640
  if (mcpUrl) {
1604
1641
  env.MCP_URL = mcpUrl;
1605
- console.log(chalk3.whiteBright(`Tunnel: ${mcpUrl}`));
1642
+ console.log(chalk3.whiteBright(`Tunnel: ${mcpUrl}/mcp`));
1606
1643
  }
1607
1644
  const serverProc = spawn("node", [serverFile], {
1608
1645
  cwd: projectPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-use/cli",
3
- "version": "2.2.2",
3
+ "version": "2.2.3-canary.1",
4
4
  "description": "Build tool for MCP UI widgets - bundles React components into standalone HTML pages for Model Context Protocol servers",
5
5
  "author": "mcp-use, Inc.",
6
6
  "license": "MIT",
@@ -44,8 +44,8 @@
44
44
  "tsx": "^4.0.0",
45
45
  "vite": "^6.0.0",
46
46
  "ws": "^8.18.0",
47
- "@mcp-use/inspector": "0.5.2",
48
- "mcp-use": "1.3.2"
47
+ "@mcp-use/inspector": "0.5.3-canary.1",
48
+ "mcp-use": "1.3.3-canary.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^20.0.0",