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 ...>] result.meta # => { "com.linear/request_id" => "..." }
In a chat, the result of a tool with a UI stays on its tool result message as Message#mcp_result, so your app can render the UI again.
Attributes
Images, audio, and embedded files, as Attachment objects.
The result’s _meta as the server sent it: a Hash with String keys, empty when there is none.
The structured content, parsed from JSON, or nil.
The text of the result, with text blocks joined by blank lines.
The URI of the UI that renders the result, from its tool’s MCP::Tool#ui_uri, or nil for a tool without one.
Public Instance Methods
Source
# File lib/ruby_llm/mcp/result.rb, line 55 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 49 def error? @data['isError'] == true end
Returns whether the tool reported a failure.
Source
# File lib/ruby_llm/mcp/result.rb, line 61 def to_h @data end
Returns the result as the server sent it.