Class: ActionMCP::Content::Image

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

Overview

Image content includes a base64-encoded image and its MIME type.

Instance Attribute Summary collapse

Attributes inherited from Base

#annotations, #type

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(data, mime_type, annotations: nil) ⇒ Image

Initializes a new Image content.

Parameters:

  • data (String)

    The base64-encoded image data.

  • mime_type (String)

    The MIME type of the image data.

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

    Optional annotations for the image content.



16
17
18
19
20
# File 'lib/action_mcp/content/image.rb', line 16

def initialize(data, mime_type, annotations: nil)
  super("image", annotations: annotations)
  @data = data
  @mime_type = mime_type
end

Instance Attribute Details

#dataString (readonly)

Returns:

  • (String)

    The base64-encoded image data.

  • (String)

    The MIME type of the image data.



9
10
11
# File 'lib/action_mcp/content/image.rb', line 9

def data
  @data
end

#mime_typeString (readonly)

Returns:

  • (String)

    The base64-encoded image data.

  • (String)

    The MIME type of the image data.



9
10
11
# File 'lib/action_mcp/content/image.rb', line 9

def mime_type
  @mime_type
end

Instance Method Details

#to_hHash

Returns a hash representation of the image content.

Returns:

  • (Hash)

    The hash representation of the image content.



25
26
27
# File 'lib/action_mcp/content/image.rb', line 25

def to_h
  super.merge(data: @data, mimeType: @mime_type)
end