@mcp-use/cli 2.11.0-canary.9 → 2.11.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 CHANGED
@@ -152,8 +152,6 @@ mcp-use deploy
152
152
  mcp-use deploy --name my-server --port 8000 --open
153
153
  ```
154
154
 
155
- See [ENVIRONMENT.md](./ENVIRONMENT.md) for configuration options.
156
-
157
155
  ---
158
156
 
159
157
  ## 💡 Examples
package/dist/index.cjs CHANGED
@@ -528,6 +528,7 @@ var import_config5 = require("dotenv/config");
528
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
+ var import_node_module = require("module");
531
532
  var import_node_path6 = __toESM(require("path"), 1);
532
533
 
533
534
  // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
@@ -4452,24 +4453,43 @@ var packageContent = (0, import_node_fs8.readFileSync)(
4452
4453
  var packageJson = JSON.parse(packageContent);
4453
4454
  var packageVersion = packageJson.version || "unknown";
4454
4455
  program.name("mcp-use").description("Create and run MCP servers with ui resources widgets").version(packageVersion);
4455
- function displayPackageVersions() {
4456
+ function displayPackageVersions(projectPath) {
4456
4457
  const packages = [
4457
- { name: "@mcp-use/cli", path: "../package.json" },
4458
- { name: "@mcp-use/inspector", path: "../../inspector/package.json" },
4458
+ { name: "@mcp-use/cli", relativePath: "../package.json" },
4459
+ {
4460
+ name: "@mcp-use/inspector",
4461
+ relativePath: "../../inspector/package.json"
4462
+ },
4459
4463
  {
4460
4464
  name: "create-mcp-use-app",
4461
- path: "../../create-mcp-use-app/package.json"
4465
+ relativePath: "../../create-mcp-use-app/package.json"
4462
4466
  },
4463
- { name: "mcp-use", path: "../../mcp-use/package.json", highlight: true }
4467
+ {
4468
+ name: "mcp-use",
4469
+ relativePath: "../../mcp-use/package.json",
4470
+ highlight: true
4471
+ }
4464
4472
  ];
4465
4473
  console.log(source_default.gray("mcp-use packages:"));
4466
4474
  for (const pkg of packages) {
4475
+ const paddedName = pkg.name.padEnd(22);
4467
4476
  try {
4468
- const pkgPath = import_node_path6.default.join(__dirname, pkg.path);
4477
+ let pkgPath;
4478
+ if (projectPath) {
4479
+ try {
4480
+ const projectRequire = (0, import_node_module.createRequire)(
4481
+ import_node_path6.default.join(projectPath, "package.json")
4482
+ );
4483
+ pkgPath = projectRequire.resolve(`${pkg.name}/package.json`);
4484
+ } catch (resolveError) {
4485
+ pkgPath = import_node_path6.default.join(__dirname, pkg.relativePath);
4486
+ }
4487
+ } else {
4488
+ pkgPath = import_node_path6.default.join(__dirname, pkg.relativePath);
4489
+ }
4469
4490
  const pkgContent = (0, import_node_fs8.readFileSync)(pkgPath, "utf-8");
4470
4491
  const pkgJson = JSON.parse(pkgContent);
4471
4492
  const version = pkgJson.version || "unknown";
4472
- const paddedName = pkg.name.padEnd(22);
4473
4493
  if (pkg.highlight) {
4474
4494
  console.log(
4475
4495
  ` ${source_default.cyan.bold(paddedName)} ${source_default.cyan.bold(`v${version}`)}`
@@ -4478,6 +4498,9 @@ function displayPackageVersions() {
4478
4498
  console.log(source_default.gray(` ${paddedName} v${version}`));
4479
4499
  }
4480
4500
  } catch (error) {
4501
+ if (process.env.DEBUG || process.env.VERBOSE) {
4502
+ console.log(source_default.dim(` ${paddedName} (not found)`));
4503
+ }
4481
4504
  }
4482
4505
  }
4483
4506
  }
@@ -5037,7 +5060,7 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
5037
5060
  try {
5038
5061
  const projectPath = import_node_path6.default.resolve(options.path);
5039
5062
  const { promises: fs10 } = await import("fs");
5040
- displayPackageVersions();
5063
+ displayPackageVersions(projectPath);
5041
5064
  const builtWidgets = await buildWidgets(projectPath);
5042
5065
  console.log(source_default.gray("Building TypeScript..."));
5043
5066
  await runCommand("npx", ["tsc"], projectPath);
@@ -5101,7 +5124,7 @@ program.command("dev").description("Run development server with auto-reload and
5101
5124
  let port = parseInt(options.port, 10);
5102
5125
  const host = options.host;
5103
5126
  const useHmr = options.hmr !== false;
5104
- displayPackageVersions();
5127
+ displayPackageVersions(projectPath);
5105
5128
  if (!await isPortAvailable(port, host)) {
5106
5129
  console.log(source_default.yellow.bold(`\u26A0\uFE0F Port ${port} is already in use`));
5107
5130
  const availablePort = await findAvailablePort2(port, host);
@@ -5109,22 +5132,26 @@ program.command("dev").description("Run development server with auto-reload and
5109
5132
  port = availablePort;
5110
5133
  }
5111
5134
  const serverFile = await findServerFile(projectPath);
5135
+ const mcpUrl = `http://${host}:${port}`;
5112
5136
  process.env.PORT = String(port);
5113
5137
  process.env.HOST = host;
5114
5138
  process.env.NODE_ENV = "development";
5139
+ process.env.MCP_URL = mcpUrl;
5115
5140
  if (!useHmr) {
5116
5141
  console.log(source_default.gray("HMR disabled, using tsx watch (full restart)"));
5117
5142
  const processes = [];
5143
+ const mcpUrl2 = `http://${host}:${port}`;
5118
5144
  const env2 = {
5119
5145
  PORT: String(port),
5120
5146
  HOST: host,
5121
- NODE_ENV: "development"
5147
+ NODE_ENV: "development",
5148
+ MCP_URL: mcpUrl2
5122
5149
  };
5123
- const { createRequire: createRequire2 } = await import("module");
5150
+ const { createRequire: createRequire3 } = await import("module");
5124
5151
  let cmd;
5125
5152
  let args;
5126
5153
  try {
5127
- const projectRequire = createRequire2(
5154
+ const projectRequire = createRequire3(
5128
5155
  import_node_path6.default.join(projectPath, "package.json")
5129
5156
  );
5130
5157
  const tsxPkgPath = projectRequire.resolve("tsx/package.json");
@@ -5190,10 +5217,10 @@ program.command("dev").description("Run development server with auto-reload and
5190
5217
  const chokidarModule = await import("chokidar");
5191
5218
  const chokidar = chokidarModule.default || chokidarModule;
5192
5219
  const { pathToFileURL } = await import("url");
5193
- const { createRequire } = await import("module");
5220
+ const { createRequire: createRequire2 } = await import("module");
5194
5221
  let tsImport = null;
5195
5222
  try {
5196
- const projectRequire = createRequire(
5223
+ const projectRequire = createRequire2(
5197
5224
  import_node_path6.default.join(projectPath, "package.json")
5198
5225
  );
5199
5226
  const tsxApiPath = projectRequire.resolve("tsx/esm/api");