@ai-sdk/mcp 1.0.0-beta.2 → 1.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +133 -0
- package/dist/index.d.mts +163 -1
- package/dist/index.d.ts +163 -1
- package/dist/index.js +291 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -9
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +84 -1
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +84 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,138 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8d9e8ad]
|
|
8
|
+
- @ai-sdk/provider@3.0.0-beta.19
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.0-beta.36
|
|
10
|
+
|
|
11
|
+
## 1.0.0-beta.19
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [10d819b]
|
|
16
|
+
- @ai-sdk/provider@3.0.0-beta.18
|
|
17
|
+
- @ai-sdk/provider-utils@4.0.0-beta.35
|
|
18
|
+
|
|
19
|
+
## 1.0.0-beta.18
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- ba2ca2d: feat(mcp): add the possibility to define client version in mcp client definition
|
|
24
|
+
|
|
25
|
+
## 1.0.0-beta.17
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- f702df2: feat(mcp): add client elicitation support
|
|
30
|
+
|
|
31
|
+
## 1.0.0-beta.16
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [db913bd]
|
|
36
|
+
- @ai-sdk/provider@3.0.0-beta.17
|
|
37
|
+
- @ai-sdk/provider-utils@4.0.0-beta.34
|
|
38
|
+
|
|
39
|
+
## 1.0.0-beta.15
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [b681d7d]
|
|
44
|
+
- @ai-sdk/provider@3.0.0-beta.16
|
|
45
|
+
- @ai-sdk/provider-utils@4.0.0-beta.33
|
|
46
|
+
|
|
47
|
+
## 1.0.0-beta.14
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [32d8dbb]
|
|
52
|
+
- @ai-sdk/provider-utils@4.0.0-beta.32
|
|
53
|
+
|
|
54
|
+
## 1.0.0-beta.13
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- 1cff766: feat(packages/mcp): add support for MCP server prompts exposed
|
|
59
|
+
|
|
60
|
+
## 1.0.0-beta.12
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [bb36798]
|
|
65
|
+
- @ai-sdk/provider@3.0.0-beta.15
|
|
66
|
+
- @ai-sdk/provider-utils@4.0.0-beta.31
|
|
67
|
+
|
|
68
|
+
## 1.0.0-beta.11
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [4f16c37]
|
|
73
|
+
- @ai-sdk/provider-utils@4.0.0-beta.30
|
|
74
|
+
|
|
75
|
+
## 1.0.0-beta.10
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [af3780b]
|
|
80
|
+
- @ai-sdk/provider@3.0.0-beta.14
|
|
81
|
+
- @ai-sdk/provider-utils@4.0.0-beta.29
|
|
82
|
+
|
|
83
|
+
## 1.0.0-beta.9
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [016b111]
|
|
88
|
+
- @ai-sdk/provider-utils@4.0.0-beta.28
|
|
89
|
+
|
|
90
|
+
## 1.0.0-beta.8
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [37c58a0]
|
|
95
|
+
- @ai-sdk/provider@3.0.0-beta.13
|
|
96
|
+
- @ai-sdk/provider-utils@4.0.0-beta.27
|
|
97
|
+
|
|
98
|
+
## 1.0.0-beta.7
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [d1bdadb]
|
|
103
|
+
- @ai-sdk/provider@3.0.0-beta.12
|
|
104
|
+
- @ai-sdk/provider-utils@4.0.0-beta.26
|
|
105
|
+
|
|
106
|
+
## 1.0.0-beta.6
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- Updated dependencies [4c44a5b]
|
|
111
|
+
- @ai-sdk/provider@3.0.0-beta.11
|
|
112
|
+
- @ai-sdk/provider-utils@4.0.0-beta.25
|
|
113
|
+
|
|
114
|
+
## 1.0.0-beta.5
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies [0c3b58b]
|
|
119
|
+
- @ai-sdk/provider@3.0.0-beta.10
|
|
120
|
+
- @ai-sdk/provider-utils@4.0.0-beta.24
|
|
121
|
+
|
|
122
|
+
## 1.0.0-beta.4
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- Updated dependencies [a755db5]
|
|
127
|
+
- @ai-sdk/provider@3.0.0-beta.9
|
|
128
|
+
- @ai-sdk/provider-utils@4.0.0-beta.23
|
|
129
|
+
|
|
130
|
+
## 1.0.0-beta.3
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- 5939b92: feat(mcp): adding resources support to MCP client
|
|
135
|
+
|
|
3
136
|
## 1.0.0-beta.2
|
|
4
137
|
|
|
5
138
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -254,6 +254,46 @@ type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS e
|
|
|
254
254
|
} : McpToolSet<Record<string, {
|
|
255
255
|
inputSchema: FlexibleSchema<unknown>;
|
|
256
256
|
}>>;
|
|
257
|
+
declare const BaseParamsSchema: z.ZodObject<{
|
|
258
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
259
|
+
}, z.core.$loose>;
|
|
260
|
+
type BaseParams = z.infer<typeof BaseParamsSchema>;
|
|
261
|
+
declare const RequestSchema: z.ZodObject<{
|
|
262
|
+
method: z.ZodString;
|
|
263
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
264
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
265
|
+
}, z.core.$loose>>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
type Request = z.infer<typeof RequestSchema>;
|
|
268
|
+
type RequestOptions = {
|
|
269
|
+
signal?: AbortSignal;
|
|
270
|
+
timeout?: number;
|
|
271
|
+
maxTotalTimeout?: number;
|
|
272
|
+
};
|
|
273
|
+
declare const ClientCapabilitiesSchema: z.ZodObject<{
|
|
274
|
+
elicitation: z.ZodOptional<z.ZodObject<{
|
|
275
|
+
applyDefaults: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
}, z.core.$loose>>;
|
|
277
|
+
}, z.core.$loose>;
|
|
278
|
+
type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
|
|
279
|
+
type PaginatedRequest = Request & {
|
|
280
|
+
params?: BaseParams & {
|
|
281
|
+
cursor?: string;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
declare const ListResourcesResultSchema: z.ZodObject<{
|
|
285
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
286
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
287
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
288
|
+
uri: z.ZodString;
|
|
289
|
+
name: z.ZodString;
|
|
290
|
+
title: z.ZodOptional<z.ZodString>;
|
|
291
|
+
description: z.ZodOptional<z.ZodString>;
|
|
292
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
293
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
}, z.core.$loose>>;
|
|
295
|
+
}, z.core.$loose>;
|
|
296
|
+
type ListResourcesResult = z.infer<typeof ListResourcesResultSchema>;
|
|
257
297
|
declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
258
298
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
259
299
|
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -267,10 +307,14 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
267
307
|
type: z.ZodLiteral<"resource">;
|
|
268
308
|
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
269
309
|
uri: z.ZodString;
|
|
310
|
+
name: z.ZodOptional<z.ZodString>;
|
|
311
|
+
title: z.ZodOptional<z.ZodString>;
|
|
270
312
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
271
313
|
text: z.ZodString;
|
|
272
314
|
}, z.core.$loose>, z.ZodObject<{
|
|
273
315
|
uri: z.ZodString;
|
|
316
|
+
name: z.ZodOptional<z.ZodString>;
|
|
317
|
+
title: z.ZodOptional<z.ZodString>;
|
|
274
318
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
275
319
|
blob: z.ZodBase64;
|
|
276
320
|
}, z.core.$loose>]>;
|
|
@@ -281,6 +325,95 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
281
325
|
toolResult: z.ZodUnknown;
|
|
282
326
|
}, z.core.$loose>]>;
|
|
283
327
|
type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
|
328
|
+
declare const ListResourceTemplatesResultSchema: z.ZodObject<{
|
|
329
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
330
|
+
resourceTemplates: z.ZodArray<z.ZodObject<{
|
|
331
|
+
uriTemplate: z.ZodString;
|
|
332
|
+
name: z.ZodString;
|
|
333
|
+
title: z.ZodOptional<z.ZodString>;
|
|
334
|
+
description: z.ZodOptional<z.ZodString>;
|
|
335
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
336
|
+
}, z.core.$loose>>;
|
|
337
|
+
}, z.core.$loose>;
|
|
338
|
+
type ListResourceTemplatesResult = z.infer<typeof ListResourceTemplatesResultSchema>;
|
|
339
|
+
declare const ReadResourceResultSchema: z.ZodObject<{
|
|
340
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
341
|
+
contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
342
|
+
uri: z.ZodString;
|
|
343
|
+
name: z.ZodOptional<z.ZodString>;
|
|
344
|
+
title: z.ZodOptional<z.ZodString>;
|
|
345
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
346
|
+
text: z.ZodString;
|
|
347
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
348
|
+
uri: z.ZodString;
|
|
349
|
+
name: z.ZodOptional<z.ZodString>;
|
|
350
|
+
title: z.ZodOptional<z.ZodString>;
|
|
351
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
352
|
+
blob: z.ZodBase64;
|
|
353
|
+
}, z.core.$loose>]>>;
|
|
354
|
+
}, z.core.$loose>;
|
|
355
|
+
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
356
|
+
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
357
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
358
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
359
|
+
prompts: z.ZodArray<z.ZodObject<{
|
|
360
|
+
name: z.ZodString;
|
|
361
|
+
title: z.ZodOptional<z.ZodString>;
|
|
362
|
+
description: z.ZodOptional<z.ZodString>;
|
|
363
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
364
|
+
name: z.ZodString;
|
|
365
|
+
description: z.ZodOptional<z.ZodString>;
|
|
366
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
367
|
+
}, z.core.$loose>>>;
|
|
368
|
+
}, z.core.$loose>>;
|
|
369
|
+
}, z.core.$loose>;
|
|
370
|
+
type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
|
|
371
|
+
declare const GetPromptResultSchema: z.ZodObject<{
|
|
372
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
373
|
+
description: z.ZodOptional<z.ZodString>;
|
|
374
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
375
|
+
role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
|
|
376
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
377
|
+
type: z.ZodLiteral<"text">;
|
|
378
|
+
text: z.ZodString;
|
|
379
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
380
|
+
type: z.ZodLiteral<"image">;
|
|
381
|
+
data: z.ZodBase64;
|
|
382
|
+
mimeType: z.ZodString;
|
|
383
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
384
|
+
type: z.ZodLiteral<"resource">;
|
|
385
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
386
|
+
uri: z.ZodString;
|
|
387
|
+
name: z.ZodOptional<z.ZodString>;
|
|
388
|
+
title: z.ZodOptional<z.ZodString>;
|
|
389
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
390
|
+
text: z.ZodString;
|
|
391
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
392
|
+
uri: z.ZodString;
|
|
393
|
+
name: z.ZodOptional<z.ZodString>;
|
|
394
|
+
title: z.ZodOptional<z.ZodString>;
|
|
395
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
396
|
+
blob: z.ZodBase64;
|
|
397
|
+
}, z.core.$loose>]>;
|
|
398
|
+
}, z.core.$loose>]>;
|
|
399
|
+
}, z.core.$loose>>;
|
|
400
|
+
}, z.core.$loose>;
|
|
401
|
+
type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
|
|
402
|
+
declare const ElicitationRequestSchema: z.ZodObject<{
|
|
403
|
+
method: z.ZodLiteral<"elicitation/create">;
|
|
404
|
+
params: z.ZodObject<{
|
|
405
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
406
|
+
message: z.ZodString;
|
|
407
|
+
requestedSchema: z.ZodUnknown;
|
|
408
|
+
}, z.core.$loose>;
|
|
409
|
+
}, z.core.$strip>;
|
|
410
|
+
type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
|
|
411
|
+
declare const ElicitResultSchema: z.ZodObject<{
|
|
412
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
413
|
+
action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
|
|
414
|
+
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
415
|
+
}, z.core.$loose>;
|
|
416
|
+
type ElicitResult = z.infer<typeof ElicitResultSchema>;
|
|
284
417
|
|
|
285
418
|
interface MCPClientConfig {
|
|
286
419
|
/** Transport configuration for connecting to the MCP server */
|
|
@@ -289,13 +422,42 @@ interface MCPClientConfig {
|
|
|
289
422
|
onUncaughtError?: (error: unknown) => void;
|
|
290
423
|
/** Optional client name, defaults to 'ai-sdk-mcp-client' */
|
|
291
424
|
name?: string;
|
|
425
|
+
/** Optional client version, defaults to '1.0.0' */
|
|
426
|
+
version?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Optional client capabilities to advertise during initialization
|
|
429
|
+
*
|
|
430
|
+
* NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server
|
|
431
|
+
*/
|
|
432
|
+
capabilities?: ClientCapabilities;
|
|
292
433
|
}
|
|
293
434
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
294
435
|
interface MCPClient {
|
|
295
436
|
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
|
|
296
437
|
schemas?: TOOL_SCHEMAS;
|
|
297
438
|
}): Promise<McpToolSet<TOOL_SCHEMAS>>;
|
|
439
|
+
listResources(options?: {
|
|
440
|
+
params?: PaginatedRequest['params'];
|
|
441
|
+
options?: RequestOptions;
|
|
442
|
+
}): Promise<ListResourcesResult>;
|
|
443
|
+
readResource(args: {
|
|
444
|
+
uri: string;
|
|
445
|
+
options?: RequestOptions;
|
|
446
|
+
}): Promise<ReadResourceResult>;
|
|
447
|
+
listResourceTemplates(options?: {
|
|
448
|
+
options?: RequestOptions;
|
|
449
|
+
}): Promise<ListResourceTemplatesResult>;
|
|
450
|
+
listPrompts(options?: {
|
|
451
|
+
params?: PaginatedRequest['params'];
|
|
452
|
+
options?: RequestOptions;
|
|
453
|
+
}): Promise<ListPromptsResult>;
|
|
454
|
+
getPrompt(args: {
|
|
455
|
+
name: string;
|
|
456
|
+
arguments?: Record<string, unknown>;
|
|
457
|
+
options?: RequestOptions;
|
|
458
|
+
}): Promise<GetPromptResult>;
|
|
459
|
+
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
298
460
|
close: () => Promise<void>;
|
|
299
461
|
}
|
|
300
462
|
|
|
301
|
-
export { type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, type MCPClient as experimental_MCPClient, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };
|
|
463
|
+
export { type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -254,6 +254,46 @@ type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS e
|
|
|
254
254
|
} : McpToolSet<Record<string, {
|
|
255
255
|
inputSchema: FlexibleSchema<unknown>;
|
|
256
256
|
}>>;
|
|
257
|
+
declare const BaseParamsSchema: z.ZodObject<{
|
|
258
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
259
|
+
}, z.core.$loose>;
|
|
260
|
+
type BaseParams = z.infer<typeof BaseParamsSchema>;
|
|
261
|
+
declare const RequestSchema: z.ZodObject<{
|
|
262
|
+
method: z.ZodString;
|
|
263
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
264
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
265
|
+
}, z.core.$loose>>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
type Request = z.infer<typeof RequestSchema>;
|
|
268
|
+
type RequestOptions = {
|
|
269
|
+
signal?: AbortSignal;
|
|
270
|
+
timeout?: number;
|
|
271
|
+
maxTotalTimeout?: number;
|
|
272
|
+
};
|
|
273
|
+
declare const ClientCapabilitiesSchema: z.ZodObject<{
|
|
274
|
+
elicitation: z.ZodOptional<z.ZodObject<{
|
|
275
|
+
applyDefaults: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
}, z.core.$loose>>;
|
|
277
|
+
}, z.core.$loose>;
|
|
278
|
+
type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
|
|
279
|
+
type PaginatedRequest = Request & {
|
|
280
|
+
params?: BaseParams & {
|
|
281
|
+
cursor?: string;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
declare const ListResourcesResultSchema: z.ZodObject<{
|
|
285
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
286
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
287
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
288
|
+
uri: z.ZodString;
|
|
289
|
+
name: z.ZodString;
|
|
290
|
+
title: z.ZodOptional<z.ZodString>;
|
|
291
|
+
description: z.ZodOptional<z.ZodString>;
|
|
292
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
293
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
}, z.core.$loose>>;
|
|
295
|
+
}, z.core.$loose>;
|
|
296
|
+
type ListResourcesResult = z.infer<typeof ListResourcesResultSchema>;
|
|
257
297
|
declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
258
298
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
259
299
|
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -267,10 +307,14 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
267
307
|
type: z.ZodLiteral<"resource">;
|
|
268
308
|
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
269
309
|
uri: z.ZodString;
|
|
310
|
+
name: z.ZodOptional<z.ZodString>;
|
|
311
|
+
title: z.ZodOptional<z.ZodString>;
|
|
270
312
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
271
313
|
text: z.ZodString;
|
|
272
314
|
}, z.core.$loose>, z.ZodObject<{
|
|
273
315
|
uri: z.ZodString;
|
|
316
|
+
name: z.ZodOptional<z.ZodString>;
|
|
317
|
+
title: z.ZodOptional<z.ZodString>;
|
|
274
318
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
275
319
|
blob: z.ZodBase64;
|
|
276
320
|
}, z.core.$loose>]>;
|
|
@@ -281,6 +325,95 @@ declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
281
325
|
toolResult: z.ZodUnknown;
|
|
282
326
|
}, z.core.$loose>]>;
|
|
283
327
|
type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
|
328
|
+
declare const ListResourceTemplatesResultSchema: z.ZodObject<{
|
|
329
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
330
|
+
resourceTemplates: z.ZodArray<z.ZodObject<{
|
|
331
|
+
uriTemplate: z.ZodString;
|
|
332
|
+
name: z.ZodString;
|
|
333
|
+
title: z.ZodOptional<z.ZodString>;
|
|
334
|
+
description: z.ZodOptional<z.ZodString>;
|
|
335
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
336
|
+
}, z.core.$loose>>;
|
|
337
|
+
}, z.core.$loose>;
|
|
338
|
+
type ListResourceTemplatesResult = z.infer<typeof ListResourceTemplatesResultSchema>;
|
|
339
|
+
declare const ReadResourceResultSchema: z.ZodObject<{
|
|
340
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
341
|
+
contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
342
|
+
uri: z.ZodString;
|
|
343
|
+
name: z.ZodOptional<z.ZodString>;
|
|
344
|
+
title: z.ZodOptional<z.ZodString>;
|
|
345
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
346
|
+
text: z.ZodString;
|
|
347
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
348
|
+
uri: z.ZodString;
|
|
349
|
+
name: z.ZodOptional<z.ZodString>;
|
|
350
|
+
title: z.ZodOptional<z.ZodString>;
|
|
351
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
352
|
+
blob: z.ZodBase64;
|
|
353
|
+
}, z.core.$loose>]>>;
|
|
354
|
+
}, z.core.$loose>;
|
|
355
|
+
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
356
|
+
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
357
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
358
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
359
|
+
prompts: z.ZodArray<z.ZodObject<{
|
|
360
|
+
name: z.ZodString;
|
|
361
|
+
title: z.ZodOptional<z.ZodString>;
|
|
362
|
+
description: z.ZodOptional<z.ZodString>;
|
|
363
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
364
|
+
name: z.ZodString;
|
|
365
|
+
description: z.ZodOptional<z.ZodString>;
|
|
366
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
367
|
+
}, z.core.$loose>>>;
|
|
368
|
+
}, z.core.$loose>>;
|
|
369
|
+
}, z.core.$loose>;
|
|
370
|
+
type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
|
|
371
|
+
declare const GetPromptResultSchema: z.ZodObject<{
|
|
372
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
373
|
+
description: z.ZodOptional<z.ZodString>;
|
|
374
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
375
|
+
role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
|
|
376
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
377
|
+
type: z.ZodLiteral<"text">;
|
|
378
|
+
text: z.ZodString;
|
|
379
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
380
|
+
type: z.ZodLiteral<"image">;
|
|
381
|
+
data: z.ZodBase64;
|
|
382
|
+
mimeType: z.ZodString;
|
|
383
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
384
|
+
type: z.ZodLiteral<"resource">;
|
|
385
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
386
|
+
uri: z.ZodString;
|
|
387
|
+
name: z.ZodOptional<z.ZodString>;
|
|
388
|
+
title: z.ZodOptional<z.ZodString>;
|
|
389
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
390
|
+
text: z.ZodString;
|
|
391
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
392
|
+
uri: z.ZodString;
|
|
393
|
+
name: z.ZodOptional<z.ZodString>;
|
|
394
|
+
title: z.ZodOptional<z.ZodString>;
|
|
395
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
396
|
+
blob: z.ZodBase64;
|
|
397
|
+
}, z.core.$loose>]>;
|
|
398
|
+
}, z.core.$loose>]>;
|
|
399
|
+
}, z.core.$loose>>;
|
|
400
|
+
}, z.core.$loose>;
|
|
401
|
+
type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
|
|
402
|
+
declare const ElicitationRequestSchema: z.ZodObject<{
|
|
403
|
+
method: z.ZodLiteral<"elicitation/create">;
|
|
404
|
+
params: z.ZodObject<{
|
|
405
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
406
|
+
message: z.ZodString;
|
|
407
|
+
requestedSchema: z.ZodUnknown;
|
|
408
|
+
}, z.core.$loose>;
|
|
409
|
+
}, z.core.$strip>;
|
|
410
|
+
type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
|
|
411
|
+
declare const ElicitResultSchema: z.ZodObject<{
|
|
412
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
413
|
+
action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
|
|
414
|
+
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
415
|
+
}, z.core.$loose>;
|
|
416
|
+
type ElicitResult = z.infer<typeof ElicitResultSchema>;
|
|
284
417
|
|
|
285
418
|
interface MCPClientConfig {
|
|
286
419
|
/** Transport configuration for connecting to the MCP server */
|
|
@@ -289,13 +422,42 @@ interface MCPClientConfig {
|
|
|
289
422
|
onUncaughtError?: (error: unknown) => void;
|
|
290
423
|
/** Optional client name, defaults to 'ai-sdk-mcp-client' */
|
|
291
424
|
name?: string;
|
|
425
|
+
/** Optional client version, defaults to '1.0.0' */
|
|
426
|
+
version?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Optional client capabilities to advertise during initialization
|
|
429
|
+
*
|
|
430
|
+
* NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server
|
|
431
|
+
*/
|
|
432
|
+
capabilities?: ClientCapabilities;
|
|
292
433
|
}
|
|
293
434
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
294
435
|
interface MCPClient {
|
|
295
436
|
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
|
|
296
437
|
schemas?: TOOL_SCHEMAS;
|
|
297
438
|
}): Promise<McpToolSet<TOOL_SCHEMAS>>;
|
|
439
|
+
listResources(options?: {
|
|
440
|
+
params?: PaginatedRequest['params'];
|
|
441
|
+
options?: RequestOptions;
|
|
442
|
+
}): Promise<ListResourcesResult>;
|
|
443
|
+
readResource(args: {
|
|
444
|
+
uri: string;
|
|
445
|
+
options?: RequestOptions;
|
|
446
|
+
}): Promise<ReadResourceResult>;
|
|
447
|
+
listResourceTemplates(options?: {
|
|
448
|
+
options?: RequestOptions;
|
|
449
|
+
}): Promise<ListResourceTemplatesResult>;
|
|
450
|
+
listPrompts(options?: {
|
|
451
|
+
params?: PaginatedRequest['params'];
|
|
452
|
+
options?: RequestOptions;
|
|
453
|
+
}): Promise<ListPromptsResult>;
|
|
454
|
+
getPrompt(args: {
|
|
455
|
+
name: string;
|
|
456
|
+
arguments?: Record<string, unknown>;
|
|
457
|
+
options?: RequestOptions;
|
|
458
|
+
}): Promise<GetPromptResult>;
|
|
459
|
+
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
298
460
|
close: () => Promise<void>;
|
|
299
461
|
}
|
|
300
462
|
|
|
301
|
-
export { type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, type MCPClient as experimental_MCPClient, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };
|
|
463
|
+
export { type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };
|