Skip to content

Shrink the first npx install from 43 packages to 4 - #12

Open
asbis wants to merge 2 commits into
claude/distribution-packagingfrom
claude/shrink-mcp-package
Open

asbis wants to merge 2 commits into
claude/distribution-packagingfrom
claude/shrink-mcp-package

Conversation

@asbis

@asbis asbis commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Stacked on #11, which is stacked on #10 (all part of the unreleased 1.30.1).

Why

A first npx -y @shapeitup/mcp-server downloaded ~38 MB across 43 tarballs (129 MB on disk) before the server could answer initialize. Claude Code waits 30 s for that, Codex 10 s. On an ordinary connection a new user's first session simply started without ShapeItUp.

What was in those 43 packages

Compressed Package Why it was there
8.8 MB replicad-opencascadejs OCCT itself — kept
8.0 MB @img/sharp-libvips (+ sharp) manifold-3d → peer @gltf-transform/functions → ndarray-pixels → sharp (native)
5.3 MB @mujoco/mujoco optionalDependencies, which npm installs for everyone
4.1 MB @shapeitup/mcp-server 1.3 MB of it the source map
3.7 + 3.6 MB esbuild-wasm twice ours (0.28) + manifold-3d's peer (0.27)
~2 MB @gltf-transform/*, fast-xml-parser, fflate, ndarray… manifold-3d's peers

ShapeItUp uses exactly one thing from manifold-3d: manifold.js + manifold.wasm (~570 KB).

Changes

  • Manifold is shipped, not depended on. copyManifoldToMcpDist() puts the two files in packages/mcp-server/dist/ in both build modes. manifold-3d moves to devDependencies. loadManifoldNode and the viewer's asset resolver look next to the bundle first (the resolver already did).
  • MuJoCo becomes an optional peer (peerDependenciesMeta.optional), which npm doesn't auto-install. Without it, engine: "mujoco" explains how to add it: npx -y -p @shapeitup/mcp-server -p @mujoco/mujoco shapeitup-mcp.
  • No source maps in the tarball ("!dist/**/*.map").
  • Guards against regressions:
    • release:check requires manifold.js/.wasm in the npm dist.
    • The CI and publish tarball smoke tests fail if manifold.wasm is missing or a .map ships.
    • CLAUDE.md explains why the dependency tree must stay small.
  • Not changed: Rapier, at 0.77 MB gzipped in index.js and again in viewer.js. It's the default dynamics engine, so making it opt-in would be a real regression for a modest gain.

Results (empty npm cache, run alternately, same network)

1.30.0 from npm this branch (packed tarball)
Time to initialize 104.7 s, 75.6 s 13.8 s, 20.1 s
On disk 129 MB 52 MB
Packages 42 4
Tarball 4.07 MB 2.95 MB

(The network was slow tonight; yesterday the old package took 34 s. The new run read its own ~3 MB tarball from disk, so it downloaded about that much less than it will from npm.)

Test plan

  • pnpm lint, pnpm build, pnpm test: 65 files, 1231 tests pass
  • pnpm pack: dist/manifold.{js,wasm} included, no .map
  • Ran the npx-installed tarball (HOME isolated so it couldn't reach a live VS Code window):
    • threads.tapInto (Manifold) renders, with no "Manifold loader failed" on stderr
    • open_viewer serves /manifold.wasm (200, 493,115 bytes)
    • Rapier dynamics run (gravity-drop example)
    • engine: "mujoco" returns the opt-in instructions
  • npx -y -p <tarball> -p @mujoco/mujoco shapeitup-mcp: the MuJoCo engine runs the same simulation
  • node scripts/release-check.mjs: manifest and asset checks pass

🤖 Generated with Claude Code

A cold `npx -y @shapeitup/mcp-server` downloaded ~38 MB across 43
tarballs (129 MB on disk). On an ordinary connection that ran past
Claude Code's 30 s MCP timeout, so a new user's first session started
without ShapeItUp. Side by side from an empty cache: 76-105 s before,
14-20 s after, 52 MB on disk.

- Ship manifold.js + manifold.wasm in dist/ instead of depending on
  manifold-3d. Its peer dependencies, which npm installs automatically,
  brought a second esbuild-wasm, @gltf-transform/* and the native sharp
  library: ~17 MB for a half-megabyte wasm. The loader and the viewer's
  asset resolver already look in dist/ first.
- @mujoco/mujoco becomes an optional peer (npm installed the optional
  dependency for everyone, 5 MB). The error for engine: "mujoco" now
  gives the npx command that adds it.
- Stop publishing source maps (1.3 MB gzipped).
- release-check and the CI tarball smoke test check that manifold.wasm
  ships and no .map does. CLAUDE.md records why the tree must stay small.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
shapeitup-landing Ready Ready Preview Oct 13, 2026 10:38am UTC

@martinrieder

martinrieder commented Oct 13, 2026 •

Copy link
Copy Markdown

@asbis To me this sounds like it is fixing networking and caching delays that do not apply when installing this as a VS Code extension.
Headless operation is a different use case, for which there is an --mcp-only flag in esbuild.config.mjs explicitly skipping some steps.

This PR might cause further issues with dependency management, while it conflates the two distribution channels.

  • VSIX: there's nothing to cache away — everything is co-located in extension/dist and resolves from disk before the agent loads the server. The PR is neutral here, but adds version skew: the shipped manifold.wasm is frozen at build time, so it only updates on release.
  • npx / --mcp-only: there's no extension host that could pre-cache anything. The install truly is the first run, and it happens before initialize answers. Caching would only help repeat runs, which were never the problem. Would there be other means to fix the first startup delay?

EDIT: I missed the fact that it depends on agent configuration and the recommended call to npx -y @shapeitup/mcp-server would bypass the VSIX package and load from NPM. The agent would need to be configured for loading the MCP server via node <extensionPath>/dist/mcp-server.mjs to avoid the version skew mentioned above.

`tar -tzf | grep -qx …` let grep exit on its first match; GNU tar then
died writing to the closed pipe ("tar: stdout: write error"), and
pipefail failed the step even though the file was there. In the
source-map check the same race would have hidden a match inside the
`if`. BSD tar on macOS doesn't hit it, which is why it passed locally.
publish.yml had the same lines and would have failed the release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — e302630d Deployed Oct 13, 2026 by vercel[bot]
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