mcp-use 1.1.8-canary.0 → 1.1.8
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.
|
@@ -939,7 +939,28 @@ if (container && Component) {
|
|
|
939
939
|
}
|
|
940
940
|
let html = "";
|
|
941
941
|
try {
|
|
942
|
-
html =
|
|
942
|
+
html = (0, import_node_fs2.readFileSync)((0, import_node_path.join)(tempDir, widget.name, "index.html"), "utf8");
|
|
943
|
+
const mcpUrl = process.env.MCP_URL || "/";
|
|
944
|
+
if (mcpUrl && html) {
|
|
945
|
+
const htmlWithoutComments = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
946
|
+
const baseTagRegex = /<base\s+[^>]*\/?>/i;
|
|
947
|
+
if (baseTagRegex.test(htmlWithoutComments)) {
|
|
948
|
+
const actualBaseTagMatch = html.match(/<base\s+[^>]*\/?>/i);
|
|
949
|
+
if (actualBaseTagMatch) {
|
|
950
|
+
html = html.replace(actualBaseTagMatch[0], `<base href="${mcpUrl}" />`);
|
|
951
|
+
}
|
|
952
|
+
} else {
|
|
953
|
+
const headTagRegex = /<head[^>]*>/i;
|
|
954
|
+
if (headTagRegex.test(html)) {
|
|
955
|
+
html = html.replace(headTagRegex, (match) => `${match}
|
|
956
|
+
<base href="${mcpUrl}" />`);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
html = html.replace(/src="\/mcp-use\/widgets\/([^"]+)"/g, `src="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
961
|
+
html = html.replace(/href="\/mcp-use\/widgets\/([^"]+)"/g, `href="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
962
|
+
html = html.replace(/<head[^>]*>/i, `<head>
|
|
963
|
+
<script>window.__getFile = (filename) => { return "${this.serverBaseUrl}/mcp-use/widgets/${widget.name}/"+filename }</script>`);
|
|
943
964
|
} catch (error) {
|
|
944
965
|
console.error(`Failed to read html template for widget ${widget.name}`, error);
|
|
945
966
|
}
|
|
@@ -1021,6 +1042,27 @@ if (container && Component) {
|
|
|
1021
1042
|
let html = "";
|
|
1022
1043
|
try {
|
|
1023
1044
|
html = (0, import_node_fs2.readFileSync)(indexPath, "utf8");
|
|
1045
|
+
const mcpUrl = process.env.MCP_URL || "/";
|
|
1046
|
+
if (mcpUrl && html) {
|
|
1047
|
+
const htmlWithoutComments = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
1048
|
+
const baseTagRegex = /<base\s+[^>]*\/?>/i;
|
|
1049
|
+
if (baseTagRegex.test(htmlWithoutComments)) {
|
|
1050
|
+
const actualBaseTagMatch = html.match(/<base\s+[^>]*\/?>/i);
|
|
1051
|
+
if (actualBaseTagMatch) {
|
|
1052
|
+
html = html.replace(actualBaseTagMatch[0], `<base href="${mcpUrl}" />`);
|
|
1053
|
+
}
|
|
1054
|
+
} else {
|
|
1055
|
+
const headTagRegex = /<head[^>]*>/i;
|
|
1056
|
+
if (headTagRegex.test(html)) {
|
|
1057
|
+
html = html.replace(headTagRegex, (match) => `${match}
|
|
1058
|
+
<base href="${mcpUrl}" />`);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
html = html.replace(/src="\/mcp-use\/widgets\/([^"]+)"/g, `src="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1062
|
+
html = html.replace(/href="\/mcp-use\/widgets\/([^"]+)"/g, `href="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1063
|
+
html = html.replace(/<head[^>]*>/i, `<head>
|
|
1064
|
+
<script>window.__getFile = (filename) => { return "${this.serverBaseUrl}/mcp-use/widgets/${widgetName}/"+filename }</script>`);
|
|
1065
|
+
}
|
|
1024
1066
|
} catch (error) {
|
|
1025
1067
|
console.error(`[WIDGET] Failed to read ${widgetName}/index.html:`, error);
|
|
1026
1068
|
continue;
|
|
@@ -1263,7 +1305,12 @@ if (container && Component) {
|
|
|
1263
1305
|
});
|
|
1264
1306
|
this.app.get("/mcp-use/widgets/:widget", (req, res, next) => {
|
|
1265
1307
|
const filePath = (0, import_node_path.join)(process.cwd(), "dist", "resources", "widgets", req.params.widget, "index.html");
|
|
1266
|
-
|
|
1308
|
+
let html = (0, import_node_fs2.readFileSync)(filePath, "utf8");
|
|
1309
|
+
html = html.replace(/src="\/mcp-use\/widgets\/([^"]+)"/g, `src="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1310
|
+
html = html.replace(/href="\/mcp-use\/widgets\/([^"]+)"/g, `href="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1311
|
+
html = html.replace(/<head[^>]*>/i, `<head>
|
|
1312
|
+
<script>window.__getFile = (filename) => { return "${this.serverBaseUrl}/mcp-use/widgets/${req.params.widget}/"+filename }</script>`);
|
|
1313
|
+
res.send(html);
|
|
1267
1314
|
});
|
|
1268
1315
|
}
|
|
1269
1316
|
/**
|
package/dist/src/server/index.js
CHANGED
|
@@ -901,7 +901,28 @@ if (container && Component) {
|
|
|
901
901
|
}
|
|
902
902
|
let html = "";
|
|
903
903
|
try {
|
|
904
|
-
html =
|
|
904
|
+
html = readFileSync(join(tempDir, widget.name, "index.html"), "utf8");
|
|
905
|
+
const mcpUrl = process.env.MCP_URL || "/";
|
|
906
|
+
if (mcpUrl && html) {
|
|
907
|
+
const htmlWithoutComments = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
908
|
+
const baseTagRegex = /<base\s+[^>]*\/?>/i;
|
|
909
|
+
if (baseTagRegex.test(htmlWithoutComments)) {
|
|
910
|
+
const actualBaseTagMatch = html.match(/<base\s+[^>]*\/?>/i);
|
|
911
|
+
if (actualBaseTagMatch) {
|
|
912
|
+
html = html.replace(actualBaseTagMatch[0], `<base href="${mcpUrl}" />`);
|
|
913
|
+
}
|
|
914
|
+
} else {
|
|
915
|
+
const headTagRegex = /<head[^>]*>/i;
|
|
916
|
+
if (headTagRegex.test(html)) {
|
|
917
|
+
html = html.replace(headTagRegex, (match) => `${match}
|
|
918
|
+
<base href="${mcpUrl}" />`);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
html = html.replace(/src="\/mcp-use\/widgets\/([^"]+)"/g, `src="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
923
|
+
html = html.replace(/href="\/mcp-use\/widgets\/([^"]+)"/g, `href="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
924
|
+
html = html.replace(/<head[^>]*>/i, `<head>
|
|
925
|
+
<script>window.__getFile = (filename) => { return "${this.serverBaseUrl}/mcp-use/widgets/${widget.name}/"+filename }</script>`);
|
|
905
926
|
} catch (error) {
|
|
906
927
|
console.error(`Failed to read html template for widget ${widget.name}`, error);
|
|
907
928
|
}
|
|
@@ -983,6 +1004,27 @@ if (container && Component) {
|
|
|
983
1004
|
let html = "";
|
|
984
1005
|
try {
|
|
985
1006
|
html = readFileSync(indexPath, "utf8");
|
|
1007
|
+
const mcpUrl = process.env.MCP_URL || "/";
|
|
1008
|
+
if (mcpUrl && html) {
|
|
1009
|
+
const htmlWithoutComments = html.replace(/<!--[\s\S]*?-->/g, "");
|
|
1010
|
+
const baseTagRegex = /<base\s+[^>]*\/?>/i;
|
|
1011
|
+
if (baseTagRegex.test(htmlWithoutComments)) {
|
|
1012
|
+
const actualBaseTagMatch = html.match(/<base\s+[^>]*\/?>/i);
|
|
1013
|
+
if (actualBaseTagMatch) {
|
|
1014
|
+
html = html.replace(actualBaseTagMatch[0], `<base href="${mcpUrl}" />`);
|
|
1015
|
+
}
|
|
1016
|
+
} else {
|
|
1017
|
+
const headTagRegex = /<head[^>]*>/i;
|
|
1018
|
+
if (headTagRegex.test(html)) {
|
|
1019
|
+
html = html.replace(headTagRegex, (match) => `${match}
|
|
1020
|
+
<base href="${mcpUrl}" />`);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
html = html.replace(/src="\/mcp-use\/widgets\/([^"]+)"/g, `src="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1024
|
+
html = html.replace(/href="\/mcp-use\/widgets\/([^"]+)"/g, `href="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1025
|
+
html = html.replace(/<head[^>]*>/i, `<head>
|
|
1026
|
+
<script>window.__getFile = (filename) => { return "${this.serverBaseUrl}/mcp-use/widgets/${widgetName}/"+filename }</script>`);
|
|
1027
|
+
}
|
|
986
1028
|
} catch (error) {
|
|
987
1029
|
console.error(`[WIDGET] Failed to read ${widgetName}/index.html:`, error);
|
|
988
1030
|
continue;
|
|
@@ -1225,7 +1267,12 @@ if (container && Component) {
|
|
|
1225
1267
|
});
|
|
1226
1268
|
this.app.get("/mcp-use/widgets/:widget", (req, res, next) => {
|
|
1227
1269
|
const filePath = join(process.cwd(), "dist", "resources", "widgets", req.params.widget, "index.html");
|
|
1228
|
-
|
|
1270
|
+
let html = readFileSync(filePath, "utf8");
|
|
1271
|
+
html = html.replace(/src="\/mcp-use\/widgets\/([^"]+)"/g, `src="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1272
|
+
html = html.replace(/href="\/mcp-use\/widgets\/([^"]+)"/g, `href="${this.serverBaseUrl}/mcp-use/widgets/$1"`);
|
|
1273
|
+
html = html.replace(/<head[^>]*>/i, `<head>
|
|
1274
|
+
<script>window.__getFile = (filename) => { return "${this.serverBaseUrl}/mcp-use/widgets/${req.params.widget}/"+filename }</script>`);
|
|
1275
|
+
res.send(html);
|
|
1229
1276
|
});
|
|
1230
1277
|
}
|
|
1231
1278
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../src/server/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,cAAc,EACd,oBAAoB,EAIrB,MAAM,kBAAkB,CAAA;AAGzB,OAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AAc/C,qBAAa,S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