Concatenated text content of a tool result, or undefined when it has none.
Joins the text of every content block with type === "text" using
"\n", then trims. Returns undefined when there are no text blocks or
the joined result is empty/whitespace — callers choose their own fallback.
Useful when reading human-readable text from a CallToolResult
(success or error) without inspecting the full content array.
Parameters
result: Pick<CallToolResult,"content">
Tool result (or any object with a content array).
Returns string|undefined
Joined trimmed text, or undefined when there is none.
Example
consttext = toolResultText(result) ?? "No message.";
Concatenated text content of a tool result, or
undefinedwhen it has none.Joins the
textof everycontentblock withtype === "text"using"\n", then trims. Returnsundefinedwhen there are no text blocks or the joined result is empty/whitespace — callers choose their own fallback.Useful when reading human-readable text from a CallToolResult (success or error) without inspecting the full
contentarray.