mcp-use 1.31.1 → 1.32.0

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 (45) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-FPB463GO.js → chunk-4TG7GIKD.js} +1 -1
  3. package/dist/{chunk-TMJINEB7.js → chunk-5OTYGJ5I.js} +4 -4
  4. package/dist/{chunk-C7ODAIQP.js → chunk-6KQBOM7B.js} +2 -2
  5. package/dist/{chunk-QSK3JFMD.js → chunk-D4MXTACG.js} +1 -1
  6. package/dist/{chunk-G2SZKR6C.js → chunk-DH2RCNK6.js} +1 -1
  7. package/dist/{chunk-GGLNYKLW.js → chunk-G3E7PJXG.js} +17 -1
  8. package/dist/{chunk-MMRBRXYD.js → chunk-HDFPTC56.js} +50 -0
  9. package/dist/{chunk-RW5IXYW4.js → chunk-MNFWS6KR.js} +1 -1
  10. package/dist/{chunk-CAOK3APG.js → chunk-NZDEUT7V.js} +68 -2
  11. package/dist/{chunk-LTCJ4JN5.js → chunk-OAFYT5AO.js} +2 -2
  12. package/dist/{chunk-L3MMM6MR.js → chunk-OKVO7FBP.js} +1 -1
  13. package/dist/{chunk-I7CE4EUX.js → chunk-RRMGSMJF.js} +1 -1
  14. package/dist/{chunk-G75KKA2M.js → chunk-S7X3LKYT.js} +1 -1
  15. package/dist/{client-ZSC7UQDB.js → client-3KX7OSGL.js} +4 -4
  16. package/dist/index.cjs +83 -2
  17. package/dist/index.js +24 -9
  18. package/dist/src/agents/index.cjs +1 -1
  19. package/dist/src/agents/index.js +4 -4
  20. package/dist/src/auth/browser-provider.d.ts +15 -0
  21. package/dist/src/auth/browser-provider.d.ts.map +1 -1
  22. package/dist/src/auth/index-node.cjs +50 -0
  23. package/dist/src/auth/index-node.js +1 -1
  24. package/dist/src/auth/index.cjs +66 -0
  25. package/dist/src/auth/index.js +2 -2
  26. package/dist/src/auth/oauth-session-store.d.ts +18 -0
  27. package/dist/src/auth/oauth-session-store.d.ts.map +1 -1
  28. package/dist/src/browser-agent.cjs +1 -1
  29. package/dist/src/browser-agent.js +2 -2
  30. package/dist/src/browser.cjs +67 -1
  31. package/dist/src/browser.js +4 -4
  32. package/dist/src/client.cjs +1 -1
  33. package/dist/src/client.js +4 -4
  34. package/dist/src/react/index.cjs +83 -2
  35. package/dist/src/react/index.js +20 -5
  36. package/dist/src/react/types.d.ts +13 -0
  37. package/dist/src/react/types.d.ts.map +1 -1
  38. package/dist/src/react/useMcp.d.ts.map +1 -1
  39. package/dist/src/server/index.cjs +1 -1
  40. package/dist/src/server/index.js +7 -7
  41. package/dist/src/version.d.ts +1 -1
  42. package/dist/{stdio-4B64EGZM.js → stdio-GW5RCDKN.js} +2 -2
  43. package/dist/{stdio-6JH35S33.js → stdio-YFXMCFDI.js} +3 -3
  44. package/dist/{tool-execution-helpers-ODTD56DJ.js → tool-execution-helpers-OVG6NMH4.js} +2 -2
  45. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseConnector
3
- } from "./chunk-RW5IXYW4.js";
3
+ } from "./chunk-MNFWS6KR.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-3GQAWCBQ.js";
@@ -3,17 +3,17 @@ import {
3
3
  } from "./chunk-GKPKUKD6.js";
