From e0f61c4ac71a95e042d7559f4a9ec2bbe5084573 Mon Sep 17 00:00:00 2001 From: olaservo Date: Sun, 22 Feb 2026 08:23:30 -0700 Subject: [PATCH] fix: add missing `size` field to ResourceSchema The MCP specification defines an optional `size?: number` field on the Resource interface (added in spec revision 2025-06-18), but the Zod schema was missing it. This adds the field so servers can declare resource sizes and hosts can display file sizes / estimate context window usage. Fixes modelcontextprotocol/typescript-sdk#1573 Co-Authored-By: Claude Opus 4.6 --- .changeset/add-resource-size-field.md | 5 +++++ packages/core/src/types/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 000000000..bef37cb40 --- /dev/null +++ b/.changeset/add-resource-size-field.md @@ -0,0 +1,5 @@ +--- +'@modelcontextprotocol/core': patch +--- + +Add missing `size` field to `ResourceSchema` to match the MCP specification diff --git a/packages/core/src/types/types.ts b/packages/core/src/types/types.ts index f9e475340..980b7649a 100644 --- a/packages/core/src/types/types.ts +++ b/packages/core/src/types/types.ts @@ -915,6 +915,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. */