Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions mcp/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ func (c *ImageContent) MarshalJSON() ([]byte, error) {
if data == nil {
data = []byte{}
}
wire := struct {
Type string `json:"type"`
MIMEType string `json:"mimeType"`
Data []byte `json:"data"`
Meta Meta `json:"_meta,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}{
wire := imageAudioWire{
Type: "image",
MIMEType: c.MIMEType,
Data: data,
Expand Down Expand Up @@ -100,13 +94,7 @@ func (c AudioContent) MarshalJSON() ([]byte, error) {
if data == nil {
data = []byte{}
}
wire := struct {
Type string `json:"type"`
MIMEType string `json:"mimeType"`
Data []byte `json:"data"`
Meta Meta `json:"_meta,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}{
wire := imageAudioWire{
Type: "audio",
MIMEType: c.MIMEType,
Data: data,
Expand All @@ -123,6 +111,15 @@ func (c *AudioContent) fromWire(wire *wireContent) {
c.Annotations = wire.Annotations
}

// Custom wire format to ensure required fields are always included, even when empty.
type imageAudioWire struct {
Type string `json:"type"`
MIMEType string `json:"mimeType"`
Data []byte `json:"data"`
Meta Meta `json:"_meta,omitempty"`
Annotations *Annotations `json:"annotations,omitempty"`
}

// ResourceLink is a link to a resource
type ResourceLink struct {
URI string
Expand Down
Loading