4
4
  import {
5
5
  CodeModeConnector
6
- } from "./chunk-FPB463GO.js";
6
+ } from "./chunk-4TG7GIKD.js";
7
7
  import {
8
8
  BaseConnector
9
- } from "./chunk-RW5IXYW4.js";
9
+ } from "./chunk-MNFWS6KR.js";
10
10
  import {
11
11
  JSONSchemaToZod
12
12
  } from "./chunk-LG5NSHEL.js";
13
13
  import {
14
14
  Tel,
15
15
  getPackageVersion
16
- } from "./chunk-I7CE4EUX.js";
16
+ } from "./chunk-RRMGSMJF.js";
17
17
  import {
18
18
  logger
19
19
  } from "./chunk-QWQYAQCK.js";
@@ -2356,7 +2356,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
2356
2356
  clientInfo: serverConfig.clientInfo ?? this.config.clientInfo
2357
2357
  };
2358
2358
  if ("command" in merged && "args" in merged) {
2359
- const { StdioConnector } = await import("./stdio-6JH35S33.js");
2359
+ const { StdioConnector } = await import("./stdio-YFXMCFDI.js");
2360
2360
  const stdioConfig = merged;
2361
2361
  return new StdioConnector({
2362
2362
  command: stdioConfig.command,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CODE_MODE_AGENT_PROMPT
3
- } from "./chunk-FPB463GO.js";
3
+ } from "./chunk-4TG7GIKD.js";
4
4
  import {
5
5
  LangChainAdapter
6
6
  } from "./chunk-27JERD25.js";
@@ -8,7 +8,7 @@ import {
8
8
  Telemetry,
9
9
  extractModelInfo,
10
10
  getPackageVersion
11
- } from "./chunk-I7CE4EUX.js";
11
+ } from "./chunk-RRMGSMJF.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-QWQYAQCK.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Telemetry
3
- } from "./chunk-G2SZKR6C.js";
3
+ } from "./chunk-DH2RCNK6.js";
4
4
  import {
5
5
  logger
6
6
  } from "./chunk-QWQYAQCK.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-3GQAWCBQ.js";
7
7
 
8
8
  // src/version.ts
9
- var VERSION = "1.31.1";
9
+ var VERSION = "1.32.0";
10
10
  function getPackageVersion() {
11
11
  return VERSION;
12
12
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OAuthSessionStore,
3
3
  sanitizeUrl
4
- } from "./chunk-MMRBRXYD.js";
4
+ } from "./chunk-HDFPTC56.js";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-3GQAWCBQ.js";
@@ -234,6 +234,22 @@ var BrowserOAuthClientProvider = class {
234
234
  invalidateCredentials(scope) {
235
235
  return this.session.invalidateCredentials(scope);
236
236
  }
237
+ /**
238
+ * Resolve this server's OAuth token endpoint (via discovery, cached). Lets
239
+ * consumers persist the endpoint alongside the tokens for server-side
240
+ * proactive refresh. Returns `null` when unavailable.
241
+ */
242
+ getTokenEndpoint() {
243
+ return this.session.getTokenEndpoint();
244
+ }
245
+ /**
246
+ * Return the stored OAuth client credentials (DCR or static). Lets consumers
247
+ * persist the `client_id`/`client_secret` for server-side refresh. Returns
248
+ * `null` when unavailable.
249
+ */
250
+ getClientCredentials() {
251
+ return this.session.getClientCredentials();
252
+ }
237
253
  /**
238
254
  * Generates and persists `StoredState` for an authorization request,
239
255
  * applies browser-only resource rewriting, and returns the sanitized URL
@@ -279,6 +279,56 @@ var OAuthSessionStore = class _OAuthSessionStore {
279
279
  if (!stored.refresh_token) return null;
280
280
  return this._dedupedRefresh(stored);
281
281
  }
282
+ /**
283
+ * Return the stored OAuth client credentials (from Dynamic Client
284
+ * Registration or a pre-registered static client). Consumers can persist
285
+ * these alongside the tokens so a backend can perform a server-side refresh
286
+ * (most token endpoints require at least the `client_id` on refresh).
287
+ * Returns `null` when no client info is available.
288
+ */
289
+ async getClientCredentials() {
290
+ try {
291
+ const info = await this.clientInformation();
292
+ if (!info?.client_id) return null;
293
+ return {
294
+ client_id: info.client_id,
295
+ ...info.client_secret ? { client_secret: info.client_secret } : {}
296
+ };
297
+ } catch {
298
+ return null;
299
+ }
300
+ }
301
+ /**
302
+ * Resolve this server's OAuth token endpoint via PRM → authorization-server
303
+ * metadata discovery. Cached in-memory and persisted (so consumers can store
304
+ * it alongside the tokens, e.g. for server-side proactive refresh). Returns
305
+ * `null` when the server is not OAuth-protected or discovery fails.
306
+ */
307
+ async getTokenEndpoint() {
308
+ if (this._cachedMetadata?.token_endpoint) {
309
+ return this._cachedMetadata.token_endpoint;
310
+ }
311
+ try {
312
+ const persisted = await this.store.get(this.getKey("token_endpoint"));
313
+ if (persisted) return persisted;
314
+ const resourceMetadata = await discoverOAuthProtectedResourceMetadata(
315
+ this.serverUrl
316
+ );
317
+ const authServerUrl = resourceMetadata.authorization_servers?.[0];
318
+ if (!authServerUrl) return null;
319
+ const metadata = await discoverAuthorizationServerMetadata(authServerUrl);
320
+ if (!metadata?.token_endpoint) return null;
321
+ this._cachedAuthServerUrl = authServerUrl;
322
+ this._cachedMetadata = metadata;
323
+ await this.store.set(
324
+ this.getKey("token_endpoint"),
325
+ metadata.token_endpoint
326
+ );
327
+ return metadata.token_endpoint;
328
+ } catch {
329
+ return null;
330
+ }
331
+ }
282
332
  };
