Class: ActionMCP::Content::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/action_mcp/content/text.rb

Overview

Text content represents plain text messages.

Instance Attribute Summary collapse

Attributes inherited from Base

#annotations, #type

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(text, annotations: nil) ⇒ Text

Initializes a new Text content.

Parameters:

  • text (String)

    The text content.

  • annotations (Hash, nil) (defaults to: nil)

    Optional annotations for the content.



14
15
16
17
# File 'lib/action_mcp/content/text.rb', line 14

def initialize(text, annotations: nil)
  super("text", annotations: annotations)
  @text = text.to_s
end

Instance Attribute Details

#textString (readonly)

Returns The text content.

Returns:

  • (String)

    The text content.



8
9
10
# File 'lib/action_mcp/content/text.rb', line 8

def text
  @text
end

Instance Method Details

#to_hHash

Returns a hash representation of the text content.

Returns:

  • (Hash)

    The hash representation of the text content.



22
23
24
# File 'lib/action_mcp/content/text.rb', line 22

def to_h
  super.merge(text: @text)
end