Class: LittleGhost::MCP::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/little_ghost/mcp/types.rb,
lib/little_ghost/mcp/types.rb

Overview

Represents one MCP Tool result without discarding server fields. Mapping callbacks can inspect normalized content, structured content, metadata, or the complete protocol value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, raw:, structured_content: nil, error: false, metadata: {}) ⇒ Result

Returns a new instance of Result.



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/little_ghost/mcp/types.rb', line 167

def initialize(content:, raw:, structured_content: nil, error: false, metadata: {})
  unless error.nil? || error == true || error == false
    raise ProtocolError, "MCP tool result isError must be boolean"
  end

  super(
    content: ImmutableValue.array(content, field: "tool result content"),
    structured_content: ImmutableValue.optional_mapping(
      structured_content,
      field: "structuredContent"
    ),
    error: !!error,
    metadata: ImmutableValue.mapping(, field: "tool result _meta"),
    raw: ImmutableValue.mapping(raw, field: "tool result")
  )
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



166
167
168
# File 'lib/little_ghost/mcp/types.rb', line 166

def content
  @content
end

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



166
167
168
# File 'lib/little_ghost/mcp/types.rb', line 166

def error
  @error
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



166
167
168
# File 'lib/little_ghost/mcp/types.rb', line 166

def 
  @metadata
end

#rawObject (readonly)

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



166
167
168
# File 'lib/little_ghost/mcp/types.rb', line 166

def raw
  @raw
end

#structured_contentObject (readonly)

Returns the value of attribute structured_content

Returns:

  • (Object)

    the current value of structured_content



166
167
168
# File 'lib/little_ghost/mcp/types.rb', line 166

def structured_content
  @structured_content
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


184
# File 'lib/little_ghost/mcp/types.rb', line 184

def error? = error