|
1 | 1 | import { z } from "zod";
|
2 | 2 |
|
3 |
| -export const PROTOCOL_VERSION = "2024-11-05"; |
| 3 | +export const LATEST_PROTOCOL_VERSION = "2024-11-05"; |
| 4 | +export const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2024-10-07"]; |
4 | 5 |
|
5 | 6 | /* JSON-RPC types */
|
6 | 7 | export const JSONRPC_VERSION = "2.0";
|
@@ -196,7 +197,7 @@ export const InitializeRequestSchema = RequestSchema.extend({
|
196 | 197 | /**
|
197 | 198 | * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
198 | 199 | */
|
199 |
| - protocolVersion: z.string().or(z.number().int()), |
| 200 | + protocolVersion: z.string(), |
200 | 201 | capabilities: ClientCapabilitiesSchema,
|
201 | 202 | clientInfo: ImplementationSchema,
|
202 | 203 | }),
|
@@ -268,7 +269,7 @@ export const InitializeResultSchema = ResultSchema.extend({
|
268 | 269 | /**
|
269 | 270 | * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
|
270 | 271 | */
|
271 |
| - protocolVersion: z.string().or(z.number().int()), |
| 272 | + protocolVersion: z.string(), |
272 | 273 | capabilities: ServerCapabilitiesSchema,
|
273 | 274 | serverInfo: ImplementationSchema,
|
274 | 275 | });
|
@@ -721,6 +722,13 @@ export const CallToolResultSchema = ResultSchema.extend({
|
721 | 722 | isError: z.boolean(),
|
722 | 723 | });
|
723 | 724 |
|
| 725 | +/** |
| 726 | + * CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07. |
| 727 | + */ |
| 728 | +export const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({ |
| 729 | + toolResult: z.unknown(), |
| 730 | +})); |
| 731 | + |
724 | 732 | /**
|
725 | 733 | * Used by the client to invoke a tool provided by the server.
|
726 | 734 | */
|
@@ -1053,6 +1061,7 @@ export const ServerResultSchema = z.union([
|
1053 | 1061 | ListResourceTemplatesResultSchema,
|
1054 | 1062 | ReadResourceResultSchema,
|
1055 | 1063 | CallToolResultSchema,
|
| 1064 | + CompatibilityCallToolResultSchema, |
1056 | 1065 | ListToolsResultSchema,
|
1057 | 1066 | ]);
|
1058 | 1067 |
|
@@ -1147,6 +1156,7 @@ export type Tool = z.infer<typeof ToolSchema>;
|
1147 | 1156 | export type ListToolsRequest = z.infer<typeof ListToolsRequestSchema>;
|
1148 | 1157 | export type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
|
1149 | 1158 | export type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
| 1159 | +export type CompatibilityCallToolResult = z.infer<typeof CompatibilityCallToolResultSchema>; |
1150 | 1160 | export type CallToolRequest = z.infer<typeof CallToolRequestSchema>;
|
1151 | 1161 | export type ToolListChangedNotification = z.infer<
|
1152 | 1162 | typeof ToolListChangedNotificationSchema
|
|
0 commit comments