@ai-sdk/mcp 1.0.53 → 1.0.55
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 +16 -0
- package/dist/index.d.mts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -0
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +29 -0
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +29 -0
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +3 -0
- package/src/tool/mcp-client.ts +37 -0
- package/src/tool/mock-mcp-transport.ts +27 -0
- package/src/tool/types.ts +47 -0
package/dist/index.mjs
CHANGED
|
@@ -78,6 +78,7 @@ var ElicitationCapabilitySchema = z.object({
|
|
|
78
78
|
var ServerCapabilitiesSchema = z.looseObject({
|
|
79
79
|
experimental: z.optional(z.object({}).loose()),
|
|
80
80
|
logging: z.optional(z.object({}).loose()),
|
|
81
|
+
completions: z.optional(z.object({}).loose()),
|
|
81
82
|
prompts: z.optional(
|
|
82
83
|
z.looseObject({
|
|
83
84
|
listChanged: z.optional(z.boolean())
|
|
@@ -222,6 +223,34 @@ var ReadResourceResultSchema = ResultSchema.extend({
|
|
|
222
223
|
z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
223
224
|
)
|
|
224
225
|
});
|
|
226
|
+
var PromptReferenceSchema = z.object({
|
|
227
|
+
type: z.literal("ref/prompt"),
|
|
228
|
+
name: z.string()
|
|
229
|
+
}).loose();
|
|
230
|
+
var ResourceReferenceSchema = z.object({
|
|
231
|
+
type: z.literal("ref/resource"),
|
|
232
|
+
uri: z.string()
|
|
233
|
+
}).loose();
|
|
234
|
+
var CompletionArgumentSchema = z.object({
|
|
235
|
+
name: z.string(),
|
|
236
|
+
value: z.string()
|
|
237
|
+
}).loose();
|
|
238
|
+
var CompleteRequestParamsSchema = BaseParamsSchema.extend({
|
|
239
|
+
ref: z.union([PromptReferenceSchema, ResourceReferenceSchema]),
|
|
240
|
+
argument: CompletionArgumentSchema,
|
|
241
|
+
context: z.optional(
|
|
242
|
+
z.object({
|
|
243
|
+
arguments: z.record(z.string(), z.string())
|
|
244
|
+
}).loose()
|
|
245
|
+
)
|
|
246
|
+
});
|
|
247
|
+
var CompleteResultSchema = ResultSchema.extend({
|
|
248
|
+
completion: z.object({
|
|
249
|
+
values: z.array(z.string()).max(100),
|
|
250
|
+
total: z.optional(z.number().int()),
|
|
251
|
+
hasMore: z.optional(z.boolean())
|
|
252
|
+
}).loose()
|
|
253
|
+
});
|
|
225
254
|
var PromptArgumentSchema = z.object({
|
|
226
255
|
name: z.string(),
|
|
227
256
|
description: z.optional(z.string()),
|
|
@@ -1989,6 +2018,13 @@ var DefaultMCPClient = class {
|
|
|
1989
2018
|
switch (method) {
|
|
1990
2019
|
case "initialize":
|
|
1991
2020
|
break;
|
|
2021
|
+
case "completion/complete":
|
|
2022
|
+
if (!this.serverCapabilities.completions) {
|
|
2023
|
+
throw new MCPClientError({
|
|
2024
|
+
message: `Server does not support completions`
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
break;
|
|
1992
2028
|
case "tools/list":
|
|
1993
2029
|
case "tools/call":
|
|
1994
2030
|
if (!this.serverCapabilities.tools) {
|
|
@@ -2171,6 +2207,16 @@ var DefaultMCPClient = class {
|
|
|
2171
2207
|
throw error;
|
|
2172
2208
|
}
|
|
2173
2209
|
}
|
|
2210
|
+
async completeInternal({
|
|
2211
|
+
options,
|
|
2212
|
+
...params
|
|
2213
|
+
}) {
|
|
2214
|
+
return this.request({
|
|
2215
|
+
request: { method: "completion/complete", params },
|
|
2216
|
+
resultSchema: CompleteResultSchema,
|
|
2217
|
+
options
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2174
2220
|
async notification(notification) {
|
|
2175
2221
|
const jsonrpcNotification = {
|
|
2176
2222
|
...notification,
|
|
@@ -2318,6 +2364,9 @@ var DefaultMCPClient = class {
|
|
|
2318
2364
|
}) {
|
|
2319
2365
|
return this.getPromptInternal({ name: name3, args, options });
|
|
2320
2366
|
}
|
|
2367
|
+
complete(args) {
|
|
2368
|
+
return this.completeInternal(args);
|
|
2369
|
+
}
|
|
2321
2370
|
onElicitationRequest(schema, handler) {
|
|
2322
2371
|
if (schema !== ElicitationRequestSchema) {
|
|
2323
2372
|
throw new MCPClientError({
|