mcp: ensure meta is not skipped on blob ResourceContents (#96)

I noticed this while working on #95. Seems Meta was accidentally skipped
in the custom wire format struct.
This commit is contained in:
Martin Emde 2025-07-04 11:35:33 -07:00 • committed by GitHub
commit 328a25d503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -187,10 +187,12 @@ func (r ResourceContents) MarshalJSON() ([]byte, error) {
URI string `json:"uri,omitempty"` URI string `json:"uri,omitempty"`
MIMEType string `json:"mimeType,omitempty"` MIMEType string `json:"mimeType,omitempty"`
Blob []byte `json:"blob"` Blob []byte `json:"blob"`
Meta Meta `json:"_meta,omitempty"`
}{ }{
URI: r.URI, URI: r.URI,
MIMEType: r.MIMEType, MIMEType: r.MIMEType,
Blob: r.Blob, Blob: r.Blob,
Meta: r.Meta,
} }
return json.Marshal(br) return json.Marshal(br)
} }

View file

@ -154,6 +154,10 @@ func TestEmbeddedResource(t *testing.T) {
&mcp.ResourceContents{URI: "u", Blob: []byte{1}}, &mcp.ResourceContents{URI: "u", Blob: []byte{1}},
`{"uri":"u","blob":"AQ=="}`, `{"uri":"u","blob":"AQ=="}`,
}, },
{
&mcp.ResourceContents{URI: "u", MIMEType: "m", Blob: []byte{1}, Meta: mcp.Meta{"key": "value"}},
`{"uri":"u","mimeType":"m","blob":"AQ==","_meta":{"key":"value"}}`,
},
} { } {
data, err := json.Marshal(tt.rc) data, err := json.Marshal(tt.rc)
if err != nil { if err != nil {