Class: ModelContextProtocol::Server::Content::Text

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:

  • (Object)

    the current value of annotations



7
8
9
# File 'lib/model_context_protocol/server/content.rb', line 7

def annotations
  @annotations
end

#metaObject (readonly)

Returns the value of attribute meta

Returns:

  • (Object)

    the current value of meta



7
8
9
# File 'lib/model_context_protocol/server/content.rb', line 7

def meta
  @meta
end

#textObject (readonly)

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



7
8
9
# File 'lib/model_context_protocol/server/content.rb', line 7

def text
  @text
end

Instance Method Details

#serializedObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/model_context_protocol/server/content.rb', line 8

def serialized
  serialized_data = {
    _meta: meta,
    annotations:,
    text:,
    type: "text"
  }.compact

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