class RubyLLM::MCP::Result
The result of calling an MCP tool. Text, files, and structured data each have their own reader.
result = linear.list_issues(query: "bug") result.text # => "Found 3 issues..." result.structured # => { "issues" => [...] } result.attachments # => [#<RubyLLM::Attachment ...>]
Attributes
Images, audio, and embedded files, as Attachment objects.
The structured content, parsed from JSON, or nil.
The text of the result, with text blocks joined by blank lines.
Public Instance Methods
Source
# File lib/ruby_llm/mcp/result.rb, line 38 def content body = text.empty? && structured ? JSON.generate(structured) : text attachments.empty? ? body : [body, *attachments] end
Returns what a chat sends to the model: the text, or the structured content as JSON when there is no text, followed by any attachments.
Source
# File lib/ruby_llm/mcp/result.rb, line 32 def error? @data['isError'] == true end
Returns whether the tool reported a failure.
Source
# File lib/ruby_llm/mcp/result.rb, line 44 def to_h @data end
Returns the result as the server sent it.