ai 4.3.11 → 4.3.13

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.mjs CHANGED
@@ -7504,6 +7504,24 @@ var MCPClient = class {
7504
7504
  await ((_a17 = this.transport) == null ? void 0 : _a17.close());
7505
7505
  this.onClose();
7506
7506
  }
7507
+ assertCapability(method) {
7508
+ switch (method) {
7509
+ case "initialize":
7510
+ break;
7511
+ case "tools/list":
7512
+ case "tools/call":
7513
+ if (!this.serverCapabilities.tools) {
7514
+ throw new MCPClientError({
7515
+ message: `Server does not support tools`
7516
+ });
7517
+ }
7518
+ break;
7519
+ default:
7520
+ throw new MCPClientError({
7521
+ message: `Unsupported method: ${method}`
7522
+ });
7523
+ }
7524
+ }
7507
7525
  async request({
7508
7526
  request,
7509
7527
  resultSchema,
@@ -7517,6 +7535,7 @@ var MCPClient = class {
7517
7535
  })
7518
7536
  );
7519
7537
  }
7538
+ this.assertCapability(request.method);
7520
7539
  const signal = options == null ? void 0 : options.signal;
7521
7540
  signal == null ? void 0 : signal.throwIfAborted();
7522
7541
  const messageId = this.requestMessageId++;
@@ -7545,7 +7564,7 @@ var MCPClient = class {
7545
7564
  resolve(result);
7546
7565
  } catch (error) {
7547
7566
  const parseError = new MCPClientError({
7548
- message: "Failed to parse server initialization result",
7567
+ message: "Failed to parse server response",
7549
7568
  cause: error
7550
7569
  });
7551
7570
  reject(parseError);
@@ -7561,11 +7580,6 @@ var MCPClient = class {
7561
7580
  params,
7562
7581
  options
7563
7582
  } = {}) {
7564
- if (!this.serverCapabilities.tools) {
7565
- throw new MCPClientError({
7566
- message: `Server does not support tools`
7567
- });
7568
- }
7569
7583
  try {
7570
7584
  return this.request({
7571
7585
  request: { method: "tools/list", params },
@@ -7581,11 +7595,6 @@ var MCPClient = class {
7581
7595
  args,
7582
7596
  options
7583
7597
  }) {
7584
- if (!this.serverCapabilities.tools) {
7585
- throw new MCPClientError({
7586
- message: `Server does not support tools`
7587
- });
7588
- }
7589
7598
  try {
7590
7599
  return this.request({
7591
7600
  request: { method: "tools/call", params: { name: name17, arguments: args } },