mcp-use 1.8.2-canary.0 → 1.9.0-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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseConnector
3
- } from "./chunk-DWTSQOEC.js";
3
+ } from "./chunk-ZQUCGISK.js";
4
4
  import {
5
5
  logger
6
6
  } from "./chunk-34R6SIER.js";
@@ -391,7 +391,9 @@ var HttpConnector = class extends BaseConnector {
391
391
  roots: { listChanged: true },
392
392
  // Always advertise roots capability
393
393
  // Add sampling capability if callback is provided
394
- ...this.opts.samplingCallback ? { sampling: {} } : {}
394
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
395
+ // Add elicitation capability if callback is provided
396
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
395
397
  }
396
398
  };
397
399
  logger.debug(
@@ -445,6 +447,7 @@ var HttpConnector = class extends BaseConnector {
445
447
  this.transportType = "streamable-http";
446
448
  this.setupNotificationHandler();
447
449
  this.setupSamplingHandler();
450
+ this.setupElicitationHandler();
448
451
  logger.debug(
449
452
  `Successfully connected to MCP implementation via streamable HTTP: ${baseUrl}`
450
453
  );
@@ -474,7 +477,9 @@ var HttpConnector = class extends BaseConnector {
474
477
  roots: { listChanged: true },
475
478
  // Always advertise roots capability
476
479
  // Add sampling capability if callback is provided
477
- ...this.opts.samplingCallback ? { sampling: {} } : {}
480
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
481
+ // Add elicitation capability if callback is provided
482
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
478
483
  }
479
484
  };
480
485
  logger.debug(
@@ -489,6 +494,7 @@ var HttpConnector = class extends BaseConnector {
489
494
  this.transportType = "sse";
490
495
  this.setupNotificationHandler();
491
496
  this.setupSamplingHandler();
497
+ this.setupElicitationHandler();
492
498
  logger.debug(
493
499
  `Successfully connected to MCP implementation via HTTP/SSE: ${baseUrl}`
494
500
  );
@@ -926,7 +932,8 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
926
932
  authProvider,
927
933
  wrapTransport,
928
934
  clientOptions,
929
- samplingCallback
935
+ samplingCallback,
936
+ elicitationCallback
930
937
  } = serverConfig;
931
938
  if (!url) {
932
939
  throw new Error("Server URL is required");
@@ -940,8 +947,10 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
940
947
  // ← Pass transport wrapper if provided
941
948
  clientOptions,
942
949
  // ← Pass client options (capabilities, etc.) to connector
943
- samplingCallback
950
+ samplingCallback,
944
951
  // ← Pass sampling callback to connector
952
+ elicitationCallback
953
+ // ← Pass elicitation callback to connector
945
954
  };
946
955
  if (clientOptions) {
947
956
  console.log(
@@ -0,0 +1,49 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-3GQAWCBQ.js";
4
+
5
+ // src/errors.ts
6
+ var ElicitationValidationError = class _ElicitationValidationError extends Error {
7
+ constructor(message, cause) {
8
+ super(message);
9
+ this.cause = cause;
10
+ this.name = "ElicitationValidationError";
11
+ if (Error.captureStackTrace) {
12
+ Error.captureStackTrace(this, _ElicitationValidationError);
13
+ }
14
+ }
15
+ static {
16
+ __name(this, "ElicitationValidationError");
17
+ }
18
+ };
19
+ var ElicitationTimeoutError = class _ElicitationTimeoutError extends Error {
20
+ constructor(message, timeoutMs) {
21
+ super(message);
22
+ this.timeoutMs = timeoutMs;
23
+ this.name = "ElicitationTimeoutError";
24
+ if (Error.captureStackTrace) {
25
+ Error.captureStackTrace(this, _ElicitationTimeoutError);
26
+ }
27
+ }
28
+ static {
29
+ __name(this, "ElicitationTimeoutError");
30
+ }
31
+ };
32
+ var ElicitationDeclinedError = class _ElicitationDeclinedError extends Error {
33
+ static {
34
+ __name(this, "ElicitationDeclinedError");
35
+ }
36
+ constructor(message = "User declined the elicitation request") {
37
+ super(message);
38
+ this.name = "ElicitationDeclinedError";
39
+ if (Error.captureStackTrace) {
40
+ Error.captureStackTrace(this, _ElicitationDeclinedError);
41
+ }
42
+ }
43
+ };
44
+
45
+ export {
46
+ ElicitationValidationError,
47
+ ElicitationTimeoutError,
48
+ ElicitationDeclinedError
49
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BrowserMCPClient
3
- } from "./chunk-X2HZKCNO.js";
3
+ } from "./chunk-D22NUQTL.js";
4
4
  import {
5
5
  BrowserOAuthClientProvider,
6
6
  sanitizeUrl
@@ -50,7 +50,8 @@ function useMcp(options) {
50
50
  // 5 minutes default for SSE read timeout
51
51
  wrapTransport,
52
52
  onNotification,
53
- samplingCallback
53
+ samplingCallback,
54
+ onElicitation
54
55
  } = options;
55
56
  const [state, setState] = useState("discovering");
56
57
  const [tools, setTools] = useState([]);
@@ -208,6 +209,8 @@ function useMcp(options) {
208
209
  // ← Pass client config to connector
209
210
  samplingCallback,
210
211
  // ← Pass sampling callback to connector
212
+ elicitationCallback: onElicitation,
213
+ // ← Pass elicitation callback to connector
211
214
  wrapTransport: wrapTransport ? (transport) => {
212
215
  console.log(
213
216
  "[useMcp] Applying transport wrapper for server:",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseConnector
3
- } from "./chunk-DWTSQOEC.js";
3
+ } from "./chunk-ZQUCGISK.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-3GQAWCBQ.js";
@@ -8,7 +8,8 @@ import {
8
8
  // src/connectors/base.ts
9
9
  import {
10
10
  ListRootsRequestSchema,
11
- CreateMessageRequestSchema
11
+ CreateMessageRequestSchema,
12
+ ElicitRequestSchema
12
13
  } from "@modelcontextprotocol/sdk/types.js";
13
14
  var BaseConnector = class {
14
15
  static {
@@ -182,6 +183,33 @@ var BaseConnector = class {
182
183
  "setupSamplingHandler: Sampling handler registered successfully"
183
184
  );
184
185
  }
186
+ /**
187
+ * Internal: set up elicitation/create request handler.
188
+ * This is called after the client connects to register the handler for elicitation requests.
189
+ */
190
+ setupElicitationHandler() {
191
+ if (!this.client) {
192
+ logger.debug("setupElicitationHandler: No client available");
193
+ return;
194
+ }
195
+ if (!this.opts.elicitationCallback) {
196
+ logger.debug("setupElicitationHandler: No elicitation callback provided");
197
+ return;
198
+ }
199
+ logger.debug(
200
+ "setupElicitationHandler: Setting up elicitation request handler"
201
+ );
202
+ this.client.setRequestHandler(
203
+ ElicitRequestSchema,
204
+ async (request, _extra) => {
205
+ logger.debug("Server requested elicitation, forwarding to callback");
206
+ return await this.opts.elicitationCallback(request.params);
207
+ }
208
+ );
209
+ logger.debug(
210
+ "setupElicitationHandler: Elicitation handler registered successfully"
211
+ );
212
+ }
185
213
  /** Disconnect and release resources. */
186
214
  async disconnect() {
187
215
  if (!this.connected) {
package/dist/index.cjs CHANGED
@@ -1055,6 +1055,9 @@ __export(index_exports, {
1055
1055
  BrowserOAuthClientProvider: () => BrowserOAuthClientProvider,
1056
1056
  ConnectMCPServerTool: () => ConnectMCPServerTool,
1057
1057
  E2BCodeExecutor: () => E2BCodeExecutor,
1058
+ ElicitationDeclinedError: () => ElicitationDeclinedError,
1059
+ ElicitationTimeoutError: () => ElicitationTimeoutError,
1060
+ ElicitationValidationError: () => ElicitationValidationError,
1058
1061
  ErrorBoundary: () => ErrorBoundary,
1059
1062
  HttpConnector: () => HttpConnector,
1060
1063
  Image: () => Image,
@@ -5650,6 +5653,33 @@ var BaseConnector = class {
5650
5653
  "setupSamplingHandler: Sampling handler registered successfully"
5651
5654
  );
5652
5655
  }
5656
+ /**
5657
+ * Internal: set up elicitation/create request handler.
5658
+ * This is called after the client connects to register the handler for elicitation requests.
5659
+ */
5660
+ setupElicitationHandler() {
5661
+ if (!this.client) {
5662
+ logger.debug("setupElicitationHandler: No client available");
5663
+ return;
5664
+ }
5665
+ if (!this.opts.elicitationCallback) {
5666
+ logger.debug("setupElicitationHandler: No elicitation callback provided");
5667
+ return;
5668
+ }
5669
+ logger.debug(
5670
+ "setupElicitationHandler: Setting up elicitation request handler"
5671
+ );
5672
+ this.client.setRequestHandler(
5673
+ import_types.ElicitRequestSchema,
5674
+ async (request, _extra) => {
5675
+ logger.debug("Server requested elicitation, forwarding to callback");
5676
+ return await this.opts.elicitationCallback(request.params);
5677
+ }
5678
+ );
5679
+ logger.debug(
5680
+ "setupElicitationHandler: Elicitation handler registered successfully"
5681
+ );
5682
+ }
5653
5683
  /** Disconnect and release resources. */
5654
5684
  async disconnect() {
5655
5685
  if (!this.connected) {
@@ -6399,7 +6429,9 @@ var HttpConnector = class extends BaseConnector {
6399
6429
  roots: { listChanged: true },
6400
6430
  // Always advertise roots capability
6401
6431
  // Add sampling capability if callback is provided
6402
- ...this.opts.samplingCallback ? { sampling: {} } : {}
6432
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
6433
+ // Add elicitation capability if callback is provided
6434
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
6403
6435
  }
6404
6436
  };
6405
6437
  logger.debug(
@@ -6453,6 +6485,7 @@ var HttpConnector = class extends BaseConnector {
6453
6485
  this.transportType = "streamable-http";
6454
6486
  this.setupNotificationHandler();
6455
6487
  this.setupSamplingHandler();
6488
+ this.setupElicitationHandler();
6456
6489
  logger.debug(
6457
6490
  `Successfully connected to MCP implementation via streamable HTTP: ${baseUrl}`
6458
6491
  );
@@ -6482,7 +6515,9 @@ var HttpConnector = class extends BaseConnector {
6482
6515
  roots: { listChanged: true },
6483
6516
  // Always advertise roots capability
6484
6517
  // Add sampling capability if callback is provided
6485
- ...this.opts.samplingCallback ? { sampling: {} } : {}
6518
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
6519
+ // Add elicitation capability if callback is provided
6520
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
6486
6521
  }
6487
6522
  };
6488
6523
  logger.debug(
@@ -6497,6 +6532,7 @@ var HttpConnector = class extends BaseConnector {
6497
6532
  this.transportType = "sse";
6498
6533
  this.setupNotificationHandler();
6499
6534
  this.setupSamplingHandler();
6535
+ this.setupElicitationHandler();
6500
6536
  logger.debug(
6501
6537
  `Successfully connected to MCP implementation via HTTP/SSE: ${baseUrl}`
6502
6538
  );
@@ -6640,7 +6676,9 @@ var StdioConnector = class extends BaseConnector {
6640
6676
  roots: { listChanged: true },
6641
6677
  // Always advertise roots capability
6642
6678
  // Add sampling capability if callback is provided
6643
- ...this.opts.samplingCallback ? { sampling: {} } : {}
6679
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
6680
+ // Add elicitation capability if callback is provided
6681
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
6644
6682
  }
6645
6683
  };
6646
6684
  this.client = new import_client2.Client(this.clientInfo, clientOptions);
@@ -6649,6 +6687,7 @@ var StdioConnector = class extends BaseConnector {
6649
6687
  this.setupNotificationHandler();
6650
6688
  this.setupRootsHandler();
6651
6689
  this.setupSamplingHandler();
6690
+ this.setupElicitationHandler();
6652
6691
  logger.debug(
6653
6692
  `Successfully connected to MCP implementation: ${this.command}`
6654
6693
  );
@@ -6991,6 +7030,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
6991
7030
  _codeExecutorConfig = "vm";
6992
7031
  _executorOptions;
6993
7032
  _samplingCallback;
7033
+ _elicitationCallback;
6994
7034
  constructor(config, options) {
6995
7035
  if (config) {
6996
7036
  if (typeof config === "string") {
@@ -7017,6 +7057,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
7017
7057
  this._codeExecutorConfig = executorConfig;
7018
7058
  this._executorOptions = executorOptions;
7019
7059
  this._samplingCallback = options?.samplingCallback;
7060
+ this._elicitationCallback = options?.elicitationCallback;
7020
7061
  if (this.codeMode) {
7021
7062
  this._setupCodeModeConnector();
7022
7063
  }
@@ -7043,7 +7084,8 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
7043
7084
  */
7044
7085
  createConnectorFromConfig(serverConfig) {
7045
7086
  return createConnectorFromConfig(serverConfig, {
7046
- samplingCallback: this._samplingCallback
7087
+ samplingCallback: this._samplingCallback,
7088
+ elicitationCallback: this._elicitationCallback
7047
7089
  });
7048
7090
  }
7049
7091
  _setupCodeModeConnector() {
@@ -8037,7 +8079,8 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
8037
8079
  authProvider,
8038
8080
  wrapTransport,
8039
8081
  clientOptions,
8040
- samplingCallback
8082
+ samplingCallback,
8083
+ elicitationCallback
8041
8084
  } = serverConfig;
8042
8085
  if (!url) {
8043
8086
  throw new Error("Server URL is required");
@@ -8051,8 +8094,10 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
8051
8094
  // ← Pass transport wrapper if provided
8052
8095
  clientOptions,
8053
8096
  // ← Pass client options (capabilities, etc.) to connector
8054
- samplingCallback
8097
+ samplingCallback,
8055
8098
  // ← Pass sampling callback to connector
8099
+ elicitationCallback
8100
+ // ← Pass elicitation callback to connector
8056
8101
  };
8057
8102
  if (clientOptions) {
8058
8103
  console.log(
@@ -8112,7 +8157,8 @@ function useMcp(options) {
8112
8157
  // 5 minutes default for SSE read timeout
8113
8158
  wrapTransport,
8114
8159
  onNotification,
8115
- samplingCallback
8160
+ samplingCallback,
8161
+ onElicitation
8116
8162
  } = options;
8117
8163
  const [state, setState] = (0, import_react.useState)("discovering");
8118
8164
  const [tools, setTools] = (0, import_react.useState)([]);
@@ -8270,6 +8316,8 @@ function useMcp(options) {
8270
8316
  // ← Pass client config to connector
8271
8317
  samplingCallback,
8272
8318
  // ← Pass sampling callback to connector
8319
+ elicitationCallback: onElicitation,
8320
+ // ← Pass elicitation callback to connector
8273
8321
  wrapTransport: wrapTransport ? (transport) => {
8274
8322
  console.log(
8275
8323
  "[useMcp] Applying transport wrapper for server:",
@@ -9692,3 +9740,43 @@ __name(McpUseProvider, "McpUseProvider");
9692
9740
  var PROMPTS = {
9693
9741
  CODE_MODE: CODE_MODE_AGENT_PROMPT
9694
9742
  };
9743
+
9744
+ // src/errors.ts
9745
+ var ElicitationValidationError = class _ElicitationValidationError extends Error {
9746
+ constructor(message, cause) {
9747
+ super(message);
9748
+ this.cause = cause;
9749
+ this.name = "ElicitationValidationError";
9750
+ if (Error.captureStackTrace) {
9751
+ Error.captureStackTrace(this, _ElicitationValidationError);
9752
+ }
9753
+ }
9754
+ static {
9755
+ __name(this, "ElicitationValidationError");
9756
+ }
9757
+ };
9758
+ var ElicitationTimeoutError = class _ElicitationTimeoutError extends Error {
9759
+ constructor(message, timeoutMs) {
9760
+ super(message);
9761
+ this.timeoutMs = timeoutMs;
9762
+ this.name = "ElicitationTimeoutError";
9763
+ if (Error.captureStackTrace) {
9764
+ Error.captureStackTrace(this, _ElicitationTimeoutError);
9765
+ }
9766
+ }
9767
+ static {
9768
+ __name(this, "ElicitationTimeoutError");
9769
+ }
9770
+ };
9771
+ var ElicitationDeclinedError = class _ElicitationDeclinedError extends Error {
9772
+ static {
9773
+ __name(this, "ElicitationDeclinedError");
9774
+ }
9775
+ constructor(message = "User declined the elicitation request") {
9776
+ super(message);
9777
+ this.name = "ElicitationDeclinedError";
9778
+ if (Error.captureStackTrace) {
9779
+ Error.captureStackTrace(this, _ElicitationDeclinedError);
9780
+ }
9781
+ }
9782
+ };
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ export type { NotificationHandler };
37
37
  export type { CodeModeConfig, E2BExecutorOptions, ExecutorOptions, MCPClientOptions, VMExecutorOptions, } from "./src/client.js";
38
38
  export { BaseCodeExecutor, E2BCodeExecutor, VMCodeExecutor, isVMAvailable, } from "./src/client.js";
39
39
  export type { ExecutionResult, SearchToolsFunction, ToolNamespaceInfo, ToolSearchResult, } from "./src/client/codeExecutor.js";
40
+ export { ElicitationDeclinedError, ElicitationTimeoutError, ElicitationValidationError, } from "./src/errors.js";
40
41
  export type { CreateMessageRequest, CreateMessageResult, } from "@modelcontextprotocol/sdk/types.js";
41
42
  /**
42
43
  * Type alias for the params property of CreateMessageRequest.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,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AAC;AAEzB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC"}
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import "./chunk-JQKKMUCT.js";
24
24
  import {
25
25
  CodeModeConnector,
26
26
  PROMPTS
27
- } from "./chunk-LWAQBWXN.js";
27
+ } from "./chunk-QREDNTLS.js";
28
28
  import {
29
29
  ErrorBoundary,
30
30
  Image,
@@ -36,25 +36,30 @@ import {
36
36
  useWidgetProps,
37
37
  useWidgetState,
38
38
  useWidgetTheme
39
- } from "./chunk-HDYKWLGV.js";
39
+ } from "./chunk-MUZ5WYE3.js";
40
40
  import {
41
41
  BaseMCPClient,
42
42
  ConnectionManager,
43
43
  HttpConnector,
44
44
  MCPSession,
45
45
  WebSocketConnector
46
- } from "./chunk-X2HZKCNO.js";
46
+ } from "./chunk-D22NUQTL.js";
47
47
  import {
48
48
  BrowserOAuthClientProvider,
49
49
  onMcpAuthorization
50
50
  } from "./chunk-3R5PDYIN.js";
51
51
  import {
52
52
  BaseConnector
53
- } from "./chunk-DWTSQOEC.js";
53
+ } from "./chunk-ZQUCGISK.js";
54
54
  import {
55
55
  Logger,
56
56
  logger
57
57
  } from "./chunk-34R6SIER.js";
58
+ import {
59
+ ElicitationDeclinedError,
60
+ ElicitationTimeoutError,
61
+ ElicitationValidationError
62
+ } from "./chunk-KUEVOU4M.js";
58
63
  import "./chunk-MTHLLDCX.js";
59
64
  import {
60
65
  __name,
@@ -819,7 +824,9 @@ var StdioConnector = class extends BaseConnector {
819
824
  roots: { listChanged: true },
820
825
  // Always advertise roots capability
821
826
  // Add sampling capability if callback is provided
822
- ...this.opts.samplingCallback ? { sampling: {} } : {}
827
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
828
+ // Add elicitation capability if callback is provided
829
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
823
830
  }
824
831
  };
825
832
  this.client = new Client(this.clientInfo, clientOptions);
@@ -828,6 +835,7 @@ var StdioConnector = class extends BaseConnector {
828
835
  this.setupNotificationHandler();
829
836
  this.setupRootsHandler();
830
837
  this.setupSamplingHandler();
838
+ this.setupElicitationHandler();
831
839
  logger.debug(
832
840
  `Successfully connected to MCP implementation: ${this.command}`
833
841
  );
@@ -892,6 +900,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
892
900
  _codeExecutorConfig = "vm";
893
901
  _executorOptions;
894
902
  _samplingCallback;
903
+ _elicitationCallback;
895
904
  constructor(config, options) {
896
905
  if (config) {
897
906
  if (typeof config === "string") {
@@ -918,6 +927,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
918
927
  this._codeExecutorConfig = executorConfig;
919
928
  this._executorOptions = executorOptions;
920
929
  this._samplingCallback = options?.samplingCallback;
930
+ this._elicitationCallback = options?.elicitationCallback;
921
931
  if (this.codeMode) {
922
932
  this._setupCodeModeConnector();
923
933
  }
@@ -944,7 +954,8 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
944
954
  */
945
955
  createConnectorFromConfig(serverConfig) {
946
956
  return createConnectorFromConfig(serverConfig, {
947
- samplingCallback: this._samplingCallback
957
+ samplingCallback: this._samplingCallback,
958
+ elicitationCallback: this._elicitationCallback
948
959
  });
949
960
  }
950
961
  _setupCodeModeConnector() {
@@ -1467,6 +1478,9 @@ export {
1467
1478
  BrowserOAuthClientProvider,
1468
1479
  ConnectMCPServerTool,
1469
1480
  E2BCodeExecutor,
1481
+ ElicitationDeclinedError,
1482
+ ElicitationTimeoutError,
1483
+ ElicitationValidationError,
1470
1484
  ErrorBoundary,
1471
1485
  HttpConnector,
1472
1486
  Image,
@@ -8,8 +8,8 @@ import {
8
8
  import "../../chunk-CPG2WZUL.js";
9
9
  import {
10
10
  PROMPTS
11
- } from "../../chunk-LWAQBWXN.js";
12
- import "../../chunk-DWTSQOEC.js";
11
+ } from "../../chunk-QREDNTLS.js";
12
+ import "../../chunk-ZQUCGISK.js";
13
13
  import "../../chunk-34R6SIER.js";
14
14
  import "../../chunk-MTHLLDCX.js";
15
15
  import "../../chunk-3GQAWCBQ.js";
@@ -1412,6 +1412,33 @@ var BaseConnector = class {
1412
1412
  "setupSamplingHandler: Sampling handler registered successfully"
1413
1413
  );
1414
1414
  }
1415
+ /**
1416
+ * Internal: set up elicitation/create request handler.
1417
+ * This is called after the client connects to register the handler for elicitation requests.
1418
+ */
1419
+ setupElicitationHandler() {
1420
+ if (!this.client) {
1421
+ logger.debug("setupElicitationHandler: No client available");
1422
+ return;
1423
+ }
1424
+ if (!this.opts.elicitationCallback) {
1425
+ logger.debug("setupElicitationHandler: No elicitation callback provided");
1426
+ return;
1427
+ }
1428
+ logger.debug(
1429
+ "setupElicitationHandler: Setting up elicitation request handler"
1430
+ );
1431
+ this.client.setRequestHandler(
1432
+ import_types.ElicitRequestSchema,
1433
+ async (request, _extra) => {
1434
+ logger.debug("Server requested elicitation, forwarding to callback");
1435
+ return await this.opts.elicitationCallback(request.params);
1436
+ }
1437
+ );
1438
+ logger.debug(
1439
+ "setupElicitationHandler: Elicitation handler registered successfully"
1440
+ );
1441
+ }
1415
1442
  /** Disconnect and release resources. */
1416
1443
  async disconnect() {
1417
1444
  if (!this.connected) {
@@ -1795,7 +1822,9 @@ var HttpConnector = class extends BaseConnector {
1795
1822
  roots: { listChanged: true },
1796
1823
  // Always advertise roots capability
1797
1824
  // Add sampling capability if callback is provided
1798
- ...this.opts.samplingCallback ? { sampling: {} } : {}
1825
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
1826
+ // Add elicitation capability if callback is provided
1827
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
1799
1828
  }
1800
1829
  };
1801
1830
  logger.debug(
@@ -1849,6 +1878,7 @@ var HttpConnector = class extends BaseConnector {
1849
1878
  this.transportType = "streamable-http";
1850
1879
  this.setupNotificationHandler();
1851
1880
  this.setupSamplingHandler();
1881
+ this.setupElicitationHandler();
1852
1882
  logger.debug(
1853
1883
  `Successfully connected to MCP implementation via streamable HTTP: ${baseUrl}`
1854
1884
  );
@@ -1878,7 +1908,9 @@ var HttpConnector = class extends BaseConnector {
1878
1908
  roots: { listChanged: true },
1879
1909
  // Always advertise roots capability
1880
1910
  // Add sampling capability if callback is provided
1881
- ...this.opts.samplingCallback ? { sampling: {} } : {}
1911
+ ...this.opts.samplingCallback ? { sampling: {} } : {},
1912
+ // Add elicitation capability if callback is provided
1913
+ ...this.opts.elicitationCallback ? { elicitation: { form: {}, url: {} } } : {}
1882
1914
  }
1883
1915
  };
1884
1916
  logger.debug(
@@ -1893,6 +1925,7 @@ var HttpConnector = class extends BaseConnector {
1893
1925
  this.transportType = "sse";
1894
1926
  this.setupNotificationHandler();
1895
1927
  this.setupSamplingHandler();
1928
+ this.setupElicitationHandler();
1896
1929
  logger.debug(
1897
1930
  `Successfully connected to MCP implementation via HTTP/SSE: ${baseUrl}`
1898
1931
  );
@@ -2417,7 +2450,8 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
2417
2450
  authProvider,
2418
2451
  wrapTransport,
2419
2452
  clientOptions,
2420
- samplingCallback
2453
+ samplingCallback,
2454
+ elicitationCallback
2421
2455
  } = serverConfig;
2422
2456
  if (!url) {
2423
2457
  throw new Error("Server URL is required");
@@ -2431,8 +2465,10 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
2431
2465
  // ← Pass transport wrapper if provided
2432
2466
  clientOptions,
2433
2467
  // ← Pass client options (capabilities, etc.) to connector
2434
- samplingCallback
2468
+ samplingCallback,
2435
2469
  // ← Pass sampling callback to connector
2470
+ elicitationCallback
2471
+ // ← Pass elicitation callback to connector
2436
2472
  };
2437
2473
  if (clientOptions) {
2438
2474
  console.log(
@@ -16,14 +16,14 @@ import {
16
16
  HttpConnector,
17
17
  MCPSession,
18
18
  WebSocketConnector
19
- } from "../chunk-X2HZKCNO.js";
19
+ } from "../chunk-D22NUQTL.js";
20
20
  import {
21
21
  BrowserOAuthClientProvider,
22
22
  onMcpAuthorization
23
23
  } from "../chunk-3R5PDYIN.js";
24
24
  import {
25
25
  BaseConnector
26
- } from "../chunk-DWTSQOEC.js";
26
+ } from "../chunk-ZQUCGISK.js";
27
27
  import {
28
28
  Logger,
29
29
  logger
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;gBACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAI1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;CAwDjB"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;gBACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;WAI1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;CA0DjB"}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PROMPTS
3
- } from "../../chunk-LWAQBWXN.js";
4
- import "../../chunk-DWTSQOEC.js";
3
+ } from "../../chunk-QREDNTLS.js";
4
+ import "../../chunk-ZQUCGISK.js";
5
5
  import "../../chunk-34R6SIER.js";
6
6
  import "../../chunk-3GQAWCBQ.js";
7
7
  export {