Class: ModelContextProtocol::Server::Content::Image

Inherits:
Data
  • Object
show all
Defined in:
lib/model_context_protocol/server/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations

Returns:

  • the current value of annotations



53
54
55
# File 'lib/model_context_protocol/server/content.rb', line 53

def annotations
  @annotations
end

#dataObject (readonly)

Returns the value of attribute data

Returns:

  • the current value of data



53
54
55
# File 'lib/model_context_protocol/server/content.rb', line 53

def data
  @data
end

#metaObject (readonly)

Returns the value of attribute meta

Returns:

  • the current value of meta



53
54
55
# File 'lib/model_context_protocol/server/content.rb', line 53

def meta
  @meta
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type

Returns:

  • the current value of mime_type



53
54
55
# File 'lib/model_context_protocol/server/content.rb', line 53

def mime_type
  @mime_type
end

Instance Method Details

#serializedObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/model_context_protocol/server/content.rb', line 54

def serialized
  serialized_data = {
    _meta: meta,
    annotations:,
    data:,
    mimeType: mime_type,
    type: "image"
  }.compact

  validation_errors = JSON::Validator.fully_validate(schema, serialized_data)
  if validation_errors.empty?
    serialized_data
  else
    raise ContentValidationError, validation_errors.join(", ")
  end
end