@mcp-use/client 2.1.1-canary.0 → 2.1.1-canary.2

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.
package/dist/index.js CHANGED
@@ -742,6 +742,13 @@ var init_base = __esm({
742
742
  get authorization() {
743
743
  return this.authorizationCache;
744
744
  }
745
+ /**
746
+ * Discover optional authorization metadata without delaying connection
747
+ * readiness. HTTP connectors override this with RFC 9728 discovery.
748
+ */
749
+ async discoverAuthorization() {
750
+ return this.authorization;
751
+ }
745
752
  /** Start optional OAuth for a connected mixed-auth server. */
746
753
  async authenticate() {
747
754
  throw new Error("This connector does not support interactive OAuth");
@@ -1518,7 +1525,7 @@ init_connector_telemetry();
1518
1525
  init_logging();
1519
1526
 
1520
1527
  // src/utils/version.ts
1521
- var VERSION = "2.1.1-canary.0";
1528
+ var VERSION = "2.1.1-canary.2";
1522
1529
  function getPackageVersion() {
1523
1530
  return VERSION;
1524
1531
  }
@@ -3012,6 +3019,7 @@ var HttpConnector = class extends BaseConnector {
3012
3019
  streamableTransport = null;
3013
3020
  hadAccessTokenAtConnect = false;
3014
3021
  pendingOAuthCompletion = null;
3022
+ authorizationDiscovery = null;
3015
3023
  /**
3016
3024
  * Creates an HTTP connector.
3017
3025
  *
@@ -3094,11 +3102,15 @@ var HttpConnector = class extends BaseConnector {
3094
3102
  }
3095
3103
  await this.completeInteractiveAuthorization();
3096
3104
  }
3097
- async initialize(defaultRequestOptions = this.opts.defaultRequestOptions ?? {}) {
3098
- const capabilities = await super.initialize(defaultRequestOptions);
3105
+ async discoverAuthorization() {
3099
3106
  if (!this.detectMixedAuth || !this.oauthProvider || this.hadAccessTokenAtConnect) {
3100
- return capabilities;
3107
+ return this.authorizationCache;
3101
3108
  }
3109
+ if (this.authorizationDiscovery) return this.authorizationDiscovery;
3110
+ this.authorizationDiscovery = this.discoverMixedAuthorization();
3111
+ return this.authorizationDiscovery;
3112
+ }
3113
+ async discoverMixedAuthorization() {
3102
3114
  const controller = new AbortController();
3103
3115
  let timeout;
3104
3116
  const discoveryTimeout = new Promise((_, reject) => {
@@ -3134,7 +3146,7 @@ var HttpConnector = class extends BaseConnector {
3134
3146
  } finally {
3135
3147
  if (timeout) clearTimeout(timeout);
3136
3148
  }
3137
- return capabilities;
3149
+ return this.authorizationCache;
3138
3150
  }
3139
3151
  buildClientOptions() {
3140
3152
  return {
@@ -3521,6 +3533,7 @@ var HttpConnector = class extends BaseConnector {
3521
3533
  }
3522
3534
  }
3523
3535
  await super.cleanupResources();
3536
+ this.authorizationDiscovery = null;
3524
3537
  }
3525
3538
  };
3526
3539
 
@@ -3857,6 +3870,10 @@ var MCPConnection = class {
3857
3870
  get authorization() {
3858
3871
  return this.connector.authorization;
3859
3872
  }
3873
+ /** Discover optional OAuth metadata without delaying MCP readiness. */
3874
+ async discoverAuthorization() {
3875
+ return this.connector.discoverAuthorization();
3876
+ }
3860
3877
  /** Authenticate an already-connected mixed-auth server. */
3861
3878
  async authenticate() {
3862
3879
  await this.connector.authenticate();
@@ -4763,6 +4780,18 @@ var BaseCodeExecutor = class {
4763
4780
  };
4764
4781
  }
4765
4782
  };
4783
+ var FunctionCodeExecutor = class extends BaseCodeExecutor {
4784
+ fn;
4785
+ constructor(client, fn) {
4786
+ super(client);
4787
+ this.fn = fn;
4788
+ }
4789
+ async execute(code, timeout) {
4790
+ return this.fn.call(this.client, code, timeout);
4791
+ }
4792
+ async cleanup() {
4793
+ }
4794
+ };
4766
4795
 
4767
4796
  // src/code-mode/executor-e2b.ts
4768
4797
  init_logging();
@@ -5358,6 +5387,7 @@ return {
5358
5387
 
5359
5388
  Remember: Always discover and understand available tools before attempting to use them in code execution.
5360
5389
  `;
5390
+ var DETAIL_LEVELS = /* @__PURE__ */ new Set(["names", "descriptions", "full"]);
5361
5391
  var CodeModeConnector = class extends BaseConnector {
5362
5392
  mcpClient;
5363
5393
  _tools;
@@ -5445,7 +5475,7 @@ var CodeModeConnector = class extends BaseConnector {
5445
5475
  const detailLevel = args.detail_level;
5446
5476
  const result = await this.mcpClient.searchTools(
5447
5477
  query,
5448
- detailLevel && detailLevel in ["names", "descriptions", "full"] ? detailLevel : "full"
5478
+ DETAIL_LEVELS.has(detailLevel) ? detailLevel : "full"
5449
5479
  );
5450
5480
  return {
5451
5481
  content: [
@@ -5571,7 +5601,6 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
5571
5601
  */
5572
5602
  codeMode = false;
5573
5603
  _codeExecutor = null;
5574
- _customCodeExecutor = null;
5575
5604
  _codeExecutorConfig = "vm";
5576
5605
  _executorOptions;
5577
5606
  _globalCallbacks;
@@ -5807,10 +5836,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
5807
5836
  if (config instanceof BaseCodeExecutor) {
5808
5837
  this._codeExecutor = config;
5809
5838
  } else if (typeof config === "function") {
5810
- this._customCodeExecutor = config;
5811
- throw new Error(
5812
- "Custom executor function should be handled in executeCode"
5813
- );
5839
+ this._codeExecutor = new FunctionCodeExecutor(this, config);
5814
5840
  } else if (config === "e2b") {
5815
5841
  const opts = this._executorOptions;
5816
5842
  if (!opts?.apiKey) {
@@ -5896,9 +5922,6 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
5896
5922
  if (!this.codeMode) {
5897
5923
  throw new Error("Code execution mode is not enabled");
5898
5924
  }
5899
- if (this._customCodeExecutor) {
5900
- return this._customCodeExecutor(code, timeout);
5901
- }
5902
5925
  return this._ensureCodeExecutor().execute(code, timeout);
5903
5926
  }
5904
5927
  /**