ai 4.3.10 → 4.3.12

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # ai
2
2
 
3
+ ## 4.3.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 1ed3755: fix (ai): don't publish mcp-stdio TypeScript files
8
+ - 46cb332: chore (ai/mcp): add `assertCapability` method to experimental MCP client
9
+
10
+ ## 4.3.11
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [77b2097]
15
+ - Updated dependencies [62181ef]
16
+ - @ai-sdk/react@1.2.10
17
+ - @ai-sdk/ui-utils@1.2.9
18
+
3
19
  ## 4.3.10
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2019,9 +2019,13 @@ declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
2019
2019
  * Tool parameters are automatically inferred from the server's JSON schema
2020
2020
  * if not explicitly provided in the tools configuration
2021
2021
  *
2022
+ * This client is meant to be used to communicate with a single server. To communicate and fetch tools across multiple servers, it's recommended to create a new client instance per server.
2023
+ *
2022
2024
  * Not supported:
2023
2025
  * - Client options (e.g. sampling, roots) as they are not needed for tool conversion
2024
2026
  * - Accepting notifications
2027
+ * - Session management (when passing a sessionId to an instance of the Streamable HTTP transport)
2028
+ * - Resumable SSE streams
2025
2029
  */
2026
2030
  declare class MCPClient {
2027
2031
  private transport;
@@ -2034,6 +2038,7 @@ declare class MCPClient {
2034
2038
  constructor({ transport: transportConfig, name, onUncaughtError, }: MCPClientConfig);
2035
2039
  init(): Promise<this>;
2036
2040
  close(): Promise<void>;
2041
+ private assertCapability;
2037
2042
  private request;
2038
2043
  private listTools;
2039
2044
  private callTool;
package/dist/index.d.ts CHANGED
@@ -2019,9 +2019,13 @@ declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
2019
2019
  * Tool parameters are automatically inferred from the server's JSON schema
2020
2020
  * if not explicitly provided in the tools configuration
2021
2021
  *
2022
+ * This client is meant to be used to communicate with a single server. To communicate and fetch tools across multiple servers, it's recommended to create a new client instance per server.
2023
+ *
2022
2024
  * Not supported:
2023
2025
  * - Client options (e.g. sampling, roots) as they are not needed for tool conversion
2024
2026
  * - Accepting notifications
2027
+ * - Session management (when passing a sessionId to an instance of the Streamable HTTP transport)
2028
+ * - Resumable SSE streams
2025
2029
  */
2026
2030
  declare class MCPClient {
2027
2031
  private transport;
@@ -2034,6 +2038,7 @@ declare class MCPClient {
2034
2038
  constructor({ transport: transportConfig, name, onUncaughtError, }: MCPClientConfig);
2035
2039
  init(): Promise<this>;
2036
2040
  close(): Promise<void>;
2041
+ private assertCapability;
2037
2042
  private request;
2038
2043
  private listTools;
2039
2044
  private callTool;
package/dist/index.js CHANGED
@@ -7556,6 +7556,24 @@ var MCPClient = class {
7556
7556
  await ((_a17 = this.transport) == null ? void 0 : _a17.close());
7557
7557
  this.onClose();
7558
7558
  }
7559
+ assertCapability(method) {
7560
+ switch (method) {
7561
+ case "initialize":
7562
+ break;
7563
+ case "tools/list":
7564
+ case "tools/call":
7565
+ if (!this.serverCapabilities.tools) {
7566
+ throw new MCPClientError({
7567
+ message: `Server does not support tools`
7568
+ });
7569
+ }
7570
+ break;
7571
+ default:
7572
+ throw new MCPClientError({
7573
+ message: `Unsupported method: ${method}`
7574
+ });
7575
+ }
7576
+ }
7559
7577
  async request({
7560
7578
  request,
7561
7579
  resultSchema,
@@ -7569,6 +7587,7 @@ var MCPClient = class {
7569
7587
  })
7570
7588
  );
7571
7589
  }
7590
+ this.assertCapability(request.method);
7572
7591
  const signal = options == null ? void 0 : options.signal;
7573
7592
  signal == null ? void 0 : signal.throwIfAborted();
7574
7593
  const messageId = this.requestMessageId++;
@@ -7597,7 +7616,7 @@ var MCPClient = class {
7597
7616
  resolve(result);
7598
7617
  } catch (error) {
7599
7618
  const parseError = new MCPClientError({
7600
- message: "Failed to parse server initialization result",
7619
+ message: "Failed to parse server response",
7601
7620
  cause: error
7602
7621
  });
7603
7622
  reject(parseError);
@@ -7613,11 +7632,6 @@ var MCPClient = class {
7613
7632
  params,
7614
7633
  options
7615
7634
  } = {}) {
7616
- if (!this.serverCapabilities.tools) {
7617
- throw new MCPClientError({
7618
- message: `Server does not support tools`
7619
- });
7620
- }
7621
7635
  try {
7622
7636
  return this.request({
7623
7637
  request: { method: "tools/list", params },
@@ -7633,11 +7647,6 @@ var MCPClient = class {
7633
7647
  args,
7634
7648
  options
7635
7649
  }) {
7636
- if (!this.serverCapabilities.tools) {
7637
- throw new MCPClientError({
7638
- message: `Server does not support tools`
7639
- });
7640
- }
7641
7650
  try {
7642
7651
  return this.request({
7643
7652
  request: { method: "tools/call", params: { name: name17, arguments: args } },