@ai-sdk/mcp 2.0.0-beta.24 → 2.0.0-beta.26

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 index_exports = {};
32
- __export(index_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(index_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,230 +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(),
88
- title: import_v4.z.optional(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())
89
59
  });
90
- var BaseParamsSchema = import_v4.z.looseObject({
91
- _meta: import_v4.z.optional(import_v4.z.object({}).loose())
60
+ var BaseParamsSchema = z.looseObject({
61
+ _meta: z.optional(z.object({}).loose())
92
62
  });
93
63
  var ResultSchema = BaseParamsSchema;
94
- var RequestSchema = import_v4.z.object({
95
- method: import_v4.z.string(),
96
- params: import_v4.z.optional(BaseParamsSchema)
64
+ var RequestSchema = z.object({
65
+ method: z.string(),
66
+ params: z.optional(BaseParamsSchema)
97
67
  });
98
- var ElicitationCapabilitySchema = import_v4.z.object({
99
- applyDefaults: import_v4.z.optional(import_v4.z.boolean())
68
+ var ElicitationCapabilitySchema = z.object({
69
+ applyDefaults: z.optional(z.boolean())
100
70
  }).loose();
101
- var ServerCapabilitiesSchema = import_v4.z.looseObject({
102
- experimental: import_v4.z.optional(import_v4.z.object({}).loose()),
103
- logging: import_v4.z.optional(import_v4.z.object({}).loose()),
104
- prompts: import_v4.z.optional(
105
- import_v4.z.looseObject({
106
- 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())
107
77
  })
108
78
  ),
109
- resources: import_v4.z.optional(
110
- import_v4.z.looseObject({
111
- subscribe: import_v4.z.optional(import_v4.z.boolean()),
112
- 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())
113
83
  })
114
84
  ),
115
- tools: import_v4.z.optional(
116
- import_v4.z.looseObject({
117
- listChanged: import_v4.z.optional(import_v4.z.boolean())
85
+ tools: z.optional(
86
+ z.looseObject({
87
+ listChanged: z.optional(z.boolean())
118
88
  })
119
89
  ),
120
- elicitation: import_v4.z.optional(ElicitationCapabilitySchema)
90
+ elicitation: z.optional(ElicitationCapabilitySchema)
121
91
  });
122
- var ClientCapabilitiesSchema = import_v4.z.object({
123
- elicitation: import_v4.z.optional(ElicitationCapabilitySchema)
92
+ var ClientCapabilitiesSchema = z.object({
93
+ elicitation: z.optional(ElicitationCapabilitySchema)
124
94
  }).loose();
125
95
  var InitializeResultSchema = ResultSchema.extend({
126
- protocolVersion: import_v4.z.string(),
96
+ protocolVersion: z.string(),
127
97
  capabilities: ServerCapabilitiesSchema,
128
98
  serverInfo: ClientOrServerImplementationSchema,
129
- instructions: import_v4.z.optional(import_v4.z.string())
99
+ instructions: z.optional(z.string())
130
100
  });
131
101
  var PaginatedResultSchema = ResultSchema.extend({
132
- nextCursor: import_v4.z.optional(import_v4.z.string())
102
+ nextCursor: z.optional(z.string())
133
103
  });
134
- var ToolSchema = import_v4.z.object({
135
- name: import_v4.z.string(),
104
+ var ToolSchema = z.object({
105
+ name: z.string(),
136
106
  /**
137
107
  * @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool
138
108
  */
139
- title: import_v4.z.optional(import_v4.z.string()),
140
- description: import_v4.z.optional(import_v4.z.string()),
141
- inputSchema: import_v4.z.object({
142
- type: import_v4.z.literal("object"),
143
- 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())
144
114
  }).loose(),
145
115
  /**
146
116
  * @see https://modelcontextprotocol.io/specification/2025-06-18/server/tools#output-schema
147
117
  */
148
- outputSchema: import_v4.z.optional(import_v4.z.object({}).loose()),
149
- annotations: import_v4.z.optional(
150
- import_v4.z.object({
151
- 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())
152
122
  }).loose()
153
123
  ),
154
124
  _meta: ToolMetaSchema
155
125
  }).loose();
156
126
  var ListToolsResultSchema = PaginatedResultSchema.extend({
157
- tools: import_v4.z.array(ToolSchema)
127
+ tools: z.array(ToolSchema)
158
128
  });
159
- var TextContentSchema = import_v4.z.object({
160
- type: import_v4.z.literal("text"),
161
- text: import_v4.z.string()
129
+ var TextContentSchema = z.object({
130
+ type: z.literal("text"),
131
+ text: z.string()
162
132
  }).loose();
163
- var ImageContentSchema = import_v4.z.object({
164
- type: import_v4.z.literal("image"),
165
- data: import_v4.z.base64(),
166
- mimeType: import_v4.z.string()
133
+ var ImageContentSchema = z.object({
134
+ type: z.literal("image"),
135
+ data: z.base64(),
136
+ mimeType: z.string()
167
137
  }).loose();
168
- var ResourceSchema = import_v4.z.object({
169
- uri: import_v4.z.string(),
170
- name: import_v4.z.string(),
171
- title: import_v4.z.optional(import_v4.z.string()),
172
- description: import_v4.z.optional(import_v4.z.string()),
173
- mimeType: import_v4.z.optional(import_v4.z.string()),
174
- 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())
175
145
  }).loose();
176
146
  var ListResourcesResultSchema = PaginatedResultSchema.extend({
177
- resources: import_v4.z.array(ResourceSchema)
147
+ resources: z.array(ResourceSchema)
178
148
  });
179
- var ResourceContentsSchema = import_v4.z.object({
149
+ var ResourceContentsSchema = z.object({
180
150
  /**
181
151
  * The URI of this resource.
182
152
  */
183
- uri: import_v4.z.string(),
153
+ uri: z.string(),
184
154
  /**
185
155
  * Optional display name of the resource content.
186
156
  */
187
- name: import_v4.z.optional(import_v4.z.string()),
157
+ name: z.optional(z.string()),
188
158
  /**
189
159
  * Optional human readable title.
190
160
  */
191
- title: import_v4.z.optional(import_v4.z.string()),
161
+ title: z.optional(z.string()),
192
162
  /**
193
163
  * The MIME type of this resource, if known.
194
164
  */
195
- mimeType: import_v4.z.optional(import_v4.z.string())
165
+ mimeType: z.optional(z.string())
196
166
  }).loose();
197
167
  var TextResourceContentsSchema = ResourceContentsSchema.extend({
198
- text: import_v4.z.string()
168
+ text: z.string()
199
169
  });
200
170
  var BlobResourceContentsSchema = ResourceContentsSchema.extend({
201
- blob: import_v4.z.base64()
171
+ blob: z.base64()
202
172
  });
203
- var EmbeddedResourceSchema = import_v4.z.object({
204
- type: import_v4.z.literal("resource"),
205
- resource: import_v4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
173
+ var EmbeddedResourceSchema = z.object({
174
+ type: z.literal("resource"),
175
+ resource: z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
206
176
  }).loose();
207
177
  var CallToolResultSchema = ResultSchema.extend({
208
- content: import_v4.z.array(
209
- import_v4.z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
178
+ content: z.array(
179
+ z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
210
180
  ),
211
181
  /**
212
182
  * @see https://modelcontextprotocol.io/specification/2025-06-18/server/tools#structured-content
213
183
  */
214
- structuredContent: import_v4.z.optional(import_v4.z.unknown()),
215
- isError: import_v4.z.boolean().default(false).optional()
184
+ structuredContent: z.optional(z.unknown()),
185
+ isError: z.boolean().default(false).optional()
216
186
  }).or(
217
187
  ResultSchema.extend({
218
- toolResult: import_v4.z.unknown()
188
+ toolResult: z.unknown()
219
189
  })
220
190
  );
221
- var ResourceTemplateSchema = import_v4.z.object({
222
- uriTemplate: import_v4.z.string(),
223
- name: import_v4.z.string(),
224
- title: import_v4.z.optional(import_v4.z.string()),
225
- description: import_v4.z.optional(import_v4.z.string()),
226
- 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())
227
197
  }).loose();
228
198
  var ListResourceTemplatesResultSchema = ResultSchema.extend({
229
- resourceTemplates: import_v4.z.array(ResourceTemplateSchema)
199
+ resourceTemplates: z.array(ResourceTemplateSchema)
230
200
  });
231
201
  var ReadResourceResultSchema = ResultSchema.extend({
232
- contents: import_v4.z.array(
233
- import_v4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
202
+ contents: z.array(
203
+ z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
234
204
  )
235
205
  });
236
- var PromptArgumentSchema = import_v4.z.object({
237
- name: import_v4.z.string(),
238
- description: import_v4.z.optional(import_v4.z.string()),
239
- 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())
240
210
  }).loose();
241
- var PromptSchema = import_v4.z.object({
242
- name: import_v4.z.string(),
243
- title: import_v4.z.optional(import_v4.z.string()),
244
- description: import_v4.z.optional(import_v4.z.string()),
245
- 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))
246
216
  }).loose();
247
217
  var ListPromptsResultSchema = PaginatedResultSchema.extend({
248
- prompts: import_v4.z.array(PromptSchema)
218
+ prompts: z.array(PromptSchema)
249
219
  });
250
- var PromptMessageSchema = import_v4.z.object({
251
- role: import_v4.z.union([import_v4.z.literal("user"), import_v4.z.literal("assistant")]),
252
- content: import_v4.z.union([
220
+ var PromptMessageSchema = z.object({
221
+ role: z.union([z.literal("user"), z.literal("assistant")]),
222
+ content: z.union([
253
223
  TextContentSchema,
254
224
  ImageContentSchema,
255
225
  EmbeddedResourceSchema
256
226
  ])
257
227
  }).loose();
258
228
  var GetPromptResultSchema = ResultSchema.extend({
259
- description: import_v4.z.optional(import_v4.z.string()),
260
- messages: import_v4.z.array(PromptMessageSchema)
229
+ description: z.optional(z.string()),
230
+ messages: z.array(PromptMessageSchema)
261
231
  });
262
232
  var ElicitationRequestParamsSchema = BaseParamsSchema.extend({
263
- message: import_v4.z.string(),
264
- requestedSchema: import_v4.z.unknown()
233
+ message: z.string(),
234
+ requestedSchema: z.unknown()
265
235
  });
266
236
  var ElicitationRequestSchema = RequestSchema.extend({
267
- method: import_v4.z.literal("elicitation/create"),
237
+ method: z.literal("elicitation/create"),
268
238
  params: ElicitationRequestParamsSchema
269
239
  });
270
240
  var ElicitResultSchema = ResultSchema.extend({
271
- action: import_v4.z.union([
272
- import_v4.z.literal("accept"),
273
- import_v4.z.literal("decline"),
274
- import_v4.z.literal("cancel")
241
+ action: z.union([
242
+ z.literal("accept"),
243
+ z.literal("decline"),
244
+ z.literal("cancel")
275
245
  ]),
276
- 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()))
277
247
  });
278
248
 
279
249
  // src/tool/json-rpc-message.ts
280
250
  var JSONRPC_VERSION = "2.0";
281
- var JSONRPCRequestSchema = import_v42.z.object({
282
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION),
283
- 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()])
284
254
  }).merge(RequestSchema).strict();
285
- var JSONRPCResponseSchema = import_v42.z.object({
286
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION),
287
- 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()]),
288
258
  result: ResultSchema
289
259
  }).strict();
290
- var JSONRPCErrorSchema = import_v42.z.object({
291
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION),
292
- id: import_v42.z.union([import_v42.z.string(), import_v42.z.number().int()]),
293
- error: import_v42.z.object({
294
- code: import_v42.z.number().int(),
295
- message: import_v42.z.string(),
296
- 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())
297
267
  })
298
268
  }).strict();
299
- var JSONRPCNotificationSchema = import_v42.z.object({
300
- jsonrpc: import_v42.z.literal(JSONRPC_VERSION)
269
+ var JSONRPCNotificationSchema = z2.object({
270
+ jsonrpc: z2.literal(JSONRPC_VERSION)
301
271
  }).merge(
302
- import_v42.z.object({
303
- method: import_v42.z.string(),
304
- params: import_v42.z.optional(BaseParamsSchema)
272
+ z2.object({
273
+ method: z2.string(),
274
+ params: z2.optional(BaseParamsSchema)
305
275
  })
306
276
  ).strict();
307
- var JSONRPCMessageSchema = import_v42.z.union([
277
+ var JSONRPCMessageSchema = z2.union([
308
278
  JSONRPCRequestSchema,
309
279
  JSONRPCNotificationSchema,
310
280
  JSONRPCResponseSchema,
@@ -315,27 +285,27 @@ var JSONRPCMessageSchema = import_v42.z.union([
315
285
  var VERSION = typeof __PACKAGE_VERSION__ !== "undefined" ? __PACKAGE_VERSION__ : "0.0.0-test";
316
286
 
317
287
  // src/tool/oauth.ts
318
- var import_pkce_challenge = __toESM(require("pkce-challenge"));
288
+ import pkceChallenge from "pkce-challenge";
319
289
 
320
290
  // src/tool/oauth-types.ts
321
- var import_v43 = require("zod/v4");
322
- var OAuthTokensSchema = import_v43.z.object({
323
- access_token: import_v43.z.string(),
324
- 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(),
325
295
  // Optional for OAuth 2.1, but necessary in OpenID Connect
326
- token_type: import_v43.z.string(),
327
- expires_in: import_v43.z.number().optional(),
328
- scope: import_v43.z.string().optional(),
329
- 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()
330
300
  }).strip();
331
- var SafeUrlSchema = import_v43.z.string().url().superRefine((val, ctx) => {
301
+ var SafeUrlSchema = z3.string().url().superRefine((val, ctx) => {
332
302
  if (!URL.canParse(val)) {
333
303
  ctx.addIssue({
334
- code: import_v43.z.ZodIssueCode.custom,
304
+ code: z3.ZodIssueCode.custom,
335
305
  message: "URL must be parseable",
336
306
  fatal: true
337
307
  });
338
- return import_v43.z.NEVER;
308
+ return z3.NEVER;
339
309
  }
340
310
  }).refine(
341
311
  (url) => {
@@ -344,94 +314,94 @@ var SafeUrlSchema = import_v43.z.string().url().superRefine((val, ctx) => {
344
314
  },
345
315
  { message: "URL cannot use javascript:, data:, or vbscript: scheme" }
346
316
  );
347
- var OAuthProtectedResourceMetadataSchema = import_v43.z.object({
348
- resource: import_v43.z.string().url(),
349
- authorization_servers: import_v43.z.array(SafeUrlSchema).optional(),
350
- jwks_uri: import_v43.z.string().url().optional(),
351
- scopes_supported: import_v43.z.array(import_v43.z.string()).optional(),
352
- bearer_methods_supported: import_v43.z.array(import_v43.z.string()).optional(),
353
- resource_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()).optional(),
354
- resource_name: import_v43.z.string().optional(),
355
- resource_documentation: import_v43.z.string().optional(),
356
- resource_policy_uri: import_v43.z.string().url().optional(),
357
- resource_tos_uri: import_v43.z.string().url().optional(),
358
- tls_client_certificate_bound_access_tokens: import_v43.z.boolean().optional(),
359
- authorization_details_types_supported: import_v43.z.array(import_v43.z.string()).optional(),
360
- dpop_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()).optional(),
361
- 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()
362
332
  }).passthrough();
363
- var OAuthMetadataSchema = import_v43.z.object({
364
- issuer: import_v43.z.string(),
333
+ var OAuthMetadataSchema = z3.object({
334
+ issuer: z3.string(),
365
335
  authorization_endpoint: SafeUrlSchema,
366
336
  token_endpoint: SafeUrlSchema,
367
337
  registration_endpoint: SafeUrlSchema.optional(),
368
- scopes_supported: import_v43.z.array(import_v43.z.string()).optional(),
369
- response_types_supported: import_v43.z.array(import_v43.z.string()),
370
- grant_types_supported: import_v43.z.array(import_v43.z.string()).optional(),
371
- code_challenge_methods_supported: import_v43.z.array(import_v43.z.string()),
372
- token_endpoint_auth_methods_supported: import_v43.z.array(import_v43.z.string()).optional(),
373
- 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()
374
344
  }).passthrough();
375
- var OpenIdProviderMetadataSchema = import_v43.z.object({
376
- issuer: import_v43.z.string(),
345
+ var OpenIdProviderMetadataSchema = z3.object({
346
+ issuer: z3.string(),
377
347
  authorization_endpoint: SafeUrlSchema,
378
348
  token_endpoint: SafeUrlSchema,
379
349
  userinfo_endpoint: SafeUrlSchema.optional(),
380
350
  jwks_uri: SafeUrlSchema,
381
351
  registration_endpoint: SafeUrlSchema.optional(),
382
- scopes_supported: import_v43.z.array(import_v43.z.string()).optional(),
383
- response_types_supported: import_v43.z.array(import_v43.z.string()),
384
- grant_types_supported: import_v43.z.array(import_v43.z.string()).optional(),
385
- subject_types_supported: import_v43.z.array(import_v43.z.string()),
386
- id_token_signing_alg_values_supported: import_v43.z.array(import_v43.z.string()),
387
- claims_supported: import_v43.z.array(import_v43.z.string()).optional(),
388
- 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()
389
359
  }).passthrough();
390
360
  var OpenIdProviderDiscoveryMetadataSchema = OpenIdProviderMetadataSchema.merge(
391
361
  OAuthMetadataSchema.pick({
392
362
  code_challenge_methods_supported: true
393
363
  })
394
364
  );
395
- var OAuthClientInformationSchema = import_v43.z.object({
396
- client_id: import_v43.z.string(),
397
- client_secret: import_v43.z.string().optional(),
398
- client_id_issued_at: import_v43.z.number().optional(),
399
- 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()
400
370
  }).strip();
401
- var OAuthClientMetadataSchema = import_v43.z.object({
402
- redirect_uris: import_v43.z.array(SafeUrlSchema),
403
- token_endpoint_auth_method: import_v43.z.string().optional(),
404
- grant_types: import_v43.z.array(import_v43.z.string()).optional(),
405
- response_types: import_v43.z.array(import_v43.z.string()).optional(),
406
- 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(),
407
377
  client_uri: SafeUrlSchema.optional(),
408
378
  logo_uri: SafeUrlSchema.optional(),
409
- scope: import_v43.z.string().optional(),
410
- contacts: import_v43.z.array(import_v43.z.string()).optional(),
379
+ scope: z3.string().optional(),
380
+ contacts: z3.array(z3.string()).optional(),
411
381
  tos_uri: SafeUrlSchema.optional(),
412
- policy_uri: import_v43.z.string().optional(),
382
+ policy_uri: z3.string().optional(),
413
383
  jwks_uri: SafeUrlSchema.optional(),
414
- jwks: import_v43.z.any().optional(),
415
- software_id: import_v43.z.string().optional(),
416
- software_version: import_v43.z.string().optional(),
417
- 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()
418
388
  }).strip();
419
- var OAuthErrorResponseSchema = import_v43.z.object({
420
- error: import_v43.z.string(),
421
- error_description: import_v43.z.string().optional(),
422
- 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()
423
393
  });
424
394
  var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(
425
395
  OAuthClientInformationSchema
426
396
  );
427
397
 
428
398
  // src/error/oauth-error.ts
429
- var import_provider2 = require("@ai-sdk/provider");
399
+ import { AISDKError as AISDKError2 } from "@ai-sdk/provider";
430
400
  var name2 = "AI_MCPClientOAuthError";
431
401
  var marker2 = `vercel.ai.error.${name2}`;
432
402
  var symbol2 = Symbol.for(marker2);
433
403
  var _a2, _b2;
434
- var MCPClientOAuthError = class extends (_b2 = import_provider2.AISDKError, _a2 = symbol2, _b2) {
404
+ var MCPClientOAuthError = class extends (_b2 = AISDKError2, _a2 = symbol2, _b2) {
435
405
  constructor({
436
406
  name: name3 = "MCPClientOAuthError",
437
407
  message,
@@ -441,7 +411,7 @@ var MCPClientOAuthError = class extends (_b2 = import_provider2.AISDKError, _a2
441
411
  this[_a2] = true;
442
412
  }
443
413
  static isInstance(error) {
444
- return import_provider2.AISDKError.hasMarker(error, marker2);
414
+ return AISDKError2.hasMarker(error, marker2);
445
415
  }
446
416
  };
447
417
  var ServerError = class extends MCPClientOAuthError {
@@ -693,7 +663,7 @@ async function startAuthorization(authorizationServerUrl, {
693
663
  } else {
694
664
  authorizationUrl = new URL("/authorize", authorizationServerUrl);
695
665
  }
696
- const challenge = await (0, import_pkce_challenge.default)();
666
+ const challenge = await pkceChallenge();
697
667
  const codeVerifier = challenge.code_verifier;
698
668
  const codeChallenge = challenge.code_challenge;
699
669
  authorizationUrl.searchParams.set("response_type", responseType);
@@ -1106,10 +1076,10 @@ var SseMCPTransport = class {
1106
1076
  headers["Authorization"] = `Bearer ${tokens.access_token}`;
1107
1077
  }
1108
1078
  }
1109
- return (0, import_provider_utils.withUserAgentSuffix)(
1079
+ return withUserAgentSuffix(
1110
1080
  headers,
1111
1081
  `ai-sdk/${VERSION}`,
1112
- (0, import_provider_utils.getRuntimeEnvironmentUserAgent)()
1082
+ getRuntimeEnvironmentUserAgent()
1113
1083
  );
1114
1084
  }
1115
1085
  async start() {
@@ -1159,7 +1129,7 @@ var SseMCPTransport = class {
1159
1129
  (_d = this.onerror) == null ? void 0 : _d.call(this, error);
1160
1130
  return reject(error);
1161
1131
  }
1162
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils.EventSourceParserStream());
1132
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream());
1163
1133
  const reader = stream.getReader();
1164
1134
  const processEvents = async () => {
1165
1135
  var _a4, _b4, _c2;
@@ -1288,7 +1258,11 @@ var SseMCPTransport = class {
1288
1258
  };
1289
1259
 
1290
1260
  // src/tool/mcp-http-transport.ts
1291
- 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";
1292
1266
  var HttpMCPTransport = class {
1293
1267
  constructor({
1294
1268
  url,
@@ -1325,10 +1299,10 @@ var HttpMCPTransport = class {
1325
1299
  headers["Authorization"] = `Bearer ${tokens.access_token}`;
1326
1300
  }
1327
1301
  }
1328
- return (0, import_provider_utils2.withUserAgentSuffix)(
1302
+ return withUserAgentSuffix2(
1329
1303
  headers,
1330
1304
  `ai-sdk/${VERSION}`,
1331
- (0, import_provider_utils2.getRuntimeEnvironmentUserAgent)()
1305
+ getRuntimeEnvironmentUserAgent2()
1332
1306
  );
1333
1307
  }
1334
1308
  async start() {
@@ -1433,7 +1407,7 @@ var HttpMCPTransport = class {
1433
1407
  (_e = this.onerror) == null ? void 0 : _e.call(this, error2);
1434
1408
  throw error2;
1435
1409
  }
1436
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils2.EventSourceParserStream());
1410
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream2());
1437
1411
  const reader = stream.getReader();
1438
1412
  const processEvents = async () => {
1439
1413
  var _a4, _b4, _c2;
@@ -1557,7 +1531,7 @@ var HttpMCPTransport = class {
1557
1531
  (_d = this.onerror) == null ? void 0 : _d.call(this, error);
1558
1532
  return;
1559
1533
  }
1560
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils2.EventSourceParserStream());
1534
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream2());
1561
1535
  const reader = stream.getReader();
1562
1536
  const processEvents = async () => {
1563
1537
  var _a4, _b4, _c2, _d2;
@@ -1982,17 +1956,17 @@ var DefaultMCPClient = class {
1982
1956
  }
1983
1957
  return result;
1984
1958
  };
1985
- const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils3.dynamicTool)({
1959
+ const toolWithExecute = schemas === "automatic" ? dynamicTool({
1986
1960
  description,
1987
1961
  title: resolvedTitle,
1988
- inputSchema: (0, import_provider_utils3.jsonSchema)({
1962
+ inputSchema: jsonSchema({
1989
1963
  ...inputSchema,
1990
1964
  properties: (_b3 = inputSchema.properties) != null ? _b3 : {},
1991
1965
  additionalProperties: false
1992
1966
  }),
1993
1967
  execute,
1994
1968
  toModelOutput: mcpToModelOutput
1995
- }) : (0, import_provider_utils3.tool)({
1969
+ }) : tool({
1996
1970
  description,
1997
1971
  title: resolvedTitle,
1998
1972
  inputSchema: schemas[name3].inputSchema,
@@ -2009,9 +1983,9 @@ var DefaultMCPClient = class {
2009
1983
  */
2010
1984
  async extractStructuredContent(result, outputSchema, toolName) {
2011
1985
  if ("structuredContent" in result && result.structuredContent != null) {
2012
- const validationResult = await (0, import_provider_utils3.safeValidateTypes)({
1986
+ const validationResult = await safeValidateTypes({
2013
1987
  value: result.structuredContent,
2014
- schema: (0, import_provider_utils3.asSchema)(outputSchema)
1988
+ schema: asSchema(outputSchema)
2015
1989
  });
2016
1990
  if (!validationResult.success) {
2017
1991
  throw new MCPClientError({
@@ -2024,7 +1998,7 @@ var DefaultMCPClient = class {
2024
1998
  if ("content" in result && Array.isArray(result.content)) {
2025
1999
  const textContent = result.content.find((c) => c.type === "text");
2026
2000
  if (textContent && "text" in textContent) {
2027
- const parseResult = await (0, import_provider_utils3.safeParseJSON)({
2001
+ const parseResult = await safeParseJSON({
2028
2002
  text: textContent.text,
2029
2003
  schema: outputSchema
2030
2004
  });
@@ -2179,13 +2153,12 @@ var DefaultMCPClient = class {
2179
2153
  );
2180
2154
  }
2181
2155
  };
2182
- // Annotate the CommonJS export names for ESM import in node:
2183
- 0 && (module.exports = {
2156
+ export {
2184
2157
  ElicitResultSchema,
2185
2158
  ElicitationRequestSchema,
2186
2159
  UnauthorizedError,
2187
2160
  auth,
2188
2161
  createMCPClient,
2189
- experimental_createMCPClient
2190
- });
2162
+ createMCPClient as experimental_createMCPClient
2163
+ };
2191
2164
  //# sourceMappingURL=index.js.map