@mcp-use/cli 2.11.0-canary.8 → 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 +0 -2
- package/dist/index.cjs +63 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -508,6 +508,7 @@ import "dotenv/config";
|
|
|
508
508
|
import { spawn } from "child_process";
|
|
509
509
|
import { readFileSync } from "fs";
|
|
510
510
|
import { access, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
511
|
+
import { createRequire } from "module";
|
|
511
512
|
import path6 from "path";
|
|
512
513
|
|
|
513
514
|
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
@@ -4434,6 +4435,57 @@ var packageContent = readFileSync(
|
|
|
4434
4435
|
var packageJson = JSON.parse(packageContent);
|
|
4435
4436
|
var packageVersion = packageJson.version || "unknown";
|
|
4436
4437
|
program.name("mcp-use").description("Create and run MCP servers with ui resources widgets").version(packageVersion);
|
|
4438
|
+
function displayPackageVersions(projectPath) {
|
|
4439
|
+
const packages = [
|
|
4440
|
+
{ name: "@mcp-use/cli", relativePath: "../package.json" },
|
|
4441
|
+
{
|
|
4442
|
+
name: "@mcp-use/inspector",
|
|
4443
|
+
relativePath: "../../inspector/package.json"
|
|
4444
|
+
},
|
|
4445
|
+
{
|
|
4446
|
+
name: "create-mcp-use-app",
|
|
4447
|
+
relativePath: "../../create-mcp-use-app/package.json"
|
|
4448
|
+
},
|
|
4449
|
+
{
|
|
4450
|
+
name: "mcp-use",
|
|
4451
|
+
relativePath: "../../mcp-use/package.json",
|
|
4452
|
+
highlight: true
|
|
4453
|
+
}
|
|
4454
|
+
];
|
|
4455
|
+
console.log(source_default.gray("mcp-use packages:"));
|
|
4456
|
+
for (const pkg of packages) {
|
|
4457
|
+
const paddedName = pkg.name.padEnd(22);
|
|
4458
|
+
try {
|
|
4459
|
+
let pkgPath;
|
|
4460
|
+
if (projectPath) {
|
|
4461
|
+
try {
|
|
4462
|
+
const projectRequire = createRequire(
|
|
4463
|
+
path6.join(projectPath, "package.json")
|
|
4464
|
+
);
|
|
4465
|
+
pkgPath = projectRequire.resolve(`${pkg.name}/package.json`);
|
|
4466
|
+
} catch (resolveError) {
|
|
4467
|
+
pkgPath = path6.join(__dirname, pkg.relativePath);
|
|
4468
|
+
}
|
|
4469
|
+
} else {
|
|
4470
|
+
pkgPath = path6.join(__dirname, pkg.relativePath);
|
|
4471
|
+
}
|
|
4472
|
+
const pkgContent = readFileSync(pkgPath, "utf-8");
|
|
4473
|
+
const pkgJson = JSON.parse(pkgContent);
|
|
4474
|
+
const version = pkgJson.version || "unknown";
|
|
4475
|
+
if (pkg.highlight) {
|
|
4476
|
+
console.log(
|
|
4477
|
+
` ${source_default.cyan.bold(paddedName)} ${source_default.cyan.bold(`v${version}`)}`
|
|
4478
|
+
);
|
|
4479
|
+
} else {
|
|
4480
|
+
console.log(source_default.gray(` ${paddedName} v${version}`));
|
|
4481
|
+
}
|
|
4482
|
+
} catch (error) {
|
|
4483
|
+
if (process.env.DEBUG || process.env.VERBOSE) {
|
|
4484
|
+
console.log(source_default.dim(` ${paddedName} (not found)`));
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4437
4489
|
async function isPortAvailable(port, host = "localhost") {
|
|
4438
4490
|
try {
|
|
4439
4491
|
await fetch(`http://${host}:${port}`);
|
|
@@ -4990,7 +5042,7 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
|
|
|
4990
5042
|
try {
|
|
4991
5043
|
const projectPath = path6.resolve(options.path);
|
|
4992
5044
|
const { promises: fs10 } = await import("fs");
|
|
4993
|
-
|
|
5045
|
+
displayPackageVersions(projectPath);
|
|
4994
5046
|
const builtWidgets = await buildWidgets(projectPath);
|
|
4995
5047
|
console.log(source_default.gray("Building TypeScript..."));
|
|
4996
5048
|
await runCommand("npx", ["tsc"], projectPath);
|
|
@@ -5054,7 +5106,7 @@ program.command("dev").description("Run development server with auto-reload and
|
|
|
5054
5106
|
let port = parseInt(options.port, 10);
|
|
5055
5107
|
const host = options.host;
|
|
5056
5108
|
const useHmr = options.hmr !== false;
|
|
5057
|
-
|
|
5109
|
+
displayPackageVersions(projectPath);
|
|
5058
5110
|
if (!await isPortAvailable(port, host)) {
|
|
5059
5111
|
console.log(source_default.yellow.bold(`\u26A0\uFE0F Port ${port} is already in use`));
|
|
5060
5112
|
const availablePort = await findAvailablePort2(port, host);
|
|
@@ -5062,22 +5114,26 @@ program.command("dev").description("Run development server with auto-reload and
|
|
|
5062
5114
|
port = availablePort;
|
|
5063
5115
|
}
|
|
5064
5116
|
const serverFile = await findServerFile(projectPath);
|
|
5117
|
+
const mcpUrl = `http://${host}:${port}`;
|
|
5065
5118
|
process.env.PORT = String(port);
|
|
5066
5119
|
process.env.HOST = host;
|
|
5067
5120
|
process.env.NODE_ENV = "development";
|
|
5121
|
+
process.env.MCP_URL = mcpUrl;
|
|
5068
5122
|
if (!useHmr) {
|
|
5069
5123
|
console.log(source_default.gray("HMR disabled, using tsx watch (full restart)"));
|
|
5070
5124
|
const processes = [];
|
|
5125
|
+
const mcpUrl2 = `http://${host}:${port}`;
|
|
5071
5126
|
const env2 = {
|
|
5072
5127
|
PORT: String(port),
|
|
5073
5128
|
HOST: host,
|
|
5074
|
-
NODE_ENV: "development"
|
|
5129
|
+
NODE_ENV: "development",
|
|
5130
|
+
MCP_URL: mcpUrl2
|
|
5075
5131
|
};
|
|
5076
|
-
const { createRequire:
|
|
5132
|
+
const { createRequire: createRequire3 } = await import("module");
|
|
5077
5133
|
let cmd;
|
|
5078
5134
|
let args;
|
|
5079
5135
|
try {
|
|
5080
|
-
const projectRequire =
|
|
5136
|
+
const projectRequire = createRequire3(
|
|
5081
5137
|
path6.join(projectPath, "package.json")
|
|
5082
5138
|
);
|
|
5083
5139
|
const tsxPkgPath = projectRequire.resolve("tsx/package.json");
|
|
@@ -5143,10 +5199,10 @@ program.command("dev").description("Run development server with auto-reload and
|
|
|
5143
5199
|
const chokidarModule = await import("chokidar");
|
|
5144
5200
|
const chokidar = chokidarModule.default || chokidarModule;
|
|
5145
5201
|
const { pathToFileURL } = await import("url");
|
|
5146
|
-
const { createRequire } = await import("module");
|
|
5202
|
+
const { createRequire: createRequire2 } = await import("module");
|
|
5147
5203
|
let tsImport = null;
|
|
5148
5204
|
try {
|
|
5149
|
-
const projectRequire =
|
|
5205
|
+
const projectRequire = createRequire2(
|
|
5150
5206
|
path6.join(projectPath, "package.json")
|
|
5151
5207
|
);
|
|
5152
5208
|
const tsxApiPath = projectRequire.resolve("tsx/esm/api");
|