Support old tools/call result structure, if explicitly opted in

This commit is contained in:
Justin Spahr-Summers 2024-11-07 13:09:20 +00:00
commit 1f3dbef66c
No known key found for this signature in database

View file

@ -722,6 +722,13 @@ export const CallToolResultSchema = ResultSchema.extend({
isError: z.boolean(),
});
/**
* CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
*/
export const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
toolResult: z.unknown(),
}));
/**
* Used by the client to invoke a tool provided by the server.
*/
@ -1054,6 +1061,7 @@ export const ServerResultSchema = z.union([
ListResourceTemplatesResultSchema,
ReadResourceResultSchema,
CallToolResultSchema,
CompatibilityCallToolResultSchema,
ListToolsResultSchema,
]);
@ -1148,6 +1156,7 @@ export type Tool = z.infer<typeof ToolSchema>;
export type ListToolsRequest = z.infer<typeof ListToolsRequestSchema>;
export type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
export type CallToolResult = z.infer<typeof CallToolResultSchema>;
export type CompatibilityCallToolResult = z.infer<typeof CompatibilityCallToolResultSchema>;
export type CallToolRequest = z.infer<typeof CallToolRequestSchema>;
export type ToolListChangedNotification = z.infer<
typeof ToolListChangedNotificationSchema