mcp-use TypeScript API
    Preparing search index...

    Function toolResultText

    • 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.

      const text = toolResultText(result) ?? "No message.";