From 432598d1cdcd1df8ce44aedc82aa8d3c752046b5 Mon Sep 17 00:00:00 2001 From: Dennis Kawurek Date: Sun, 30 Mar 2025 20:49:04 +0200 Subject: [PATCH] feat(McpSchema): Add constructor to CallToolResult with one String entry --- .../io/modelcontextprotocol/spec/McpSchema.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java b/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java index 37d9e0c0a..6c67eb04c 100644 --- a/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java +++ b/mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java @@ -756,6 +756,22 @@ public record CallToolRequest(// @formatter:off public record CallToolResult( // @formatter:off @JsonProperty("content") List content, @JsonProperty("isError") Boolean isError) { + + /** + * Creates a new instance of {@link CallToolResult} with a string containing the + * tool result. + * + * @param content The content of the tool result. This will be mapped to a one-sized list + * with a {@link TextContent} element. + * @param isError If true, indicates that the tool execution failed and the content contains error information. + * If false or absent, indicates successful execution. + */ + public CallToolResult(String content, Boolean isError) { + this( + List.of(new TextContent(content)), + isError + ); + } } // @formatter:on // ---------------------------