@mcp-use/cli 2.18.3 → 2.19.0-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.
- package/dist/index.cjs +115 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +115 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5454,10 +5454,97 @@ export default {
|
|
|
5454
5454
|
);
|
|
5455
5455
|
return builtWidgets;
|
|
5456
5456
|
}
|
|
5457
|
+
async function collectTsFiles(projectPath, includePatterns, excludePatterns) {
|
|
5458
|
+
const { promises: fs10 } = await import("fs");
|
|
5459
|
+
const literalFiles = [];
|
|
5460
|
+
const dirPrefixes = [];
|
|
5461
|
+
for (const pattern of includePatterns) {
|
|
5462
|
+
if (pattern.includes("*")) {
|
|
5463
|
+
const prefix = pattern.split("*")[0].replace(/\/+$/, "") || ".";
|
|
5464
|
+
dirPrefixes.push(prefix);
|
|
5465
|
+
} else {
|
|
5466
|
+
literalFiles.push(pattern);
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
const files = [];
|
|
5470
|
+
for (const file of literalFiles) {
|
|
5471
|
+
if (/\.tsx?$/.test(file) && !file.endsWith(".d.ts")) {
|
|
5472
|
+
try {
|
|
5473
|
+
await access(path7.join(projectPath, file));
|
|
5474
|
+
files.push(file);
|
|
5475
|
+
} catch {
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
const excludeSet = new Set(excludePatterns.map((e) => e.replace(/\*+/g, "")));
|
|
5480
|
+
for (const prefix of dirPrefixes) {
|
|
5481
|
+
const dirPath = path7.join(projectPath, prefix);
|
|
5482
|
+
try {
|
|
5483
|
+
const entries = await fs10.readdir(dirPath, { recursive: true });
|
|
5484
|
+
for (const entry of entries) {
|
|
5485
|
+
const entryStr = String(entry);
|
|
5486
|
+
const rel = path7.join(prefix, entryStr);
|
|
5487
|
+
if (/\.tsx?$/.test(entryStr) && !entryStr.endsWith(".d.ts") && !excludeSet.has(rel.split(path7.sep)[0])) {
|
|
5488
|
+
files.push(rel);
|
|
5489
|
+
}
|
|
5490
|
+
}
|
|
5491
|
+
} catch {
|
|
5492
|
+
}
|
|
5493
|
+
}
|
|
5494
|
+
return files;
|
|
5495
|
+
}
|
|
5496
|
+
async function transpileWithEsbuild(projectPath) {
|
|
5497
|
+
const esbuild = await import("esbuild");
|
|
5498
|
+
const { promises: fs10 } = await import("fs");
|
|
5499
|
+
const tsconfigPath = path7.join(projectPath, "tsconfig.json");
|
|
5500
|
+
let tsconfig = {};
|
|
5501
|
+
try {
|
|
5502
|
+
const raw = await fs10.readFile(tsconfigPath, "utf-8");
|
|
5503
|
+
tsconfig = JSON.parse(raw);
|
|
5504
|
+
} catch {
|
|
5505
|
+
}
|
|
5506
|
+
const compilerOptions = tsconfig.compilerOptions || {};
|
|
5507
|
+
const outDir = compilerOptions.outDir || "./dist";
|
|
5508
|
+
const includePatterns = tsconfig.include || ["**/*.ts", "**/*.tsx"];
|
|
5509
|
+
const excludePatterns = tsconfig.exclude || ["node_modules", "dist"];
|
|
5510
|
+
const files = await collectTsFiles(
|
|
5511
|
+
projectPath,
|
|
5512
|
+
includePatterns,
|
|
5513
|
+
excludePatterns
|
|
5514
|
+
);
|
|
5515
|
+
if (files.length === 0) {
|
|
5516
|
+
console.log(source_default.yellow(" No TypeScript files found to transpile."));
|
|
5517
|
+
return;
|
|
5518
|
+
}
|
|
5519
|
+
const jsxMap = {
|
|
5520
|
+
"react-jsx": "automatic",
|
|
5521
|
+
"react-jsxdev": "automatic",
|
|
5522
|
+
react: "transform",
|
|
5523
|
+
preserve: "preserve"
|
|
5524
|
+
};
|
|
5525
|
+
const jsx = jsxMap[compilerOptions.jsx] || void 0;
|
|
5526
|
+
const target = (compilerOptions.target || "ES2022").toLowerCase();
|
|
5527
|
+
const moduleStr = (compilerOptions.module || "ESNext").toLowerCase();
|
|
5528
|
+
const format = moduleStr.includes("commonjs") ? "cjs" : "esm";
|
|
5529
|
+
const outbase = compilerOptions.rootDir ? path7.resolve(projectPath, compilerOptions.rootDir) : projectPath;
|
|
5530
|
+
await esbuild.build({
|
|
5531
|
+
entryPoints: files.map((f) => path7.join(projectPath, f)),
|
|
5532
|
+
outdir: path7.join(projectPath, outDir),
|
|
5533
|
+
outbase,
|
|
5534
|
+
bundle: false,
|
|
5535
|
+
format,
|
|
5536
|
+
target,
|
|
5537
|
+
jsx,
|
|
5538
|
+
sourcemap: compilerOptions.sourceMap ?? true,
|
|
5539
|
+
tsconfig: tsconfigPath,
|
|
5540
|
+
platform: "node",
|
|
5541
|
+
logLevel: "warning"
|
|
5542
|
+
});
|
|
5543
|
+
}
|
|
5457
5544
|
program.command("build").description("Build TypeScript and MCP UI widgets").option("-p, --path <path>", "Path to project directory", process.cwd()).option("--with-inspector", "Include inspector in production build").option(
|
|
5458
5545
|
"--inline",
|
|
5459
5546
|
"Inline all JS/CSS into HTML (required for VS Code MCP Apps)"
|
|
5460
|
-
).option("--no-inline", "Keep JS/CSS as separate files (default)").action(async (options) => {
|
|
5547
|
+
).option("--no-inline", "Keep JS/CSS as separate files (default)").option("--no-typecheck", "Skip TypeScript type checking (faster builds)").action(async (options) => {
|
|
5461
5548
|
try {
|
|
5462
5549
|
const projectPath = path7.resolve(options.path);
|
|
5463
5550
|
const { promises: fs10 } = await import("fs");
|
|
@@ -5476,15 +5563,34 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
|
|
|
5476
5563
|
console.log(source_default.green("\u2713 Tool registry types generated"));
|
|
5477
5564
|
}
|
|
5478
5565
|
console.log(source_default.gray("Building TypeScript..."));
|
|
5479
|
-
await
|
|
5480
|
-
"node",
|
|
5481
|
-
[
|
|
5482
|
-
"--max-old-space-size=4096",
|
|
5483
|
-
path7.join(projectPath, "node_modules", "typescript", "bin", "tsc")
|
|
5484
|
-
],
|
|
5485
|
-
projectPath
|
|
5486
|
-
).promise;
|
|
5566
|
+
await transpileWithEsbuild(projectPath);
|
|
5487
5567
|
console.log(source_default.green("\u2713 TypeScript build complete!"));
|
|
5568
|
+
if (options.typecheck !== false) {
|
|
5569
|
+
console.log(source_default.gray("Type checking..."));
|
|
5570
|
+
try {
|
|
5571
|
+
await runCommand(
|
|
5572
|
+
"node",
|
|
5573
|
+
[
|
|
5574
|
+
"--max-old-space-size=4096",
|
|
5575
|
+
path7.join(
|
|
5576
|
+
projectPath,
|
|
5577
|
+
"node_modules",
|
|
5578
|
+
"typescript",
|
|
5579
|
+
"bin",
|
|
5580
|
+
"tsc"
|
|
5581
|
+
),
|
|
5582
|
+
"--noEmit"
|
|
5583
|
+
],
|
|
5584
|
+
projectPath
|
|
5585
|
+
).promise;
|
|
5586
|
+
console.log(source_default.green("\u2713 Type check passed!"));
|
|
5587
|
+
} catch {
|
|
5588
|
+
console.error(
|
|
5589
|
+
source_default.red("\u2717 Type check failed.") + source_default.gray(" Use --no-typecheck to skip.")
|
|
5590
|
+
);
|
|
5591
|
+
process.exit(1);
|
|
5592
|
+
}
|
|
5593
|
+
}
|
|
5488
5594
|
let entryPoint;
|
|
5489
5595
|
if (sourceServerFile) {
|
|
5490
5596
|
const baseName = path7.basename(sourceServerFile, ".ts") + ".js";
|