Observation
The workerd shims in both @modelcontextprotocol/client@2.0.0 and @modelcontextprotocol/server@2.0.0 call preloadSchemas() at module scope. In a Connecta Worker-example bundle, removing only those two calls for measurement reduced cold used V8 heap by about 10.03 MiB on average across three fresh local workerd isolates per variant.
| Pair |
Original used heap |
Without the two preload calls |
| 1 |
23,184,168 B |
12,485,064 B |
| 2 |
22,998,196 B |
12,478,996 B |
| 3 |
22,846,584 B |
12,503,924 B |
Environment: Node 26.9.0, Miniflare 4.20260722.0, workerd 1.20260722.1, compatibility date 2025-01-01, nodejs_compat, both SDK packages 2.0.0.
Reproduction and limits
Measurement script, raw observations, and method and interpretation.
The script bundles the Worker example, retains its imported export to prevent tree shaking, answers one synthetic request, then reads Runtime.getHeapUsage from the exact core:user: inspector target. The comparison plugin removes the two shim calls without modifying installed dependencies. Each sample uses a fresh Miniflare instance, disposed afterward. No provider is called or Worker deployed.
This measures cold allocation without forced GC, not retained heap after GC or production isolate churn. HeapProfiler.collectGarbage did not respond within ten seconds in this runtime. We have not verified that removing preload preserves all SDK schema paths on Workers and are not shipping a patch or recommending that workaround.
Could the workerd entry avoid eagerly materializing unused schemas while preserving its no-runtime-code-generation requirements? An upstream supported approach would let consumers benefit without modifying their dependencies.
Observation
The workerd shims in both
@modelcontextprotocol/client@2.0.0and@modelcontextprotocol/server@2.0.0callpreloadSchemas()at module scope. In a Connecta Worker-example bundle, removing only those two calls for measurement reduced cold used V8 heap by about 10.03 MiB on average across three fresh local workerd isolates per variant.Environment: Node 26.9.0, Miniflare 4.20260722.0, workerd 1.20260722.1, compatibility date 2025-01-01, nodejs_compat, both SDK packages 2.0.0.
Reproduction and limits
Measurement script, raw observations, and method and interpretation.
The script bundles the Worker example, retains its imported export to prevent tree shaking, answers one synthetic request, then reads
Runtime.getHeapUsagefrom the exactcore:user:inspector target. The comparison plugin removes the two shim calls without modifying installed dependencies. Each sample uses a fresh Miniflare instance, disposed afterward. No provider is called or Worker deployed.This measures cold allocation without forced GC, not retained heap after GC or production isolate churn.
HeapProfiler.collectGarbagedid not respond within ten seconds in this runtime. We have not verified that removing preload preserves all SDK schema paths on Workers and are not shipping a patch or recommending that workaround.Could the workerd entry avoid eagerly materializing unused schemas while preserving its no-runtime-code-generation requirements? An upstream supported approach would let consumers benefit without modifying their dependencies.