Skip to content

Commit 432598d

Browse files
committed
feat(McpSchema): Add constructor to CallToolResult with one String entry
1 parent 79ec5b5 commit 432598d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mcp/src/main/java/io/modelcontextprotocol/spec/McpSchema.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,22 @@ public record CallToolRequest(// @formatter:off
756756
public record CallToolResult( // @formatter:off
757757
@JsonProperty("content") List<Content> content,
758758
@JsonProperty("isError") Boolean isError) {
759+
760+
/**
761+
* Creates a new instance of {@link CallToolResult} with a string containing the
762+
* tool result.
763+
*
764+
* @param content The content of the tool result. This will be mapped to a one-sized list
765+
* with a {@link TextContent} element.
766+
* @param isError If true, indicates that the tool execution failed and the content contains error information.
767+
* If false or absent, indicates successful execution.
768+
*/
769+
public CallToolResult(String content, Boolean isError) {
770+
this(
771+
List.of(new TextContent(content)),
772+
isError
773+
);
774+
}
759775
} // @formatter:on
760776

761777
// ---------------------------

0 commit comments

Comments
 (0)