@ai-sdk/mcp 1.0.0-beta.4 → 1.0.0-beta.40
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 +265 -0
- package/dist/index.d.mts +95 -5
- package/dist/index.d.ts +95 -5
- package/dist/index.js +200 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +197 -13
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +53 -2
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +53 -2
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,270 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.40
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 90ede04: feat(mcp): make MCPClient stable
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.39
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [366f50b]
|
|
14
|
+
- @ai-sdk/provider@3.0.0-beta.27
|
|
15
|
+
- @ai-sdk/provider-utils@4.0.0-beta.53
|
|
16
|
+
|
|
17
|
+
## 1.0.0-beta.38
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [763d04a]
|
|
22
|
+
- @ai-sdk/provider-utils@4.0.0-beta.52
|
|
23
|
+
|
|
24
|
+
## 1.0.0-beta.37
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [c1efac4]
|
|
29
|
+
- @ai-sdk/provider-utils@4.0.0-beta.51
|
|
30
|
+
|
|
31
|
+
## 1.0.0-beta.36
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [32223c8]
|
|
36
|
+
- @ai-sdk/provider-utils@4.0.0-beta.50
|
|
37
|
+
|
|
38
|
+
## 1.0.0-beta.35
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [83e5744]
|
|
43
|
+
- @ai-sdk/provider-utils@4.0.0-beta.49
|
|
44
|
+
|
|
45
|
+
## 1.0.0-beta.34
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [960ec8f]
|
|
50
|
+
- @ai-sdk/provider-utils@4.0.0-beta.48
|
|
51
|
+
|
|
52
|
+
## 1.0.0-beta.33
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [e9e157f]
|
|
57
|
+
- @ai-sdk/provider-utils@4.0.0-beta.47
|
|
58
|
+
|
|
59
|
+
## 1.0.0-beta.32
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies [81e29ab]
|
|
64
|
+
- @ai-sdk/provider-utils@4.0.0-beta.46
|
|
65
|
+
|
|
66
|
+
## 1.0.0-beta.31
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Updated dependencies [3bd2689]
|
|
71
|
+
- @ai-sdk/provider@3.0.0-beta.26
|
|
72
|
+
- @ai-sdk/provider-utils@4.0.0-beta.45
|
|
73
|
+
|
|
74
|
+
## 1.0.0-beta.30
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- 6f1577e: fix(mcp): pass json header for refreshAuth
|
|
79
|
+
|
|
80
|
+
## 1.0.0-beta.29
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [53f3368]
|
|
85
|
+
- @ai-sdk/provider@3.0.0-beta.25
|
|
86
|
+
- @ai-sdk/provider-utils@4.0.0-beta.44
|
|
87
|
+
|
|
88
|
+
## 1.0.0-beta.28
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- Updated dependencies [dce03c4]
|
|
93
|
+
- @ai-sdk/provider-utils@4.0.0-beta.43
|
|
94
|
+
- @ai-sdk/provider@3.0.0-beta.24
|
|
95
|
+
|
|
96
|
+
## 1.0.0-beta.27
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- 3ed5519: chore: rename ToolCallOptions to ToolExecutionOptions
|
|
101
|
+
- Updated dependencies [3ed5519]
|
|
102
|
+
- @ai-sdk/provider-utils@4.0.0-beta.42
|
|
103
|
+
|
|
104
|
+
## 1.0.0-beta.26
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- 17c04d4: feat(mcp): expose `_meta` field from MCP tool definitions
|
|
109
|
+
|
|
110
|
+
## 1.0.0-beta.25
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies [1bd7d32]
|
|
115
|
+
- @ai-sdk/provider-utils@4.0.0-beta.41
|
|
116
|
+
- @ai-sdk/provider@3.0.0-beta.23
|
|
117
|
+
|
|
118
|
+
## 1.0.0-beta.24
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- Updated dependencies [544d4e8]
|
|
123
|
+
- @ai-sdk/provider-utils@4.0.0-beta.40
|
|
124
|
+
- @ai-sdk/provider@3.0.0-beta.22
|
|
125
|
+
|
|
126
|
+
## 1.0.0-beta.23
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [954c356]
|
|
131
|
+
- @ai-sdk/provider-utils@4.0.0-beta.39
|
|
132
|
+
- @ai-sdk/provider@3.0.0-beta.21
|
|
133
|
+
|
|
134
|
+
## 1.0.0-beta.22
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- Updated dependencies [03849b0]
|
|
139
|
+
- @ai-sdk/provider-utils@4.0.0-beta.38
|
|
140
|
+
|
|
141
|
+
## 1.0.0-beta.21
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [457318b]
|
|
146
|
+
- @ai-sdk/provider@3.0.0-beta.20
|
|
147
|
+
- @ai-sdk/provider-utils@4.0.0-beta.37
|
|
148
|
+
|
|
149
|
+
## 1.0.0-beta.20
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [8d9e8ad]
|
|
154
|
+
- @ai-sdk/provider@3.0.0-beta.19
|
|
155
|
+
- @ai-sdk/provider-utils@4.0.0-beta.36
|
|
156
|
+
|
|
157
|
+
## 1.0.0-beta.19
|
|
158
|
+
|
|
159
|
+
### Patch Changes
|
|
160
|
+
|
|
161
|
+
- Updated dependencies [10d819b]
|
|
162
|
+
- @ai-sdk/provider@3.0.0-beta.18
|
|
163
|
+
- @ai-sdk/provider-utils@4.0.0-beta.35
|
|
164
|
+
|
|
165
|
+
## 1.0.0-beta.18
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- ba2ca2d: feat(mcp): add the possibility to define client version in mcp client definition
|
|
170
|
+
|
|
171
|
+
## 1.0.0-beta.17
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- f702df2: feat(mcp): add client elicitation support
|
|
176
|
+
|
|
177
|
+
## 1.0.0-beta.16
|
|
178
|
+
|
|
179
|
+
### Patch Changes
|
|
180
|
+
|
|
181
|
+
- Updated dependencies [db913bd]
|
|
182
|
+
- @ai-sdk/provider@3.0.0-beta.17
|
|
183
|
+
- @ai-sdk/provider-utils@4.0.0-beta.34
|
|
184
|
+
|
|
185
|
+
## 1.0.0-beta.15
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies [b681d7d]
|
|
190
|
+
- @ai-sdk/provider@3.0.0-beta.16
|
|
191
|
+
- @ai-sdk/provider-utils@4.0.0-beta.33
|
|
192
|
+
|
|
193
|
+
## 1.0.0-beta.14
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- Updated dependencies [32d8dbb]
|
|
198
|
+
- @ai-sdk/provider-utils@4.0.0-beta.32
|
|
199
|
+
|
|
200
|
+
## 1.0.0-beta.13
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- 1cff766: feat(packages/mcp): add support for MCP server prompts exposed
|
|
205
|
+
|
|
206
|
+
## 1.0.0-beta.12
|
|
207
|
+
|
|
208
|
+
### Patch Changes
|
|
209
|
+
|
|
210
|
+
- Updated dependencies [bb36798]
|
|
211
|
+
- @ai-sdk/provider@3.0.0-beta.15
|
|
212
|
+
- @ai-sdk/provider-utils@4.0.0-beta.31
|
|
213
|
+
|
|
214
|
+
## 1.0.0-beta.11
|
|
215
|
+
|
|
216
|
+
### Patch Changes
|
|
217
|
+
|
|
218
|
+
- Updated dependencies [4f16c37]
|
|
219
|
+
- @ai-sdk/provider-utils@4.0.0-beta.30
|
|
220
|
+
|
|
221
|
+
## 1.0.0-beta.10
|
|
222
|
+
|
|
223
|
+
### Patch Changes
|
|
224
|
+
|
|
225
|
+
- Updated dependencies [af3780b]
|
|
226
|
+
- @ai-sdk/provider@3.0.0-beta.14
|
|
227
|
+
- @ai-sdk/provider-utils@4.0.0-beta.29
|
|
228
|
+
|
|
229
|
+
## 1.0.0-beta.9
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- Updated dependencies [016b111]
|
|
234
|
+
- @ai-sdk/provider-utils@4.0.0-beta.28
|
|
235
|
+
|
|
236
|
+
## 1.0.0-beta.8
|
|
237
|
+
|
|
238
|
+
### Patch Changes
|
|
239
|
+
|
|
240
|
+
- Updated dependencies [37c58a0]
|
|
241
|
+
- @ai-sdk/provider@3.0.0-beta.13
|
|
242
|
+
- @ai-sdk/provider-utils@4.0.0-beta.27
|
|
243
|
+
|
|
244
|
+
## 1.0.0-beta.7
|
|
245
|
+
|
|
246
|
+
### Patch Changes
|
|
247
|
+
|
|
248
|
+
- Updated dependencies [d1bdadb]
|
|
249
|
+
- @ai-sdk/provider@3.0.0-beta.12
|
|
250
|
+
- @ai-sdk/provider-utils@4.0.0-beta.26
|
|
251
|
+
|
|
252
|
+
## 1.0.0-beta.6
|
|
253
|
+
|
|
254
|
+
### Patch Changes
|
|
255
|
+
|
|
256
|
+
- Updated dependencies [4c44a5b]
|
|
257
|
+
- @ai-sdk/provider@3.0.0-beta.11
|
|
258
|
+
- @ai-sdk/provider-utils@4.0.0-beta.25
|
|
259
|
+
|
|
260
|
+
## 1.0.0-beta.5
|
|
261
|
+
|
|
262
|
+
### Patch Changes
|
|
263
|
+
|
|
264
|
+
- Updated dependencies [0c3b58b]
|
|
265
|
+
- @ai-sdk/provider@3.0.0-beta.10
|
|
266
|
+
- @ai-sdk/provider-utils@4.0.0-beta.24
|
|
267
|
+
|
|
3
268
|
## 1.0.0-beta.4
|
|
4
269
|
|
|
5
270
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -242,18 +242,23 @@ type MCPTransportConfig = {
|
|
|
242
242
|
authProvider?: OAuthClientProvider;
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
+
/** MCP tool metadata - keys should follow MCP _meta key format specification */
|
|
246
|
+
declare const ToolMetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
247
|
+
type ToolMeta = z.infer<typeof ToolMetaSchema>;
|
|
245
248
|
type ToolSchemas = Record<string, {
|
|
246
249
|
inputSchema: FlexibleSchema<JSONObject | unknown>;
|
|
247
250
|
}> | 'automatic' | undefined;
|
|
251
|
+
/** Base MCP tool type with execute and _meta */
|
|
252
|
+
type McpToolBase<INPUT = unknown> = Tool<INPUT, CallToolResult> & Required<Pick<Tool<INPUT, CallToolResult>, 'execute'>> & {
|
|
253
|
+
_meta?: ToolMeta;
|
|
254
|
+
};
|
|
248
255
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
|
249
256
|
inputSchema: FlexibleSchema<any>;
|
|
250
257
|
}> ? {
|
|
251
258
|
[K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
|
|
252
259
|
inputSchema: FlexibleSchema<infer INPUT>;
|
|
253
|
-
} ?
|
|
254
|
-
} :
|
|
255
|
-
inputSchema: FlexibleSchema<unknown>;
|
|
256
|
-
}>>;
|
|
260
|
+
} ? McpToolBase<INPUT> : never;
|
|
261
|
+
} : Record<string, McpToolBase<unknown>>;
|
|
257
262
|
declare const BaseParamsSchema: z.ZodObject<{
|
|
258
263
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
259
264
|
}, z.core.$loose>;
|
|
@@ -270,6 +275,12 @@ type RequestOptions = {
|
|
|
270
275
|
timeout?: number;
|
|
271
276
|
maxTotalTimeout?: number;
|
|
272
277
|
};
|
|
278
|
+
declare const ClientCapabilitiesSchema: z.ZodObject<{
|
|
279
|
+
elicitation: z.ZodOptional<z.ZodObject<{
|
|
280
|
+
applyDefaults: z.ZodOptional<z.ZodBoolean>;
|
|
281
|
+
}, z.core.$loose>>;
|
|
282
|
+
}, z.core.$loose>;
|
|
283
|
+
type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
|
|
273
284
|
type PaginatedRequest = Request & {
|
|
274
285
|
params?: BaseParams & {
|
|
275
286
|
cursor?: string;
|
|
@@ -347,6 +358,67 @@ declare const ReadResourceResultSchema: z.ZodObject<{
|
|
|
347
358
|
}, z.core.$loose>]>>;
|
|
348
359
|
}, z.core.$loose>;
|
|
349
360
|
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
361
|
+
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
362
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
363
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
364
|
+
prompts: z.ZodArray<z.ZodObject<{
|
|
365
|
+
name: z.ZodString;
|
|
366
|
+
title: z.ZodOptional<z.ZodString>;
|
|
367
|
+
description: z.ZodOptional<z.ZodString>;
|
|
368
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
369
|
+
name: z.ZodString;
|
|
370
|
+
description: z.ZodOptional<z.ZodString>;
|
|
371
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
372
|
+
}, z.core.$loose>>>;
|
|
373
|
+
}, z.core.$loose>>;
|
|
374
|
+
}, z.core.$loose>;
|
|
375
|
+
type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
|
|
376
|
+
declare const GetPromptResultSchema: z.ZodObject<{
|
|
377
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
378
|
+
description: z.ZodOptional<z.ZodString>;
|
|
379
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
380
|
+
role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
|
|
381
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
382
|
+
type: z.ZodLiteral<"text">;
|
|
383
|
+
text: z.ZodString;
|
|
384
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
385
|
+
type: z.ZodLiteral<"image">;
|
|
386
|
+
data: z.ZodBase64;
|
|
387
|
+
mimeType: z.ZodString;
|
|
388
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
389
|
+
type: z.ZodLiteral<"resource">;
|
|
390
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
391
|
+
uri: z.ZodString;
|
|
392
|
+
name: z.ZodOptional<z.ZodString>;
|
|
393
|
+
title: z.ZodOptional<z.ZodString>;
|
|
394
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
395
|
+
text: z.ZodString;
|
|
396
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
397
|
+
uri: z.ZodString;
|
|
398
|
+
name: z.ZodOptional<z.ZodString>;
|
|
399
|
+
title: z.ZodOptional<z.ZodString>;
|
|
400
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
401
|
+
blob: z.ZodBase64;
|
|
402
|
+
}, z.core.$loose>]>;
|
|
403
|
+
}, z.core.$loose>]>;
|
|
404
|
+
}, z.core.$loose>>;
|
|
405
|
+
}, z.core.$loose>;
|
|
406
|
+
type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
|
|
407
|
+
declare const ElicitationRequestSchema: z.ZodObject<{
|
|
408
|
+
method: z.ZodLiteral<"elicitation/create">;
|
|
409
|
+
params: z.ZodObject<{
|
|
410
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
411
|
+
message: z.ZodString;
|
|
412
|
+
requestedSchema: z.ZodUnknown;
|
|
413
|
+
}, z.core.$loose>;
|
|
414
|
+
}, z.core.$strip>;
|
|
415
|
+
type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
|
|
416
|
+
declare const ElicitResultSchema: z.ZodObject<{
|
|
417
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
418
|
+
action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
|
|
419
|
+
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
420
|
+
}, z.core.$loose>;
|
|
421
|
+
type ElicitResult = z.infer<typeof ElicitResultSchema>;
|
|
350
422
|
|
|
351
423
|
interface MCPClientConfig {
|
|
352
424
|
/** Transport configuration for connecting to the MCP server */
|
|
@@ -355,6 +427,14 @@ interface MCPClientConfig {
|
|
|
355
427
|
onUncaughtError?: (error: unknown) => void;
|
|
356
428
|
/** Optional client name, defaults to 'ai-sdk-mcp-client' */
|
|
357
429
|
name?: string;
|
|
430
|
+
/** Optional client version, defaults to '1.0.0' */
|
|
431
|
+
version?: string;
|
|
432
|
+
/**
|
|
433
|
+
* Optional client capabilities to advertise during initialization
|
|
434
|
+
*
|
|
435
|
+
* NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server
|
|
436
|
+
*/
|
|
437
|
+
capabilities?: ClientCapabilities;
|
|
358
438
|
}
|
|
359
439
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
360
440
|
interface MCPClient {
|
|
@@ -372,7 +452,17 @@ interface MCPClient {
|
|
|
372
452
|
listResourceTemplates(options?: {
|
|
373
453
|
options?: RequestOptions;
|
|
374
454
|
}): Promise<ListResourceTemplatesResult>;
|
|
455
|
+
experimental_listPrompts(options?: {
|
|
456
|
+
params?: PaginatedRequest['params'];
|
|
457
|
+
options?: RequestOptions;
|
|
458
|
+
}): Promise<ListPromptsResult>;
|
|
459
|
+
experimental_getPrompt(args: {
|
|
460
|
+
name: string;
|
|
461
|
+
arguments?: Record<string, unknown>;
|
|
462
|
+
options?: RequestOptions;
|
|
463
|
+
}): Promise<GetPromptResult>;
|
|
464
|
+
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
375
465
|
close: () => Promise<void>;
|
|
376
466
|
}
|
|
377
467
|
|
|
378
|
-
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 };
|
|
468
|
+
export { type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -242,18 +242,23 @@ type MCPTransportConfig = {
|
|
|
242
242
|
authProvider?: OAuthClientProvider;
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
+
/** MCP tool metadata - keys should follow MCP _meta key format specification */
|
|
246
|
+
declare const ToolMetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
247
|
+
type ToolMeta = z.infer<typeof ToolMetaSchema>;
|
|
245
248
|
type ToolSchemas = Record<string, {
|
|
246
249
|
inputSchema: FlexibleSchema<JSONObject | unknown>;
|
|
247
250
|
}> | 'automatic' | undefined;
|
|
251
|
+
/** Base MCP tool type with execute and _meta */
|
|
252
|
+
type McpToolBase<INPUT = unknown> = Tool<INPUT, CallToolResult> & Required<Pick<Tool<INPUT, CallToolResult>, 'execute'>> & {
|
|
253
|
+
_meta?: ToolMeta;
|
|
254
|
+
};
|
|
248
255
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
|
249
256
|
inputSchema: FlexibleSchema<any>;
|
|
250
257
|
}> ? {
|
|
251
258
|
[K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
|
|
252
259
|
inputSchema: FlexibleSchema<infer INPUT>;
|
|
253
|
-
} ?
|
|
254
|
-
} :
|
|
255
|
-
inputSchema: FlexibleSchema<unknown>;
|
|
256
|
-
}>>;
|
|
260
|
+
} ? McpToolBase<INPUT> : never;
|
|
261
|
+
} : Record<string, McpToolBase<unknown>>;
|
|
257
262
|
declare const BaseParamsSchema: z.ZodObject<{
|
|
258
263
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
259
264
|
}, z.core.$loose>;
|
|
@@ -270,6 +275,12 @@ type RequestOptions = {
|
|
|
270
275
|
timeout?: number;
|
|
271
276
|
maxTotalTimeout?: number;
|
|
272
277
|
};
|
|
278
|
+
declare const ClientCapabilitiesSchema: z.ZodObject<{
|
|
279
|
+
elicitation: z.ZodOptional<z.ZodObject<{
|
|
280
|
+
applyDefaults: z.ZodOptional<z.ZodBoolean>;
|
|
281
|
+
}, z.core.$loose>>;
|
|
282
|
+
}, z.core.$loose>;
|
|
283
|
+
type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
|
|
273
284
|
type PaginatedRequest = Request & {
|
|
274
285
|
params?: BaseParams & {
|
|
275
286
|
cursor?: string;
|
|
@@ -347,6 +358,67 @@ declare const ReadResourceResultSchema: z.ZodObject<{
|
|
|
347
358
|
}, z.core.$loose>]>>;
|
|
348
359
|
}, z.core.$loose>;
|
|
349
360
|
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
361
|
+
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
362
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
363
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
364
|
+
prompts: z.ZodArray<z.ZodObject<{
|
|
365
|
+
name: z.ZodString;
|
|
366
|
+
title: z.ZodOptional<z.ZodString>;
|
|
367
|
+
description: z.ZodOptional<z.ZodString>;
|
|
368
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
369
|
+
name: z.ZodString;
|
|
370
|
+
description: z.ZodOptional<z.ZodString>;
|
|
371
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
372
|
+
}, z.core.$loose>>>;
|
|
373
|
+
}, z.core.$loose>>;
|
|
374
|
+
}, z.core.$loose>;
|
|
375
|
+
type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
|
|
376
|
+
declare const GetPromptResultSchema: z.ZodObject<{
|
|
377
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
378
|
+
description: z.ZodOptional<z.ZodString>;
|
|
379
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
380
|
+
role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
|
|
381
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
382
|
+
type: z.ZodLiteral<"text">;
|
|
383
|
+
text: z.ZodString;
|
|
384
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
385
|
+
type: z.ZodLiteral<"image">;
|
|
386
|
+
data: z.ZodBase64;
|
|
387
|
+
mimeType: z.ZodString;
|
|
388
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
389
|
+
type: z.ZodLiteral<"resource">;
|
|
390
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
391
|
+
uri: z.ZodString;
|
|
392
|
+
name: z.ZodOptional<z.ZodString>;
|
|
393
|
+
title: z.ZodOptional<z.ZodString>;
|
|
394
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
395
|
+
text: z.ZodString;
|
|
396
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
397
|
+
uri: z.ZodString;
|
|
398
|
+
name: z.ZodOptional<z.ZodString>;
|
|
399
|
+
title: z.ZodOptional<z.ZodString>;
|
|
400
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
401
|
+
blob: z.ZodBase64;
|
|
402
|
+
}, z.core.$loose>]>;
|
|
403
|
+
}, z.core.$loose>]>;
|
|
404
|
+
}, z.core.$loose>>;
|
|
405
|
+
}, z.core.$loose>;
|
|
406
|
+
type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
|
|
407
|
+
declare const ElicitationRequestSchema: z.ZodObject<{
|
|
408
|
+
method: z.ZodLiteral<"elicitation/create">;
|
|
409
|
+
params: z.ZodObject<{
|
|
410
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
411
|
+
message: z.ZodString;
|
|
412
|
+
requestedSchema: z.ZodUnknown;
|
|
413
|
+
}, z.core.$loose>;
|
|
414
|
+
}, z.core.$strip>;
|
|
415
|
+
type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
|
|
416
|
+
declare const ElicitResultSchema: z.ZodObject<{
|
|
417
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
418
|
+
action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
|
|
419
|
+
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
420
|
+
}, z.core.$loose>;
|
|
421
|
+
type ElicitResult = z.infer<typeof ElicitResultSchema>;
|
|
350
422
|
|
|
351
423
|
interface MCPClientConfig {
|
|
352
424
|
/** Transport configuration for connecting to the MCP server */
|
|
@@ -355,6 +427,14 @@ interface MCPClientConfig {
|
|
|
355
427
|
onUncaughtError?: (error: unknown) => void;
|
|
356
428
|
/** Optional client name, defaults to 'ai-sdk-mcp-client' */
|
|
357
429
|
name?: string;
|
|
430
|
+
/** Optional client version, defaults to '1.0.0' */
|
|
431
|
+
version?: string;
|
|
432
|
+
/**
|
|
433
|
+
* Optional client capabilities to advertise during initialization
|
|
434
|
+
*
|
|
435
|
+
* NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server
|
|
436
|
+
*/
|
|
437
|
+
capabilities?: ClientCapabilities;
|
|
358
438
|
}
|
|
359
439
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
360
440
|
interface MCPClient {
|
|
@@ -372,7 +452,17 @@ interface MCPClient {
|
|
|
372
452
|
listResourceTemplates(options?: {
|
|
373
453
|
options?: RequestOptions;
|
|
374
454
|
}): Promise<ListResourceTemplatesResult>;
|
|
455
|
+
experimental_listPrompts(options?: {
|
|
456
|
+
params?: PaginatedRequest['params'];
|
|
457
|
+
options?: RequestOptions;
|
|
458
|
+
}): Promise<ListPromptsResult>;
|
|
459
|
+
experimental_getPrompt(args: {
|
|
460
|
+
name: string;
|
|
461
|
+
arguments?: Record<string, unknown>;
|
|
462
|
+
options?: RequestOptions;
|
|
463
|
+
}): Promise<GetPromptResult>;
|
|
464
|
+
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
375
465
|
close: () => Promise<void>;
|
|
376
466
|
}
|
|
377
467
|
|
|
378
|
-
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 };
|
|
468
|
+
export { type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, 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 };
|