Skip to content

Commit e0f61c4

Browse files
olaservoclaude
andcommitted
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#1573 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c4ee360 commit e0f61c4

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/core': patch
3+
---
4+
5+
Add missing `size` field to `ResourceSchema` to match the MCP specification

packages/core/src/types/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,13 @@ export const ResourceSchema = z.object({
915915
*/
916916
mimeType: z.optional(z.string()),
917917

918+
/**
919+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
920+
*
921+
* This can be used by Hosts to display file sizes and estimate context window usage.
922+
*/
923+
size: z.optional(z.number()),
924+
918925
/**
919926
* Optional annotations for the client.
920927
*/

0 commit comments

Comments
 (0)