@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.d.mts DELETED
@@ -1,509 +0,0 @@
1
- import { z } from 'zod/v4';
2
- import { FetchFunction, FlexibleSchema, Tool } from '@ai-sdk/provider-utils';
3
- import { JSONObject } from '@ai-sdk/provider';
4
-
5
- declare const JSONRPCRequestSchema: z.ZodObject<{
6
- jsonrpc: z.ZodLiteral<"2.0">;
7
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
8
- method: z.ZodString;
9
- params: z.ZodOptional<z.ZodObject<{
10
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
11
- }, z.core.$loose>>;
12
- }, z.core.$strict>;
13
- type JSONRPCRequest = z.infer<typeof JSONRPCRequestSchema>;
14
- declare const JSONRPCResponseSchema: z.ZodObject<{
15
- jsonrpc: z.ZodLiteral<"2.0">;
16
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
17
- result: z.ZodObject<{
18
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
19
- }, z.core.$loose>;
20
- }, z.core.$strict>;
21
- type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
22
- declare const JSONRPCErrorSchema: z.ZodObject<{
23
- jsonrpc: z.ZodLiteral<"2.0">;
24
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
25
- error: z.ZodObject<{
26
- code: z.ZodNumber;
27
- message: z.ZodString;
28
- data: z.ZodOptional<z.ZodUnknown>;
29
- }, z.core.$strip>;
30
- }, z.core.$strict>;
31
- type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
32
- declare const JSONRPCNotificationSchema: z.ZodObject<{
33
- jsonrpc: z.ZodLiteral<"2.0">;
34
- method: z.ZodString;
35
- params: z.ZodOptional<z.ZodObject<{
36
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
37
- }, z.core.$loose>>;
38
- }, z.core.$strict>;
39
- type JSONRPCNotification = z.infer<typeof JSONRPCNotificationSchema>;
40
- declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
41
- jsonrpc: z.ZodLiteral<"2.0">;
42
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
43
- method: z.ZodString;
44
- params: z.ZodOptional<z.ZodObject<{
45
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
46
- }, z.core.$loose>>;
47
- }, z.core.$strict>, z.ZodObject<{
48
- jsonrpc: z.ZodLiteral<"2.0">;
49
- method: z.ZodString;
50
- params: z.ZodOptional<z.ZodObject<{
51
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
52
- }, z.core.$loose>>;
53
- }, z.core.$strict>, z.ZodObject<{
54
- jsonrpc: z.ZodLiteral<"2.0">;
55
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
56
- result: z.ZodObject<{
57
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
58
- }, z.core.$loose>;
59
- }, z.core.$strict>, z.ZodObject<{
60
- jsonrpc: z.ZodLiteral<"2.0">;
61
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
62
- error: z.ZodObject<{
63
- code: z.ZodNumber;
64
- message: z.ZodString;
65
- data: z.ZodOptional<z.ZodUnknown>;
66
- }, z.core.$strip>;
67
- }, z.core.$strict>]>;
68
- type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
69
-
70
- /**
71
- * OAuth 2.1 token response
72
- */
73
- declare const OAuthTokensSchema: z.ZodObject<{
74
- access_token: z.ZodString;
75
- id_token: z.ZodOptional<z.ZodString>;
76
- token_type: z.ZodString;
77
- expires_in: z.ZodOptional<z.ZodNumber>;
78
- scope: z.ZodOptional<z.ZodString>;
79
- refresh_token: z.ZodOptional<z.ZodString>;
80
- }, z.core.$strip>;
81
- declare const OAuthMetadataSchema: z.ZodObject<{
82
- issuer: z.ZodString;
83
- authorization_endpoint: z.ZodString;
84
- token_endpoint: z.ZodString;
85
- registration_endpoint: z.ZodOptional<z.ZodString>;
86
- scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
- response_types_supported: z.ZodArray<z.ZodString>;
88
- grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
89
- code_challenge_methods_supported: z.ZodArray<z.ZodString>;
90
- token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
91
- token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
92
- }, z.core.$loose>;
93
- /**
94
- * OpenID Connect Discovery metadata that may include OAuth 2.0 fields
95
- * This schema represents the real-world scenario where OIDC providers
96
- * return a mix of OpenID Connect and OAuth 2.0 metadata fields
97
- */
98
- declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
99
- issuer: z.ZodString;
100
- authorization_endpoint: z.ZodString;
101
- token_endpoint: z.ZodString;
102
- userinfo_endpoint: z.ZodOptional<z.ZodString>;
103
- jwks_uri: z.ZodString;
104
- registration_endpoint: z.ZodOptional<z.ZodString>;
105
- scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
- response_types_supported: z.ZodArray<z.ZodString>;
107
- grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
108
- subject_types_supported: z.ZodArray<z.ZodString>;
109
- id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
110
- claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
- token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
112
- code_challenge_methods_supported: z.ZodArray<z.ZodString>;
113
- }, z.core.$loose>;
114
- declare const OAuthClientInformationSchema: z.ZodObject<{
115
- client_id: z.ZodString;
116
- client_secret: z.ZodOptional<z.ZodString>;
117
- client_id_issued_at: z.ZodOptional<z.ZodNumber>;
118
- client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
119
- }, z.core.$strip>;
120
- declare const OAuthClientMetadataSchema: z.ZodObject<{
121
- redirect_uris: z.ZodArray<z.ZodString>;
122
- token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
123
- grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
124
- response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
125
- client_name: z.ZodOptional<z.ZodString>;
126
- client_uri: z.ZodOptional<z.ZodString>;
127
- logo_uri: z.ZodOptional<z.ZodString>;
128
- scope: z.ZodOptional<z.ZodString>;
129
- contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
- tos_uri: z.ZodOptional<z.ZodString>;
131
- policy_uri: z.ZodOptional<z.ZodString>;
132
- jwks_uri: z.ZodOptional<z.ZodString>;
133
- jwks: z.ZodOptional<z.ZodAny>;
134
- software_id: z.ZodOptional<z.ZodString>;
135
- software_version: z.ZodOptional<z.ZodString>;
136
- software_statement: z.ZodOptional<z.ZodString>;
137
- }, z.core.$strip>;
138
- type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
139
- type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
140
- type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
141
- type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
142
- type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
143
- type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
144
-
145
- type AuthResult = 'AUTHORIZED' | 'REDIRECT';
146
- interface OAuthClientProvider {
147
- /**
148
- * Returns current access token if present; undefined otherwise.
149
- */
150
- tokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;
151
- saveTokens(tokens: OAuthTokens): void | Promise<void>;
152
- redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
153
- saveCodeVerifier(codeVerifier: string): void | Promise<void>;
154
- codeVerifier(): string | Promise<string>;
155
- /**
156
- * Adds custom client authentication to OAuth token requests.
157
- *
158
- * This optional method allows implementations to customize how client credentials
159
- * are included in token exchange and refresh requests. When provided, this method
160
- * is called instead of the default authentication logic, giving full control over
161
- * the authentication mechanism.
162
- *
163
- * Common use cases include:
164
- * - Supporting authentication methods beyond the standard OAuth 2.0 methods
165
- * - Adding custom headers for proprietary authentication schemes
166
- * - Implementing client assertion-based authentication (e.g., JWT bearer tokens)
167
- *
168
- * @param headers - The request headers (can be modified to add authentication)
169
- * @param params - The request body parameters (can be modified to add credentials)
170
- * @param url - The token endpoint URL being called
171
- * @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods
172
- */
173
- addClientAuthentication?(headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata): void | Promise<void>;
174
- /**
175
- * If implemented, provides a way for the client to invalidate (e.g. delete) the specified
176
- * credentials, in the case where the server has indicated that they are no longer valid.
177
- * This avoids requiring the user to intervene manually.
178
- */
179
- invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier'): void | Promise<void>;
180
- get redirectUrl(): string | URL;
181
- get clientMetadata(): OAuthClientMetadata;
182
- clientInformation(): OAuthClientInformation | undefined | Promise<OAuthClientInformation | undefined>;
183
- saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise<void>;
184
- state?(): string | Promise<string>;
185
- saveState?(state: string): void | Promise<void>;
186
- storedState?(): string | undefined | Promise<string | undefined>;
187
- validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
188
- }
189
- declare class UnauthorizedError extends Error {
190
- constructor(message?: string);
191
- }
192
- declare function auth(provider: OAuthClientProvider, options: {
193
- serverUrl: string | URL;
194
- authorizationCode?: string;
195
- callbackState?: string;
196
- scope?: string;
197
- resourceMetadataUrl?: URL;
198
- fetchFn?: FetchFunction;
199
- }): Promise<AuthResult>;
200
-
201
- /**
202
- * Transport interface for MCP (Model Context Protocol) communication.
203
- * Maps to the `Transport` interface in the MCP spec.
204
- */
205
- interface MCPTransport {
206
- /**
207
- * Initialize and start the transport
208
- */
209
- start(): Promise<void>;
210
- /**
211
- * Send a JSON-RPC message through the transport
212
- * @param message The JSON-RPC message to send
213
- */
214
- send(message: JSONRPCMessage): Promise<void>;
215
- /**
216
- * Clean up and close the transport
217
- */
218
- close(): Promise<void>;
219
- /**
220
- * Event handler for transport closure
221
- */
222
- onclose?: () => void;
223
- /**
224
- * Event handler for transport errors
225
- */
226
- onerror?: (error: Error) => void;
227
- /**
228
- * Event handler for received messages
229
- */
230
- onmessage?: (message: JSONRPCMessage) => void;
231
- }
232
- type MCPTransportConfig = {
233
- type: 'sse' | 'http';
234
- /**
235
- * The URL of the MCP server.
236
- */
237
- url: string;
238
- /**
239
- * Additional HTTP headers to be sent with requests.
240
- */
241
- headers?: Record<string, string>;
242
- /**
243
- * An optional OAuth client provider to use for authentication for MCP servers.
244
- */
245
- authProvider?: OAuthClientProvider;
246
- };
247
-
248
- /** MCP tool metadata - keys should follow MCP _meta key format specification */
249
- declare const ToolMetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
250
- type ToolMeta = z.infer<typeof ToolMetaSchema>;
251
- type ToolSchemas = Record<string, {
252
- inputSchema: FlexibleSchema<JSONObject | unknown>;
253
- outputSchema?: FlexibleSchema<JSONObject | unknown>;
254
- }> | 'automatic' | undefined;
255
- /** Base MCP tool type with execute and _meta */
256
- type McpToolBase<INPUT = unknown, OUTPUT = CallToolResult> = Tool<INPUT, OUTPUT> & Required<Pick<Tool<INPUT, OUTPUT>, 'execute'>> & {
257
- _meta?: ToolMeta;
258
- };
259
- type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
260
- inputSchema: FlexibleSchema<any>;
261
- outputSchema?: FlexibleSchema<any>;
262
- }> ? {
263
- [K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
264
- inputSchema: FlexibleSchema<infer INPUT>;
265
- outputSchema: FlexibleSchema<infer OUTPUT>;
266
- } ? McpToolBase<INPUT, OUTPUT> : TOOL_SCHEMAS[K] extends {
267
- inputSchema: FlexibleSchema<infer INPUT>;
268
- } ? McpToolBase<INPUT, CallToolResult> : never;
269
- } : Record<string, McpToolBase<unknown, CallToolResult>>;
270
- declare const BaseParamsSchema: z.ZodObject<{
271
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
272
- }, z.core.$loose>;
273
- type BaseParams = z.infer<typeof BaseParamsSchema>;
274
- declare const RequestSchema: z.ZodObject<{
275
- method: z.ZodString;
276
- params: z.ZodOptional<z.ZodObject<{
277
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
278
- }, z.core.$loose>>;
279
- }, z.core.$strip>;
280
- type Request = z.infer<typeof RequestSchema>;
281
- type RequestOptions = {
282
- signal?: AbortSignal;
283
- timeout?: number;
284
- maxTotalTimeout?: number;
285
- };
286
- declare const ClientCapabilitiesSchema: z.ZodObject<{
287
- elicitation: z.ZodOptional<z.ZodObject<{
288
- applyDefaults: z.ZodOptional<z.ZodBoolean>;
289
- }, z.core.$loose>>;
290
- }, z.core.$loose>;
291
- type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
292
- type PaginatedRequest = Request & {
293
- params?: BaseParams & {
294
- cursor?: string;
295
- };
296
- };
297
- declare const ListToolsResultSchema: z.ZodObject<{
298
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
299
- nextCursor: z.ZodOptional<z.ZodString>;
300
- tools: z.ZodArray<z.ZodObject<{
301
- name: z.ZodString;
302
- title: z.ZodOptional<z.ZodString>;
303
- description: z.ZodOptional<z.ZodString>;
304
- inputSchema: z.ZodObject<{
305
- type: z.ZodLiteral<"object">;
306
- properties: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
307
- }, z.core.$loose>;
308
- outputSchema: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
309
- annotations: z.ZodOptional<z.ZodObject<{
310
- title: z.ZodOptional<z.ZodString>;
311
- }, z.core.$loose>>;
312
- _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
313
- }, z.core.$loose>>;
314
- }, z.core.$loose>;
315
- type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
316
- declare const ListResourcesResultSchema: z.ZodObject<{
317
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
318
- nextCursor: z.ZodOptional<z.ZodString>;
319
- resources: z.ZodArray<z.ZodObject<{
320
- uri: z.ZodString;
321
- name: z.ZodString;
322
- title: z.ZodOptional<z.ZodString>;
323
- description: z.ZodOptional<z.ZodString>;
324
- mimeType: z.ZodOptional<z.ZodString>;
325
- size: z.ZodOptional<z.ZodNumber>;
326
- }, z.core.$loose>>;
327
- }, z.core.$loose>;
328
- type ListResourcesResult = z.infer<typeof ListResourcesResultSchema>;
329
- declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
330
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
331
- content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
332
- type: z.ZodLiteral<"text">;
333
- text: z.ZodString;
334
- }, z.core.$loose>, z.ZodObject<{
335
- type: z.ZodLiteral<"image">;
336
- data: z.ZodBase64;
337
- mimeType: z.ZodString;
338
- }, z.core.$loose>, z.ZodObject<{
339
- type: z.ZodLiteral<"resource">;
340
- resource: z.ZodUnion<readonly [z.ZodObject<{
341
- uri: z.ZodString;
342
- name: z.ZodOptional<z.ZodString>;
343
- title: z.ZodOptional<z.ZodString>;
344
- mimeType: z.ZodOptional<z.ZodString>;
345
- text: z.ZodString;
346
- }, z.core.$loose>, z.ZodObject<{
347
- uri: z.ZodString;
348
- name: z.ZodOptional<z.ZodString>;
349
- title: z.ZodOptional<z.ZodString>;
350
- mimeType: z.ZodOptional<z.ZodString>;
351
- blob: z.ZodBase64;
352
- }, z.core.$loose>]>;
353
- }, z.core.$loose>]>>;
354
- structuredContent: z.ZodOptional<z.ZodUnknown>;
355
- isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
356
- }, z.core.$loose>, z.ZodObject<{
357
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
358
- toolResult: z.ZodUnknown;
359
- }, z.core.$loose>]>;
360
- type CallToolResult = z.infer<typeof CallToolResultSchema>;
361
- declare const ListResourceTemplatesResultSchema: z.ZodObject<{
362
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
363
- resourceTemplates: z.ZodArray<z.ZodObject<{
364
- uriTemplate: z.ZodString;
365
- name: z.ZodString;
366
- title: z.ZodOptional<z.ZodString>;
367
- description: z.ZodOptional<z.ZodString>;
368
- mimeType: z.ZodOptional<z.ZodString>;
369
- }, z.core.$loose>>;
370
- }, z.core.$loose>;
371
- type ListResourceTemplatesResult = z.infer<typeof ListResourceTemplatesResultSchema>;
372
- declare const ReadResourceResultSchema: z.ZodObject<{
373
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
374
- contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
375
- uri: z.ZodString;
376
- name: z.ZodOptional<z.ZodString>;
377
- title: z.ZodOptional<z.ZodString>;
378
- mimeType: z.ZodOptional<z.ZodString>;
379
- text: z.ZodString;
380
- }, z.core.$loose>, z.ZodObject<{
381
- uri: z.ZodString;
382
- name: z.ZodOptional<z.ZodString>;
383
- title: z.ZodOptional<z.ZodString>;
384
- mimeType: z.ZodOptional<z.ZodString>;
385
- blob: z.ZodBase64;
386
- }, z.core.$loose>]>>;
387
- }, z.core.$loose>;
388
- type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
389
- declare const ListPromptsResultSchema: z.ZodObject<{
390
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
391
- nextCursor: z.ZodOptional<z.ZodString>;
392
- prompts: z.ZodArray<z.ZodObject<{
393
- name: z.ZodString;
394
- title: z.ZodOptional<z.ZodString>;
395
- description: z.ZodOptional<z.ZodString>;
396
- arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
397
- name: z.ZodString;
398
- description: z.ZodOptional<z.ZodString>;
399
- required: z.ZodOptional<z.ZodBoolean>;
400
- }, z.core.$loose>>>;
401
- }, z.core.$loose>>;
402
- }, z.core.$loose>;
403
- type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
404
- declare const GetPromptResultSchema: z.ZodObject<{
405
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
406
- description: z.ZodOptional<z.ZodString>;
407
- messages: z.ZodArray<z.ZodObject<{
408
- role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
409
- content: z.ZodUnion<readonly [z.ZodObject<{
410
- type: z.ZodLiteral<"text">;
411
- text: z.ZodString;
412
- }, z.core.$loose>, z.ZodObject<{
413
- type: z.ZodLiteral<"image">;
414
- data: z.ZodBase64;
415
- mimeType: z.ZodString;
416
- }, z.core.$loose>, z.ZodObject<{
417
- type: z.ZodLiteral<"resource">;
418
- resource: z.ZodUnion<readonly [z.ZodObject<{
419
- uri: z.ZodString;
420
- name: z.ZodOptional<z.ZodString>;
421
- title: z.ZodOptional<z.ZodString>;
422
- mimeType: z.ZodOptional<z.ZodString>;
423
- text: z.ZodString;
424
- }, z.core.$loose>, z.ZodObject<{
425
- uri: z.ZodString;
426
- name: z.ZodOptional<z.ZodString>;
427
- title: z.ZodOptional<z.ZodString>;
428
- mimeType: z.ZodOptional<z.ZodString>;
429
- blob: z.ZodBase64;
430
- }, z.core.$loose>]>;
431
- }, z.core.$loose>]>;
432
- }, z.core.$loose>>;
433
- }, z.core.$loose>;
434
- type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
435
- declare const ElicitationRequestSchema: z.ZodObject<{
436
- method: z.ZodLiteral<"elicitation/create">;
437
- params: z.ZodObject<{
438
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
439
- message: z.ZodString;
440
- requestedSchema: z.ZodUnknown;
441
- }, z.core.$loose>;
442
- }, z.core.$strip>;
443
- type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
444
- declare const ElicitResultSchema: z.ZodObject<{
445
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
446
- action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
447
- content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
448
- }, z.core.$loose>;
449
- type ElicitResult = z.infer<typeof ElicitResultSchema>;
450
-
451
- interface MCPClientConfig {
452
- /** Transport configuration for connecting to the MCP server */
453
- transport: MCPTransportConfig | MCPTransport;
454
- /** Optional callback for uncaught errors */
455
- onUncaughtError?: (error: unknown) => void;
456
- /** Optional client name, defaults to 'ai-sdk-mcp-client' */
457
- name?: string;
458
- /** Optional client version, defaults to '1.0.0' */
459
- version?: string;
460
- /**
461
- * Optional client capabilities to advertise during initialization
462
- *
463
- * NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server
464
- */
465
- capabilities?: ClientCapabilities;
466
- }
467
- declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
468
- interface MCPClient {
469
- tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
470
- schemas?: TOOL_SCHEMAS;
471
- }): Promise<McpToolSet<TOOL_SCHEMAS>>;
472
- /**
473
- * Lists available tools from the MCP server.
474
- */
475
- listTools(options?: {
476
- params?: PaginatedRequest['params'];
477
- options?: RequestOptions;
478
- }): Promise<ListToolsResult>;
479
- /**
480
- * Creates AI SDK tools from tool definitions.
481
- */
482
- toolsFromDefinitions<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(definitions: ListToolsResult, options?: {
483
- schemas?: TOOL_SCHEMAS;
484
- }): McpToolSet<TOOL_SCHEMAS>;
485
- listResources(options?: {
486
- params?: PaginatedRequest['params'];
487
- options?: RequestOptions;
488
- }): Promise<ListResourcesResult>;
489
- readResource(args: {
490
- uri: string;
491
- options?: RequestOptions;
492
- }): Promise<ReadResourceResult>;
493
- listResourceTemplates(options?: {
494
- options?: RequestOptions;
495
- }): Promise<ListResourceTemplatesResult>;
496
- experimental_listPrompts(options?: {
497
- params?: PaginatedRequest['params'];
498
- options?: RequestOptions;
499
- }): Promise<ListPromptsResult>;
500
- experimental_getPrompt(args: {
501
- name: string;
502
- arguments?: Record<string, unknown>;
503
- options?: RequestOptions;
504
- }): Promise<GetPromptResult>;
505
- onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
506
- close: () => Promise<void>;
507
- }
508
-
509
- export { type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };