Skip to content

fix(core): keep the 2025 wire schemas lazy on import - #3255

Draft
ochafik wants to merge 1 commit into
mainfrom
claude/loving-johnson-onwvrg-lazy-2025-schemas
Draft

ochafik wants to merge 1 commit into
mainfrom
claude/loving-johnson-onwvrg-lazy-2025-schemas

Conversation

@ochafik

@ochafik ochafik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Importing client or server builds all the 2025-11-25 wire schemas up front again. This reads them through the lazy factory instead. Draft, as a basis for discussion; independent of other PRs.

Motivation and Context

wire/rev2025-11-25/schemas.ts says runtime modules must import buildSchemas, because importing the shim makes construction eager. Since #2820, wire/codec.ts imports the shim for isCoreRequestReceivedBy.

Effect of the fix: importing client in Node goes from about 161 ms to 152 ms (median of 31 runs), and browser bundles lose about 4 kB minified.

How Has This Been Tested?

New lazySchemas.test.ts asserts that importing the package calls neither schema factory. It fails on main and passes here. The core-internal, client and server suites show no new failures, using unlocked dependencies; two tests fail there with and without this change.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Additional context

No changeset: the eager import has not been released.


Generated by Claude Code

wire/codec.ts imported the eager schemas shim, so every import of client
or server built the 2025-11-25 schemas. Read them through the lazy factory.

Co-authored-by: ochafik <ochafik@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d470ff5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3255

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3255

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3255

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3255

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3255

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3255

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3255

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3255

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3255

commit: d470ff5

This branch has not been deployed

No deployments
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.

2 participants