Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/com/google/cloud/mcp/tool/ToolResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public record ToolResult(
@JsonProperty("content") List<Content> content, @JsonProperty("isError") boolean isError) {

/**
* Returns the concatenated text content from all text items in this result, or an empty string if
* no text content is available.
*
* @return The concatenated text content.
*/
public String text() {
if (content == null) {
return "";
}
return content.stream()
.filter(c -> "text".equals(c.type()) && c.text() != null)
.map(Content::text)
.collect(java.util.stream.Collectors.joining("\n"));
}

/**
* Represents a single content item in a tool result.
*
Expand Down
Loading
Loading