@mcp-use/client 2.4.2 → 2.4.3-canary.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.
package/dist/index.d.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  * `@mcp-use/client` — MCP client for connecting to Model Context Protocol servers.
3
3
  *
4
4
  * Connectors, protocol-neutral MCP connections, project configuration, OAuth,
5
- * and code-mode helpers. The SDK negotiates legacy sessionful and modern
6
- * sessionless MCP servers automatically.
5
+ * and code-mode helpers. By default, HTTP connections negotiate the server's
6
+ * supported MCP protocol automatically and stdio connections use the sessionful
7
+ * protocol; set `protocolNegotiation` to override either default.
7
8
  */
8
9
  import "./telemetry/configure-node.js";
9
10
  export { auth, UnauthorizedError } from "@modelcontextprotocol/client";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1559,7 +1559,7 @@ init_connector_telemetry();
1559
1559
  init_logging();
1560
1560
 
1561
1561
  // src/utils/version.ts
1562
- var VERSION = "2.4.2";
1562
+ var VERSION = "2.4.3-canary.0";
1563
1563
  function getPackageVersion() {
1564
1564
  return VERSION;
1565
1565
  }
@@ -3611,7 +3611,8 @@ var SKILLS_EXTENSION_ID = "io.modelcontextprotocol/skills";
3611
3611
  var MCPConnection = class {
3612
3612
  /**
3613
3613
  * The underlying connector managing the transport layer.
3614
- * This is the Stdio, HTTP, or WebSocket connector handling actual communication.
3614
+ * This is the stdio or HTTP connector for a server, or the in-process
3615
+ * connector that backs code mode.
3615
3616
  */
3616
3617
  connector;
3617
3618
  /**
@@ -3622,12 +3623,12 @@ var MCPConnection = class {
3622
3623
  /**
3623
3624
  * Creates a new MCP session.
3624
3625
  *
3625
- * @param connector - The connector to use for communication (Stdio, HTTP, WebSocket)
3626
+ * @param connector - The connector to use for communication (stdio, HTTP, or code mode)
3626
3627
  * @param autoConnect - Whether to automatically connect during initialization (default: true)
3627
3628
  *
3628
3629
  * @example
3629
3630
  * ```typescript
3630
- * const connector = new HttpConnector({ url: 'http://localhost:3000/mcp' });
3631
+ * const connector = new HttpConnector('http://localhost:3000/mcp');
3631
3632
  * const session = new MCPSession(connector);
3632
3633
  * await session.initialize(); // Auto-connects and initializes
3633
3634
  * ```
@@ -3647,9 +3648,11 @@ var MCPConnection = class {
3647
3648
  /**
3648
3649
  * Establishes the connection to the MCP server.
3649
3650
  *
3650
- * This method starts the underlying transport (spawns process for Stdio,
3651
- * opens WebSocket, etc.) but does not perform the MCP initialization
3652
- * handshake. Call {@link initialize} after connecting.
3651
+ * For stdio and HTTP connectors, this method starts the underlying
3652
+ * transport (spawns the process for stdio, opens the HTTP transport) and
3653
+ * performs the MCP initialization handshake through the SDK client. Call
3654
+ * {@link initialize} afterwards to cache the server's capabilities, server
3655
+ * info, and tools.
3653
3656
  *
3654
3657
  * @returns Promise that resolves when connected
3655
3658
  *
@@ -3687,9 +3690,10 @@ var MCPConnection = class {
3687
3690
  /**
3688
3691
  * Initializes the MCP session with the server.
3689
3692
  *
3690
- * This method performs the MCP initialization handshake, exchanging
3691
- * capabilities and metadata with the server. If `autoConnect` is true
3692
- * and the session is not yet connected, it will connect first.
3693
+ * This method caches the capabilities, server info, and tools negotiated
3694
+ * during {@link connect}. If `autoConnect` is true and the session is not
3695
+ * yet connected, it connects first, which performs the MCP initialization
3696
+ * handshake.
3693
3697
  *
3694
3698
  * After initialization, you can list and call tools, read resources, etc.
3695
3699
  *
@@ -4322,7 +4326,7 @@ var BaseMCPClient = class {
4322
4326
  *
4323
4327
  * @param serverName - The name of the server as defined in the client configuration
4324
4328
  * @param autoInitialize - Whether to automatically initialize the session (default: true)
4325
- * @returns A promise that resolves to the created MCPSession instance
4329
+ * @returns A promise that resolves to the created MCPConnection instance (also exported as MCPSession).
4326
4330
  * @throws If the server is not found in the configuration
4327
4331
  *
4328
4332
  * @example
@@ -4417,6 +4421,7 @@ var BaseMCPClient = class {
4417
4421
  * the negotiated protocol version and normalized server metadata.
4418
4422
  *
4419
4423
  * @param serverName - The configured server name.
4424
+ * @returns A ready MCPConnection for calling tools and accessing server resources.
4420
4425
  */
4421
4426
  async connect(serverName) {
4422
4427
  return this.createSession(serverName);
@@ -5721,7 +5726,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
5721
5726
  * ```typescript
5722
5727
  * if (client.codeMode) {
5723
5728
  * const result = await client.executeCode('return 2 + 2');
5724
- * console.log(result.output); // "4"
5729
+ * console.log(result.result); // 4
5725
5730
  * }
5726
5731
  * ```
5727
5732
  */
@@ -6012,11 +6017,12 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
6012
6017
  *
6013
6018
  * This method is only available when code mode is enabled. It executes the
6014
6019
  * provided code in an isolated environment (VM or E2B sandbox) and returns
6015
- * the results including stdout, stderr, and return value.
6020
+ * the return value, captured console output, any error message, and the
6021
+ * execution time.
6016
6022
  *
6017
6023
  * @param code - JavaScript/TypeScript code to execute
6018
6024
  * @param timeout - Optional execution timeout in milliseconds
6019
- * @returns Execution result with output, errors, and return value
6025
+ * @returns Execution result with `result`, `logs`, `error`, and `execution_time`
6020
6026
  * @throws If code mode is not enabled
6021
6027
  *
6022
6028
  * @example
@@ -6028,17 +6034,16 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
6028
6034
  * return 2 + 2;
6029
6035
  * `);
6030
6036
  *
6031
- * console.log(result.stdout); // "Hello, world!\n"
6032
- * console.log(result.returnValue); // 4
6037
+ * console.log(result.logs); // ["Hello, world!"]
6038
+ * console.log(result.result); // 4
6033
6039
  * ```
6034
6040
  *
6035
6041
  * @example
6036
6042
  * ```typescript
6037
- * // With timeout
6038
- * try {
6039
- * const result = await client.executeCode('while(true) {}', 1000);
6040
- * } catch (error) {
6041
- * console.log('Execution timed out');
6043
+ * // With timeout: errors are reported in the result, not thrown
6044
+ * const result = await client.executeCode('while(true) {}', 1000);
6045
+ * if (result.error) {
6046
+ * console.log(result.error); // "Script execution timed out"
6042
6047
  * }
6043
6048
  * ```
6044
6049
  *
@@ -6069,7 +6074,7 @@ var MCPClient = class _MCPClient extends BaseMCPClient {
6069
6074
  *
6070
6075
  * // Search for all tools
6071
6076
  * const allTools = await client.searchTools();
6072
- * console.log(`Found ${allTools.tools.length} tools`);
6077
+ * console.log(`Found ${allTools.results.length} tools`);
6073
6078
  *
6074
6079
  * // Search for specific tools
6075
6080
  * const fileTools = await client.searchTools('file', 'descriptions');