@ai-sdk/mcp 2.0.0-beta.3 → 2.0.0-beta.30

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
@@ -1,54 +1,20 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name3 in all)
10
- __defProp(target, name3, { get: all[name3], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- ElicitResultSchema: () => ElicitResultSchema,
34
- ElicitationRequestSchema: () => ElicitationRequestSchema,
35
- UnauthorizedError: () => UnauthorizedError,
36
- auth: () => auth,
37
- createMCPClient: () => createMCPClient,
38
- experimental_createMCPClient: () => createMCPClient
39
- });
40
- module.exports = __toCommonJS(src_exports);
41
-
42
1
  // src/tool/mcp-client.ts
43
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ asSchema,
4
+ dynamicTool,
5
+ jsonSchema,
6
+ safeParseJSON,
7
+ safeValidateTypes,
8
+ tool
9
+ } from "@ai-sdk/provider-utils";
44
10
 
45
11
  // src/error/mcp-client-error.ts
46
- var import_provider = require("@ai-sdk/provider");
12
+ import { AISDKError } from "@ai-sdk/provider";
47
13
  var name = "AI_MCPClientError";
48
14
  var marker = `vercel.ai.error.${name}`;
49
15
  var symbol = Symbol.for(marker);
50
16
  var _a, _b;
51
- var MCPClientError = class extends (_b = import_provider.AISDKError, _a = symbol, _b) {
17
+ var MCPClientError = class extends (_b = AISDKError, _a = symbol, _b) {
52
18
  constructor({
53
19
  name: name3 = "MCPClientError",
54
20
  message,
@@ -62,18 +28,22 @@ var MCPClientError = class extends (_b = import_provider.AISDKError, _a = symbol
62
28
  this.code = code;
63
29
  }
64
30
  static isInstance(error) {
65
- return import_provider.AISDKError.hasMarker(error, marker);
31
+ return AISDKError.hasMarker(error, marker);
66
32
  }
67
33
  };
68
34
 
69
35
  // src/tool/mcp-sse-transport.ts
70
- var import_provider_utils = require("@ai-sdk/provider-utils");
36
+ import {
37
+ EventSourceParserStream,
38
+ withUserAgentSuffix,
39
+ getRuntimeEnvironmentUserAgent
40
+ } from "@ai-sdk/provider-utils";
71
41
 
72
42
  // src/tool/json-rpc-message.ts
73
- var import_v42 = require("zod/v4");
43
+ import { z as z2 } from "zod/v4";
74
44
 
75
45
  // src/tool/types.ts
76
- var import_v4 = require("zod/v4");
46
+ import { z } from "zod/v4";
77
47
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
78
48
  var SUPPORTED_PROTOCOL_VERSIONS = [
79
49
  LATEST_PROTOCOL_VERSION,
@@ -81,229 +51,230 @@ var SUPPORTED_PROTOCOL_VERSIONS = [
81
51
  "2025-03-26",
82
52
  "2024-11-05"
83
53
  ];
84
- var ToolMetaSchema = import_v4.z.optional(import_v4.z.record(import_v4.z.string(), import_v4.z.unknown()));
85
- var ClientOrServerImplementationSchema = import_v4.z.looseObject({
86
- name: import_v4.z.string(),
87
- version: import_v4.z.string()
54
+ var ToolMetaSchema = z.optional(z.record(z.string(), z.unknown()));
55
+ var ClientOrServerImplementationSchema = z.looseObject({
56
+ name: z.string(),
57
+ version: z.string(),
58
+ title: z.optional(z.string())
88
59
  });
89
- var BaseParamsSchema = import_v4.z.looseObject({
90
- _meta: import_v4.z.optional(import_v4.z.object({}).loose())
60
+ var BaseParamsSchema = z.looseObject({
61
+ _meta: z.optional(z.object({}).loose())
91
62
  });
92
63
  var ResultSchema = BaseParamsSchema;
93
- var RequestSchema = import_v4.z.object({
94
- method: import_v4.z.string(),
95
- params: import_v4.z.optional(BaseParamsSchema)
64
+ var RequestSchema = z.object({
65
+ method: z.string(),
66
+ params: z.optional(BaseParamsSchema)
96
67
  });
97
- var ElicitationCapabilitySchema = import_v4.z.object({
98
- applyDefaults: import_v4.z.optional(import_v4.z.boolean())
68
+ var ElicitationCapabilitySchema = z.object({
69
+ applyDefaults: z.optional(z.boolean())
99
70
  }).loose();
100
- var ServerCapabilitiesSchema = import_v4.z.looseObject({
101
- experimental: import_v4.z.optional(import_v4.z.object({}).loose()),
102
- logging: import_v4.z.optional(import_v4.z.object({}).loose()),
103
- prompts: import_v4.z.optional(
104
- import_v4.z.looseObject({
105
- listChanged: import_v4.z.optional(import_v4.z.boolean())
71
+ var ServerCapabilitiesSchema = z.looseObject({
72
+ experimental: z.optional(z.object({}).loose()),
73
+ logging: z.optional(z.object({}).loose()),
74
+ prompts: z.optional(
75
+ z.looseObject({
76
+ listChanged: z.optional(z.boolean())
106
77
  })
107
78
  ),
108
- resources: import_v4.z.optional(
109
- import_v4.z.looseObject({
110
- subscribe: import_v4.z.optional(import_v4.z.boolean()),
111
- listChanged: import_v4.z.optional(import_v4.z.boolean())
79
+ resources: z.optional(
80
+ z.looseObject({
81
+ subscribe: z.optional(z.boolean()),
82
+ listChanged: z.optional(z.boolean())
112
83
  })
113
84
  ),
114
- tools: import_v4.z.optional(
115
- import_v4.z.looseObject({
116
- listChanged: import_v4.z.optional(import_v4.z.boolean())
85
+ tools: z.optional(
86
+ z.looseObject({
87
+ listChanged: z.optional(z.boolean())
117
88
  })
118
89
  ),
119
- elicitation: import_v4.z.optional(ElicitationCapabilitySchema)
90
+ elicitation: z.optional(ElicitationCapabilitySchema)
120
91
  });
121
- var ClientCapabilitiesSchema = import_v4.z.object({
122
- elicitation: import_v4.z.optional(ElicitationCapabilitySchema)
92
+ var ClientCapabilitiesSchema = z.object({
93
+ elicitation: z.optional(ElicitationCapabilitySchema)
123
94
  }).loose();
124
95
  var InitializeResultSchema = ResultSchema.extend({
125
- protocolVersion: import_v4.z.string(),
96
+ protocolVersion: z.string(),
126
97
  capabilities: ServerCapabilitiesSchema,
127
98
  serverInfo: ClientOrServerImplementationSchema,
128
- instructions: import_v4.z.optional(import_v4.z.string())
99
+ instructions: z.optional(z.string())
129
100
  });
130
101
  var PaginatedResultSchema = ResultSchema.extend({
131
- nextCursor: import_v4.z.optional(import_v4.z.string())
102
+ nextCursor: z.optional(z.string())
132
103
  });
133
- var ToolSchema = import_v4.z.object({
134
- name: import_v4.z.string(),
104
+ var ToolSchema = z.object({
105
+ name: z.string(),
135
106
  /**
136
107
  * @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool
137
108
  */
138
- title: import_v4.z.optional(import_v4.z.string()),
139
- description: import_v4.z.optional(import_v4.z.string()),
140
- inputSchema: import_v4.z.object({
141
- type: import_v4.z.literal("object"),
142
- properties: import_v4.z.optional(import_v4.z.object({}).loose())
109
+ title: z.optional(z.string()),
110
+ description: z.optional(z.string()),
111
+ inputSchema: z.object({
112
+ type: z.literal("object"),
113
+ properties: z.optional(z.object({}).loose())
143
114
  }).loose(),
144
115
  /**
145
116
  * @see https://modelcontextprotocol.io/specification/2025-06-18/server/tools#output-schema
146
117
  */
147
- outputSchema: import_v4.z.optional(import_v4.z.object({}).loose()),
148
- annotations: import_v4.z.optional(
149
- import_v4.z.object({
150
- title: import_v4.z.optional(import_v4.z.string())
118
+ outputSchema: z.optional(z.object({}).loose()),
119
+ annotations: z.optional(
120
+ z.object({
121
+ title: z.optional(z.string())
151
122
  }).loose()
152
123
  ),
153
124
  _meta: ToolMetaSchema
154
125
  }).loose();
155
126
  var ListToolsResultSchema = PaginatedResultSchema.extend({
156
- tools: import_v4.z.array(ToolSchema)
127
+ tools: z.array(ToolSchema)
157
128
  });
158
- var TextContentSchema = import_v4.z.object({
159
- type: import_v4.z.literal("text"),
160
- text: import_v4.z.string()
129
+ var TextContentSchema = z.object({
130
+ type: z.literal("text"),
131
+ text: z.string()
161
132
  }).loose();
162
- var ImageContentSchema = import_v4.z.object({
163
- type: import_v4.z.literal("image"),
164
- data: import_v4.z.base64(),
165
- mimeType: import_v4.z.string()
133
+ var ImageContentSchema = z.object({
134
+ type: z.literal("image"),
135
+ data: z.base64(),
136
+ mimeType: z.string()
166
137
  }).loose();
167
- var ResourceSchema = import_v4.z.object({
168
- uri: import_v4.z.string(),
169
- name: import_v4.z.string(),
170
- title: import_v4.z.optional(import_v4.z.string()),
171
- description: import_v4.z.optional(import_v4.z.string()),
172
- mimeType: import_v4.z.optional(import_v4.z.string()),
173
- size: import_v4.z.optional(import_v4.z.number())
138
+ var ResourceSchema = z.object({
139
+ uri: z.string(),
140
+ name: z.string(),
141
+ title: z.optional(z.string()),
142
+ description: z.optional(z.string()),
143
+ mimeType: z.optional(z.string()),
144
+ size: z.optional(z.number())
174
145
  }).loose();
175
146
  var ListResourcesResultSchema = PaginatedResultSchema.extend({
176
- resources: import_v4.z.array(ResourceSchema)
147
+ resources: z.array(ResourceSchema)
177
148
  });
178
- var ResourceContentsSchema = import_v4.z.object({
149
+ var ResourceContentsSchema = z.object({
179
150
  /**
180
151
  * The URI of this resource.
181
152
  */
182
- uri: import_v4.z.string(),
153
+ uri: z.string(),
183
154
  /**
184
155
  * Optional display name of the resource content.
185
156
  */
186
- name: import_v4.z.optional(import_v4.z.string()),
157
+ name: z.optional(z.string()),
187
158
  /**
188
159
  * Optional human readable title.
189
160
  */
190
- title: import_v4.z.optional(import_v4.z.string()),
161
+ title: z.optional(z.string()),
191
162
  /**
192
163
  * The MIME type of this resource, if known.
193
164
  */
194
- mimeType: import_v4.z.optional(import_v4.z.string())
165
+ mimeType: z.optional(z.string())
195
166
  }).loose();
196
167
  var TextResourceContentsSchema = ResourceContentsSchema.extend({
197
- text: import_v4.z.string()
168
+ text: z.string()
198
169
  });
199
170
  var BlobResourceContentsSchema = ResourceContentsSchema.extend({
200
- blob: import_v4.z.base64()
171
+ blob: z.base64()
201
172
  });
202
- var EmbeddedResourceSchema = import_v4.z.object({
203
- type: import_v4.z.literal("resource"),
204
- resource: import_v4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
173
+ var EmbeddedResourceSchema = z.object({
174
+ type: z.literal("resource"),
175
+ resource: z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
205
176
  }).loose();
206
177
  var CallToolResultSchema = ResultSchema.extend({
207
- content: import_v4.z.array(
208
- import_v4.z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
178
+ content: z.array(
179
+ z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
209
180
  ),
210
181
  /**
211
182
  * @see https://modelcontextprotocol.io/specification/2025-06-18/server/tools#structured-content
212
183
  */
213
- structuredContent: import_v4.z.optional(import_v4.z.unknown()),
214
- isError: import_v4.z.boolean().default(false).optional()
184
+ structuredContent: z.optional(z.unknown()),
185
+ isError: z.boolean().default(false).optional()
215
186
  }).or(
216
187
  ResultSchema.extend({
217
- toolResult: import_v4.z.unknown()
188
+ toolResult: z.unknown()
218
189
  })
219
190
  );
220
- var ResourceTemplateSchema = import_v4.z.object({
221
- uriTemplate: import_v4.z.string(),
222
- name: import_v4.z.string(),
223
- title: import_v4.z.optional(import_v4.z.string()),
224
- description: import_v4.z.optional(import_v4.z.string()),
225
- mimeType: import_v4.z.optional(import_v4.z.string())
191
+ var ResourceTemplateSchema = z.object({
192
+ uriTemplate: z.string(),
193
+ name: z.string(),
194
+ title: z.optional(z.string()),
195
+ description: z.optional(z.string()),
196
+ mimeType: z.optional(z.string())
226
197
  }).loose();
227
198
  var ListResourceTemplatesResultSchema = ResultSchema.extend({
228
- resourceTemplates: import_v4.z.array(ResourceTemplateSchema)
199
+ resourceTemplates: z.array(ResourceTemplateSchema)
229
200
  });
230
201
  var ReadResourceResultSchema = ResultSchema.extend({
231
- contents: import_v4.z.array(
232
- import_v4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
202
+ contents: z.array(
203
+ z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
233
204
  )
234
205
  });
235
- var PromptArgumentSchema = import_v4.z.object({
236
- name: import_v4.z.string(),
237
- description: import_v4.z.optional(import_v4.z.string()),
238
- required: import_v4.z.optional(import_v4.z.boolean())
206
+ var PromptArgumentSchema = z.object({
207
+ name: z.string(),
208
+ description: z.optional(z.string()),
209
+ required: z.optional(z.boolean())
239
210
  }).loose();
240
- var PromptSchema = import_v4.z.object({
241
- name: import_v4.z.string(),
242
- title: import_v4.z.optional(import_v4.z.string()),
243
- description: import_v4.z.optional(import_v4.z.string()),
244
- arguments: import_v4.z.optional(import_v4.z.array(PromptArgumentSchema))
211
+ var PromptSchema = z.object({
212
+ name: z.string(),
213
+ title: z.optional(z.string()),
214
+ description: z.optional(z.string()),
215
+ arguments: z.optional(z.array(PromptArgumentSchema))
245
216
  }).loose();
246
217
  var ListPromptsResultSchema = PaginatedResultSchema.extend({
247
- prompts: import_v4.z.array(PromptSchema)
218
+ prompts: z.array(PromptSchema)
248
219
  });
249
- var PromptMessageSchema = import_v4.z.object({
250
- role: import_v4.z.union([import_v4.z.literal("user"), import_v4.z.literal("assistant")]),
251
- content: import_v4.z.union([
220
+ var PromptMessageSchema = z.object({
221
+ role: z.union([z.literal("user"), z.literal("assistant")]),
222
+ content: z.union([
252
223
  TextContentSchema,
253
224
  ImageContentSchema,
254
225
  EmbeddedResourceSchema
255
226
  ])
256
227
  }).loose();
257
228
  var GetPromptResultSchema = ResultSchema.extend({
258
- description: import_v4.z.optional(import_v4.z.string()),
259
- messages: import_v4.z.array(PromptMessageSchema)
229
+ description: z.optional(z.string()),
230
+ messages: z.array(PromptMessageSchema)
260
231
  });
261
232
  var ElicitationRequestParamsSchema = BaseParamsSchema.extend({
262
- message: import_v4.z.string(),
263
- requestedSchema: import_v4.z.unknown()
233
+ message: z.string(),
234
+ requestedSchema: z.unknown()
264
235
  });
265
236
  var ElicitationRequestSchema = RequestSchema.extend({
266
- method: import_v4.z.literal("elicitation/create"),
237
+ method: z.literal("elicitation/create"),
267
238
  params: ElicitationRequestParamsSchema
268
239
  });
269
240
  var ElicitResultSchema = ResultSchema.extend({
270
- action: import_v4.z.union([
271
- import_v4.z.literal("accept"),
272
- import_v4.z.literal("decline"),
273
- import_v4.z.literal("cancel")
241
+ action: z.union([
242
+ z.literal("accept"),
243
+ z.literal("decline"),
244
+ z.literal("cancel")
274
245
  ]),
275
- content: import_v4.z.optional(import_v4.z.record(import_v4.z.string(), import_v4.z.unknown()))
246
+ content: z.optional(z.record(z.string(), z.unknown()))
276
247
  });
277
248
 
278
249
  // src/tool/json-rpc-message.ts
279
250
  var JSONRPC_VERSION = "2.0";
280
- var JSONRPCRequestSchema = import_v42.z.object({
281
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION),
282
- id: import_v42.z.union([import_v42.z.string(), import_v42.z.number().int()])
251
+ var JSONRPCRequestSchema = z2.object({
252
+ jsonrpc: z2.literal(JSONRPC_VERSION),
253
+ id: z2.union([z2.string(), z2.number().int()])
283
254
  }).merge(RequestSchema).strict();
284
- var JSONRPCResponseSchema = import_v42.z.object({
285
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION),
286
- id: import_v42.z.union([import_v42.z.string(), import_v42.z.number().int()]),
255
+ var JSONRPCResponseSchema = z2.object({
256
+ jsonrpc: z2.literal(JSONRPC_VERSION),
257
+ id: z2.union([z2.string(), z2.number().int()]),
287
258
  result: ResultSchema
288
259
  }).strict();
289
- var JSONRPCErrorSchema = import_v42.z.object({
290
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION),
291
- id: import_v42.z.union([import_v42.z.string(), import_v42.z.number().int()]),
292
- error: import_v42.z.object({
293
- code: import_v42.z.number().int(),
294
- message: import_v42.z.string(),
295
- data: import_v42.z.optional(import_v42.z.unknown())
260
+ var JSONRPCErrorSchema = z2.object({
261
+ jsonrpc: z2.literal(JSONRPC_VERSION),
262
+ id: z2.union([z2.string(), z2.number().int()]),
263
+ error: z2.object({
264
+ code: z2.number().int(),
265
+ message: z2.string(),
266
+ data: z2.optional(z2.unknown())
296
267
  })
297
268
  }).strict();
298
- var JSONRPCNotificationSchema = import_v42.z.object({
299
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION)
269
+ var JSONRPCNotificationSchema = z2.object({
270
+ jsonrpc: z2.literal(JSONRPC_VERSION)
300
271
  }).merge(
301
- import_v42.z.object({
302
- method: import_v42.z.string(),
303
- params: import_v42.z.optional(BaseParamsSchema)
272
+ z2.object({
273
+ method: z2.string(),
274
+ params: z2.optional(BaseParamsSchema)
304
275
  })
305
276
  ).strict();
306
- var JSONRPCMessageSchema = import_v42.z.union([
277
+ var JSONRPCMessageSchema = z2.union([
307
278
  JSONRPCRequestSchema,
308
279
  JSONRPCNotificationSchema,
309
280
  JSONRPCResponseSchema,
@@ -314,27 +285,27 @@ var JSONRPCMessageSchema = import_v42.z.union([
314
285
  var VERSION = typeof __PACKAGE_VERSION__ !== "undefined" ? __PACKAGE_VERSION__ : "0.0.0-test";
315
286
 
316
287
  // src/tool/oauth.ts
317
- var import_pkce_challenge = __toESM(require("pkce-challenge"));
288
+ import pkceChallenge from "pkce-challenge";
318
289
 
319
290
  // src/tool/oauth-types.ts
320
- var import_v43 = require("zod/v4");
321
- var OAuthTokensSchema = import_v43.z.object({
322
- access_token: import_v43.z.string(),
323
- id_token: import_v43.z.string().optional(),
291
+ import { z as z3 } from "zod/v4";
292
+ var OAuthTokensSchema = z3.object({
293
+ access_token: z3.string(),
294
+ id_token: z3.string().optional(),
324
295
  // Optional for OAuth 2.1, but necessary in OpenID Connect
325
- token_type: import_v43.z.string(),
326
- expires_in: import_v43.z.number().optional(),
327
- scope: import_v43.z.string().optional(),
328
- refresh_token: import_v43.z.string().optional()
296
+ token_type: z3.string(),
297
+ expires_in: z3.number().optional(),
298
+ scope: z3.string().optional(),
299
+ refresh_token: z3.string().optional()
329
300
  }).strip();
330
- var SafeUrlSchema = import_v43.z.string().url().superRefine((val, ctx) => {
301
+ var SafeUrlSchema = z3.string().url().superRefine((val, ctx) => {
331
302
  if (!URL.canParse(val)) {
332
303
  ctx.addIssue({
333
- code: import_v43.z.ZodIssueCode.custom,
304
+ code: z3.ZodIssueCode.custom,
334
305
  message: "URL must be parseable",
335
306
  fatal: true
336
307
  });
337
- return import_v43.z.NEVER;
308
+ return z3.NEVER;
338
309
  }
339
310
  }).refine(
340
311
  (url) => {
@@ -343,94 +314,94 @@ var SafeUrlSchema = import_v43.z.string().url().superRefine((val, ctx) => {
343
314
  },
344
315
  { message: "URL cannot use javascript:, data:, or vbscript: scheme" }
345
316
  );
346
- var OAuthProtectedResourceMetadataSchema = import_v43.z.object({
347
- resource: import_v43.z.string().url(),
348
- authorization_servers: import_v43.z.array(SafeUrlSchema).optional(),
349
- jwks_uri: import_v43.z.string().url().optional(),
350
- scopes_supported: import_v43.z.array(import_v43.z.string()).optional(),
351
- bearer_methods_supported: import_v43.z.array(import_v43.z.string()).optional(),
352
- resource_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()).optional(),
353
- resource_name: import_v43.z.string().optional(),
354
- resource_documentation: import_v43.z.string().optional(),
355
- resource_policy_uri: import_v43.z.string().url().optional(),
356
- resource_tos_uri: import_v43.z.string().url().optional(),
357
- tls_client_certificate_bound_access_tokens: import_v43.z.boolean().optional(),
358
- authorization_details_types_supported: import_v43.z.array(import_v43.z.string()).optional(),
359
- dpop_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()).optional(),
360
- dpop_bound_access_tokens_required: import_v43.z.boolean().optional()
317
+ var OAuthProtectedResourceMetadataSchema = z3.object({
318
+ resource: z3.string().url(),
319
+ authorization_servers: z3.array(SafeUrlSchema).optional(),
320
+ jwks_uri: z3.string().url().optional(),
321
+ scopes_supported: z3.array(z3.string()).optional(),
322
+ bearer_methods_supported: z3.array(z3.string()).optional(),
323
+ resource_signing_alg_values_supported: z3.array(z3.string()).optional(),
324
+ resource_name: z3.string().optional(),
325
+ resource_documentation: z3.string().optional(),
326
+ resource_policy_uri: z3.string().url().optional(),
327
+ resource_tos_uri: z3.string().url().optional(),
328
+ tls_client_certificate_bound_access_tokens: z3.boolean().optional(),
329
+ authorization_details_types_supported: z3.array(z3.string()).optional(),
330
+ dpop_signing_alg_values_supported: z3.array(z3.string()).optional(),
331
+ dpop_bound_access_tokens_required: z3.boolean().optional()
361
332
  }).passthrough();
362
- var OAuthMetadataSchema = import_v43.z.object({
363
- issuer: import_v43.z.string(),
333
+ var OAuthMetadataSchema = z3.object({
334
+ issuer: z3.string(),
364
335
  authorization_endpoint: SafeUrlSchema,
365
336
  token_endpoint: SafeUrlSchema,
366
337
  registration_endpoint: SafeUrlSchema.optional(),
367
- scopes_supported: import_v43.z.array(import_v43.z.string()).optional(),
368
- response_types_supported: import_v43.z.array(import_v43.z.string()),
369
- grant_types_supported: import_v43.z.array(import_v43.z.string()).optional(),
370
- code_challenge_methods_supported: import_v43.z.array(import_v43.z.string()),
371
- token_endpoint_auth_methods_supported: import_v43.z.array(import_v43.z.string()).optional(),
372
- token_endpoint_auth_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()).optional()
338
+ scopes_supported: z3.array(z3.string()).optional(),
339
+ response_types_supported: z3.array(z3.string()),
340
+ grant_types_supported: z3.array(z3.string()).optional(),
341
+ code_challenge_methods_supported: z3.array(z3.string()),
342
+ token_endpoint_auth_methods_supported: z3.array(z3.string()).optional(),
343
+ token_endpoint_auth_signing_alg_values_supported: z3.array(z3.string()).optional()
373
344
  }).passthrough();
374
- var OpenIdProviderMetadataSchema = import_v43.z.object({
375
- issuer: import_v43.z.string(),
345
+ var OpenIdProviderMetadataSchema = z3.object({
346
+ issuer: z3.string(),
376
347
  authorization_endpoint: SafeUrlSchema,
377
348
  token_endpoint: SafeUrlSchema,
378
349
  userinfo_endpoint: SafeUrlSchema.optional(),
379
350
  jwks_uri: SafeUrlSchema,
380
351
  registration_endpoint: SafeUrlSchema.optional(),
381
- scopes_supported: import_v43.z.array(import_v43.z.string()).optional(),
382
- response_types_supported: import_v43.z.array(import_v43.z.string()),
383
- grant_types_supported: import_v43.z.array(import_v43.z.string()).optional(),
384
- subject_types_supported: import_v43.z.array(import_v43.z.string()),
385
- id_token_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()),
386
- claims_supported: import_v43.z.array(import_v43.z.string()).optional(),
387
- token_endpoint_auth_methods_supported: import_v43.z.array(import_v43.z.string()).optional()
352
+ scopes_supported: z3.array(z3.string()).optional(),
353
+ response_types_supported: z3.array(z3.string()),
354
+ grant_types_supported: z3.array(z3.string()).optional(),
355
+ subject_types_supported: z3.array(z3.string()),
356
+ id_token_signing_alg_values_supported: z3.array(z3.string()),
357
+ claims_supported: z3.array(z3.string()).optional(),
358
+ token_endpoint_auth_methods_supported: z3.array(z3.string()).optional()
388
359
  }).passthrough();
389
360
  var OpenIdProviderDiscoveryMetadataSchema = OpenIdProviderMetadataSchema.merge(
390
361
  OAuthMetadataSchema.pick({
391
362
  code_challenge_methods_supported: true
392
363
  })
393
364
  );
394
- var OAuthClientInformationSchema = import_v43.z.object({
395
- client_id: import_v43.z.string(),
396
- client_secret: import_v43.z.string().optional(),
397
- client_id_issued_at: import_v43.z.number().optional(),
398
- client_secret_expires_at: import_v43.z.number().optional()
365
+ var OAuthClientInformationSchema = z3.object({
366
+ client_id: z3.string(),
367
+ client_secret: z3.string().optional(),
368
+ client_id_issued_at: z3.number().optional(),
369
+ client_secret_expires_at: z3.number().optional()
399
370
  }).strip();
400
- var OAuthClientMetadataSchema = import_v43.z.object({
401
- redirect_uris: import_v43.z.array(SafeUrlSchema),
402
- token_endpoint_auth_method: import_v43.z.string().optional(),
403
- grant_types: import_v43.z.array(import_v43.z.string()).optional(),
404
- response_types: import_v43.z.array(import_v43.z.string()).optional(),
405
- client_name: import_v43.z.string().optional(),
371
+ var OAuthClientMetadataSchema = z3.object({
372
+ redirect_uris: z3.array(SafeUrlSchema),
373
+ token_endpoint_auth_method: z3.string().optional(),
374
+ grant_types: z3.array(z3.string()).optional(),
375
+ response_types: z3.array(z3.string()).optional(),
376
+ client_name: z3.string().optional(),
406
377
  client_uri: SafeUrlSchema.optional(),
407
378
  logo_uri: SafeUrlSchema.optional(),
408
- scope: import_v43.z.string().optional(),
409
- contacts: import_v43.z.array(import_v43.z.string()).optional(),
379
+ scope: z3.string().optional(),
380
+ contacts: z3.array(z3.string()).optional(),
410
381
  tos_uri: SafeUrlSchema.optional(),
411
- policy_uri: import_v43.z.string().optional(),
382
+ policy_uri: z3.string().optional(),
412
383
  jwks_uri: SafeUrlSchema.optional(),
413
- jwks: import_v43.z.any().optional(),
414
- software_id: import_v43.z.string().optional(),
415
- software_version: import_v43.z.string().optional(),
416
- software_statement: import_v43.z.string().optional()
384
+ jwks: z3.any().optional(),
385
+ software_id: z3.string().optional(),
386
+ software_version: z3.string().optional(),
387
+ software_statement: z3.string().optional()
417
388
  }).strip();
418
- var OAuthErrorResponseSchema = import_v43.z.object({
419
- error: import_v43.z.string(),
420
- error_description: import_v43.z.string().optional(),
421
- error_uri: import_v43.z.string().optional()
389
+ var OAuthErrorResponseSchema = z3.object({
390
+ error: z3.string(),
391
+ error_description: z3.string().optional(),
392
+ error_uri: z3.string().optional()
422
393
  });
423
394
  var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(
424
395
  OAuthClientInformationSchema
425
396
  );
426
397
 
427
398
  // src/error/oauth-error.ts
428
- var import_provider2 = require("@ai-sdk/provider");
399
+ import { AISDKError as AISDKError2 } from "@ai-sdk/provider";
429
400
  var name2 = "AI_MCPClientOAuthError";
430
401
  var marker2 = `vercel.ai.error.${name2}`;
431
402
  var symbol2 = Symbol.for(marker2);
432
403
  var _a2, _b2;
433
- var MCPClientOAuthError = class extends (_b2 = import_provider2.AISDKError, _a2 = symbol2, _b2) {
404
+ var MCPClientOAuthError = class extends (_b2 = AISDKError2, _a2 = symbol2, _b2) {
434
405
  constructor({
435
406
  name: name3 = "MCPClientOAuthError",
436
407
  message,
@@ -440,7 +411,7 @@ var MCPClientOAuthError = class extends (_b2 = import_provider2.AISDKError, _a2
440
411
  this[_a2] = true;
441
412
  }
442
413
  static isInstance(error) {
443
- return import_provider2.AISDKError.hasMarker(error, marker2);
414
+ return AISDKError2.hasMarker(error, marker2);
444
415
  }
445
416
  };
446
417
  var ServerError = class extends MCPClientOAuthError {
@@ -468,6 +439,13 @@ function resourceUrlFromServerUrl(url) {
468
439
  resourceURL.hash = "";
469
440
  return resourceURL;
470
441
  }
442
+ function resourceUrlStripSlash(resource) {
443
+ const href = resource.href;
444
+ if (resource.pathname === "/" && href.endsWith("/")) {
445
+ return href.slice(0, -1);
446
+ }
447
+ return href;
448
+ }
471
449
  function checkResourceAllowed({
472
450
  requestedResource,
473
451
  configuredResource
@@ -685,7 +663,7 @@ async function startAuthorization(authorizationServerUrl, {
685
663
  } else {
686
664
  authorizationUrl = new URL("/authorize", authorizationServerUrl);
687
665
  }
688
- const challenge = await (0, import_pkce_challenge.default)();
666
+ const challenge = await pkceChallenge();
689
667
  const codeVerifier = challenge.code_verifier;
690
668
  const codeChallenge = challenge.code_challenge;
691
669
  authorizationUrl.searchParams.set("response_type", responseType);
@@ -706,7 +684,10 @@ async function startAuthorization(authorizationServerUrl, {
706
684
  authorizationUrl.searchParams.append("prompt", "consent");
707
685
  }
708
686
  if (resource) {
709
- authorizationUrl.searchParams.set("resource", resource.href);
687
+ authorizationUrl.searchParams.set(
688
+ "resource",
689
+ resourceUrlStripSlash(resource)
690
+ );
710
691
  }
711
692
  return { authorizationUrl, codeVerifier };
712
693
  }
@@ -815,7 +796,7 @@ async function exchangeAuthorization(authorizationServerUrl, {
815
796
  applyClientAuthentication(authMethod, clientInformation, headers, params);
816
797
  }
817
798
  if (resource) {
818
- params.set("resource", resource.href);
799
+ params.set("resource", resourceUrlStripSlash(resource));
819
800
  }
820
801
  const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
821
802
  method: "POST",
@@ -867,7 +848,7 @@ async function refreshAuthorization(authorizationServerUrl, {
867
848
  applyClientAuthentication(authMethod, clientInformation, headers, params);
868
849
  }
869
850
  if (resource) {
870
- params.set("resource", resource.href);
851
+ params.set("resource", resourceUrlStripSlash(resource));
871
852
  }
872
853
  const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
873
854
  method: "POST",
@@ -1072,12 +1053,16 @@ var SseMCPTransport = class {
1072
1053
  constructor({
1073
1054
  url,
1074
1055
  headers,
1075
- authProvider
1056
+ authProvider,
1057
+ redirect = "error",
1058
+ fetch: fetchFn
1076
1059
  }) {
1077
1060
  this.connected = false;
1078
1061
  this.url = new URL(url);
1079
1062
  this.headers = headers;
1080
1063
  this.authProvider = authProvider;
1064
+ this.redirectMode = redirect;
1065
+ this.fetchFn = fetchFn != null ? fetchFn : globalThis.fetch;
1081
1066
  }
1082
1067
  async commonHeaders(base) {
1083
1068
  const headers = {
@@ -1091,10 +1076,10 @@ var SseMCPTransport = class {
1091
1076
  headers["Authorization"] = `Bearer ${tokens.access_token}`;
1092
1077
  }
1093
1078
  }
1094
- return (0, import_provider_utils.withUserAgentSuffix)(
1079
+ return withUserAgentSuffix(
1095
1080
  headers,
1096
1081
  `ai-sdk/${VERSION}`,
1097
- (0, import_provider_utils.getRuntimeEnvironmentUserAgent)()
1082
+ getRuntimeEnvironmentUserAgent()
1098
1083
  );
1099
1084
  }
1100
1085
  async start() {
@@ -1109,16 +1094,18 @@ var SseMCPTransport = class {
1109
1094
  const headers = await this.commonHeaders({
1110
1095
  Accept: "text/event-stream"
1111
1096
  });
1112
- const response = await fetch(this.url.href, {
1097
+ const response = await this.fetchFn(this.url.href, {
1113
1098
  headers,
1114
- signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal
1099
+ signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal,
1100
+ redirect: this.redirectMode
1115
1101
  });
1116
1102
  if (response.status === 401 && this.authProvider && !triedAuth) {
1117
1103
  this.resourceMetadataUrl = extractResourceMetadataUrl(response);
1118
1104
  try {
1119
1105
  const result = await auth(this.authProvider, {
1120
1106
  serverUrl: this.url,
1121
- resourceMetadataUrl: this.resourceMetadataUrl
1107
+ resourceMetadataUrl: this.resourceMetadataUrl,
1108
+ fetchFn: this.fetchFn
1122
1109
  });
1123
1110
  if (result !== "AUTHORIZED") {
1124
1111
  const error = new UnauthorizedError();
@@ -1142,7 +1129,7 @@ var SseMCPTransport = class {
1142
1129
  (_d = this.onerror) == null ? void 0 : _d.call(this, error);
1143
1130
  return reject(error);
1144
1131
  }
1145
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils.EventSourceParserStream());
1132
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream());
1146
1133
  const reader = stream.getReader();
1147
1134
  const processEvents = async () => {
1148
1135
  var _a4, _b4, _c2;
@@ -1230,15 +1217,17 @@ var SseMCPTransport = class {
1230
1217
  method: "POST",
1231
1218
  headers,
1232
1219
  body: JSON.stringify(message),
1233
- signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal
1220
+ signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal,
1221
+ redirect: this.redirectMode
1234
1222
  };
1235
- const response = await fetch(endpoint, init);
1223
+ const response = await this.fetchFn(endpoint.href, init);
1236
1224
  if (response.status === 401 && this.authProvider && !triedAuth) {
1237
1225
  this.resourceMetadataUrl = extractResourceMetadataUrl(response);
1238
1226
  try {
1239
1227
  const result = await auth(this.authProvider, {
1240
1228
  serverUrl: this.url,
1241
- resourceMetadataUrl: this.resourceMetadataUrl
1229
+ resourceMetadataUrl: this.resourceMetadataUrl,
1230
+ fetchFn: this.fetchFn
1242
1231
  });
1243
1232
  if (result !== "AUTHORIZED") {
1244
1233
  const error = new UnauthorizedError();
@@ -1269,12 +1258,18 @@ var SseMCPTransport = class {
1269
1258
  };
1270
1259
 
1271
1260
  // src/tool/mcp-http-transport.ts
1272
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
1261
+ import {
1262
+ EventSourceParserStream as EventSourceParserStream2,
1263
+ withUserAgentSuffix as withUserAgentSuffix2,
1264
+ getRuntimeEnvironmentUserAgent as getRuntimeEnvironmentUserAgent2
1265
+ } from "@ai-sdk/provider-utils";
1273
1266
  var HttpMCPTransport = class {
1274
1267
  constructor({
1275
1268
  url,
1276
1269
  headers,
1277
- authProvider
1270
+ authProvider,
1271
+ redirect = "error",
1272
+ fetch: fetchFn
1278
1273
  }) {
1279
1274
  this.inboundReconnectAttempts = 0;
1280
1275
  this.reconnectionOptions = {
@@ -1286,6 +1281,8 @@ var HttpMCPTransport = class {
1286
1281
  this.url = new URL(url);
1287
1282
  this.headers = headers;
1288
1283
  this.authProvider = authProvider;
1284
+ this.redirectMode = redirect;
1285
+ this.fetchFn = fetchFn != null ? fetchFn : globalThis.fetch;
1289
1286
  }
1290
1287
  async commonHeaders(base) {
1291
1288
  const headers = {
@@ -1302,10 +1299,10 @@ var HttpMCPTransport = class {
1302
1299
  headers["Authorization"] = `Bearer ${tokens.access_token}`;
1303
1300
  }
1304
1301
  }
1305
- return (0, import_provider_utils2.withUserAgentSuffix)(
1302
+ return withUserAgentSuffix2(
1306
1303
  headers,
1307
1304
  `ai-sdk/${VERSION}`,
1308
- (0, import_provider_utils2.getRuntimeEnvironmentUserAgent)()
1305
+ getRuntimeEnvironmentUserAgent2()
1309
1306
  );
1310
1307
  }
1311
1308
  async start() {
@@ -1323,10 +1320,11 @@ var HttpMCPTransport = class {
1323
1320
  try {
1324
1321
  if (this.sessionId && this.abortController && !this.abortController.signal.aborted) {
1325
1322
  const headers = await this.commonHeaders({});
1326
- await fetch(this.url, {
1323
+ await this.fetchFn(this.url.href, {
1327
1324
  method: "DELETE",
1328
1325
  headers,
1329
- signal: this.abortController.signal
1326
+ signal: this.abortController.signal,
1327
+ redirect: this.redirectMode
1330
1328
  }).catch(() => void 0);
1331
1329
  }
1332
1330
  } catch (e) {
@@ -1346,9 +1344,10 @@ var HttpMCPTransport = class {
1346
1344
  method: "POST",
1347
1345
  headers,
1348
1346
  body: JSON.stringify(message),
1349
- signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal
1347
+ signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal,
1348
+ redirect: this.redirectMode
1350
1349
  };
1351
- const response = await fetch(this.url, init);
1350
+ const response = await this.fetchFn(this.url.href, init);
1352
1351
  const sessionId = response.headers.get("mcp-session-id");
1353
1352
  if (sessionId) {
1354
1353
  this.sessionId = sessionId;
@@ -1358,7 +1357,8 @@ var HttpMCPTransport = class {
1358
1357
  try {
1359
1358
  const result = await auth(this.authProvider, {
1360
1359
  serverUrl: this.url,
1361
- resourceMetadataUrl: this.resourceMetadataUrl
1360
+ resourceMetadataUrl: this.resourceMetadataUrl,
1361
+ fetchFn: this.fetchFn
1362
1362
  });
1363
1363
  if (result !== "AUTHORIZED") {
1364
1364
  const error2 = new UnauthorizedError();
@@ -1407,7 +1407,7 @@ var HttpMCPTransport = class {
1407
1407
  (_e = this.onerror) == null ? void 0 : _e.call(this, error2);
1408
1408
  throw error2;
1409
1409
  }
1410
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils2.EventSourceParserStream());
1410
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream2());
1411
1411
  const reader = stream.getReader();
1412
1412
  const processEvents = async () => {
1413
1413
  var _a4, _b4, _c2;
@@ -1492,10 +1492,11 @@ var HttpMCPTransport = class {
1492
1492
  if (resumeToken) {
1493
1493
  headers["last-event-id"] = resumeToken;
1494
1494
  }
1495
- const response = await fetch(this.url.href, {
1495
+ const response = await this.fetchFn(this.url.href, {
1496
1496
  method: "GET",
1497
1497
  headers,
1498
- signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal
1498
+ signal: (_a3 = this.abortController) == null ? void 0 : _a3.signal,
1499
+ redirect: this.redirectMode
1499
1500
  });
1500
1501
  const sessionId = response.headers.get("mcp-session-id");
1501
1502
  if (sessionId) {
@@ -1506,7 +1507,8 @@ var HttpMCPTransport = class {
1506
1507
  try {
1507
1508
  const result = await auth(this.authProvider, {
1508
1509
  serverUrl: this.url,
1509
- resourceMetadataUrl: this.resourceMetadataUrl
1510
+ resourceMetadataUrl: this.resourceMetadataUrl,
1511
+ fetchFn: this.fetchFn
1510
1512
  });
1511
1513
  if (result !== "AUTHORIZED") {
1512
1514
  const error = new UnauthorizedError();
@@ -1529,7 +1531,7 @@ var HttpMCPTransport = class {
1529
1531
  (_d = this.onerror) == null ? void 0 : _d.call(this, error);
1530
1532
  return;
1531
1533
  }
1532
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils2.EventSourceParserStream());
1534
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream2());
1533
1535
  const reader = stream.getReader();
1534
1536
  const processEvents = async () => {
1535
1537
  var _a4, _b4, _c2, _d2;
@@ -1614,7 +1616,7 @@ function mcpToModelOutput({
1614
1616
  }
1615
1617
  if (part.type === "image" && "data" in part && "mimeType" in part) {
1616
1618
  return {
1617
- type: "image-data",
1619
+ type: "file-data",
1618
1620
  data: part.data,
1619
1621
  mediaType: part.mimeType
1620
1622
  };
@@ -1640,6 +1642,7 @@ var DefaultMCPClient = class {
1640
1642
  this.requestMessageId = 0;
1641
1643
  this.responseHandlers = /* @__PURE__ */ new Map();
1642
1644
  this.serverCapabilities = {};
1645
+ this._serverInfo = { name: "", version: "" };
1643
1646
  this.isClosed = true;
1644
1647
  this.onUncaughtError = onUncaughtError;
1645
1648
  this.clientCapabilities = capabilities != null ? capabilities : {};
@@ -1670,6 +1673,9 @@ var DefaultMCPClient = class {
1670
1673
  version
1671
1674
  };
1672
1675
  }
1676
+ get serverInfo() {
1677
+ return this._serverInfo;
1678
+ }
1673
1679
  async init() {
1674
1680
  try {
1675
1681
  await this.transport.start();
@@ -1696,6 +1702,7 @@ var DefaultMCPClient = class {
1696
1702
  });
1697
1703
  }
1698
1704
  this.serverCapabilities = result.capabilities;
1705
+ this._serverInfo = result.serverInfo;
1699
1706
  await this.notification({
1700
1707
  method: "notifications/initialized"
1701
1708
  });
@@ -1941,22 +1948,25 @@ var DefaultMCPClient = class {
1941
1948
  var _a4;
1942
1949
  (_a4 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a4.throwIfAborted();
1943
1950
  const result = await self.callTool({ name: name3, args, options });
1951
+ if (result.isError) {
1952
+ return result;
1953
+ }
1944
1954
  if (outputSchema != null) {
1945
1955
  return self.extractStructuredContent(result, outputSchema, name3);
1946
1956
  }
1947
1957
  return result;
1948
1958
  };
1949
- const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils3.dynamicTool)({
1959
+ const toolWithExecute = schemas === "automatic" ? dynamicTool({
1950
1960
  description,
1951
1961
  title: resolvedTitle,
1952
- inputSchema: (0, import_provider_utils3.jsonSchema)({
1962
+ inputSchema: jsonSchema({
1953
1963
  ...inputSchema,
1954
1964
  properties: (_b3 = inputSchema.properties) != null ? _b3 : {},
1955
1965
  additionalProperties: false
1956
1966
  }),
1957
1967
  execute,
1958
1968
  toModelOutput: mcpToModelOutput
1959
- }) : (0, import_provider_utils3.tool)({
1969
+ }) : tool({
1960
1970
  description,
1961
1971
  title: resolvedTitle,
1962
1972
  inputSchema: schemas[name3].inputSchema,
@@ -1973,9 +1983,9 @@ var DefaultMCPClient = class {
1973
1983
  */
1974
1984
  async extractStructuredContent(result, outputSchema, toolName) {
1975
1985
  if ("structuredContent" in result && result.structuredContent != null) {
1976
- const validationResult = await (0, import_provider_utils3.safeValidateTypes)({
1986
+ const validationResult = await safeValidateTypes({
1977
1987
  value: result.structuredContent,
1978
- schema: (0, import_provider_utils3.asSchema)(outputSchema)
1988
+ schema: asSchema(outputSchema)
1979
1989
  });
1980
1990
  if (!validationResult.success) {
1981
1991
  throw new MCPClientError({
@@ -1988,7 +1998,7 @@ var DefaultMCPClient = class {
1988
1998
  if ("content" in result && Array.isArray(result.content)) {
1989
1999
  const textContent = result.content.find((c) => c.type === "text");
1990
2000
  if (textContent && "text" in textContent) {
1991
- const parseResult = await (0, import_provider_utils3.safeParseJSON)({
2001
+ const parseResult = await safeParseJSON({
1992
2002
  text: textContent.text,
1993
2003
  schema: outputSchema
1994
2004
  });
@@ -2143,13 +2153,12 @@ var DefaultMCPClient = class {
2143
2153
  );
2144
2154
  }
2145
2155
  };
2146
- // Annotate the CommonJS export names for ESM import in node:
2147
- 0 && (module.exports = {
2156
+ export {
2148
2157
  ElicitResultSchema,
2149
2158
  ElicitationRequestSchema,
2150
2159
  UnauthorizedError,
2151
2160
  auth,
2152
2161
  createMCPClient,
2153
- experimental_createMCPClient
2154
- });
2162
+ createMCPClient as experimental_createMCPClient
2163
+ };
2155
2164
  //# sourceMappingURL=index.js.map