Skip to content

Commit 328a25d

Browse files
authored
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.
1 parent c6b229c commit 328a25d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

mcp/content.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,12 @@ func (r ResourceContents) MarshalJSON() ([]byte, error) {
187187
URI string `json:"uri,omitempty"`
188188
MIMEType string `json:"mimeType,omitempty"`
189189
Blob []byte `json:"blob"`
190+
Meta Meta `json:"_meta,omitempty"`
190191
}{
191192
URI: r.URI,
192193
MIMEType: r.MIMEType,
193194
Blob: r.Blob,
195+
Meta: r.Meta,
194196
}
195197
return json.Marshal(br)
196198
}

mcp/content_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func TestEmbeddedResource(t *testing.T) {
154154
&mcp.ResourceContents{URI: "u", Blob: []byte{1}},
155155
`{"uri":"u","blob":"AQ=="}`,
156156
},
157+
{
158+
&mcp.ResourceContents{URI: "u", MIMEType: "m", Blob: []byte{1}, Meta: mcp.Meta{"key": "value"}},
159+
`{"uri":"u","mimeType":"m","blob":"AQ==","_meta":{"key":"value"}}`,
160+
},
157161
} {
158162
data, err := json.Marshal(tt.rc)
159163
if err != nil {

0 commit comments

Comments
 (0)