From ddadaa6cc633fb5db0c094bf031b15b68a357820 Mon Sep 17 00:00:00 2001 From: Ola Hungerford Date: Thu, 26 Mar 2026 09:10:55 -0700 Subject: [PATCH] [v1.x] fix: add missing size field to ResourceSchema (#1575) Co-authored-by: Claude Opus 4.6 Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com> --- .changeset/add-resource-size-field.md | 5 +++++ src/types.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/add-resource-size-field.md diff --git a/.changeset/add-resource-size-field.md b/.changeset/add-resource-size-field.md new file mode 100644 index 00000000..92064689 --- /dev/null +++ b/.changeset/add-resource-size-field.md @@ -0,0 +1,5 @@ +--- +'@modelcontextprotocol/sdk': patch +--- + +Add missing `size` field to `ResourceSchema` to match the MCP specification diff --git a/src/types.ts b/src/types.ts index 173147a4..87899a38 100644 --- a/src/types.ts +++ b/src/types.ts @@ -900,6 +900,13 @@ export const ResourceSchema = z.object({ */ mimeType: z.optional(z.string()), + /** + * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. + * + * This can be used by Hosts to display file sizes and estimate context window usage. + */ + size: z.optional(z.number()), + /** * Optional annotations for the client. */