@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.55
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3d0bd52: feat(mcp): allow MCP client to use server completions
|
|
8
|
+
- Updated dependencies [b30e43a]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.33
|
|
10
|
+
|
|
11
|
+
## 1.0.54
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [f19334d]
|
|
16
|
+
- @ai-sdk/provider@3.0.12
|
|
17
|
+
- @ai-sdk/provider-utils@4.0.32
|
|
18
|
+
|
|
3
19
|
## 1.0.53
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -434,6 +434,33 @@ declare const ReadResourceResultSchema: z.ZodObject<{
|
|
|
434
434
|
}, z.core.$loose>]>>;
|
|
435
435
|
}, z.core.$loose>;
|
|
436
436
|
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
437
|
+
declare const CompleteRequestParamsSchema: z.ZodObject<{
|
|
438
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
439
|
+
ref: z.ZodUnion<readonly [z.ZodObject<{
|
|
440
|
+
type: z.ZodLiteral<"ref/prompt">;
|
|
441
|
+
name: z.ZodString;
|
|
442
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
443
|
+
type: z.ZodLiteral<"ref/resource">;
|
|
444
|
+
uri: z.ZodString;
|
|
445
|
+
}, z.core.$loose>]>;
|
|
446
|
+
argument: z.ZodObject<{
|
|
447
|
+
name: z.ZodString;
|
|
448
|
+
value: z.ZodString;
|
|
449
|
+
}, z.core.$loose>;
|
|
450
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
451
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
452
|
+
}, z.core.$loose>>;
|
|
453
|
+
}, z.core.$loose>;
|
|
454
|
+
type CompleteRequestParams = z.infer<typeof CompleteRequestParamsSchema>;
|
|
455
|
+
declare const CompleteResultSchema: z.ZodObject<{
|
|
456
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
457
|
+
completion: z.ZodObject<{
|
|
458
|
+
values: z.ZodArray<z.ZodString>;
|
|
459
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
460
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
461
|
+
}, z.core.$loose>;
|
|
462
|
+
}, z.core.$loose>;
|
|
463
|
+
type CompleteResult = z.infer<typeof CompleteResultSchema>;
|
|
437
464
|
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
438
465
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
439
466
|
nextCursor: z.ZodOptional<z.ZodString>;
|
|
@@ -576,8 +603,11 @@ interface MCPClient {
|
|
|
576
603
|
arguments?: Record<string, unknown>;
|
|
577
604
|
options?: RequestOptions;
|
|
578
605
|
}): Promise<GetPromptResult>;
|
|
606
|
+
complete(args: CompleteRequestParams & {
|
|
607
|
+
options?: RequestOptions;
|
|
608
|
+
}): Promise<CompleteResult>;
|
|
579
609
|
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
580
610
|
close: () => Promise<void>;
|
|
581
611
|
}
|
|
582
612
|
|
|
583
|
-
export { type Configuration, 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 OAuthAuthorizationServerInformation, 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 };
|
|
613
|
+
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, 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 OAuthAuthorizationServerInformation, 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
|
@@ -434,6 +434,33 @@ declare const ReadResourceResultSchema: z.ZodObject<{
|
|
|
434
434
|
}, z.core.$loose>]>>;
|
|
435
435
|
}, z.core.$loose>;
|
|
436
436
|
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
437
|
+
declare const CompleteRequestParamsSchema: z.ZodObject<{
|
|
438
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
439
|
+
ref: z.ZodUnion<readonly [z.ZodObject<{
|
|
440
|
+
type: z.ZodLiteral<"ref/prompt">;
|
|
441
|
+
name: z.ZodString;
|
|
442
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
443
|
+
type: z.ZodLiteral<"ref/resource">;
|
|
444
|
+
uri: z.ZodString;
|
|
445
|
+
}, z.core.$loose>]>;
|
|
446
|
+
argument: z.ZodObject<{
|
|
447
|
+
name: z.ZodString;
|
|
448
|
+
value: z.ZodString;
|
|
449
|
+
}, z.core.$loose>;
|
|
450
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
451
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
452
|
+
}, z.core.$loose>>;
|
|
453
|
+
}, z.core.$loose>;
|
|
454
|
+
type CompleteRequestParams = z.infer<typeof CompleteRequestParamsSchema>;
|
|
455
|
+
declare const CompleteResultSchema: z.ZodObject<{
|
|
456
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
457
|
+
completion: z.ZodObject<{
|
|
458
|
+
values: z.ZodArray<z.ZodString>;
|
|
459
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
460
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
461
|
+
}, z.core.$loose>;
|
|
462
|
+
}, z.core.$loose>;
|
|
463
|
+
type CompleteResult = z.infer<typeof CompleteResultSchema>;
|
|
437
464
|
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
438
465
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
439
466
|
nextCursor: z.ZodOptional<z.ZodString>;
|
|
@@ -576,8 +603,11 @@ interface MCPClient {
|
|
|
576
603
|
arguments?: Record<string, unknown>;
|
|
577
604
|
options?: RequestOptions;
|
|
578
605
|
}): Promise<GetPromptResult>;
|
|
606
|
+
complete(args: CompleteRequestParams & {
|
|
607
|
+
options?: RequestOptions;
|
|
608
|
+
}): Promise<CompleteResult>;
|
|
579
609
|
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
580
610
|
close: () => Promise<void>;
|
|
581
611
|
}
|
|
582
612
|
|
|
583
|
-
export { type Configuration, 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 OAuthAuthorizationServerInformation, 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 };
|
|
613
|
+
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, 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 OAuthAuthorizationServerInformation, 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.js
CHANGED
|
@@ -108,6 +108,7 @@ var ElicitationCapabilitySchema = import_v4.z.object({
|
|
|
108
108
|
var ServerCapabilitiesSchema = import_v4.z.looseObject({
|
|
109
109
|
experimental: import_v4.z.optional(import_v4.z.object({}).loose()),
|
|
110
110
|
logging: import_v4.z.optional(import_v4.z.object({}).loose()),
|
|
111
|
+
completions: import_v4.z.optional(import_v4.z.object({}).loose()),
|
|
111
112
|
prompts: import_v4.z.optional(
|
|
112
113
|
import_v4.z.looseObject({
|
|
113
114
|
listChanged: import_v4.z.optional(import_v4.z.boolean())
|
|
@@ -252,6 +253,34 @@ var ReadResourceResultSchema = ResultSchema.extend({
|
|
|
252
253
|
import_v4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
253
254
|
)
|
|
254
255
|
});
|
|
256
|
+
var PromptReferenceSchema = import_v4.z.object({
|
|
257
|
+
type: import_v4.z.literal("ref/prompt"),
|
|
258
|
+
name: import_v4.z.string()
|
|
259
|
+
}).loose();
|
|
260
|
+
var ResourceReferenceSchema = import_v4.z.object({
|
|
261
|
+
type: import_v4.z.literal("ref/resource"),
|
|
262
|
+
uri: import_v4.z.string()
|
|
263
|
+
}).loose();
|
|
264
|
+
var CompletionArgumentSchema = import_v4.z.object({
|
|
265
|
+
name: import_v4.z.string(),
|
|
266
|
+
value: import_v4.z.string()
|
|
267
|
+
}).loose();
|
|
268
|
+
var CompleteRequestParamsSchema = BaseParamsSchema.extend({
|
|
269
|
+
ref: import_v4.z.union([PromptReferenceSchema, ResourceReferenceSchema]),
|
|
270
|
+
argument: CompletionArgumentSchema,
|
|
271
|
+
context: import_v4.z.optional(
|
|
272
|
+
import_v4.z.object({
|
|
273
|
+
arguments: import_v4.z.record(import_v4.z.string(), import_v4.z.string())
|
|
274
|
+
}).loose()
|
|
275
|
+
)
|
|
276
|
+
});
|
|
277
|
+
var CompleteResultSchema = ResultSchema.extend({
|
|
278
|
+
completion: import_v4.z.object({
|
|
279
|
+
values: import_v4.z.array(import_v4.z.string()).max(100),
|
|
280
|
+
total: import_v4.z.optional(import_v4.z.number().int()),
|
|
281
|
+
hasMore: import_v4.z.optional(import_v4.z.boolean())
|
|
282
|
+
}).loose()
|
|
283
|
+
});
|
|
255
284
|
var PromptArgumentSchema = import_v4.z.object({
|
|
256
285
|
name: import_v4.z.string(),
|
|
257
286
|
description: import_v4.z.optional(import_v4.z.string()),
|
|
@@ -2015,6 +2044,13 @@ var DefaultMCPClient = class {
|
|
|
2015
2044
|
switch (method) {
|
|
2016
2045
|
case "initialize":
|
|
2017
2046
|
break;
|
|
2047
|
+
case "completion/complete":
|
|
2048
|
+
if (!this.serverCapabilities.completions) {
|
|
2049
|
+
throw new MCPClientError({
|
|
2050
|
+
message: `Server does not support completions`
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
break;
|
|
2018
2054
|
case "tools/list":
|
|
2019
2055
|
case "tools/call":
|
|
2020
2056
|
if (!this.serverCapabilities.tools) {
|
|
@@ -2197,6 +2233,16 @@ var DefaultMCPClient = class {
|
|
|
2197
2233
|
throw error;
|
|
2198
2234
|
}
|
|
2199
2235
|
}
|
|
2236
|
+
async completeInternal({
|
|
2237
|
+
options,
|
|
2238
|
+
...params
|
|
2239
|
+
}) {
|
|
2240
|
+
return this.request({
|
|
2241
|
+
request: { method: "completion/complete", params },
|
|
2242
|
+
resultSchema: CompleteResultSchema,
|
|
2243
|
+
options
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2200
2246
|
async notification(notification) {
|
|
2201
2247
|
const jsonrpcNotification = {
|
|
2202
2248
|
...notification,
|
|
@@ -2344,6 +2390,9 @@ var DefaultMCPClient = class {
|
|
|
2344
2390
|
}) {
|
|
2345
2391
|
return this.getPromptInternal({ name: name3, args, options });
|
|
2346
2392
|
}
|
|
2393
|
+
complete(args) {
|
|
2394
|
+
return this.completeInternal(args);
|
|
2395
|
+
}
|
|
2347
2396
|
onElicitationRequest(schema, handler) {
|
|
2348
2397
|
if (schema !== ElicitationRequestSchema) {
|
|
2349
2398
|
throw new MCPClientError({
|