Skip to content

fix: add missing size field to ResourceSchema per MCP spec#1600

Open
giulio-leone wants to merge 3 commits intomodelcontextprotocol:v1.xfrom
giulio-leone:fix/resource-schema-missing-size
Open

fix: add missing size field to ResourceSchema per MCP spec#1600
giulio-leone wants to merge 3 commits intomodelcontextprotocol:v1.xfrom
giulio-leone:fix/resource-schema-missing-size

Conversation

@giulio-leone
Copy link

Summary

The MCP specification (revisions 2025-06-18, 2025-11-25, and draft) defines an optional size?: number field on the Resource interface:

size: 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.

This field is missing from the TypeScript SDK's ResourceSchema Zod definition.

Fix

Added size: z.optional(z.number()) to ResourceSchema in src/types.ts.

Since ResourceMetadata is derived as Omit<Resource, 'uri' | 'name'>, servers can immediately pass size in resource metadata and it will be included in resources/list responses.

Test

Added 1 test verifying that a resource registered with size: 102400 correctly returns the size field in the resources/list response.

Verification

2 consecutive clean test runs: 1549/1549 tests passed, 0 failures.

Fixes #1573

@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: 18bc0c8

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@1600

commit: ae3e1bb

g97iulio1609 added 3 commits February 28, 2026 15:50
The MCP specification (revisions 2025-06-18, 2025-11-25, and draft)
defines an optional `size?: number` field on the Resource interface
for declaring raw resource content size in bytes. This field was
missing from the TypeScript SDK's ResourceSchema Zod definition.

Fixes modelcontextprotocol#1573
@giulio-leone
Copy link
Author

All CI checks pass. Ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant