Merge pull request #84 from modelcontextprotocol/revert-83-justin/remove-compatibility-tool-result

Revert "Remove `CompatibilityCallToolResult`"
This commit is contained in:
Justin Spahr-Summers 2024-12-04 17:38:35 +00:00 • committed by GitHub
commit 989550d5f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View file

@ -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)",

View file

@ -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(

View file

@ -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<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