mcp-use 1.2.5-canary.3 → 1.2.5-canary.5
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.
|
@@ -465,7 +465,7 @@ var McpServer = class {
|
|
|
465
465
|
return new Proxy(this, {
|
|
466
466
|
get(target, prop) {
|
|
467
467
|
if (prop === "use") {
|
|
468
|
-
return (...args) => {
|
|
468
|
+
return async (...args) => {
|
|
469
469
|
const hasPath = typeof args[0] === "string";
|
|
470
470
|
const path = hasPath ? args[0] : "*";
|
|
471
471
|
const handlers = hasPath ? args.slice(1) : args;
|
|
@@ -479,7 +479,7 @@ var McpServer = class {
|
|
|
479
479
|
(h) => h.__isExpressMiddleware
|
|
480
480
|
);
|
|
481
481
|
if (hasExpressMiddleware) {
|
|
482
|
-
Promise.all(
|
|
482
|
+
await Promise.all(
|
|
483
483
|
adaptedHandlers.map(async (h) => {
|
|
484
484
|
if (h.__isExpressMiddleware) {
|
|
485
485
|
const adapted = await adaptConnectMiddleware(
|
|
@@ -499,12 +499,7 @@ var McpServer = class {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
})
|
|
502
|
-
)
|
|
503
|
-
console.error(
|
|
504
|
-
"[MIDDLEWARE] Failed to adapt Express middleware:",
|
|
505
|
-
err
|
|
506
|
-
);
|
|
507
|
-
});
|
|
502
|
+
);
|
|
508
503
|
return target;
|
|
509
504
|
}
|
|
510
505
|
return target.app.use(...args);
|
|
@@ -1288,7 +1283,6 @@ if (container && Component) {
|
|
|
1288
1283
|
error
|
|
1289
1284
|
);
|
|
1290
1285
|
}
|
|
1291
|
-
console.log("[WIDGET dev] Metadata:", metadata);
|
|
1292
1286
|
let html = "";
|
|
1293
1287
|
try {
|
|
1294
1288
|
html = await fsHelpers.readFileSync(
|
|
@@ -1405,14 +1399,26 @@ if (container && Component) {
|
|
|
1405
1399
|
this.setupWidgetRoutes();
|
|
1406
1400
|
const manifestPath = "./dist/mcp-use.json";
|
|
1407
1401
|
let widgets = [];
|
|
1402
|
+
let widgetsMetadata = {};
|
|
1408
1403
|
try {
|
|
1409
|
-
const manifestContent = await fsHelpers.readFileSync(
|
|
1404
|
+
const manifestContent = await fsHelpers.readFileSync(
|
|
1405
|
+
manifestPath,
|
|
1406
|
+
"utf8"
|
|
1407
|
+
);
|
|
1410
1408
|
const manifest = JSON.parse(manifestContent);
|
|
1411
|
-
if (manifest.widgets && Array.isArray(manifest.widgets)) {
|
|
1409
|
+
if (manifest.widgets && typeof manifest.widgets === "object" && !Array.isArray(manifest.widgets)) {
|
|
1410
|
+
widgets = Object.keys(manifest.widgets);
|
|
1411
|
+
widgetsMetadata = manifest.widgets;
|
|
1412
|
+
console.log(
|
|
1413
|
+
`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`
|
|
1414
|
+
);
|
|
1415
|
+
} else if (manifest.widgets && Array.isArray(manifest.widgets)) {
|
|
1412
1416
|
widgets = manifest.widgets;
|
|
1413
|
-
console.log(
|
|
1417
|
+
console.log(
|
|
1418
|
+
`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`
|
|
1419
|
+
);
|
|
1414
1420
|
} else {
|
|
1415
|
-
console.log("[WIDGETS] No widgets
|
|
1421
|
+
console.log("[WIDGETS] No widgets found in manifest");
|
|
1416
1422
|
}
|
|
1417
1423
|
} catch (error) {
|
|
1418
1424
|
console.log(
|
|
@@ -1433,9 +1439,7 @@ if (container && Component) {
|
|
|
1433
1439
|
}
|
|
1434
1440
|
}
|
|
1435
1441
|
if (widgets.length === 0) {
|
|
1436
|
-
console.log(
|
|
1437
|
-
"[WIDGETS] No built widgets found"
|
|
1438
|
-
);
|
|
1442
|
+
console.log("[WIDGETS] No built widgets found");
|
|
1439
1443
|
return;
|
|
1440
1444
|
}
|
|
1441
1445
|
console.log(
|
|
@@ -1444,7 +1448,6 @@ if (container && Component) {
|
|
|
1444
1448
|
for (const widgetName of widgets) {
|
|
1445
1449
|
const widgetPath = pathHelpers.join(widgetsDir, widgetName);
|
|
1446
1450
|
const indexPath = pathHelpers.join(widgetPath, "index.html");
|
|
1447
|
-
const metadataPath = pathHelpers.join(widgetPath, "metadata.json");
|
|
1448
1451
|
let html = "";
|
|
1449
1452
|
try {
|
|
1450
1453
|
html = await fsHelpers.readFileSync(indexPath, "utf8");
|
|
@@ -1491,25 +1494,14 @@ if (container && Component) {
|
|
|
1491
1494
|
);
|
|
1492
1495
|
continue;
|
|
1493
1496
|
}
|
|
1494
|
-
|
|
1497
|
+
const metadata = widgetsMetadata[widgetName] || {};
|
|
1495
1498
|
let props = {};
|
|
1496
1499
|
let description = `Widget: ${widgetName}`;
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
metadata = JSON.parse(metadataContent);
|
|
1503
|
-
if (metadata.description) {
|
|
1504
|
-
description = metadata.description;
|
|
1505
|
-
}
|
|
1506
|
-
if (metadata.inputs) {
|
|
1507
|
-
props = metadata.inputs;
|
|
1508
|
-
}
|
|
1509
|
-
} catch (error) {
|
|
1510
|
-
console.log(
|
|
1511
|
-
`[WIDGET] No metadata found for ${widgetName}, using defaults`
|
|
1512
|
-
);
|
|
1500
|
+
if (metadata.description) {
|
|
1501
|
+
description = metadata.description;
|
|
1502
|
+
}
|
|
1503
|
+
if (metadata.inputs) {
|
|
1504
|
+
props = metadata.inputs;
|
|
1513
1505
|
}
|
|
1514
1506
|
this.uiResource({
|
|
1515
1507
|
name: widgetName,
|
|
@@ -1787,9 +1779,27 @@ if (container && Component) {
|
|
|
1787
1779
|
await this.mountMcp();
|
|
1788
1780
|
await this.mountInspector();
|
|
1789
1781
|
if (isDeno) {
|
|
1782
|
+
const corsHeaders = {
|
|
1783
|
+
"Access-Control-Allow-Origin": "*",
|
|
1784
|
+
"Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type"
|
|
1785
|
+
};
|
|
1790
1786
|
globalThis.Deno.serve(
|
|
1791
1787
|
{ port: this.serverPort, hostname: this.serverHost },
|
|
1792
|
-
|
|
1788
|
+
async (req) => {
|
|
1789
|
+
if (req.method === "OPTIONS") {
|
|
1790
|
+
return new Response("ok", { headers: corsHeaders });
|
|
1791
|
+
}
|
|
1792
|
+
const response = await this.app.fetch(req);
|
|
1793
|
+
const newHeaders = new Headers(response.headers);
|
|
1794
|
+
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
1795
|
+
newHeaders.set(key, value);
|
|
1796
|
+
});
|
|
1797
|
+
return new Response(response.body, {
|
|
1798
|
+
status: response.status,
|
|
1799
|
+
statusText: response.statusText,
|
|
1800
|
+
headers: newHeaders
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1793
1803
|
);
|
|
1794
1804
|
console.log(
|
|
1795
1805
|
`[SERVER] Listening on http://${this.serverHost}:${this.serverPort}`
|
package/dist/src/server/index.js
CHANGED
|
@@ -427,7 +427,7 @@ var McpServer = class {
|
|
|
427
427
|
return new Proxy(this, {
|
|
428
428
|
get(target, prop) {
|
|
429
429
|
if (prop === "use") {
|
|
430
|
-
return (...args) => {
|
|
430
|
+
return async (...args) => {
|
|
431
431
|
const hasPath = typeof args[0] === "string";
|
|
432
432
|
const path = hasPath ? args[0] : "*";
|
|
433
433
|
const handlers = hasPath ? args.slice(1) : args;
|
|
@@ -441,7 +441,7 @@ var McpServer = class {
|
|
|
441
441
|
(h) => h.__isExpressMiddleware
|
|
442
442
|
);
|
|
443
443
|
if (hasExpressMiddleware) {
|
|
444
|
-
Promise.all(
|
|
444
|
+
await Promise.all(
|
|
445
445
|
adaptedHandlers.map(async (h) => {
|
|
446
446
|
if (h.__isExpressMiddleware) {
|
|
447
447
|
const adapted = await adaptConnectMiddleware(
|
|
@@ -461,12 +461,7 @@ var McpServer = class {
|
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
463
|
})
|
|
464
|
-
)
|
|
465
|
-
console.error(
|
|
466
|
-
"[MIDDLEWARE] Failed to adapt Express middleware:",
|
|
467
|
-
err
|
|
468
|
-
);
|
|
469
|
-
});
|
|
464
|
+
);
|
|
470
465
|
return target;
|
|
471
466
|
}
|
|
472
467
|
return target.app.use(...args);
|
|
@@ -1250,7 +1245,6 @@ if (container && Component) {
|
|
|
1250
1245
|
error
|
|
1251
1246
|
);
|
|
1252
1247
|
}
|
|
1253
|
-
console.log("[WIDGET dev] Metadata:", metadata);
|
|
1254
1248
|
let html = "";
|
|
1255
1249
|
try {
|
|
1256
1250
|
html = await fsHelpers.readFileSync(
|
|
@@ -1367,14 +1361,26 @@ if (container && Component) {
|
|
|
1367
1361
|
this.setupWidgetRoutes();
|
|
1368
1362
|
const manifestPath = "./dist/mcp-use.json";
|
|
1369
1363
|
let widgets = [];
|
|
1364
|
+
let widgetsMetadata = {};
|
|
1370
1365
|
try {
|
|
1371
|
-
const manifestContent = await fsHelpers.readFileSync(
|
|
1366
|
+
const manifestContent = await fsHelpers.readFileSync(
|
|
1367
|
+
manifestPath,
|
|
1368
|
+
"utf8"
|
|
1369
|
+
);
|
|
1372
1370
|
const manifest = JSON.parse(manifestContent);
|
|
1373
|
-
if (manifest.widgets && Array.isArray(manifest.widgets)) {
|
|
1371
|
+
if (manifest.widgets && typeof manifest.widgets === "object" && !Array.isArray(manifest.widgets)) {
|
|
1372
|
+
widgets = Object.keys(manifest.widgets);
|
|
1373
|
+
widgetsMetadata = manifest.widgets;
|
|
1374
|
+
console.log(
|
|
1375
|
+
`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`
|
|
1376
|
+
);
|
|
1377
|
+
} else if (manifest.widgets && Array.isArray(manifest.widgets)) {
|
|
1374
1378
|
widgets = manifest.widgets;
|
|
1375
|
-
console.log(
|
|
1379
|
+
console.log(
|
|
1380
|
+
`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`
|
|
1381
|
+
);
|
|
1376
1382
|
} else {
|
|
1377
|
-
console.log("[WIDGETS] No widgets
|
|
1383
|
+
console.log("[WIDGETS] No widgets found in manifest");
|
|
1378
1384
|
}
|
|
1379
1385
|
} catch (error) {
|
|
1380
1386
|
console.log(
|
|
@@ -1395,9 +1401,7 @@ if (container && Component) {
|
|
|
1395
1401
|
}
|
|
1396
1402
|
}
|
|
1397
1403
|
if (widgets.length === 0) {
|
|
1398
|
-
console.log(
|
|
1399
|
-
"[WIDGETS] No built widgets found"
|
|
1400
|
-
);
|
|
1404
|
+
console.log("[WIDGETS] No built widgets found");
|
|
1401
1405
|
return;
|
|
1402
1406
|
}
|
|
1403
1407
|
console.log(
|
|
@@ -1406,7 +1410,6 @@ if (container && Component) {
|
|
|
1406
1410
|
for (const widgetName of widgets) {
|
|
1407
1411
|
const widgetPath = pathHelpers.join(widgetsDir, widgetName);
|
|
1408
1412
|
const indexPath = pathHelpers.join(widgetPath, "index.html");
|
|
1409
|
-
const metadataPath = pathHelpers.join(widgetPath, "metadata.json");
|
|
1410
1413
|
let html = "";
|
|
1411
1414
|
try {
|
|
1412
1415
|
html = await fsHelpers.readFileSync(indexPath, "utf8");
|
|
@@ -1453,25 +1456,14 @@ if (container && Component) {
|
|
|
1453
1456
|
);
|
|
1454
1457
|
continue;
|
|
1455
1458
|
}
|
|
1456
|
-
|
|
1459
|
+
const metadata = widgetsMetadata[widgetName] || {};
|
|
1457
1460
|
let props = {};
|
|
1458
1461
|
let description = `Widget: ${widgetName}`;
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
metadata = JSON.parse(metadataContent);
|
|
1465
|
-
if (metadata.description) {
|
|
1466
|
-
description = metadata.description;
|
|
1467
|
-
}
|
|
1468
|
-
if (metadata.inputs) {
|
|
1469
|
-
props = metadata.inputs;
|
|
1470
|
-
}
|
|
1471
|
-
} catch (error) {
|
|
1472
|
-
console.log(
|
|
1473
|
-
`[WIDGET] No metadata found for ${widgetName}, using defaults`
|
|
1474
|
-
);
|
|
1462
|
+
if (metadata.description) {
|
|
1463
|
+
description = metadata.description;
|
|
1464
|
+
}
|
|
1465
|
+
if (metadata.inputs) {
|
|
1466
|
+
props = metadata.inputs;
|
|
1475
1467
|
}
|
|
1476
1468
|
this.uiResource({
|
|
1477
1469
|
name: widgetName,
|
|
@@ -1749,9 +1741,27 @@ if (container && Component) {
|
|
|
1749
1741
|
await this.mountMcp();
|
|
1750
1742
|
await this.mountInspector();
|
|
1751
1743
|
if (isDeno) {
|
|
1744
|
+
const corsHeaders = {
|
|
1745
|
+
"Access-Control-Allow-Origin": "*",
|
|
1746
|
+
"Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type"
|
|
1747
|
+
};
|
|
1752
1748
|
globalThis.Deno.serve(
|
|
1753
1749
|
{ port: this.serverPort, hostname: this.serverHost },
|
|
1754
|
-
|
|
1750
|
+
async (req) => {
|
|
1751
|
+
if (req.method === "OPTIONS") {
|
|
1752
|
+
return new Response("ok", { headers: corsHeaders });
|
|
1753
|
+
}
|
|
1754
|
+
const response = await this.app.fetch(req);
|
|
1755
|
+
const newHeaders = new Headers(response.headers);
|
|
1756
|
+
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
1757
|
+
newHeaders.set(key, value);
|
|
1758
|
+
});
|
|
1759
|
+
return new Response(response.body, {
|
|
1760
|
+
status: response.status,
|
|
1761
|
+
statusText: response.statusText,
|
|
1762
|
+
headers: newHeaders
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1755
1765
|
);
|
|
1756
1766
|
console.log(
|
|
1757
1767
|
`[SERVER] Listening on http://${this.serverHost}:${this.serverPort}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../src/server/mcp-server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,IAAI,IAAI,QAAQ,EAAa,MAAM,MAAM,CAAC;AAY5E,OAAO,KAAK,EAEV,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,cAAc,EAEd,oBAAoB,EAErB,MAAM,kBAAkB,CAAC;AA4G1B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Ac;IAgC5B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,iBAAiB;IAgIzB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,kBAAkB;IA+C1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,sBAAsB;IAqC9B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,gBAAgB;CA4BzB;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,QAAQ,CAAC,GAC7D,QAAQ,GAAG;IACT,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE;QACrB,QAAQ,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;KACtD,KAAK,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;CACpD,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,GACjC,iBAAiB,CASnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-use",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.5-canary.
|
|
4
|
+
"version": "1.2.5-canary.5",
|
|
5
5
|
"packageManager": "pnpm@10.6.1",
|
|
6
6
|
"description": "Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents and Clients + MCP Servers with support for MCP-UI.",
|
|
7
7
|
"author": "mcp-use, Inc.",
|