From 328a25d503562bfc89037e98e08fddfc0073dfc2 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Fri, 4 Jul 2025 11:35:33 -0700 Subject: [PATCH] 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. --- mcp/content.go | 2 ++ mcp/content_test.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/mcp/content.go b/mcp/content.go index 61111a9..fd027cf 100644 --- a/mcp/content.go +++ b/mcp/content.go @@ -187,10 +187,12 @@ func (r ResourceContents) MarshalJSON() ([]byte, error) { URI string `json:"uri,omitempty"` MIMEType string `json:"mimeType,omitempty"` Blob []byte `json:"blob"` + Meta Meta `json:"_meta,omitempty"` }{ URI: r.URI, MIMEType: r.MIMEType, Blob: r.Blob, + Meta: r.Meta, } return json.Marshal(br) } diff --git a/mcp/content_test.go b/mcp/content_test.go index 8c4e530..7a549be 100644 --- a/mcp/content_test.go +++ b/mcp/content_test.go @@ -154,6 +154,10 @@ func TestEmbeddedResource(t *testing.T) { &mcp.ResourceContents{URI: "u", Blob: []byte{1}}, `{"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) if err != nil {