File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 66 ClientNotification ,
77 ClientRequest ,
88 ClientResult ,
9+ CompatibilityCallToolResultSchema ,
910 CompleteRequest ,
1011 CompleteResultSchema ,
1112 EmptyResultSchema ,
@@ -218,11 +219,12 @@ export class Client<
218219
219220 async callTool (
220221 params : CallToolRequest [ "params" ] ,
222+ resultSchema : typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema = CallToolResultSchema ,
221223 onprogress ?: ProgressCallback ,
222224 ) {
223225 return this . request (
224226 { method : "tools/call" , params } ,
225- CallToolResultSchema ,
227+ resultSchema ,
226228 onprogress ,
227229 ) ;
228230 }
Original file line number Diff line number Diff line change 1- import { AnyZodObject , ZodLiteral , ZodObject , z } from "zod" ;
1+ import { ZodLiteral , ZodObject , ZodType , z } from "zod" ;
22import {
33 ErrorCode ,
44 JSONRPCError ,
@@ -250,7 +250,7 @@ export class Protocol<
250250 *
251251 * Do not use this method to emit notifications! Use notification() instead.
252252 */
253- request < T extends AnyZodObject > (
253+ request < T extends ZodType < object > > (
254254 request : SendRequestT ,
255255 resultSchema : T ,
256256 onprogress ?: ProgressCallback ,
Original file line number Diff line number Diff line change @@ -722,6 +722,13 @@ export const CallToolResultSchema = ResultSchema.extend({
722722 isError : z . boolean ( ) ,
723723} ) ;
724724
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+
725732/**
726733 * Used by the client to invoke a tool provided by the server.
727734 */
@@ -1054,6 +1061,7 @@ export const ServerResultSchema = z.union([
10541061 ListResourceTemplatesResultSchema ,
10551062 ReadResourceResultSchema ,
10561063 CallToolResultSchema ,
1064+ CompatibilityCallToolResultSchema ,
10571065 ListToolsResultSchema ,
10581066] ) ;
10591067
@@ -1148,6 +1156,7 @@ export type Tool = z.infer<typeof ToolSchema>;
11481156export type ListToolsRequest = z . infer < typeof ListToolsRequestSchema > ;
11491157export type ListToolsResult = z . infer < typeof ListToolsResultSchema > ;
11501158export type CallToolResult = z . infer < typeof CallToolResultSchema > ;
1159+ export type CompatibilityCallToolResult = z . infer < typeof CompatibilityCallToolResultSchema > ;
11511160export type CallToolRequest = z . infer < typeof CallToolRequestSchema > ;
11521161export type ToolListChangedNotification = z . infer <
11531162 typeof ToolListChangedNotificationSchema
You can’t perform that action at this time.
0 commit comments