@mcp-use/cli 2.2.5 → 2.3.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.js CHANGED
@@ -1192,12 +1192,20 @@ async function findAvailablePort2(startPort, host = "localhost") {
1192
1192
  }
1193
1193
  async function waitForServer(port, host = "localhost", maxAttempts = 30) {
1194
1194
  for (let i = 0; i < maxAttempts; i++) {
1195
+ const controller = new AbortController();
1195
1196
  try {
1196
- const response = await fetch(`http://${host}:${port}/mcp`);
1197
+ const response = await fetch(`http://${host}:${port}/mcp`, {
1198
+ headers: {
1199
+ Accept: "text/event-stream"
1200
+ },
1201
+ signal: controller.signal
1202
+ });
1197
1203
  if (response.status !== 404) {
1198
1204
  return true;
1199
1205
  }
1200
1206
  } catch {
1207
+ } finally {
1208
+ controller.abort();
1201
1209
  }
1202
1210
  await new Promise((resolve) => setTimeout(resolve, 1e3));
1203
1211
  }
@@ -1323,15 +1331,30 @@ async function buildWidgets(projectPath) {
1323
1331
  );
1324
1332
  return [];
1325
1333
  }
1326
- let entries = [];
1334
+ const entries = [];
1327
1335
  try {
1328
- const files = await fs3.readdir(resourcesDir);
1329
- entries = files.filter((f) => {
1330
- if (f.startsWith("._") || f.startsWith(".DS_Store")) {
1331
- return false;
1336
+ const files = await fs3.readdir(resourcesDir, { withFileTypes: true });
1337
+ for (const dirent of files) {
1338
+ if (dirent.name.startsWith("._") || dirent.name.startsWith(".DS_Store")) {
1339
+ continue;
1332
1340
  }
1333
- return f.endsWith(".tsx") || f.endsWith(".ts");
1334
- }).map((f) => import_node_path3.default.join(resourcesDir, f));
1341
+ if (dirent.isFile() && (dirent.name.endsWith(".tsx") || dirent.name.endsWith(".ts"))) {
1342
+ entries.push({
1343
+ name: dirent.name.replace(/\.tsx?$/, ""),
1344
+ path: import_node_path3.default.join(resourcesDir, dirent.name)
1345
+ });
1346
+ } else if (dirent.isDirectory()) {
1347
+ const widgetPath = import_node_path3.default.join(resourcesDir, dirent.name, "widget.tsx");
1348
+ try {
1349
+ await fs3.access(widgetPath);
1350
+ entries.push({
1351
+ name: dirent.name,
1352
+ path: widgetPath
1353
+ });
1354
+ } catch {
1355
+ }
1356
+ }
1357
+ }
1335
1358
  } catch (error) {
1336
1359
  console.log(import_chalk3.default.gray("No widgets found in resources/ directory"));
1337
1360
  return [];
@@ -1345,8 +1368,8 @@ async function buildWidgets(projectPath) {
1345
1368
  const tailwindcss = (await import("@tailwindcss/vite")).default;
1346
1369
  const builtWidgets = [];
1347
1370
  for (const entry of entries) {
1348
- const baseName = import_node_path3.default.basename(entry).replace(/\.tsx?$/, "");
1349
- const widgetName = baseName;
1371
+ const widgetName = entry.name;
1372
+ const entryPath = entry.path;
1350
1373
  console.log(import_chalk3.default.gray(` - Building ${widgetName}...`));
1351
1374
  const tempDir = import_node_path3.default.join(projectPath, ".mcp-use", widgetName);
1352
1375
  await fs3.mkdir(tempDir, { recursive: true });
@@ -1360,7 +1383,7 @@ async function buildWidgets(projectPath) {
1360
1383
  const entryContent = `import React from 'react'
1361
1384
  import { createRoot } from 'react-dom/client'
1362
1385
  import './styles.css'
1363
- import Component from '${entry}'
1386
+ import Component from '${entryPath}'
1364
1387
 
1365
1388
  const container = document.getElementById('widget-root')
1366
1389
  if (container && Component) {
@@ -1411,6 +1434,20 @@ if (container && Component) {
1411
1434
  server: {
1412
1435
  middlewareMode: true
1413
1436
  },
1437
+ ssr: {
1438
+ // Force Vite to transform these packages in SSR instead of using external requires
1439
+ noExternal: ["@openai/apps-sdk-ui", "react-router"]
1440
+ },
1441
+ define: {
1442
+ // Define process.env for SSR context
1443
+ "process.env.NODE_ENV": JSON.stringify(
1444
+ process.env.NODE_ENV || "development"
1445
+ ),
1446
+ "import.meta.env.DEV": true,
1447
+ "import.meta.env.PROD": false,
1448
+ "import.meta.env.MODE": JSON.stringify("development"),
1449
+ "import.meta.env.SSR": true
1450
+ },
1414
1451
  clearScreen: false,
1415
1452
  logLevel: "silent",
1416
1453
  customLogger: {
@@ -1429,7 +1466,7 @@ if (container && Component) {
1429
1466
  }
1430
1467
  });
1431
1468
  try {
1432
- const mod = await metadataServer.ssrLoadModule(entry);
1469
+ const mod = await metadataServer.ssrLoadModule(entryPath);
1433
1470
  if (mod.widgetMetadata) {
1434
1471
  widgetMetadata = {
1435
1472
  ...mod.widgetMetadata,
@@ -1501,6 +1538,16 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
1501
1538
  console.log(import_chalk3.default.gray("Building TypeScript..."));
1502
1539
  await runCommand("npx", ["tsc"], projectPath);
1503
1540
  console.log(import_chalk3.default.green("\u2713 TypeScript build complete!"));
1541
+ const publicDir = import_node_path3.default.join(projectPath, "public");
1542
+ try {
1543
+ await fs3.access(publicDir);
1544
+ console.log(import_chalk3.default.gray("Copying public assets..."));
1545
+ await fs3.cp(publicDir, import_node_path3.default.join(projectPath, "dist", "public"), {
1546
+ recursive: true
1547
+ });
1548
+ console.log(import_chalk3.default.green("\u2713 Public assets copied"));
1549
+ } catch {
1550
+ }
1504
1551
  const manifestPath = import_node_path3.default.join(projectPath, "dist", "mcp-use.json");
1505
1552
  let existingManifest = {};
1506
1553
  try {
package/dist/index.mjs CHANGED
@@ -1171,12 +1171,20 @@ async function findAvailablePort2(startPort, host = "localhost") {
1171
1171
  }
1172
1172
  async function waitForServer(port, host = "localhost", maxAttempts = 30) {
1173
1173
  for (let i = 0; i < maxAttempts; i++) {
1174
+ const controller = new AbortController();
1174
1175
  try {
1175
- const response = await fetch(`http://${host}:${port}/mcp`);
1176
+ const response = await fetch(`http://${host}:${port}/mcp`, {
1177
+ headers: {
1178
+ Accept: "text/event-stream"
1179
+ },
1180
+ signal: controller.signal
1181
+ });
1176
1182
  if (response.status !== 404) {
1177
1183
  return true;
1178
1184
  }
1179
1185
  } catch {
1186
+ } finally {
1187
+ controller.abort();
1180
1188
  }
1181
1189
  await new Promise((resolve) => setTimeout(resolve, 1e3));
1182
1190
  }
@@ -1302,15 +1310,30 @@ async function buildWidgets(projectPath) {
1302
1310
  );
1303
1311
  return [];
1304
1312
  }
1305
- let entries = [];
1313
+ const entries = [];
1306
1314
  try {
1307
- const files = await fs3.readdir(resourcesDir);
1308
- entries = files.filter((f) => {
1309
- if (f.startsWith("._") || f.startsWith(".DS_Store")) {
1310
- return false;
1315
+ const files = await fs3.readdir(resourcesDir, { withFileTypes: true });
1316
+ for (const dirent of files) {
1317
+ if (dirent.name.startsWith("._") || dirent.name.startsWith(".DS_Store")) {
1318
+ continue;
1311
1319
  }
1312
- return f.endsWith(".tsx") || f.endsWith(".ts");
1313
- }).map((f) => path3.join(resourcesDir, f));
1320
+ if (dirent.isFile() && (dirent.name.endsWith(".tsx") || dirent.name.endsWith(".ts"))) {
1321
+ entries.push({
1322
+ name: dirent.name.replace(/\.tsx?$/, ""),
1323
+ path: path3.join(resourcesDir, dirent.name)
1324
+ });
1325
+ } else if (dirent.isDirectory()) {
1326
+ const widgetPath = path3.join(resourcesDir, dirent.name, "widget.tsx");
1327
+ try {
1328
+ await fs3.access(widgetPath);
1329
+ entries.push({
1330
+ name: dirent.name,
1331
+ path: widgetPath
1332
+ });
1333
+ } catch {
1334
+ }
1335
+ }
1336
+ }
1314
1337
  } catch (error) {
1315
1338
  console.log(chalk3.gray("No widgets found in resources/ directory"));
1316
1339
  return [];
@@ -1324,8 +1347,8 @@ async function buildWidgets(projectPath) {
1324
1347
  const tailwindcss = (await import("@tailwindcss/vite")).default;
1325
1348
  const builtWidgets = [];
1326
1349
  for (const entry of entries) {
1327
- const baseName = path3.basename(entry).replace(/\.tsx?$/, "");
1328
- const widgetName = baseName;
1350
+ const widgetName = entry.name;
1351
+ const entryPath = entry.path;
1329
1352
  console.log(chalk3.gray(` - Building ${widgetName}...`));
1330
1353
  const tempDir = path3.join(projectPath, ".mcp-use", widgetName);
1331
1354
  await fs3.mkdir(tempDir, { recursive: true });
@@ -1339,7 +1362,7 @@ async function buildWidgets(projectPath) {
1339
1362
  const entryContent = `import React from 'react'
1340
1363
  import { createRoot } from 'react-dom/client'
1341
1364
  import './styles.css'
1342
- import Component from '${entry}'
1365
+ import Component from '${entryPath}'
1343
1366
 
1344
1367
  const container = document.getElementById('widget-root')
1345
1368
  if (container && Component) {
@@ -1390,6 +1413,20 @@ if (container && Component) {
1390
1413
  server: {
1391
1414
  middlewareMode: true
1392
1415
  },
1416
+ ssr: {
1417
+ // Force Vite to transform these packages in SSR instead of using external requires
1418
+ noExternal: ["@openai/apps-sdk-ui", "react-router"]
1419
+ },
1420
+ define: {
1421
+ // Define process.env for SSR context
1422
+ "process.env.NODE_ENV": JSON.stringify(
1423
+ process.env.NODE_ENV || "development"
1424
+ ),
1425
+ "import.meta.env.DEV": true,
1426
+ "import.meta.env.PROD": false,
1427
+ "import.meta.env.MODE": JSON.stringify("development"),
1428
+ "import.meta.env.SSR": true
1429
+ },
1393
1430
  clearScreen: false,
1394
1431
  logLevel: "silent",
1395
1432
  customLogger: {
@@ -1408,7 +1445,7 @@ if (container && Component) {
1408
1445
  }
1409
1446
  });
1410
1447
  try {
1411
- const mod = await metadataServer.ssrLoadModule(entry);
1448
+ const mod = await metadataServer.ssrLoadModule(entryPath);
1412
1449
  if (mod.widgetMetadata) {
1413
1450
  widgetMetadata = {
1414
1451
  ...mod.widgetMetadata,
@@ -1480,6 +1517,16 @@ program.command("build").description("Build TypeScript and MCP UI widgets").opti
1480
1517
  console.log(chalk3.gray("Building TypeScript..."));
1481
1518
  await runCommand("npx", ["tsc"], projectPath);
1482
1519
  console.log(chalk3.green("\u2713 TypeScript build complete!"));
1520
+ const publicDir = path3.join(projectPath, "public");
1521
+ try {
1522
+ await fs3.access(publicDir);
1523
+ console.log(chalk3.gray("Copying public assets..."));
1524
+ await fs3.cp(publicDir, path3.join(projectPath, "dist", "public"), {
1525
+ recursive: true
1526
+ });
1527
+ console.log(chalk3.green("\u2713 Public assets copied"));
1528
+ } catch {
1529
+ }
1483
1530
  const manifestPath = path3.join(projectPath, "dist", "mcp-use.json");
1484
1531
  let existingManifest = {};
1485
1532
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-use/cli",
3
- "version": "2.2.5",
3
+ "version": "2.3.0-canary.2",
4
4
  "description": "Build tool for MCP UI widgets - bundles React components into standalone HTML pages for Model Context Protocol servers",
5
5
  "author": "mcp-use, Inc.",
6
6
  "license": "MIT",
@@ -44,8 +44,8 @@
44
44
  "tsx": "^4.0.0",
45
45
  "vite": "^6.0.0",
46
46
  "ws": "^8.18.0",
47
- "@mcp-use/inspector": "0.6.1",
48
- "mcp-use": "1.4.1"
47
+ "@mcp-use/inspector": "0.7.0-canary.2",
48
+ "mcp-use": "1.5.0-canary.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^20.0.0",