From 1962943b226b2370a7380ff7527c37ecde121996 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Wed, 4 Dec 2024 17:09:31 +0000 Subject: [PATCH 1/2] Revert "Remove `CompatibilityCallToolResult`" --- src/client/index.ts | 5 ++++- src/types.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/client/index.ts b/src/client/index.ts index afc724208..1ad516166 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -11,6 +11,7 @@ import { ClientNotification, ClientRequest, ClientResult, + CompatibilityCallToolResultSchema, CompleteRequest, CompleteResultSchema, EmptyResultSchema, @@ -376,7 +377,9 @@ export class Client< async callTool( params: CallToolRequest["params"], - resultSchema: typeof CallToolResultSchema, + resultSchema: + | typeof CallToolResultSchema + | typeof CompatibilityCallToolResultSchema = CallToolResultSchema, options?: RequestOptions, ) { return this.request( diff --git a/src/types.ts b/src/types.ts index 5db06a5da..44a44d8f0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -752,6 +752,15 @@ export const CallToolResultSchema = ResultSchema.extend({ isError: z.boolean().default(false).optional(), }); +/** + * 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. */ @@ -1186,6 +1195,9 @@ export type Tool = z.infer; export type ListToolsRequest = z.infer; export type ListToolsResult = z.infer; export type CallToolResult = z.infer; +export type CompatibilityCallToolResult = z.infer< + typeof CompatibilityCallToolResultSchema +>; export type CallToolRequest = z.infer; export type ToolListChangedNotification = z.infer< typeof ToolListChangedNotificationSchema From 620cb5cb52140d3397dcd8fb2641a5cf59c5f0ea Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Wed, 4 Dec 2024 17:19:00 +0000 Subject: [PATCH 2/2] Bump to 1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 212eaf669..63fb871d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/sdk", - "version": "1.0.2", + "version": "1.0.3", "description": "Model Context Protocol implementation for TypeScript", "license": "MIT", "author": "Anthropic, PBC (https://anthropic.com)",