class RubyLLM::MCP::Result

def error?

def error?
  !@error.empty?
end

def execution_error?

def execution_error?
  @result_is_error
end

def initialize(response, session_id: nil)

def initialize(response, session_id: nil)
  @response = response
  @session_id = session_id
  @id = response["id"]
  @method = response["method"]
  @result = response["result"] || {}
  @params = response["params"] || {}
  @error = response["error"] || {}
  @result_is_error = response.dig("result", "isError") || false
  @next_cursor = response.dig("result", "nextCursor")
end

def inspect

def inspect
  "#<#{self.class.name}:0x#{object_id.to_s(16)} id: #{@id}, result: #{@result}, error: #{@error}, method: #{@method}, params: #{@params}>" # rubocop:disable Layout/LineLength
end

def matching_id?(request_id)

def matching_id?(request_id)
  @id&.to_s == request_id.to_s
end

def next_cursor?

def next_cursor?
  !@next_cursor.nil?
end

def notification

def notification
  Notification.new(@response)
end

def notification?

def notification?
  @method&.include?("notifications") || false
end

def raise_error!

def raise_error!
  error = to_error
  message = "Response error: #{error}"
  raise Errors::ResponseError.new(message: message, error: error)
end

def request?

def request?
  !@method.nil? && !notification? && @result.none? && @error.none?
end

def response?

def response?
  !@id.nil? && (@result || @error.any?) && !@method
end

def success?

def success?
  !@result.empty?
end

def to_error

def to_error
  Error.new(@error)
end

def to_s

def to_s
  inspect
end

def tool_success?

def tool_success?
  success? && !@result_is_error
end