@mcp-use/cli 2.3.1-canary.2 → 2.3.1-canary.4
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 +40 -5
- package/dist/index.mjs +40 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1194,13 +1194,10 @@ async function waitForServer(port, host = "localhost", maxAttempts = 30) {
|
|
|
1194
1194
|
for (let i = 0; i < maxAttempts; i++) {
|
|
1195
1195
|
const controller = new AbortController();
|
|
1196
1196
|
try {
|
|
1197
|
-
const response = await fetch(`http://${host}:${port}/
|
|
1198
|
-
headers: {
|
|
1199
|
-
Accept: "text/event-stream"
|
|
1200
|
-
},
|
|
1197
|
+
const response = await fetch(`http://${host}:${port}/inspector/health`, {
|
|
1201
1198
|
signal: controller.signal
|
|
1202
1199
|
});
|
|
1203
|
-
if (response.
|
|
1200
|
+
if (response.ok) {
|
|
1204
1201
|
return true;
|
|
1205
1202
|
}
|
|
1206
1203
|
} catch {
|
|
@@ -1518,6 +1515,44 @@ if (container && Component) {
|
|
|
1518
1515
|
}
|
|
1519
1516
|
}
|
|
1520
1517
|
});
|
|
1518
|
+
const mcpServerUrl = process.env.MCP_SERVER_URL;
|
|
1519
|
+
if (mcpServerUrl) {
|
|
1520
|
+
try {
|
|
1521
|
+
const htmlPath = import_node_path3.default.join(outDir, "index.html");
|
|
1522
|
+
let html = await fs3.readFile(htmlPath, "utf8");
|
|
1523
|
+
const injectionScript = `<script>window.__getFile = (filename) => { return "${mcpUrl}/${widgetName}/"+filename }; window.__mcpPublicUrl = "${mcpServerUrl}/mcp-use/public"; window.__mcpPublicAssetsUrl = "${mcpUrl}/public";</script>`;
|
|
1524
|
+
if (!html.includes("window.__mcpPublicUrl")) {
|
|
1525
|
+
html = html.replace(
|
|
1526
|
+
/<head[^>]*>/i,
|
|
1527
|
+
`<head>
|
|
1528
|
+
${injectionScript}`
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
if (/<base\s+[^>]*\/?>/i.test(html)) {
|
|
1532
|
+
html = html.replace(
|
|
1533
|
+
/<base\s+[^>]*\/?>/i,
|
|
1534
|
+
`<base href="${mcpServerUrl}">`
|
|
1535
|
+
);
|
|
1536
|
+
} else {
|
|
1537
|
+
html = html.replace(
|
|
1538
|
+
injectionScript,
|
|
1539
|
+
`${injectionScript}
|
|
1540
|
+
<base href="${mcpServerUrl}">`
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
await fs3.writeFile(htmlPath, html, "utf8");
|
|
1544
|
+
console.log(
|
|
1545
|
+
import_chalk3.default.gray(` \u2192 Injected MCP_SERVER_URL into ${widgetName}`)
|
|
1546
|
+
);
|
|
1547
|
+
} catch (error) {
|
|
1548
|
+
console.warn(
|
|
1549
|
+
import_chalk3.default.yellow(
|
|
1550
|
+
` \u26A0 Failed to post-process HTML for ${widgetName}:`,
|
|
1551
|
+
error
|
|
1552
|
+
)
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1521
1556
|
builtWidgets.push({
|
|
1522
1557
|
name: widgetName,
|
|
1523
1558
|
metadata: widgetMetadata
|
package/dist/index.mjs
CHANGED
|
@@ -1173,13 +1173,10 @@ async function waitForServer(port, host = "localhost", maxAttempts = 30) {
|
|
|
1173
1173
|
for (let i = 0; i < maxAttempts; i++) {
|
|
1174
1174
|
const controller = new AbortController();
|
|
1175
1175
|
try {
|
|
1176
|
-
const response = await fetch(`http://${host}:${port}/
|
|
1177
|
-
headers: {
|
|
1178
|
-
Accept: "text/event-stream"
|
|
1179
|
-
},
|
|
1176
|
+
const response = await fetch(`http://${host}:${port}/inspector/health`, {
|
|
1180
1177
|
signal: controller.signal
|
|
1181
1178
|
});
|
|
1182
|
-
if (response.
|
|
1179
|
+
if (response.ok) {
|
|
1183
1180
|
return true;
|
|
1184
1181
|
}
|
|
1185
1182
|
} catch {
|
|
@@ -1497,6 +1494,44 @@ if (container && Component) {
|
|
|
1497
1494
|
}
|
|
1498
1495
|
}
|
|
1499
1496
|
});
|
|
1497
|
+
const mcpServerUrl = process.env.MCP_SERVER_URL;
|
|
1498
|
+
if (mcpServerUrl) {
|
|
1499
|
+
try {
|
|
1500
|
+
const htmlPath = path3.join(outDir, "index.html");
|
|
1501
|
+
let html = await fs3.readFile(htmlPath, "utf8");
|
|
1502
|
+
const injectionScript = `<script>window.__getFile = (filename) => { return "${mcpUrl}/${widgetName}/"+filename }; window.__mcpPublicUrl = "${mcpServerUrl}/mcp-use/public"; window.__mcpPublicAssetsUrl = "${mcpUrl}/public";</script>`;
|
|
1503
|
+
if (!html.includes("window.__mcpPublicUrl")) {
|
|
1504
|
+
html = html.replace(
|
|
1505
|
+
/<head[^>]*>/i,
|
|
1506
|
+
`<head>
|
|
1507
|
+
${injectionScript}`
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
if (/<base\s+[^>]*\/?>/i.test(html)) {
|
|
1511
|
+
html = html.replace(
|
|
1512
|
+
/<base\s+[^>]*\/?>/i,
|
|
1513
|
+
`<base href="${mcpServerUrl}">`
|
|
1514
|
+
);
|
|
1515
|
+
} else {
|
|
1516
|
+
html = html.replace(
|
|
1517
|
+
injectionScript,
|
|
1518
|
+
`${injectionScript}
|
|
1519
|
+
<base href="${mcpServerUrl}">`
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1522
|
+
await fs3.writeFile(htmlPath, html, "utf8");
|
|
1523
|
+
console.log(
|
|
1524
|
+
chalk3.gray(` \u2192 Injected MCP_SERVER_URL into ${widgetName}`)
|
|
1525
|
+
);
|
|
1526
|
+
} catch (error) {
|
|
1527
|
+
console.warn(
|
|
1528
|
+
chalk3.yellow(
|
|
1529
|
+
` \u26A0 Failed to post-process HTML for ${widgetName}:`,
|
|
1530
|
+
error
|
|
1531
|
+
)
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1500
1535
|
builtWidgets.push({
|
|
1501
1536
|
name: widgetName,
|
|
1502
1537
|
metadata: widgetMetadata
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/cli",
|
|
3
|
-
"version": "2.3.1-canary.
|
|
3
|
+
"version": "2.3.1-canary.4",
|
|
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": "
|
|
48
|
-
"
|
|
47
|
+
"@mcp-use/inspector": "0.7.1-canary.4",
|
|
48
|
+
"mcp-use": "1.5.1-canary.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^20.0.0",
|