Skip to content

Commit d74ebee

Browse files
committed
Fix _meta parameter passing in TextResourceContents and BlobResourceContents
Use the field name 'meta' instead of the alias '_meta' when constructing Pydantic model instances. The alias is only used for JSON serialization. This fixes a bug where passing **{'_meta': meta} would cause Pydantic validation errors since '_meta' is an alias, not a field name.
1 parent c3117b6 commit d74ebee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/mcp/server/lowlevel/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def create_content(data: str | bytes, mime_type: str | None, meta: dict[str, Any
325325
uri=req.params.uri,
326326
text=data,
327327
mimeType=mime_type or "text/plain",
328-
**{"_meta": meta} if meta is not None else {},
328+
meta=meta,
329329
)
330330
case bytes() as data: # pragma: no cover
331331
import base64
@@ -334,7 +334,7 @@ def create_content(data: str | bytes, mime_type: str | None, meta: dict[str, Any
334334
uri=req.params.uri,
335335
blob=base64.b64encode(data).decode(),
336336
mimeType=mime_type or "application/octet-stream",
337-
**{"_meta": meta} if meta is not None else {},
337+
meta=meta,
338338
)
339339

340340
match result:

0 commit comments

Comments
 (0)