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