You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
app-bridge pulls in entire Zod library (~1.4MB pre-minified) - most of it unused #649
When importing AppBridge and PostMessageTransport from @modelcontextprotocol/ext-apps/app-bridge, the bundle includes ~1.65MB of dependencies (pre-minified), resulting in a 377KB minified bundle for a minimal host app. The vast majority is Zod code that cannot be tree-shaken.
Reproduction
// Minimal import - just AppBridge for host-side integration
import { AppBridge, PostMessageTransport } from '@modelcontextprotocol/ext-apps/app-bridge';
The Zod library is the primary culprit at 1,386KB (84% of total):
Zod Component
Size
Notes
Locales (48 languages)
485 KB
ar, bg, cs, da, de, en, es, fa, fi, fr, he, hu, id, it, ja, ko, nl, no, pl, pt, ru, sv, th, tr, uk, vi, zh-CN, zh-TW, etc.
v4 core + classic
982 KB
Full v4 API
v3 compatibility
146 KB
Legacy v3 API
v4-mini
33 KB
Minimal v4
Why This Happens
Zod v4 bundles all locales by default - 48 locale files are included even though most apps only need 1-2
Multiple Zod versions included - v3, v4, v4-classic, v4-mini are all bundled
Cannot be tree-shaken - The MCP SDK imports from zod which pulls in the full package
Suggested Solutions
Use Zod v4-mini - If only runtime validation is needed (not JSON schema generation), v4-mini is ~33KB vs ~1MB
Externalize Zod as peer dependency - Let consumers provide Zod, enabling deduplication and locale subsetting:
"peerDependencies": {
"zod": "^4.0.0"
}
Subset locales - Only bundle en locale by default, let consumers add others:
import { z } from 'zod/v4-mini'; // or zod/v4/core with manual locale
Lazy-load schema validation - If Zod is only needed for certain operations, dynamically import it
Environment
@modelcontextprotocol/ext-apps: 1.7.1
@modelcontextprotocol/sdk: 1.27.1
zod: 4.3.6
Bundler: Webpack 5.x (production mode)
Workaround
We implemented dynamic import() to lazy-load the app-bridge chunk only when MCP protocol is used, reducing our main bundle from 812KB to 358KB. The MCP chunk (377KB) loads on-demand.
Reacted by Lloyd Smith, Christian Jensen, schelv, Cameron Yick and Lu
Another data point from a production host. OpenWaggle, an Electron desktop app, embeds MCP Apps through AppBridge + PostMessageTransport from @modelcontextprotocol/ext-apps@2.0.0/app-bridge, loaded as a lazy chunk only when a tool result opens an app.
The chunk is 260,914 B minified (68,014 B gzipped). By source map:
Part
Minified
zod
97,428 B (37%, ~27 kB gzipped)
@modelcontextprotocol/client
89,900 B
@modelcontextprotocol/ext-apps
28,600 B
@modelcontextprotocol/core
16,300 B
host code
16,800 B
Our own code no longer uses zod (tool schemas go through Standard Schema with Effect Schema), so zod is in the bundle only because app-bridge.js defines its ui/* message schemas with zod/v4 and extends the client Protocol, which validates with zod too. A pluggable validator for those messages, or plain type guards for the ui/* notifications, would let hosts drop it. The SDK-side part is modelcontextprotocol/typescript-sdk#3178 (#1252 covered user-supplied schemas only).
Activity
DiegoGBrisa commentedon Nov 12, 2026
Another data point from a production host. OpenWaggle, an Electron desktop app, embeds MCP Apps through
AppBridge+PostMessageTransportfrom@modelcontextprotocol/ext-apps@2.0.0/app-bridge, loaded as a lazy chunk only when a tool result opens an app.The chunk is 260,914 B minified (68,014 B gzipped). By source map:
@modelcontextprotocol/client@modelcontextprotocol/ext-apps@modelcontextprotocol/coreOur own code no longer uses zod (tool schemas go through Standard Schema with Effect Schema), so zod is in the bundle only because
app-bridge.jsdefines itsui/*message schemas withzod/v4and extends the clientProtocol, which validates with zod too. A pluggable validator for those messages, or plain type guards for theui/*notifications, would let hosts drop it. The SDK-side part is modelcontextprotocol/typescript-sdk#3178 (#1252 covered user-supplied schemas only).