Class: MCPClient::AudioContent
- Inherits:
-
Object
- Object
- MCPClient::AudioContent
- Defined in:
- lib/mcp_client/audio_content.rb
Overview
Representation of MCP audio content (MCP 2025-11-25) Used for base64-encoded audio data in messages and tool results
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#data ⇒ String
readonly
Base64-encoded audio data.
-
#mime_type ⇒ String
readonly
MIME type of the audio (e.g., ‘audio/wav’, ‘audio/mpeg’, ‘audio/ogg’).
Class Method Summary collapse
-
.from_json(json_data) ⇒ MCPClient::AudioContent
Create an AudioContent instance from JSON data.
Instance Method Summary collapse
-
#content ⇒ String
Get the decoded audio content.
-
#initialize(data:, mime_type:, annotations: nil) ⇒ AudioContent
constructor
Initialize audio content.
Constructor Details
#initialize(data:, mime_type:, annotations: nil) ⇒ AudioContent
Initialize audio content
19 20 21 22 23 24 25 26 |
# File 'lib/mcp_client/audio_content.rb', line 19 def initialize(data:, mime_type:, annotations: nil) raise ArgumentError, 'AudioContent requires data' if data.nil? || data.empty? raise ArgumentError, 'AudioContent requires mime_type' if mime_type.nil? || mime_type.empty? @data = data @mime_type = mime_type @annotations = annotations end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
13 |
# File 'lib/mcp_client/audio_content.rb', line 13 attr_reader :data, :mime_type, :annotations |
#data ⇒ String (readonly)
Returns base64-encoded audio data.
13 14 15 |
# File 'lib/mcp_client/audio_content.rb', line 13 def data @data end |
#mime_type ⇒ String (readonly)
Returns MIME type of the audio (e.g., ‘audio/wav’, ‘audio/mpeg’, ‘audio/ogg’).
13 |
# File 'lib/mcp_client/audio_content.rb', line 13 attr_reader :data, :mime_type, :annotations |
Class Method Details
.from_json(json_data) ⇒ MCPClient::AudioContent
Create an AudioContent instance from JSON data
31 32 33 34 35 36 37 |
# File 'lib/mcp_client/audio_content.rb', line 31 def self.from_json(json_data) new( data: json_data['data'], mime_type: json_data['mimeType'], annotations: json_data['annotations'] ) end |
Instance Method Details
#content ⇒ String
Get the decoded audio content
41 42 43 44 |
# File 'lib/mcp_client/audio_content.rb', line 41 def content require 'base64' Base64.decode64(@data) end |