mcp-use 1.2.5-canary.4 → 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
- ).catch((err) => {
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(
@@ -1407,15 +1401,22 @@ if (container && Component) {
1407
1401
  let widgets = [];
1408
1402
  let widgetsMetadata = {};
1409
1403
  try {
1410
- const manifestContent = await fsHelpers.readFileSync(manifestPath, "utf8");
1404
+ const manifestContent = await fsHelpers.readFileSync(
1405
+ manifestPath,
1406
+ "utf8"
1407
+ );
1411
1408
  const manifest = JSON.parse(manifestContent);
1412
1409
  if (manifest.widgets && typeof manifest.widgets === "object" && !Array.isArray(manifest.widgets)) {
1413
1410
  widgets = Object.keys(manifest.widgets);
1414
1411
  widgetsMetadata = manifest.widgets;
1415
- console.log(`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`);
1412
+ console.log(
1413
+ `[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`
1414
+ );
1416
1415
  } else if (manifest.widgets && Array.isArray(manifest.widgets)) {
1417
1416
  widgets = manifest.widgets;
1418
- console.log(`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`);
1417
+ console.log(
1418
+ `[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`
1419
+ );
1419
1420
  } else {
1420
1421
  console.log("[WIDGETS] No widgets found in manifest");
1421
1422
  }
@@ -1438,9 +1439,7 @@ if (container && Component) {
1438
1439
  }
1439
1440
  }
1440
1441
  if (widgets.length === 0) {
1441
- console.log(
1442
- "[WIDGETS] No built widgets found"
1443
- );
1442
+ console.log("[WIDGETS] No built widgets found");
1444
1443
  return;
1445
1444
  }
1446
1445
  console.log(
@@ -1780,9 +1779,27 @@ if (container && Component) {
1780
1779
  await this.mountMcp();
1781
1780
  await this.mountInspector();
1782
1781
  if (isDeno) {
1782
+ const corsHeaders = {
1783
+ "Access-Control-Allow-Origin": "*",
1784
+ "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type"
1785
+ };
1783
1786
  globalThis.Deno.serve(
1784
1787
  { port: this.serverPort, hostname: this.serverHost },
1785
- this.app.fetch
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
+ }
1786
1803
  );
1787
1804
  console.log(
1788
1805
  `[SERVER] Listening on http://${this.serverHost}:${this.serverPort}`
@@ -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
- ).catch((err) => {
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(
@@ -1369,15 +1363,22 @@ if (container && Component) {
1369
1363
  let widgets = [];
1370
1364
  let widgetsMetadata = {};
1371
1365
  try {
1372
- const manifestContent = await fsHelpers.readFileSync(manifestPath, "utf8");
1366
+ const manifestContent = await fsHelpers.readFileSync(
1367
+ manifestPath,
1368
+ "utf8"
1369
+ );
1373
1370
  const manifest = JSON.parse(manifestContent);
1374
1371
  if (manifest.widgets && typeof manifest.widgets === "object" && !Array.isArray(manifest.widgets)) {
1375
1372
  widgets = Object.keys(manifest.widgets);
1376
1373
  widgetsMetadata = manifest.widgets;
1377
- console.log(`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`);
1374
+ console.log(
1375
+ `[WIDGETS] Loaded ${widgets.length} widget(s) from manifest`
1376
+ );
1378
1377
  } else if (manifest.widgets && Array.isArray(manifest.widgets)) {
1379
1378
  widgets = manifest.widgets;
1380
- console.log(`[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`);
1379
+ console.log(
1380
+ `[WIDGETS] Loaded ${widgets.length} widget(s) from manifest (legacy format)`
1381
+ );
1381
1382
  } else {
1382
1383
  console.log("[WIDGETS] No widgets found in manifest");
1383
1384
  }
@@ -1400,9 +1401,7 @@ if (container && Component) {
1400
1401
  }
1401
1402
  }
1402
1403
  if (widgets.length === 0) {
1403
- console.log(
1404
- "[WIDGETS] No built widgets found"
1405
- );
1404
+ console.log("[WIDGETS] No built widgets found");
1406
1405
  return;
1407
1406
  }
1408
1407
  console.log(
@@ -1742,9 +1741,27 @@ if (container && Component) {
1742
1741
  await this.mountMcp();
1743
1742
  await this.mountInspector();
1744
1743
  if (isDeno) {
1744
+ const corsHeaders = {
1745
+ "Access-Control-Allow-Origin": "*",
1746
+ "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type"
1747
+ };
1745
1748
  globalThis.Deno.serve(
1746
1749
  { port: this.serverPort, hostname: this.serverHost },
1747
- this.app.fetch
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
+ }
1748
1765
  );
1749
1766
  console.log(
1750
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,oBA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;;;;;;;;;;;;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",
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.",