Skip to content

Commit 1962943

Browse files
Revert "Remove CompatibilityCallToolResult"
1 parent 45af382 commit 1962943

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/client/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ClientNotification,
1212
ClientRequest,
1313
ClientResult,
14+
CompatibilityCallToolResultSchema,
1415
CompleteRequest,
1516
CompleteResultSchema,
1617
EmptyResultSchema,
@@ -376,7 +377,9 @@ export class Client<
376377

377378
async callTool(
378379
params: CallToolRequest["params"],
379-
resultSchema: typeof CallToolResultSchema,
380+
resultSchema:
381+
| typeof CallToolResultSchema
382+
| typeof CompatibilityCallToolResultSchema = CallToolResultSchema,
380383
options?: RequestOptions,
381384
) {
382385
return this.request(

src/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,15 @@ export const CallToolResultSchema = ResultSchema.extend({
752752
isError: z.boolean().default(false).optional(),
753753
});
754754

755+
/**
756+
* CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
757+
*/
758+
export const CompatibilityCallToolResultSchema = CallToolResultSchema.or(
759+
ResultSchema.extend({
760+
toolResult: z.unknown(),
761+
}),
762+
);
763+
755764
/**
756765
* Used by the client to invoke a tool provided by the server.
757766
*/
@@ -1186,6 +1195,9 @@ export type Tool = z.infer<typeof ToolSchema>;
11861195
export type ListToolsRequest = z.infer<typeof ListToolsRequestSchema>;
11871196
export type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
11881197
export type CallToolResult = z.infer<typeof CallToolResultSchema>;
1198+
export type CompatibilityCallToolResult = z.infer<
1199+
typeof CompatibilityCallToolResultSchema
1200+
>;
11891201
export type CallToolRequest = z.infer<typeof CallToolRequestSchema>;
11901202
export type ToolListChangedNotification = z.infer<
11911203
typeof ToolListChangedNotificationSchema

0 commit comments

Comments
 (0)