mcp-use 1.34.4 → 1.34.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.
Files changed (38) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-AON7VXVM.js → chunk-35DRMA7E.js} +43 -0
  3. package/dist/{chunk-CI6MW6DM.js → chunk-3BUU264G.js} +4 -4
  4. package/dist/{chunk-YYUZ7XGB.js → chunk-6P7JMLV2.js} +45 -2
  5. package/dist/{chunk-GYSF6PR5.js → chunk-DAFFOVMW.js} +1 -1
  6. package/dist/{chunk-7DSZJBE2.js → chunk-JFYUK3XX.js} +1 -1
  7. package/dist/{chunk-WJ2EMDBB.js → chunk-LS73EEWA.js} +1 -1
  8. package/dist/{chunk-KO5XAWZ3.js → chunk-MD7U5C3K.js} +1 -1
  9. package/dist/{chunk-MKRTKKXV.js → chunk-NDIVAYZ3.js} +1 -1
  10. package/dist/{chunk-LEWR3GBF.js → chunk-V7Q4HEFC.js} +2 -2
  11. package/dist/{chunk-2J5OVVW6.js → chunk-VSSL5DL7.js} +1 -1
  12. package/dist/{chunk-WGK7GOZV.js → chunk-YH33JHUI.js} +2 -2
  13. package/dist/{chunk-XNWBPRVB.js → chunk-ZDC5CD3L.js} +1 -1
  14. package/dist/{client-A4Z5ZFV2.js → client-A5GK5WZD.js} +4 -4
  15. package/dist/index.cjs +51 -2
  16. package/dist/index.js +17 -8
  17. package/dist/src/agents/index.cjs +1 -1
  18. package/dist/src/agents/index.js +4 -4
  19. package/dist/src/auth/browser-provider.d.ts +10 -0
  20. package/dist/src/auth/browser-provider.d.ts.map +1 -1
  21. package/dist/src/auth/index.cjs +40 -0
  22. package/dist/src/auth/index.js +1 -1
  23. package/dist/src/browser-agent.cjs +1 -1
  24. package/dist/src/browser-agent.js +2 -2
  25. package/dist/src/browser.cjs +41 -1
  26. package/dist/src/browser.js +4 -4
  27. package/dist/src/client.cjs +1 -1
  28. package/dist/src/client.js +4 -4
  29. package/dist/src/react/index.cjs +51 -2
  30. package/dist/src/react/index.js +14 -5
  31. package/dist/src/react/useMcp.d.ts.map +1 -1
  32. package/dist/src/server/index.cjs +1 -1
  33. package/dist/src/server/index.js +7 -7
  34. package/dist/src/version.d.ts +1 -1
  35. package/dist/{stdio-4SNFIKTV.js → stdio-I5TXQ4ET.js} +3 -3
  36. package/dist/{stdio-ZAOHF4EV.js → stdio-OFLQV3DJ.js} +2 -2
  37. package/dist/{tool-execution-helpers-ODJCEDUR.js → tool-execution-helpers-CEE337HP.js} +2 -2
  38. package/package.json +3 -3
@@ -783,7 +783,7 @@ var ClientRemoveServerEvent = class extends BaseTelemetryEvent {
783
783
  };
784
784
 
785
785
  // src/version.ts
786
- var VERSION = "1.34.4";
786
+ var VERSION = "1.34.5";
787
787
  function getPackageVersion() {
788
788
  return VERSION;
789
789
  }
@@ -3098,6 +3098,9 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
3098
3098
  }
3099
3099
  };
3100
3100
 
3101
+ // src/auth/browser-provider.ts
3102
+ var import_auth_utils = require("@modelcontextprotocol/sdk/shared/auth-utils.js");
3103
+
3101
3104
  // src/utils/url-sanitize.ts