283
333
 
284
334
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Telemetry
3
- } from "./chunk-I7CE4EUX.js";
3
+ } from "./chunk-RRMGSMJF.js";
4
4
  import {
5
5
  logger
6
6
  } from "./chunk-QWQYAQCK.js";
@@ -3,11 +3,11 @@ import {
3
3
  HttpConnector,
4
4
  normalizeClientInfo,
5
5
  resolveCallbacks
6
- } from "./chunk-LTCJ4JN5.js";
6
+ } from "./chunk-OAFYT5AO.js";
7
7
  import {
8
8
  Tel,
9
9
  getPackageVersion
10
- } from "./chunk-G2SZKR6C.js";
10
+ } from "./chunk-DH2RCNK6.js";
11
11
  import {
12
12
  logger
13
13
  } from "./chunk-QWQYAQCK.js";
@@ -406,6 +406,56 @@ var OAuthSessionStore = class _OAuthSessionStore {
406
406
  if (!stored.refresh_token) return null;
407
407
  return this._dedupedRefresh(stored);
408
408
  }
409
+ /**
410
+ * Return the stored OAuth client credentials (from Dynamic Client
411
+ * Registration or a pre-registered static client). Consumers can persist
412
+ * these alongside the tokens so a backend can perform a server-side refresh
413
+ * (most token endpoints require at least the `client_id` on refresh).
414
+ * Returns `null` when no client info is available.
415
+ */
416
+ async getClientCredentials() {
417
+ try {
418
+ const info = await this.clientInformation();
419
+ if (!info?.client_id) return null;
420
+ return {
421
+ client_id: info.client_id,
422
+ ...info.client_secret ? { client_secret: info.client_secret } : {}
423
+ };
424
+ } catch {
425
+ return null;
426
+ }
427
+ }
428
+ /**
429
+ * Resolve this server's OAuth token endpoint via PRM → authorization-server
430
+ * metadata discovery. Cached in-memory and persisted (so consumers can store
431
+ * it alongside the tokens, e.g. for server-side proactive refresh). Returns
432
+ * `null` when the server is not OAuth-protected or discovery fails.
433
+ */
434
+ async getTokenEndpoint() {
435
+ if (this._cachedMetadata?.token_endpoint) {
436
+ return this._cachedMetadata.token_endpoint;
437
+ }
438
+ try {
439
+ const persisted = await this.store.get(this.getKey("token_endpoint"));
440
+ if (persisted) return persisted;
441
+ const resourceMetadata = await discoverOAuthProtectedResourceMetadata(
442
+ this.serverUrl
443
+ );
444
+ const authServerUrl = resourceMetadata.authorization_servers?.[0];
445
+ if (!authServerUrl) return null;
446
+ const metadata = await discoverAuthorizationServerMetadata(authServerUrl);
447
+ if (!metadata?.token_endpoint) return null;
448
+ this._cachedAuthServerUrl = authServerUrl;
449
+ this._cachedMetadata = metadata;
450
+ await this.store.set(
451
+ this.getKey("token_endpoint"),
452
+ metadata.token_endpoint
453
+ );
454
+ return metadata.token_endpoint;
455
+ } catch {
456
+ return null;
457
+ }
458
+ }
409
459
  };
