@@ -78,6 +78,11 @@ func AsImageContent(content interface{}) (*ImageContent, bool) {
7878 return asType [ImageContent ](content )
7979}
8080
81+ // AsAudioContent attempts to cast the given interface to AudioContent
82+ func AsAudioContent (content interface {}) (* AudioContent , bool ) {
83+ return asType [AudioContent ](content )
84+ }
85+
8186// AsEmbeddedResource attempts to cast the given interface to EmbeddedResource
8287func AsEmbeddedResource (content interface {}) (* EmbeddedResource , bool ) {
8388 return asType [EmbeddedResource ](content )
@@ -208,7 +213,15 @@ func NewImageContent(data, mimeType string) ImageContent {
208213 }
209214}
210215
211- // NewEmbeddedResource
216+ // Helper function to create a new AudioContent
217+ func NewAudioContent (data , mimeType string ) AudioContent {
218+ return AudioContent {
219+ Type : "audio" ,
220+ Data : data ,
221+ MIMEType : mimeType ,
222+ }
223+ }
224+
212225// Helper function to create a new EmbeddedResource
213226func NewEmbeddedResource (resource ResourceContents ) EmbeddedResource {
214227 return EmbeddedResource {
@@ -246,6 +259,23 @@ func NewToolResultImage(text, imageData, mimeType string) *CallToolResult {
246259 }
247260}
248261
262+ // NewToolResultAudio creates a new CallToolResult with both text and audio content
263+ func NewToolResultAudio (text , imageData , mimeType string ) * CallToolResult {
264+ return & CallToolResult {
265+ Content : []Content {
266+ TextContent {
267+ Type : "text" ,
268+ Text : text ,
269+ },
270+ AudioContent {
271+ Type : "audio" ,
272+ Data : imageData ,
273+ MIMEType : mimeType ,
274+ },
275+ },
276+ }
277+ }
278+
249279// NewToolResultResource creates a new CallToolResult with an embedded resource
250280func NewToolResultResource (
251281 text string ,
@@ -423,6 +453,14 @@ func ParseContent(contentMap map[string]any) (Content, error) {
423453 }
424454 return NewImageContent (data , mimeType ), nil
425455
456+ case "audio" :
457+ data := ExtractString (contentMap , "data" )
458+ mimeType := ExtractString (contentMap , "mimeType" )
459+ if data == "" || mimeType == "" {
460+ return nil , fmt .Errorf ("audio data or mimeType is missing" )
461+ }
462+ return NewAudioContent (data , mimeType ), nil
463+
426464 case "resource" :
427465 resourceMap := ExtractMap (contentMap , "resource" )
428466 if resourceMap == nil {
0 commit comments