Skip to content

perf(core): mark module-level lookup tables as pure - #3257

Draft
ochafik wants to merge 1 commit into
claude/loving-johnson-onwvrg-droppable-clientfrom
claude/loving-johnson-onwvrg-pure-tables
Draft

ochafik wants to merge 1 commit into
claude/loving-johnson-onwvrg-droppable-clientfrom
claude/loving-johnson-onwvrg-pure-tables

Conversation

@ochafik

@ochafik ochafik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Lets bundlers drop specTypeSchemas, isSpecType, inputRequired and the elicitation and validation-ladder tables when an app does not use them. Draft, as a basis for discussion; last of the stack that starts at #3254.

Motivation and Context

These are built by top-level calls and loops in the shared chunk, so every bundle keeps them and the schemas they reference.

Minified size of a bundle using App from @modelcontextprotocol/ext-apps, zod included:

esbuild webpack rolldown rollup
with #3254 256 kB 245 kB 246 kB 243 kB
with this 225 kB 220 kB 222 kB 224 kB
plus #3255 220 kB 216 kB 218 kB 219 kB

It also helps apps that use the main classes: about 14 kB less for Client and 27 kB less for the server (esbuild).

How Has This Been Tested?

A new case in treeShaking.test.ts fails before and passes after. Suites as described in #3254. The ext-apps unit tests pass against packed builds of the full set.

Breaking Changes

None.

Types of changes

  • Refactoring (non-breaking change which makes things better)

Additional context

To discuss:


Generated by Claude Code

specTypeSchemas, isSpecType, inputRequired and the elicitation and ladder
tables were built by top-level calls that bundlers could not drop.

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

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 28d9473

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/client Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/core-internal Patch

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

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@3257

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 28d9473

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