Skip to content

fix(client): let bundlers drop an unused Client - #3256

Draft
ochafik wants to merge 1 commit into
claude/loving-johnson-onwvrg-side-effectsfrom
claude/loving-johnson-onwvrg-droppable-client
Draft

ochafik wants to merge 1 commit into
claude/loving-johnson-onwvrg-side-effectsfrom
claude/loving-johnson-onwvrg-droppable-client

Conversation

@ochafik

@ochafik ochafik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Replaces the static {} block in Client with a plain object, so esbuild, webpack and Bun can drop the class when an app does not use it. Draft, as a basis for discussion; stacked on #3254 for its test helper.

Motivation and Context

The block added in #3047 (released in 2.4.0) counts as a side effect for those bundlers, so they keep Client and the JSON Schema validator. A bundle using App from @modelcontextprotocol/ext-apps went from 255 kB on 2.3.1 to 319 kB on 2.4.0 (esbuild, minified, zod included). Rollup and rolldown are not affected.

On main alone this saves about 82 kB. On top of #3254 it saves nothing today, because Client happens to sit in its own chunk. It stops the result depending on that chunking.

How Has This Been Tested?

A new case in treeShaking.test.ts bundles with annotations ignored; it fails before and passes after. Bun was checked by hand. Suites as described in #3254.

Breaking Changes

None expected; see below.

Types of changes

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

Additional context

To discuss:

  • Quoted access to private members is not renamed by property manglers, so an app that mangles _-prefixed names inside its dependencies would break ext/skills. Acceptable, or is another shape preferred?
  • Server has a similar static block, left alone here.

Generated by Claude Code

The static block that filled clientInternals made the class a side effect
for esbuild, webpack and Bun. Define the accessors as a plain object.

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

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b1394d0

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/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/server 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@3256

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: b1394d0

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