410
460
 
411
461
  // src/auth/browser-provider.ts
@@ -612,6 +662,22 @@ var BrowserOAuthClientProvider = class {
612
662
  invalidateCredentials(scope) {
613
663
  return this.session.invalidateCredentials(scope);
614
664
  }
665
+ /**
666
+ * Resolve this server's OAuth token endpoint (via discovery, cached). Lets
667
+ * consumers persist the endpoint alongside the tokens for server-side
668
+ * proactive refresh. Returns `null` when unavailable.
669
+ */
670
+ getTokenEndpoint() {
671
+ return this.session.getTokenEndpoint();
672
+ }
673
+ /**
674
+ * Return the stored OAuth client credentials (DCR or static). Lets consumers
675
+ * persist the `client_id`/`client_secret` for server-side refresh. Returns
676
+ * `null` when unavailable.
677
+ */
678
+ getClientCredentials() {
679
+ return this.session.getClientCredentials();
680
+ }
615
681
  /**
616
682
  * Generates and persists `StoredState` for an authorization request,
617
683
  * applies browser-only resource rewriting, and returns the sanitized URL
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BaseConnector,
3
3
  ConnectionManager
4
- } from "./chunk-QSK3JFMD.js";
4
+ } from "./chunk-D4MXTACG.js";
5
5
  import {
6
6
  Tel,
7
7
  getPackageVersion
8
- } from "./chunk-G2SZKR6C.js";
8
+ } from "./chunk-DH2RCNK6.js";
9
9
  import {
10
10
  logger
11
11
  } from "./chunk-QWQYAQCK.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GKPKUKD6.js";
4
4
  import {
5
5
  BaseConnector
6
- } from "./chunk-RW5IXYW4.js";
6
+ } from "./chunk-MNFWS6KR.js";
7
7
  import {
8
8
  logger
9
9
  } from "./chunk-QWQYAQCK.js";
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-3GQAWCBQ.js";
14
14
 
15
15
  // src/version.ts
16
- var VERSION = "1.31.1";
16
+ var VERSION = "1.32.0";
17
17
  function getPackageVersion() {
18
18
  return VERSION;
19
19
  }
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-KUEVOU4M.js";
7
7
  import {
8
8
  Telemetry
9
- } from "./chunk-I7CE4EUX.js";
9
+ } from "./chunk-RRMGSMJF.js";
10
10
  import {
11
11
  generateUUID
12
12
  } from "./chunk-MTHLLDCX.js";
@@ -7,15 +7,15 @@ import {
7
7
  createConnectorFromConfig,
8
8
  normalizeClientInfo,
9
9
  resolveCallbacks
10
- } from "./chunk-LTCJ4JN5.js";
10
+ } from "./chunk-OAFYT5AO.js";
11
11
  import "./chunk-URE3PRDB.js";
12
12
  import {
13
13
  BaseConnector
14
- } from "./chunk-QSK3JFMD.js";
14
+ } from "./chunk-D4MXTACG.js";
15
15
  import {
16
16
  Tel,
17
17
  getPackageVersion
18
- } from "./chunk-G2SZKR6C.js";
18
+ } from "./chunk-DH2RCNK6.js";
19
19
  import {
20
20
  logger
21
21
  } from "./chunk-QWQYAQCK.js";
@@ -1107,7 +1107,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
1107
1107
  clientInfo: serverConfig.clientInfo ?? this.config.clientInfo
1108
1108
  };
1109
1109
  if ("command" in merged && "args" in merged) {
1110
- const { StdioConnector } = await import("./stdio-4B64EGZM.js");
1110
+ const { StdioConnector } = await import("./stdio-GW5RCDKN.js");
1111
1111
  const stdioConfig = merged;
1112
1112
  return new StdioConnector({
1113
1113
  command: stdioConfig.command,
package/dist/index.cjs CHANGED
@@ -1170,7 +1170,7 @@ var VERSION;
1170
1170
  var init_version = __esm({
1171
1171
  "src/version.ts"() {
1172
1172
  "use strict";
1173
- VERSION = "1.31.1";
1173
+ VERSION = "1.32.0";
1174
1174
  __name(getPackageVersion, "getPackageVersion");
1175
1175
  }
1176
1176
  });
@@ -9981,6 +9981,56 @@ var OAuthSessionStore = class _OAuthSessionStore {
9981
9981
  if (!stored.refresh_token) return null;
9982
9982
  return this._dedupedRefresh(stored);
9983
9983
  }
9984
+ /**
9985
+ * Return the stored OAuth client credentials (from Dynamic Client
9986
+ * Registration or a pre-registered static client). Consumers can persist
9987
+ * these alongside the tokens so a backend can perform a server-side refresh
9988
+ * (most token endpoints require at least the `client_id` on refresh).
9989
+ * Returns `null` when no client info is available.
9990
+ */
9991
+ async getClientCredentials() {
9992
+ try {
9993
+ const info = await this.clientInformation();
9994
+ if (!info?.client_id) return null;
9995
+ return {
9996
+ client_id: info.client_id,
9997
+ ...info.client_secret ? { client_secret: info.client_secret } : {}
9998
+ };
9999
+ } catch {
10000
+ return null;
10001
+ }
10002
+ }
10003
+ /**
10004
+ * Resolve this server's OAuth token endpoint via PRM → authorization-server
10005
+ * metadata discovery. Cached in-memory and persisted (so consumers can store
10006
+ * it alongside the tokens, e.g. for server-side proactive refresh). Returns
10007
+ * `null` when the server is not OAuth-protected or discovery fails.
10008
+ */
10009
+ async getTokenEndpoint() {
10010
+ if (this._cachedMetadata?.token_endpoint) {
10011
+ return this._cachedMetadata.token_endpoint;
10012
+ }
10013
+ try {
10014
+ const persisted = await this.store.get(this.getKey("token_endpoint"));
10015
+ if (persisted) return persisted;
10016
+ const resourceMetadata = await (0, import_auth.discoverOAuthProtectedResourceMetadata)(
10017
+ this.serverUrl
10018
+ );
10019
+ const authServerUrl = resourceMetadata.authorization_servers?.[0];
10020
+ if (!authServerUrl) return null;
10021
+ const metadata = await (0, import_auth.discoverAuthorizationServerMetadata)(authServerUrl);
10022
+ if (!metadata?.token_endpoint) return null;
10023
+ this._cachedAuthServerUrl = authServerUrl;
10024
+ this._cachedMetadata = metadata;
10025
+ await this.store.set(
10026
+ this.getKey("token_endpoint"),
10027
+ metadata.token_endpoint
10028
+ );
10029
+ return metadata.token_endpoint;
10030
+ } catch {
10031
+ return null;
10032
+ }
10033
+ }
9984
10034
  };
