@mcp-use/cli 2.14.1-canary.1 → 2.15.0-canary.2

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/index.cjs CHANGED
@@ -526,10 +526,10 @@ var source_default = chalk;
526
526
  var import_commander4 = require("commander");
527
527
  var import_config5 = require("dotenv/config");
528
528
  var import_node_child_process9 = require("child_process");
529
- var import_node_fs9 = require("fs");
530
- var import_promises6 = require("fs/promises");
531
- var import_node_module = require("module");
532
- var import_node_path7 = __toESM(require("path"), 1);
529
+ var import_node_fs10 = require("fs");
530
+ var import_promises7 = require("fs/promises");
531
+ var import_node_module2 = require("module");
532
+ var import_node_path8 = __toESM(require("path"), 1);
533
533
 
534
534
  // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
535
535
  var import_node_process8 = __toESM(require("process"), 1);
@@ -715,15 +715,15 @@ var wslDefaultBrowser = async () => {
715
715
  const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
716
716
  return stdout.trim();
717
717
  };
718
- var convertWslPathToWindows = async (path6) => {
719
- if (/^[a-z]+:\/\//i.test(path6)) {
720
- return path6;
718
+ var convertWslPathToWindows = async (path7) => {
719
+ if (/^[a-z]+:\/\//i.test(path7)) {
720
+ return path7;
721
721
  }
722
722
  try {
723
- const { stdout } = await execFile2("wslpath", ["-aw", path6], { encoding: "utf8" });
723
+ const { stdout } = await execFile2("wslpath", ["-aw", path7], { encoding: "utf8" });
724
724
  return stdout.trim();
725
725
  } catch {
726
- return path6;
726
+ return path7;
727
727
  }
728
728
  };
729
729
 
@@ -1343,7 +1343,7 @@ var McpUseAPI = class _McpUseAPI {
1343
1343
  * Create deployment with source code upload
1344
1344
  */
1345
1345
  async createDeploymentWithUpload(request, filePath) {
1346
- const { readFile: readFile3 } = await import("fs/promises");
1346
+ const { readFile: readFile4 } = await import("fs/promises");
1347
1347
  const { basename } = await import("path");
1348
1348
  const { stat } = await import("fs/promises");
1349
1349
  const stats = await stat(filePath);
@@ -1353,7 +1353,7 @@ var McpUseAPI = class _McpUseAPI {
1353
1353
  `File size (${(stats.size / 1024 / 1024).toFixed(2)}MB) exceeds maximum of 2MB`
1354
1354
  );
1355
1355
  }
1356
- const fileBuffer = await readFile3(filePath);
1356
+ const fileBuffer = await readFile4(filePath);
1357
1357
  const filename = basename(filePath);
1358
1358
  const formData = new FormData();
1359
1359
  const blob = new Blob([fileBuffer], { type: "application/gzip" });
@@ -1429,7 +1429,7 @@ var McpUseAPI = class _McpUseAPI {
1429
1429
  async redeployDeployment(deploymentId, configOrFilePath) {
1430
1430
  if (typeof configOrFilePath === "string") {
1431
1431
  const filePath = configOrFilePath;
1432
- const { readFile: readFile3 } = await import("fs/promises");
1432
+ const { readFile: readFile4 } = await import("fs/promises");
1433
1433
  const { basename } = await import("path");
1434
1434
  const { stat } = await import("fs/promises");
1435
1435
  const stats = await stat(filePath);
@@ -1439,7 +1439,7 @@ var McpUseAPI = class _McpUseAPI {
1439
1439
  `File size (${(stats.size / 1024 / 1024).toFixed(2)}MB) exceeds maximum of 2MB`
1440
1440
  );
1441
1441
  }
1442
- const fileBuffer = await readFile3(filePath);
1442
+ const fileBuffer = await readFile4(filePath);
1443
1443
  const formData = new FormData();
1444
1444
  const blob = new Blob([fileBuffer], { type: "application/gzip" });
1445
1445
  formData.append("source_file", blob, basename(filePath));
@@ -4550,7 +4550,7 @@ async function addSkillsToProject(projectPath) {
4550
4550
  import_node_stream.Readable.fromWeb(response.body),
4551
4551
  (0, import_tar.extract)({
4552
4552
  cwd: tempDir,
4553
- filter: (path6) => path6.includes("/skills/"),
4553
+ filter: (path7) => path7.includes("/skills/"),
4554
4554
  strip: 1
4555
4555
  })
4556
4556
  );
@@ -4615,10 +4615,140 @@ function createSkillsCommand() {
4615
4615
  return skills;
4616
4616
  }
4617
4617
 
4618
+ // src/utils/update-check.ts
4619
+ var import_node_fs9 = require("fs");
4620
+ var import_promises6 = require("fs/promises");
4621
+ var import_node_module = require("module");
4622
+ var import_node_os6 = __toESM(require("os"), 1);
4623
+ var import_node_path7 = __toESM(require("path"), 1);
4624
+ var CACHE_DIR = import_node_path7.default.join(import_node_os6.default.homedir(), ".mcp-use");
4625
+ var CACHE_FILE = import_node_path7.default.join(CACHE_DIR, "update-check.json");
4626
+ var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
4627
+ var FETCH_TIMEOUT_MS = 3e3;
4628
+ var PACKAGE_NAME = "mcp-use";
4629
+ function parseSemver(version) {
4630
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
4631
+ if (!match) return null;
4632
+ return [
4633
+ parseInt(match[1], 10),
4634
+ parseInt(match[2], 10),
4635
+ parseInt(match[3], 10)
4636
+ ];
4637
+ }
4638
+ function isNewer(current, candidate) {
4639
+ const a = parseSemver(current);
4640
+ const b = parseSemver(candidate);
4641
+ if (!a || !b) return false;
4642
+ for (let i = 0; i < 3; i++) {
4643
+ if (b[i] > a[i]) return true;
4644
+ if (b[i] < a[i]) return false;
4645
+ }
4646
+ return false;
4647
+ }
4648
+ async function readCache() {
4649
+ try {
4650
+ const content = await (0, import_promises6.readFile)(CACHE_FILE, "utf-8");
4651
+ return JSON.parse(content);
4652
+ } catch {
4653
+ return null;
4654
+ }
4655
+ }
4656
+ async function writeCache(latestVersion) {
4657
+ try {
4658
+ await (0, import_promises6.mkdir)(CACHE_DIR, { recursive: true });
4659
+ const cache = {
4660
+ lastChecked: (/* @__PURE__ */ new Date()).toISOString(),
4661
+ latestVersion
4662
+ };
4663
+ await (0, import_promises6.writeFile)(CACHE_FILE, JSON.stringify(cache, null, 2), "utf-8");
4664
+ } catch {
4665
+ }
4666
+ }
4667
+ async function fetchLatestVersion() {
4668
+ try {
4669
+ const controller = new AbortController();
4670
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
4671
+ try {
4672
+ const res = await fetch(
4673
+ `https://registry.npmjs.org/${PACKAGE_NAME}/latest`,
4674
+ {
4675
+ signal: controller.signal,
4676
+ headers: { Accept: "application/json" }
4677
+ }
4678
+ );
4679
+ if (!res.ok) return null;
4680
+ const data = await res.json();
4681
+ return data.version ?? null;
4682
+ } finally {
4683
+ clearTimeout(timer);
4684
+ }
4685
+ } catch {
4686
+ return null;
4687
+ }
4688
+ }
4689
+ async function getLatestVersion() {
4690
+ const cache = await readCache();
4691
+ if (cache) {
4692
+ const age = Date.now() - new Date(cache.lastChecked).getTime();
4693
+ if (age < CACHE_TTL_MS) {
4694
+ return cache.latestVersion;
4695
+ }
4696
+ }
4697
+ const latest = await fetchLatestVersion();
4698
+ if (latest) {
4699
+ await writeCache(latest);
4700
+ }
4701
+ return latest;
4702
+ }
4703
+ function resolveInstalledVersion(projectPath) {
4704
+ const attempts = [];
4705
+ if (projectPath) {
4706
+ attempts.push(() => {
4707
+ const projectRequire = (0, import_node_module.createRequire)(
4708
+ import_node_path7.default.join(projectPath, "package.json")
4709
+ );
4710
+ return projectRequire.resolve(`${PACKAGE_NAME}/package.json`);
4711
+ });
4712
+ }
4713
+ attempts.push(() => import_node_path7.default.join(__dirname, "../../mcp-use/package.json"));
4714
+ for (const attempt of attempts) {
4715
+ try {
4716
+ const pkgPath = attempt();
4717
+ const json = JSON.parse((0, import_node_fs9.readFileSync)(pkgPath, "utf-8"));
4718
+ if (typeof json.version === "string") return json.version;
4719
+ } catch {
4720
+ }
4721
+ }
4722
+ return null;
4723
+ }
4724
+ async function notifyIfUpdateAvailable(projectPath) {
4725
+ try {
4726
+ const installed = resolveInstalledVersion(projectPath);
4727
+ if (!installed) return;
4728
+ const latest = await getLatestVersion();
4729
+ if (!latest) return;
4730
+ if (isNewer(installed, latest)) {
4731
+ console.log(
4732
+ source_default.yellow(
4733
+ `
4734
+ A new release of ${source_default.bold(PACKAGE_NAME)} is available: ${source_default.dim(installed)} \u2192 ${source_default.cyan.bold(latest)}`
4735
+ )
4736
+ );
4737
+ console.log(
4738
+ source_default.gray(
4739
+ `Run ${source_default.white(`npm install ${PACKAGE_NAME}@latest`)} to update
4740
+ `
4741
+ )
4742
+ );
4743
+ }
4744
+ } catch {
4745
+ }
4746
+ }
4747
+
4618
4748
  // src/index.ts
4619
4749
  var program = new import_commander4.Command();
4620
- var packageContent = (0, import_node_fs9.readFileSync)(
4621
- import_node_path7.default.join(__dirname, "../package.json"),
4750
+ var packageContent = (0, import_node_fs10.readFileSync)(
4751
+ import_node_path8.default.join(__dirname, "../package.json"),
4622
4752
  "utf-8"
4623
4753
  );
4624
4754
  var packageJson = JSON.parse(packageContent);
@@ -4648,17 +4778,17 @@ function displayPackageVersions(projectPath) {
4648
4778
  let pkgPath;
4649
4779
  if (projectPath) {
4650
4780
  try {
4651
- const projectRequire = (0, import_node_module.createRequire)(
4652
- import_node_path7.default.join(projectPath, "package.json")
4781
+ const projectRequire = (0, import_node_module2.createRequire)(
4782
+ import_node_path8.default.join(projectPath, "package.json")
4653
4783
  );
4654
4784
  pkgPath = projectRequire.resolve(`${pkg.name}/package.json`);
4655
4785
  } catch (resolveError) {
4656
- pkgPath = import_node_path7.default.join(__dirname, pkg.relativePath);
4786
+ pkgPath = import_node_path8.default.join(__dirname, pkg.relativePath);
4657
4787
  }
4658
4788
  } else {
4659
- pkgPath = import_node_path7.default.join(__dirname, pkg.relativePath);
4789
+ pkgPath = import_node_path8.default.join(__dirname, pkg.relativePath);
4660
4790
  }
4661
- const pkgContent = (0, import_node_fs9.readFileSync)(pkgPath, "utf-8");
4791
+ const pkgContent = (0, import_node_fs10.readFileSync)(pkgPath, "utf-8");
4662
4792
  const pkgJson = JSON.parse(pkgContent);
4663
4793
  const version = pkgJson.version || "unknown";
4664
4794
  if (pkg.highlight) {
@@ -4811,7 +4941,7 @@ async function findServerFile(projectPath) {
4811
4941
  const candidates = ["index.ts", "src/index.ts", "server.ts", "src/server.ts"];
4812
4942
  for (const candidate of candidates) {
4813
4943
  try {
4814
- await (0, import_promises6.access)(import_node_path7.default.join(projectPath, candidate));
4944
+ await (0, import_promises7.access)(import_node_path8.default.join(projectPath, candidate));
4815
4945
  return candidate;
4816
4946
  } catch {
4817
4947
  continue;
@@ -4823,10 +4953,10 @@ async function buildWidgets(projectPath, options = {}) {
4823
4953
  const { inline = true } = options;
4824
4954
  const { promises: fs10 } = await import("fs");
4825
4955
  const { build } = await import("vite");
4826
- const resourcesDir = import_node_path7.default.join(projectPath, "resources");
4956
+ const resourcesDir = import_node_path8.default.join(projectPath, "resources");
4827
4957
  const mcpUrl = process.env.MCP_URL;
4828
4958
  try {
4829
- await (0, import_promises6.access)(resourcesDir);
4959
+ await (0, import_promises7.access)(resourcesDir);
4830
4960
  } catch {
4831
4961
  console.log(
4832
4962
  source_default.gray("No resources/ directory found - skipping widget build")
@@ -4843,10 +4973,10 @@ async function buildWidgets(projectPath, options = {}) {
4843
4973
  if (dirent.isFile() && (dirent.name.endsWith(".tsx") || dirent.name.endsWith(".ts"))) {
4844
4974
  entries.push({
4845
4975
  name: dirent.name.replace(/\.tsx?$/, ""),
4846
- path: import_node_path7.default.join(resourcesDir, dirent.name)
4976
+ path: import_node_path8.default.join(resourcesDir, dirent.name)
4847
4977
  });
4848
4978
  } else if (dirent.isDirectory()) {
4849
- const widgetPath = import_node_path7.default.join(resourcesDir, dirent.name, "widget.tsx");
4979
+ const widgetPath = import_node_path8.default.join(resourcesDir, dirent.name, "widget.tsx");
4850
4980
  try {
4851
4981
  await fs10.access(widgetPath);
4852
4982
  entries.push({
@@ -4872,7 +5002,7 @@ async function buildWidgets(projectPath, options = {}) {
4872
5002
  );
4873
5003
  const react = (await import("@vitejs/plugin-react")).default;
4874
5004
  const tailwindcss = (await import("@tailwindcss/vite")).default;
4875
- const packageJsonPath = import_node_path7.default.join(projectPath, "package.json");
5005
+ const packageJsonPath = import_node_path8.default.join(projectPath, "package.json");
4876
5006
  let favicon = "";
4877
5007
  try {
4878
5008
  const pkgContent = await fs10.readFile(packageJsonPath, "utf-8");
@@ -4884,18 +5014,18 @@ async function buildWidgets(projectPath, options = {}) {
4884
5014
  const widgetName = entry.name;
4885
5015
  const entryPath = entry.path.replace(/\\/g, "/");
4886
5016
  console.log(source_default.gray(` - Building ${widgetName}...`));
4887
- const tempDir = import_node_path7.default.join(projectPath, ".mcp-use", widgetName);
5017
+ const tempDir = import_node_path8.default.join(projectPath, ".mcp-use", widgetName);
4888
5018
  await fs10.mkdir(tempDir, { recursive: true });
4889
- const relativeResourcesPath = import_node_path7.default.relative(tempDir, resourcesDir).replace(/\\/g, "/");
4890
- const mcpUsePath = import_node_path7.default.join(projectPath, "node_modules", "mcp-use");
4891
- const relativeMcpUsePath = import_node_path7.default.relative(tempDir, mcpUsePath).replace(/\\/g, "/");
5019
+ const relativeResourcesPath = import_node_path8.default.relative(tempDir, resourcesDir).replace(/\\/g, "/");
5020
+ const mcpUsePath = import_node_path8.default.join(projectPath, "node_modules", "mcp-use");
5021
+ const relativeMcpUsePath = import_node_path8.default.relative(tempDir, mcpUsePath).replace(/\\/g, "/");
4892
5022
  const cssContent = `@import "tailwindcss";
4893
5023
 
4894
5024
  /* Configure Tailwind to scan the resources directory and mcp-use package */
4895
5025
  @source "${relativeResourcesPath}";
4896
5026
  @source "${relativeMcpUsePath}/**/*.{ts,tsx,js,jsx}";
4897
5027
  `;
4898
- await fs10.writeFile(import_node_path7.default.join(tempDir, "styles.css"), cssContent, "utf8");
5028
+ await fs10.writeFile(import_node_path8.default.join(tempDir, "styles.css"), cssContent, "utf8");
4899
5029
  const entryContent = `import React from 'react'
4900
5030
  import { createRoot } from 'react-dom/client'
4901
5031
  import './styles.css'
@@ -4920,9 +5050,9 @@ if (container && Component) {
4920
5050
  <script type="module" src="/entry.tsx"></script>
4921
5051
  </body>
4922
5052
  </html>`;
4923
- await fs10.writeFile(import_node_path7.default.join(tempDir, "entry.tsx"), entryContent, "utf8");
4924
- await fs10.writeFile(import_node_path7.default.join(tempDir, "index.html"), htmlContent, "utf8");
4925
- const outDir = import_node_path7.default.join(
5053
+ await fs10.writeFile(import_node_path8.default.join(tempDir, "entry.tsx"), entryContent, "utf8");
5054
+ await fs10.writeFile(import_node_path8.default.join(tempDir, "index.html"), htmlContent, "utf8");
5055
+ const outDir = import_node_path8.default.join(
4926
5056
  projectPath,
4927
5057
  "dist",
4928
5058
  "resources",
@@ -4932,7 +5062,7 @@ if (container && Component) {
4932
5062
  const baseUrl = mcpUrl ? `${mcpUrl}/${widgetName}/` : `/mcp-use/widgets/${widgetName}/`;
4933
5063
  let widgetMetadata = {};
4934
5064
  try {
4935
- const metadataTempDir = import_node_path7.default.join(
5065
+ const metadataTempDir = import_node_path8.default.join(
4936
5066
  projectPath,
4937
5067
  ".mcp-use",
4938
5068
  `${widgetName}-metadata`
@@ -4967,7 +5097,7 @@ export default PostHog;
4967
5097
  };
4968
5098
  const metadataServer = await createServer2({
4969
5099
  root: metadataTempDir,
4970
- cacheDir: import_node_path7.default.join(metadataTempDir, ".vite-cache"),
5100
+ cacheDir: import_node_path8.default.join(metadataTempDir, ".vite-cache"),
4971
5101
  plugins: [nodeStubsPlugin, tailwindcss(), react()],
4972
5102
  resolve: {
4973
5103
  alias: {
@@ -5197,7 +5327,7 @@ export default {
5197
5327
  // Inline all assets under 100MB (effectively all)
5198
5328
  } : {},
5199
5329
  rollupOptions: {
5200
- input: import_node_path7.default.join(tempDir, "index.html"),
5330
+ input: import_node_path8.default.join(tempDir, "index.html"),
5201
5331
  external: (id) => {
5202
5332
  return false;
5203
5333
  }
@@ -5205,11 +5335,11 @@ export default {
5205
5335
  }
5206
5336
  });
5207
5337
  try {
5208
- const assetsDir = import_node_path7.default.join(outDir, "assets");
5338
+ const assetsDir = import_node_path8.default.join(outDir, "assets");
5209
5339
  const assetFiles = await fs10.readdir(assetsDir);
5210
5340
  const jsFiles = assetFiles.filter((f) => f.endsWith(".js"));
5211
5341
  for (const jsFile of jsFiles) {
5212
- const jsPath = import_node_path7.default.join(assetsDir, jsFile);
5342
+ const jsPath = import_node_path8.default.join(assetsDir, jsFile);
5213
5343
  let content = await fs10.readFile(jsPath, "utf8");
5214
5344
  const zodConfigPatterns = [
5215
5345
  // Non-minified: export const globalConfig = {}
@@ -5241,7 +5371,7 @@ export default {
5241
5371
  const mcpServerUrl = process.env.MCP_SERVER_URL;
5242
5372
  if (mcpServerUrl) {
5243
5373
  try {
5244
- const htmlPath = import_node_path7.default.join(outDir, "index.html");
5374
+ const htmlPath = import_node_path8.default.join(outDir, "index.html");
5245
5375
  let html = await fs10.readFile(htmlPath, "utf8");
5246
5376
  const injectionScript = `<script>window.__getFile = (filename) => { return "${mcpUrl}/${widgetName}/"+filename }; window.__mcpPublicUrl = "${mcpServerUrl}/mcp-use/public"; window.__mcpPublicAssetsUrl = "${mcpUrl}/public";</script>`;
5247
5377
  if (!html.includes("window.__mcpPublicUrl")) {
@@ -5296,7 +5426,7 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
5296
5426
  "Inline all JS/CSS into HTML (required for VS Code MCP Apps)"
5297
5427
  ).option("--no-inline", "Keep JS/CSS as separate files (default)").action(async (options) => {
5298
5428
  try {
5299
- const projectPath = import_node_path7.default.resolve(options.path);
5429
+ const projectPath = import_node_path8.default.resolve(options.path);
5300
5430
  const { promises: fs10 } = await import("fs");
5301
5431
  displayPackageVersions(projectPath);
5302
5432
  const builtWidgets = await buildWidgets(projectPath, {
@@ -5308,11 +5438,18 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
5308
5438
  } catch {
5309
5439
  }
5310
5440
  console.log(source_default.gray("Building TypeScript..."));
5311
- await runCommand("npx", ["tsc"], projectPath);
5441
+ await runCommand(
5442
+ "node",
5443
+ [
5444
+ "--max-old-space-size=4096",
5445
+ import_node_path8.default.join(projectPath, "node_modules", "typescript", "bin", "tsc")
5446
+ ],
5447
+ projectPath
5448
+ ).promise;
5312
5449
  console.log(source_default.green("\u2713 TypeScript build complete!"));
5313
5450
  let entryPoint;
5314
5451
  if (sourceServerFile) {
5315
- const baseName = import_node_path7.default.basename(sourceServerFile, ".ts") + ".js";
5452
+ const baseName = import_node_path8.default.basename(sourceServerFile, ".ts") + ".js";
5316
5453
  const possibleOutputs = [
5317
5454
  `dist/${baseName}`,
5318
5455
  // rootDir set to project root or src
@@ -5323,7 +5460,7 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
5323
5460
  ];
5324
5461
  for (const candidate of possibleOutputs) {
5325
5462
  try {
5326
- await (0, import_promises6.access)(import_node_path7.default.join(projectPath, candidate));
5463
+ await (0, import_promises7.access)(import_node_path8.default.join(projectPath, candidate));
5327
5464
  entryPoint = candidate;
5328
5465
  break;
5329
5466
  } catch {
@@ -5331,17 +5468,17 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
5331
5468
  }
5332
5469
  }
5333
5470
  }
5334
- const publicDir = import_node_path7.default.join(projectPath, "public");
5471
+ const publicDir = import_node_path8.default.join(projectPath, "public");
5335
5472
  try {
5336
5473
  await fs10.access(publicDir);
5337
5474
  console.log(source_default.gray("Copying public assets..."));
5338
- await fs10.cp(publicDir, import_node_path7.default.join(projectPath, "dist", "public"), {
5475
+ await fs10.cp(publicDir, import_node_path8.default.join(projectPath, "dist", "public"), {
5339
5476
  recursive: true
5340
5477
  });
5341
5478
  console.log(source_default.green("\u2713 Public assets copied"));
5342
5479
  } catch {
5343
5480
  }
5344
- const manifestPath = import_node_path7.default.join(projectPath, "dist", "mcp-use.json");
5481
+ const manifestPath = import_node_path8.default.join(projectPath, "dist", "mcp-use.json");
5345
5482
  let existingManifest = {};
5346
5483
  try {
5347
5484
  const existingContent = await fs10.readFile(manifestPath, "utf-8");
@@ -5366,7 +5503,7 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
5366
5503
  // Server entry point for `mcp-use start`
5367
5504
  widgets: widgetsData
5368
5505
  };
5369
- await fs10.mkdir(import_node_path7.default.dirname(manifestPath), { recursive: true });
5506
+ await fs10.mkdir(import_node_path8.default.dirname(manifestPath), { recursive: true });
5370
5507
  await fs10.writeFile(
5371
5508
  manifestPath,
5372
5509
  JSON.stringify(manifest, null, 2),
@@ -5392,7 +5529,7 @@ program.command("dev").description("Run development server with auto-reload and
5392
5529
  "0.0.0.0"
5393
5530
  ).option("--no-open", "Do not auto-open inspector").option("--no-hmr", "Disable hot module reloading (use tsx watch instead)").action(async (options) => {
5394
5531
  try {
5395
- const projectPath = import_node_path7.default.resolve(options.path);
5532
+ const projectPath = import_node_path8.default.resolve(options.path);
5396
5533
  let port = parseInt(options.port, 10);
5397
5534
  const host = options.host;
5398
5535
  const useHmr = options.hmr !== false;
@@ -5421,15 +5558,15 @@ program.command("dev").description("Run development server with auto-reload and
5421
5558
  // Preserve user-provided MCP_URL (e.g., for reverse proxy setups)
5422
5559
  MCP_URL: process.env.MCP_URL || mcpUrl
5423
5560
  };
5424
- const { createRequire: createRequire3 } = await import("module");
5561
+ const { createRequire: createRequire4 } = await import("module");
5425
5562
  let cmd;
5426
5563
  let args;
5427
5564
  try {
5428
- const projectRequire = createRequire3(
5429
- import_node_path7.default.join(projectPath, "package.json")
5565
+ const projectRequire = createRequire4(
5566
+ import_node_path8.default.join(projectPath, "package.json")
5430
5567
  );
5431
5568
  const tsxPkgPath = projectRequire.resolve("tsx/package.json");
5432
- const tsxPkg = JSON.parse(await (0, import_promises6.readFile)(tsxPkgPath, "utf-8"));
5569
+ const tsxPkg = JSON.parse(await (0, import_promises7.readFile)(tsxPkgPath, "utf-8"));
5433
5570
  let binPath;
5434
5571
  if (typeof tsxPkg.bin === "string") {
5435
5572
  binPath = tsxPkg.bin;
@@ -5438,7 +5575,7 @@ program.command("dev").description("Run development server with auto-reload and
5438
5575
  } else {
5439
5576
  throw new Error("No bin field found in tsx package.json");
5440
5577
  }
5441
- const tsxBin = import_node_path7.default.resolve(import_node_path7.default.dirname(tsxPkgPath), binPath);
5578
+ const tsxBin = import_node_path8.default.resolve(import_node_path8.default.dirname(tsxPkgPath), binPath);
5442
5579
  cmd = "node";
5443
5580
  args = [tsxBin, "watch", serverFile];
5444
5581
  } catch (error) {
@@ -5494,11 +5631,11 @@ program.command("dev").description("Run development server with auto-reload and
5494
5631
  const chokidarModule = await import("chokidar");
5495
5632
  const chokidar = chokidarModule.default || chokidarModule;
5496
5633
  const { pathToFileURL, fileURLToPath: fileURLToPath2 } = await import("url");
5497
- const { createRequire: createRequire2 } = await import("module");
5634
+ const { createRequire: createRequire3 } = await import("module");
5498
5635
  let tsImport = null;
5499
5636
  try {
5500
- const projectRequire = createRequire2(
5501
- import_node_path7.default.join(projectPath, "package.json")
5637
+ const projectRequire = createRequire3(
5638
+ import_node_path8.default.join(projectPath, "package.json")
5502
5639
  );
5503
5640
  const tsxApiPath = projectRequire.resolve("tsx/esm/api");
5504
5641
  const tsxApi = await import(pathToFileURL(tsxApiPath).href);
@@ -5510,7 +5647,7 @@ program.command("dev").description("Run development server with auto-reload and
5510
5647
  )
5511
5648
  );
5512
5649
  }
5513
- const serverFilePath = import_node_path7.default.join(projectPath, serverFile);
5650
+ const serverFilePath = import_node_path8.default.join(projectPath, serverFile);
5514
5651
  const serverFileUrl = pathToFileURL(serverFilePath).href;
5515
5652
  globalThis.__mcpUseHmrMode = true;
5516
5653
  const importServerModule = async () => {
@@ -5610,8 +5747,8 @@ program.command("dev").description("Run development server with auto-reload and
5610
5747
  }
5611
5748
  const watcher = chokidar.watch(".", {
5612
5749
  cwd: projectPath,
5613
- ignored: (path6, stats) => {
5614
- const normalizedPath = path6.replace(/\\/g, "/");
5750
+ ignored: (path7, stats) => {
5751
+ const normalizedPath = path7.replace(/\\/g, "/");
5615
5752
  if (/(^|\/)\.[^/]/.test(normalizedPath)) {
5616
5753
  return true;
5617
5754
  }
@@ -5744,7 +5881,7 @@ program.command("dev").description("Run development server with auto-reload and
5744
5881
  });
5745
5882
  program.command("start").description("Start production server").option("-p, --path <path>", "Path to project directory", process.cwd()).option("--port <port>", "Server port", "3000").option("--tunnel", "Expose server through a tunnel").action(async (options) => {
5746
5883
  try {
5747
- const projectPath = import_node_path7.default.resolve(options.path);
5884
+ const projectPath = import_node_path8.default.resolve(options.path);
5748
5885
  const portFlagProvided = process.argv.includes("--port") || process.argv.includes("-p") || process.argv.some((arg) => arg.startsWith("--port=")) || process.argv.some((arg) => arg.startsWith("-p="));
5749
5886
  const port = portFlagProvided ? parseInt(options.port, 10) : parseInt(process.env.PORT || options.port || "3000", 10);
5750
5887
  console.log(
@@ -5756,10 +5893,10 @@ program.command("start").description("Start production server").option("-p, --pa
5756
5893
  let tunnelSubdomain = void 0;
5757
5894
  if (options.tunnel) {
5758
5895
  try {
5759
- const manifestPath2 = import_node_path7.default.join(projectPath, "dist", "mcp-use.json");
5896
+ const manifestPath2 = import_node_path8.default.join(projectPath, "dist", "mcp-use.json");
5760
5897
  let existingSubdomain;
5761
5898
  try {
5762
- const manifestContent = await (0, import_promises6.readFile)(manifestPath2, "utf-8");
5899
+ const manifestContent = await (0, import_promises7.readFile)(manifestPath2, "utf-8");
5763
5900
  const manifest = JSON.parse(manifestContent);
5764
5901
  existingSubdomain = manifest.tunnel?.subdomain;
5765
5902
  if (existingSubdomain) {
@@ -5782,7 +5919,7 @@ program.command("start").description("Start production server").option("-p, --pa
5782
5919
  try {
5783
5920
  let manifest = {};
5784
5921
  try {
5785
- const manifestContent = await (0, import_promises6.readFile)(manifestPath2, "utf-8");
5922
+ const manifestContent = await (0, import_promises7.readFile)(manifestPath2, "utf-8");
5786
5923
  manifest = JSON.parse(manifestContent);
5787
5924
  } catch {
5788
5925
  }
@@ -5790,8 +5927,8 @@ program.command("start").description("Start production server").option("-p, --pa
5790
5927
  manifest.tunnel = {};
5791
5928
  }
5792
5929
  manifest.tunnel.subdomain = subdomain;
5793
- await (0, import_promises6.mkdir)(import_node_path7.default.dirname(manifestPath2), { recursive: true });
5794
- await (0, import_promises6.writeFile)(
5930
+ await (0, import_promises7.mkdir)(import_node_path8.default.dirname(manifestPath2), { recursive: true });
5931
+ await (0, import_promises7.writeFile)(
5795
5932
  manifestPath2,
5796
5933
  JSON.stringify(manifest, null, 2),
5797
5934
  "utf-8"
@@ -5809,12 +5946,12 @@ program.command("start").description("Start production server").option("-p, --pa
5809
5946
  }
5810
5947
  }
5811
5948
  let serverFile;
5812
- const manifestPath = import_node_path7.default.join(projectPath, "dist", "mcp-use.json");
5949
+ const manifestPath = import_node_path8.default.join(projectPath, "dist", "mcp-use.json");
5813
5950
  try {
5814
- const manifestContent = await (0, import_promises6.readFile)(manifestPath, "utf-8");
5951
+ const manifestContent = await (0, import_promises7.readFile)(manifestPath, "utf-8");
5815
5952
  const manifest = JSON.parse(manifestContent);
5816
5953
  if (manifest.entryPoint) {
5817
- await (0, import_promises6.access)(import_node_path7.default.join(projectPath, manifest.entryPoint));
5954
+ await (0, import_promises7.access)(import_node_path8.default.join(projectPath, manifest.entryPoint));
5818
5955
  serverFile = manifest.entryPoint;
5819
5956
  }
5820
5957
  } catch {
@@ -5828,7 +5965,7 @@ program.command("start").description("Start production server").option("-p, --pa
5828
5965
  ];
5829
5966
  for (const candidate of serverCandidates) {
5830
5967
  try {
5831
- await (0, import_promises6.access)(import_node_path7.default.join(projectPath, candidate));
5968
+ await (0, import_promises7.access)(import_node_path8.default.join(projectPath, candidate));
5832
5969
  serverFile = candidate;
5833
5970
  break;
5834
5971
  } catch {
@@ -5965,10 +6102,10 @@ program.addCommand(createSkillsCommand());
5965
6102
  program.command("generate-types").description(
5966
6103
  "Generate TypeScript type definitions for tools (writes .mcp-use/tool-registry.d.ts)"
5967
6104
  ).option("-p, --path <path>", "Path to project directory", process.cwd()).option("--server <file>", "Server entry file", "index.ts").action(async (options) => {
5968
- const projectPath = import_node_path7.default.resolve(options.path);
5969
- const serverFile = import_node_path7.default.join(projectPath, options.server);
6105
+ const projectPath = import_node_path8.default.resolve(options.path);
6106
+ const serverFile = import_node_path8.default.join(projectPath, options.server);
5970
6107
  try {
5971
- if (!await (0, import_promises6.access)(serverFile).then(() => true).catch(() => false)) {
6108
+ if (!await (0, import_promises7.access)(serverFile).then(() => true).catch(() => false)) {
5972
6109
  console.error(source_default.red(`Server file not found: ${serverFile}`));
5973
6110
  process.exit(1);
5974
6111
  }
@@ -5977,7 +6114,7 @@ program.command("generate-types").description(
5977
6114
  const { tsImport } = await import("tsx/esm/api");
5978
6115
  await tsImport(serverFile, {
5979
6116
  parentURL: importMetaUrl,
5980
- tsconfig: import_node_path7.default.join(projectPath, "tsconfig.json")
6117
+ tsconfig: import_node_path8.default.join(projectPath, "tsconfig.json")
5981
6118
  });
5982
6119
  const server = globalThis.__mcpUseLastServer;
5983
6120
  if (!server) {
@@ -5988,8 +6125,8 @@ program.command("generate-types").description(
5988
6125
  );
5989
6126
  process.exit(1);
5990
6127
  }
5991
- const mcpUsePath = import_node_path7.default.join(projectPath, "node_modules", "mcp-use");
5992
- const { generateToolRegistryTypes } = await import(import_node_path7.default.join(mcpUsePath, "dist", "src", "server", "index.js")).then((mod) => mod);
6128
+ const mcpUsePath = import_node_path8.default.join(projectPath, "node_modules", "mcp-use");
6129
+ const { generateToolRegistryTypes } = await import(import_node_path8.default.join(mcpUsePath, "dist", "src", "server", "index.js")).then((mod) => mod);
5993
6130
  if (!generateToolRegistryTypes) {
5994
6131
  throw new Error(
5995
6132
  "generateToolRegistryTypes not found in mcp-use package"
@@ -6011,5 +6148,9 @@ program.command("generate-types").description(
6011
6148
  globalThis.__mcpUseHmrMode = false;
6012
6149
  }
6013
6150
  });
6151
+ program.hook("preAction", async (_thisCommand, actionCommand) => {
6152
+ const projectPath = actionCommand.opts().path;
6153
+ await notifyIfUpdateAvailable(projectPath);
6154
+ });
6014
6155
  program.parse();
6015
6156
  //# sourceMappingURL=index.cjs.map