3102
3105
  function sanitizeUrl(raw) {
3103
3106
  const abort = /* @__PURE__ */ __name(() => {
@@ -3715,6 +3718,43 @@ var BrowserOAuthClientProvider = class {
3715
3718
  invalidateCredentials(scope) {
3716
3719
  return this.session.invalidateCredentials(scope);
3717
3720
  }
3721
+ /**
3722
+ * Validate the protected resource discovered through the OAuth proxy.
3723
+ *
3724
+ * The proxy rewrites protected-resource metadata to the MCP connection URL
3725
+ * so transport-anchored discovery remains valid. Manual authentication is
3726
+ * anchored on the upstream MCP URL instead, so accept that rewrite and
3727
+ * return the original upstream resource that the authorization server
3728
+ * protects.
3729
+ */
3730
+ async validateResourceURL(serverUrl, resource) {
3731
+ if (!resource) return void 0;
3732
+ const requestedResource = (0, import_auth_utils.resourceUrlFromServerUrl)(serverUrl);
3733
+ if ((0, import_auth_utils.checkResourceAllowed)({
3734
+ requestedResource,
3735
+ configuredResource: resource
3736
+ })) {
3737
+ return new URL(resource);
3738
+ }
3739
+ const isConnectionResource = this.connectionUrl && (0, import_auth_utils.checkResourceAllowed)({
3740
+ requestedResource: (0, import_auth_utils.resourceUrlFromServerUrl)(this.connectionUrl),
3741
+ configuredResource: resource
3742
+ });
3743
+ if (isConnectionResource) {
3744
+ const upstreamResource = (0, import_auth_utils.resourceUrlFromServerUrl)(
3745
+ this._lastOriginalResource ?? this.serverUrl
3746
+ );
3747
+ if ((0, import_auth_utils.checkResourceAllowed)({
3748
+ requestedResource,
3749
+ configuredResource: upstreamResource
3750
+ })) {
3751
+ return upstreamResource;
3752
+ }
3753
+ }
3754
+ throw new Error(
3755
+ `Protected resource ${resource} does not match expected ${requestedResource} (or origin)`
3756
+ );
3757
+ }
3718
3758
  /**
3719
3759
  * Resolve this server's OAuth token endpoint (via discovery, cached). Lets
3720
3760
  * consumers persist the endpoint alongside the tokens for server-side
@@ -2,22 +2,22 @@ import {
2
2
  BrowserMCPClient,
3
3
  BrowserOAuthClientProvider,
4
4
  onMcpAuthorization
5
- } from "../chunk-YYUZ7XGB.js";
5
+ } from "../chunk-6P7JMLV2.js";
6
6
  import {
7
7
  HttpConnector,
8
8
  MCPSession
9
- } from "../chunk-LEWR3GBF.js";
9
+ } from "../chunk-V7Q4HEFC.js";
10
10
  import "../chunk-URE3PRDB.js";
11
11
  import {
12
12
  BaseConnector
13
- } from "../chunk-GYSF6PR5.js";
13
+ } from "../chunk-DAFFOVMW.js";
14
14
  import {
15
15
  Tel,
16
16
  Telemetry,
17
17
  VERSION,
18
18
  getPackageVersion,
19
19
  setTelemetrySource
20
- } from "../chunk-2J5OVVW6.js";
20
+ } from "../chunk-VSSL5DL7.js";
21
21
  import {
22
22
  Logger,
23
23
  logger
@@ -215,7 +215,7 @@ var VERSION;
215
215
  var init_version = __esm({
216
216
  "src/version.ts"() {
217
217
  "use strict";
218
- VERSION = "1.34.4";
218
+ VERSION = "1.34.5";
219
219
  __name(getPackageVersion, "getPackageVersion");
220
220
  }
221
221
  });
@@ -13,12 +13,12 @@ import {
13
13
  isVMAvailable,
14
14
  reject,
15
15
  validate
16
- } from "../chunk-CI6MW6DM.js";
16
+ } from "../chunk-3BUU264G.js";
17
17
  import "../chunk-GKPKUKD6.js";
18
- import "../chunk-WJ2EMDBB.js";
19
- import "../chunk-7DSZJBE2.js";
18
+ import "../chunk-LS73EEWA.js";
19
+ import "../chunk-JFYUK3XX.js";
20
20
  import "../chunk-LG5NSHEL.js";
21
- import "../chunk-MKRTKKXV.js";
21
+ import "../chunk-NDIVAYZ3.js";
22
22
  import "../chunk-BXZHMYMM.js";
23
23
  import "../chunk-MTHLLDCX.js";
24
24
  import "../chunk-QWQYAQCK.js";
@@ -1110,7 +1110,7 @@ var ClientRemoveServerEvent = class extends BaseTelemetryEvent {
1110
1110
  };
1111
1111
 
1112
1112
  // src/version.ts
1113
- var VERSION = "1.34.4";
1113
+ var VERSION = "1.34.5";
1114
1114
  function getPackageVersion() {
1115
1115
  return VERSION;
1116
1116
  }
@@ -3635,6 +3635,9 @@ function sanitizeParam([k, v]) {
3635
3635
  }
3636
3636
  __name(sanitizeParam, "sanitizeParam");
3637
3637
 
3638
+ // src/auth/browser-provider.ts
3639
+ var import_auth_utils = require("@modelcontextprotocol/sdk/shared/auth-utils.js");
3640
+
3638
3641
  // src/auth/kv-store.ts
3639
3642
  var LocalStorageKVStore = class {
3640
3643
  static {
@@ -4226,6 +4229,43 @@ var BrowserOAuthClientProvider = class {
4226
4229
  invalidateCredentials(scope) {
4227
4230
  return this.session.invalidateCredentials(scope);
4228
4231
  }
4232
+ /**
4233
+ * Validate the protected resource discovered through the OAuth proxy.
4234
+ *
4235
+ * The proxy rewrites protected-resource metadata to the MCP connection URL
4236
+ * so transport-anchored discovery remains valid. Manual authentication is
4237
+ * anchored on the upstream MCP URL instead, so accept that rewrite and
4238
+ * return the original upstream resource that the authorization server
4239
+ * protects.
4240
+ */
4241
+ async validateResourceURL(serverUrl, resource) {
4242
+ if (!resource) return void 0;
4243
+ const requestedResource = (0, import_auth_utils.resourceUrlFromServerUrl)(serverUrl);
4244
+ if ((0, import_auth_utils.checkResourceAllowed)({
4245
+ requestedResource,
4246
+ configuredResource: resource
4247
+ })) {
4248
+ return new URL(resource);
4249
+ }
4250
+ const isConnectionResource = this.connectionUrl && (0, import_auth_utils.checkResourceAllowed)({
4251
+ requestedResource: (0, import_auth_utils.resourceUrlFromServerUrl)(this.connectionUrl),
4252
+ configuredResource: resource
4253
+ });
4254
+ if (isConnectionResource) {
4255
+ const upstreamResource = (0, import_auth_utils.resourceUrlFromServerUrl)(
4256
+ this._lastOriginalResource ?? this.serverUrl
4257
+ );
4258
+ if ((0, import_auth_utils.checkResourceAllowed)({
4259
+ requestedResource,
4260
+ configuredResource: upstreamResource
4261
+ })) {
4262
+ return upstreamResource;
4263
+ }
4264
+ }
4265
+ throw new Error(
4266
+ `Protected resource ${resource} does not match expected ${requestedResource} (or origin)`
4267
+ );
4268
+ }
4229
4269
  /**
4230
4270
  * Resolve this server's OAuth token endpoint (via discovery, cached). Lets
4231
4271
  * consumers persist the endpoint alongside the tokens for server-side
@@ -5553,6 +5593,7 @@ function useMcp(options) {
5553
5593
  addLog("info", "Triggering fresh OAuth authorization...");
5554
5594
  const parsedUrl = new URL(url);
5555
5595
  const baseUrl = parsedUrl.origin + parsedUrl.pathname.replace(/\/+$/, "");
5596
+ let authFlowError = null;
5556
5597
  try {
5557
5598
  await (0, import_auth3.auth)(freshAuthProvider, {
5558
5599
  serverUrl: baseUrl,
@@ -5560,13 +5601,21 @@ function useMcp(options) {
5560
5601
  });
5561
5602
  addLog("info", "OAuth flow completed (tokens obtained)");
5562
5603
  } catch (err) {
5604
+ authFlowError = err instanceof Error ? err : new Error(String(err));
5563
5605
  addLog(
5564
5606
  "info",
5565
5607
  "OAuth flow initiated (popup/redirect):",
5566
- err instanceof Error ? err.message : "Redirecting..."
5608
+ authFlowError.message
5567
5609
  );
5568
5610
  }
5569
5611
  const newAuthUrl = freshAuthProvider.getLastAttemptedAuthUrl?.();
5612
+ if (authFlowError && !capturedPopup && !newAuthUrl) {
5613
+ failConnection(
5614
+ `Authentication failed: ${authFlowError.message}`,
5615
+ authFlowError
5616
+ );
5617
+ return;
5618
+ }
5570
5619
  if (newAuthUrl) {
5571
5620
  setAuthUrl(newAuthUrl);
5572
5621
  addLog("info", "Updated auth URL for fallback:", newAuthUrl);
@@ -6,16 +6,16 @@ import {
6
6
  onMcpAuthorization,
7
7
  runAuthPopup,
8
8
  sanitizeUrl
9
- } from "../../chunk-YYUZ7XGB.js";
10
- import "../../chunk-LEWR3GBF.js";
9
+ } from "../../chunk-6P7JMLV2.js";
10
+ import "../../chunk-V7Q4HEFC.js";
11
11
  import "../../chunk-URE3PRDB.js";
12
- import "../../chunk-GYSF6PR5.js";
12
+ import "../../chunk-DAFFOVMW.js";
13
13
  import {
14
14
  Tel,
15
15
  Telemetry,
16
16
  getPackageVersion,
17
17
  setTelemetrySource
18
- } from "../../chunk-2J5OVVW6.js";
18
+ } from "../../chunk-VSSL5DL7.js";
19
19
  import {
20
20
  clearRpcLogs,
21
21
  getAllRpcLogs,
@@ -1410,6 +1410,7 @@ function useMcp(options) {
1410
1410
  addLog("info", "Triggering fresh OAuth authorization...");
1411
1411
  const parsedUrl = new URL(url);
1412
1412
  const baseUrl = parsedUrl.origin + parsedUrl.pathname.replace(/\/+$/, "");
1413
+ let authFlowError = null;
1413
1414
  try {
1414
1415
  await auth(freshAuthProvider, {
1415
1416
  serverUrl: baseUrl,
@@ -1417,13 +1418,21 @@ function useMcp(options) {
1417
1418
  });
1418
1419
  addLog("info", "OAuth flow completed (tokens obtained)");
1419
1420
  } catch (err) {
1421
+ authFlowError = err instanceof Error ? err : new Error(String(err));
1420
1422
  addLog(
1421
1423
  "info",
1422
1424
  "OAuth flow initiated (popup/redirect):",
1423
- err instanceof Error ? err.message : "Redirecting..."
1425
+ authFlowError.message
1424
1426
  );
1425
1427
  }
1426
1428
  const newAuthUrl = freshAuthProvider.getLastAttemptedAuthUrl?.();
1429
+ if (authFlowError && !capturedPopup && !newAuthUrl) {
1430
+ failConnection(
1431
+ `Authentication failed: ${authFlowError.message}`,
1432
+ authFlowError
1433
+ );
1434
+ return;
1435
+ }
1427
1436
  if (newAuthUrl) {
1428
1437
  setAuthUrl(newAuthUrl);
1429
1438
  addLog("info", "Updated auth URL for fallback:", newAuthUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"useMcp.d.ts","sourceRoot":"","sources":["../../../src/react/useMcp.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CAo1E3D"}
1
+ {"version":3,"file":"useMcp.d.ts","sourceRoot":"","sources":["../../../src/react/useMcp.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CAi2E3D"}
@@ -661,7 +661,7 @@ var VERSION;
661
661
  var init_version = __esm({
662
662
  "src/version.ts"() {
663
663
  "use strict";
664
- VERSION = "1.34.4";
664
+ VERSION = "1.34.5";
665
665
  __name(getPackageVersion, "getPackageVersion");
666
666
  }
667
667
  });
@@ -17,7 +17,7 @@ import {
17
17
  findSessionContext,
18
18
  isValidLogLevel,
19
19
  supportsApps
20
- } from "../../chunk-KO5XAWZ3.js";
20
+ } from "../../chunk-MD7U5C3K.js";
21
21
  import {
22
22
  getRequestContext,
23
23
  hasRequestContext,
@@ -59,7 +59,7 @@ import {
59
59
  Telemetry,
60
60
  VERSION,
61
61
  getPackageVersion
62
- } from "../../chunk-MKRTKKXV.js";
62
+ } from "../../chunk-NDIVAYZ3.js";
63
63
  import "../../chunk-BXZHMYMM.js";
64
64
  import {
65
65
  fsHelpers,
@@ -3332,7 +3332,7 @@ function registerPrompt(promptDefinition, callback) {
3332
3332
  }
3333
3333
  const wrappedCallback = /* @__PURE__ */ __name(async (params, extra) => {
3334
3334
  const { getRequestContext: getRequestContext2, runWithContext: runWithContext2 } = await import("../../context-storage-KMOAHEL7.js");
3335
- const { findSessionContext: findSessionContext2, createClientCapabilityChecker } = await import("../../tool-execution-helpers-ODJCEDUR.js");
3335
+ const { findSessionContext: findSessionContext2, createClientCapabilityChecker } = await import("../../tool-execution-helpers-CEE337HP.js");
3336
3336
  const initialRequestContext = getRequestContext2();
3337
3337
  const sessions = this.sessions || /* @__PURE__ */ new Map();
3338
3338
  const { requestContext, session } = findSessionContext2(
@@ -3537,7 +3537,7 @@ function registerResource(resourceDefinition, callback) {
3537
3537
  const explicitMimeType = resourceDefinition.mimeType;
3538
3538
  const wrappedCallback = /* @__PURE__ */ __name(async () => {
3539
3539
  const { getRequestContext: getRequestContext2, runWithContext: runWithContext2 } = await import("../../context-storage-KMOAHEL7.js");
3540
- const { findSessionContext: findSessionContext2, createClientCapabilityChecker } = await import("../../tool-execution-helpers-ODJCEDUR.js");
3540
+ const { findSessionContext: findSessionContext2, createClientCapabilityChecker } = await import("../../tool-execution-helpers-CEE337HP.js");
3541
3541
  const initialRequestContext = getRequestContext2();
3542
3542
  const sessions = this.sessions || /* @__PURE__ */ new Map();
3543
3543
  const { requestContext, session } = findSessionContext2(
@@ -3625,7 +3625,7 @@ function registerResourceTemplate(resourceTemplateDefinition, callback) {
3625
3625
  async (uri) => {
3626
3626
  const params = this.parseTemplateUri(uriTemplate, uri.toString());
3627
3627
  const { getRequestContext: getRequestContext2, runWithContext: runWithContext2 } = await import("../../context-storage-KMOAHEL7.js");
3628
- const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-ODJCEDUR.js");
3628
+ const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-CEE337HP.js");
3629
3629
  const initialRequestContext = getRequestContext2();
3630
3630
  const sessions = this.sessions || /* @__PURE__ */ new Map();
3631
3631
  const { requestContext } = findSessionContext2(
@@ -6987,7 +6987,7 @@ var MCPServerClass = class _MCPServerClass {
6987
6987
  onSampling: /* @__PURE__ */ __name(async (params) => {
6988
6988
  try {
6989
6989
  const { getRequestContext: getRequestContext2 } = await import("../../context-storage-KMOAHEL7.js");
6990
- const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-ODJCEDUR.js");
6990
+ const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-CEE337HP.js");
6991
6991
  const ctx = getRequestContext2();
6992
6992
  if (!ctx) throw new Error("No request context");
6993
6993
  const { session } = findSessionContext2(
@@ -7015,7 +7015,7 @@ var MCPServerClass = class _MCPServerClass {
7015
7015
  onElicitation: /* @__PURE__ */ __name(async (params) => {
7016
7016
  try {
7017
7017
  const { getRequestContext: getRequestContext2 } = await import("../../context-storage-KMOAHEL7.js");
7018
- const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-ODJCEDUR.js");
7018
+ const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-CEE337HP.js");
7019
7019
  const ctx = getRequestContext2();
7020
7020
  if (!ctx) throw new Error("No request context");
7021
7021
  const { session } = findSessionContext2(
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "1.34.4";
1
+ export declare const VERSION = "1.34.5";
2
2
  /**
3
3
  * Get the package version.
4
4
  * The version is embedded at build time via scripts/generate-version.mjs
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  StdioConnector
3
- } from "./chunk-XNWBPRVB.js";
3
+ } from "./chunk-ZDC5CD3L.js";
4
4
  import "./chunk-GKPKUKD6.js";
5
- import "./chunk-7DSZJBE2.js";
6
- import "./chunk-MKRTKKXV.js";
5
+ import "./chunk-JFYUK3XX.js";
6
+ import "./chunk-NDIVAYZ3.js";
7
7
  import "./chunk-BXZHMYMM.js";
8
8
  import "./chunk-MTHLLDCX.js";
9
9
  import "./chunk-QWQYAQCK.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  BaseConnector,
3
3
  ConnectionManager
4
- } from "./chunk-GYSF6PR5.js";
5
- import "./chunk-2J5OVVW6.js";
4
+ } from "./chunk-DAFFOVMW.js";
5
+ import "./chunk-VSSL5DL7.js";
6
6
  import {
7
7
  logger
8
8
  } from "./chunk-QWQYAQCK.js";
@@ -7,10 +7,10 @@ import {
7
7
  findSessionContext,
8
8
  isValidLogLevel,
9
9
  supportsApps
10
- } from "./chunk-KO5XAWZ3.js";
10
+ } from "./chunk-MD7U5C3K.js";
11
11
  import "./chunk-G7JEMXJW.js";
12
12
  import "./chunk-KUEVOU4M.js";
13
- import "./chunk-MKRTKKXV.js";
13
+ import "./chunk-NDIVAYZ3.js";
14
14
  import "./chunk-BXZHMYMM.js";
15
15
  import "./chunk-MTHLLDCX.js";
16
16
  import "./chunk-QWQYAQCK.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mcp-use",
3
3
  "type": "module",
4
- "version": "1.34.4",
4
+ "version": "1.34.5",
5
5
  "description": "Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.",
6
6
  "author": "mcp-use, Inc.",
7
7
  "license": "MIT",
@@ -158,8 +158,8 @@
158
158
  "node-mocks-http": "1.17.2",
159
159
  "posthog-js": "1.351.3",
160
160
  "posthog-node": "5.24.17",
161
- "@mcp-use/cli": "3.6.5",
162
- "@mcp-use/inspector": "12.0.4"
161
+ "@mcp-use/cli": "3.6.6",
162
+ "@mcp-use/inspector": "12.0.5"
163
163
  },
164
164
  "optionalDependencies": {
165
165
  "cli-highlight": "2.1.11",