9985
10035
 
9986
10036
  // src/auth/browser-provider.ts
@@ -10187,6 +10237,22 @@ var BrowserOAuthClientProvider = class {
10187
10237
  invalidateCredentials(scope) {
10188
10238
  return this.session.invalidateCredentials(scope);
10189
10239
  }
10240
+ /**
10241
+ * Resolve this server's OAuth token endpoint (via discovery, cached). Lets
10242
+ * consumers persist the endpoint alongside the tokens for server-side
10243
+ * proactive refresh. Returns `null` when unavailable.
10244
+ */
10245
+ getTokenEndpoint() {
10246
+ return this.session.getTokenEndpoint();
10247
+ }
10248
+ /**
10249
+ * Return the stored OAuth client credentials (DCR or static). Lets consumers
10250
+ * persist the `client_id`/`client_secret` for server-side refresh. Returns
10251
+ * `null` when unavailable.
10252
+ */
10253
+ getClientCredentials() {
10254
+ return this.session.getClientCredentials();
10255
+ }
10190
10256
  /**
10191
10257
  * Generates and persists `StoredState` for an authorization request,
10192
10258
  * applies browser-only resource rewriting, and returns the sanitized URL
@@ -12453,6 +12519,18 @@ function useMcp(options) {
12453
12519
  }
12454
12520
  if (tokens?.access_token) {
12455
12521
  const expiresAt = tokens.expires_in ? Date.now() + tokens.expires_in * 1e3 : void 0;
12522
+ let tokenEndpoint = null;
12523
+ let clientCreds = null;
12524
+ try {
12525
+ tokenEndpoint = await authProviderRef.current.getTokenEndpoint?.() ?? null;
12526
+ } catch {
12527
+ tokenEndpoint = null;
12528
+ }
12529
+ try {
12530
+ clientCreds = await authProviderRef.current.getClientCredentials?.() ?? null;
12531
+ } catch {
12532
+ clientCreds = null;
12533
+ }
12456
12534
  if (!isMountedRef.current) {
12457
12535
  addLog("debug", "Skipping state update - component unmounted");
12458
12536
  return "failed";
@@ -12462,7 +12540,10 @@ function useMcp(options) {
12462
12540
  token_type: tokens.token_type || "Bearer",
12463
12541
  expires_at: expiresAt,
12464
12542
  refresh_token: tokens.refresh_token,
12465
- scope: tokens.scope
12543
+ scope: tokens.scope,
12544
+ ...tokenEndpoint ? { token_endpoint: tokenEndpoint } : {},
12545
+ ...clientCreds?.client_id ? { client_id: clientCreds.client_id } : {},
12546
+ ...clientCreds?.client_secret ? { client_secret: clientCreds.client_secret } : {}
12466
12547
  });
12467
12548
  }
12468
12549
  }
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-OWF2HVMR.js";
6
6
  import {
7
7
  StdioConnector
8
- } from "./chunk-L3MMM6MR.js";
8
+ } from "./chunk-OKVO7FBP.js";
9
9
  import {
10
10
  clearRpcLogs,
11
11
  getAllRpcLogs,
@@ -32,7 +32,7 @@ import {
32
32
  reject,
33
33
  resolveCallbacks,
34
34
  validate
35
- } from "./chunk-TMJINEB7.js";
35
+ } from "./chunk-5OTYGJ5I.js";
36
36
  import "./chunk-GKPKUKD6.js";
37
37
  import "./chunk-GXNAXUDI.js";
38
38
  import {
@@ -50,12 +50,12 @@ import {
50
50
  getSupportedProviders,
51
51
  isValidLLMString,
52
52
  parseLLMString
53
- } from "./chunk-C7ODAIQP.js";
53
+ } from "./chunk-6KQBOM7B.js";
54
54
  import "./chunk-N27VLLMA.js";
55
- import "./chunk-FPB463GO.js";
55
+ import "./chunk-4TG7GIKD.js";
56
56
  import {
57
57
  BaseConnector
58
- } from "./chunk-RW5IXYW4.js";
58
+ } from "./chunk-MNFWS6KR.js";
59
59
  import {
60
60
  BaseAdapter
61
61
  } from "./chunk-27JERD25.js";
@@ -67,10 +67,10 @@ import {
67
67
  onMcpAuthorization,
68
68
  probeAuthParams,
69
69
  runAuthPopup
70
- } from "./chunk-GGLNYKLW.js";
70
+ } from "./chunk-G3E7PJXG.js";
71
71
  import {
72
72
  sanitizeUrl
73
- } from "./chunk-MMRBRXYD.js";
73
+ } from "./chunk-HDFPTC56.js";
74
74
  import {
75
75
  createNotification,
76
76
  createRequest
@@ -98,7 +98,7 @@ import {
98
98
  createServerRunEventData,
99
99
  getPackageVersion,
100
100
  setTelemetrySource
101
- } from "./chunk-I7CE4EUX.js";
101
+ } from "./chunk-RRMGSMJF.js";
102
102
  import {
103
103
  telFetch
104
104
  } from "./chunk-BXZHMYMM.js";
@@ -1531,6 +1531,18 @@ function useMcp(options) {
1531
1531
  }
1532
1532
  if (tokens?.access_token) {
1533
1533
  const expiresAt = tokens.expires_in ? Date.now() + tokens.expires_in * 1e3 : void 0;
1534
+ let tokenEndpoint = null;
1535
+ let clientCreds = null;
1536
+ try {
1537
+ tokenEndpoint = await authProviderRef.current.getTokenEndpoint?.() ?? null;
1538
+ } catch {
1539
+ tokenEndpoint = null;
1540
+ }
1541
+ try {
1542
+ clientCreds = await authProviderRef.current.getClientCredentials?.() ?? null;
1543
+ } catch {
1544
+ clientCreds = null;
1545
+ }
1534
1546
  if (!isMountedRef.current) {
1535
1547
  addLog("debug", "Skipping state update - component unmounted");
1536
1548
  return "failed";
@@ -1540,7 +1552,10 @@ function useMcp(options) {
1540
1552
  token_type: tokens.token_type || "Bearer",
1541
1553
  expires_at: expiresAt,
1542
1554
  refresh_token: tokens.refresh_token,
1543
- scope: tokens.scope
1555
+ scope: tokens.scope,
1556
+ ...tokenEndpoint ? { token_endpoint: tokenEndpoint } : {},
1557
+ ...clientCreds?.client_id ? { client_id: clientCreds.client_id } : {},
1558
+ ...clientCreds?.client_secret ? { client_secret: clientCreds.client_secret } : {}
1544
1559
  });
1545
1560
  }
1546
1561
  }
@@ -583,7 +583,7 @@ var VERSION;
583
583
  var init_version = __esm({
584
584
  "src/version.ts"() {
585
585
  "use strict";
586
- VERSION = "1.31.1";
586
+ VERSION = "1.32.0";
587
587
  __name(getPackageVersion, "getPackageVersion");
588
588
  }
589
589
  });
@@ -3,13 +3,13 @@ import {
3
3
  MCPAgent,
4
4
  PROMPTS,
5
5
  RemoteAgent
6
- } from "../../chunk-C7ODAIQP.js";
6
+ } from "../../chunk-6KQBOM7B.js";
7
7
  import "../../chunk-N27VLLMA.js";
8
- import "../../chunk-FPB463GO.js";
9
- import "../../chunk-RW5IXYW4.js";
8
+ import "../../chunk-4TG7GIKD.js";
9
+ import "../../chunk-MNFWS6KR.js";
10
10
  import "../../chunk-27JERD25.js";
11
11
  import "../../chunk-LG5NSHEL.js";
12
- import "../../chunk-I7CE4EUX.js";
12
+ import "../../chunk-RRMGSMJF.js";
13
13
  import "../../chunk-BXZHMYMM.js";
14
14
  import "../../chunk-MTHLLDCX.js";
15
15
  import "../../chunk-QWQYAQCK.js";
@@ -62,6 +62,21 @@ export declare class BrowserOAuthClientProvider implements OAuthClientProvider {
62
62
  codeVerifier(): Promise<string>;
63
63
  saveCodeVerifier(codeVerifier: string): Promise<void>;
64
64
  invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier"): Promise<void>;
65
+ /**
66
+ * Resolve this server's OAuth token endpoint (via discovery, cached). Lets
67
+ * consumers persist the endpoint alongside the tokens for server-side
68
+ * proactive refresh. Returns `null` when unavailable.
69
+ */
70
+ getTokenEndpoint(): Promise<string | null>;
71
+ /**
72
+ * Return the stored OAuth client credentials (DCR or static). Lets consumers
73
+ * persist the `client_id`/`client_secret` for server-side refresh. Returns
74
+ * `null` when unavailable.
75
+ */
76
+ getClientCredentials(): Promise<{
77
+ client_id: string;
78
+ client_secret?: string;
79
+ } | null>;
65
80
  /**
66
81
  * Generates and persists `StoredState` for an authorization request,
67
82
  * applies browser-only resource rewriting, and returns the sanitized URL
@@ -1 +1 @@
1
- {"version":3,"file":"browser-provider.d.ts","sourceRoot":"","sources":["../../../src/auth/browser-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AACpF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GAAG,UAAU,GAC9C,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI1C;;;;OAIG;IACH,oBAAoB,IAAI,OAAO,CAAC;QAC9B,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,IAAI,CAAC;IAIT;;;;;OAKG;IACG,uBAAuB,CAAC,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBrE;;;OAGG;IACG,uBAAuB,CAAC,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAuDnE;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAyBnC;;OAEG;IACH,uBAAuB,IAAI,MAAM,GAAG,IAAI;IAMxC,YAAY,IAAI,MAAM;CAqCvB"}
@@ -389,6 +389,56 @@ var OAuthSessionStore = class _OAuthSessionStore {
389
389
  if (!stored.refresh_token) return null;
390
390
  return this._dedupedRefresh(stored);
391
391
  }
392
+ /**
393
+ * Return the stored OAuth client credentials (from Dynamic Client
394
+ * Registration or a pre-registered static client). Consumers can persist
395
+ * these alongside the tokens so a backend can perform a server-side refresh
396
+ * (most token endpoints require at least the `client_id` on refresh).
397
+ * Returns `null` when no client info is available.
398
+ */
399
+ async getClientCredentials() {
400
+ try {
401
+ const info = await this.clientInformation();
402
+ if (!info?.client_id) return null;
403
+ return {
404
+ client_id: info.client_id,
405
+ ...info.client_secret ? { client_secret: info.client_secret } : {}
406
+ };
407
+ } catch {
408
+ return null;
409
+ }
410
+ }
411
+ /**
412
+ * Resolve this server's OAuth token endpoint via PRM → authorization-server
413
+ * metadata discovery. Cached in-memory and persisted (so consumers can store
414
+ * it alongside the tokens, e.g. for server-side proactive refresh). Returns
415
+ * `null` when the server is not OAuth-protected or discovery fails.
416
+ */
417
+ async getTokenEndpoint() {
418
+ if (this._cachedMetadata?.token_endpoint) {
419
+ return this._cachedMetadata.token_endpoint;
420
+ }
421
+ try {
422
+ const persisted = await this.store.get(this.getKey("token_endpoint"));
423
+ if (persisted) return persisted;
424
+ const resourceMetadata = await (0, import_auth.discoverOAuthProtectedResourceMetadata)(
425
+ this.serverUrl
426
+ );
427
+ const authServerUrl = resourceMetadata.authorization_servers?.[0];
428
+ if (!authServerUrl) return null;
429
+ const metadata = await (0, import_auth.discoverAuthorizationServerMetadata)(authServerUrl);
430
+ if (!metadata?.token_endpoint) return null;
431
+ this._cachedAuthServerUrl = authServerUrl;
432
+ this._cachedMetadata = metadata;
433
+ await this.store.set(
434
+ this.getKey("token_endpoint"),
435
+ metadata.token_endpoint
436
+ );
437
+ return metadata.token_endpoint;
438
+ } catch {
439
+ return null;
440
+ }
441
+ }
392
442
  };
393
443
 
394
444
  // src/auth/node-provider.ts