From 379392d04460ee2cbeecae374901fae21e525031 Mon Sep 17 00:00:00 2001 From: Ola Hungerford Date: Thu, 26 Mar 2026 09:08:59 -0700 Subject: [PATCH] fix: add missing size field to ResourceSchema (#1574) Co-authored-by: Ola Hungerford --- .changeset/add-resource-size-field.md | 5 +++++ packages/core/src/types/schemas.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..bef37cb4 --- /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/schemas.ts b/packages/core/src/types/schemas.ts index 1c0e6086..c8f0c997 100644 --- a/packages/core/src/types/schemas.ts +++ b/packages/core/src/types/schemas.ts @@ -832,6 +832,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. */