MCP servers are re-fetched from npm on every daemon start #572

Closed
opened 2026-10-27 13:36:52 +00:00 by sam · 0 comments
Owner

config.docker.toml launches desktop-commander with 'npx -y @wonderwhy-er/desktop-commander@0.2.46'. The container has no persistent npm cache, so every restart re-resolves and re-downloads the package and its puppeteer browser payload. That is slow, makes startup depend on npm registry availability, and turns a registry outage or a yanked version into a daemon outage. It also amplified the crash loop observed on 2026-07-30, since each restart repeated the whole download.

Acceptance Criteria

Daemon startup does not depend on reaching the npm registry. Either the MCP servers are installed into the image at build time and invoked directly, or the npm cache is persisted across restarts. Startup time no longer scales with the size of the server's dependency tree.

Notes

Not fixed in code, but operationally contained: CLAUDE.md now states 'No npx-launched servers are configured in production anyway -- the builtin tools (read, write, edit, find, grep, shell) and web_fetch.' Confirmed no persistent-cache or build-time-install mechanism exists in internal/tools/provider/provider.go. If an operator adds an npx-based MCP server back, this bug reproduces exactly as described. Fix is still the structural one (build-time install or persisted cache), not just avoiding the config -- don't close this on the operational workaround alone.

Close reason

Fixed: configuredMCPProvider (cmd/archied/main.go) now sets NPM_CONFIG_CACHE under the daemon's persistent work_dir and NPM_CONFIG_PREFER_OFFLINE=true for any npx-launched MCP server (matched by base name so an absolute-path npx still qualifies), so a daemon restart reuses a warm npm cache instead of re-resolving/re-downloading from the registry every time -- the amplifier behind the 2026-07-30 crash loop. Guards an empty workDir explicitly (unreachable in production since config defaulting runs first, but matches memoryProvider's existing precedent for the same defense). Adversarially reviewed by a fresh subagent; findings addressed: narrowed an overclaim that this also covers a package's own separate downloads (e.g. Playwright/Puppeteer fetching browser binaries via CDN, which NPM_CONFIG_CACHE does not touch), and closed the absolute-path-command gap. Full task check clean. The identical, arguably-worse instance in internal/app/agentworker/mcp_providers.go (every per-task ephemeral container, not just daemon restarts) needs real new infra -- a persistent Docker volume bind-mounted into task containers, which doesn't exist yet -- so it's filed separately as archie-core-qk8m rather than folded into this scoped fix.


Imported from beads archie-core-1786637490923-43-d4bb914b · GitHub #64 · type task · priority P2 · created 2026-08-08 · closed 2026-08-18

config.docker.toml launches desktop-commander with 'npx -y @wonderwhy-er/desktop-commander@0.2.46'. The container has no persistent npm cache, so every restart re-resolves and re-downloads the package and its puppeteer browser payload. That is slow, makes startup depend on npm registry availability, and turns a registry outage or a yanked version into a daemon outage. It also amplified the crash loop observed on 2026-07-30, since each restart repeated the whole download. ### Acceptance Criteria Daemon startup does not depend on reaching the npm registry. Either the MCP servers are installed into the image at build time and invoked directly, or the npm cache is persisted across restarts. Startup time no longer scales with the size of the server's dependency tree. ### Notes Not fixed in code, but operationally contained: CLAUDE.md now states 'No npx-launched servers are configured in production anyway -- the builtin tools (read, write, edit, find, grep, shell) and web_fetch.' Confirmed no persistent-cache or build-time-install mechanism exists in internal/tools/provider/provider.go. If an operator adds an npx-based MCP server back, this bug reproduces exactly as described. Fix is still the structural one (build-time install or persisted cache), not just avoiding the config -- don't close this on the operational workaround alone. ### Close reason Fixed: configuredMCPProvider (cmd/archied/main.go) now sets NPM_CONFIG_CACHE under the daemon's persistent work_dir and NPM_CONFIG_PREFER_OFFLINE=true for any npx-launched MCP server (matched by base name so an absolute-path npx still qualifies), so a daemon restart reuses a warm npm cache instead of re-resolving/re-downloading from the registry every time -- the amplifier behind the 2026-07-30 crash loop. Guards an empty workDir explicitly (unreachable in production since config defaulting runs first, but matches memoryProvider's existing precedent for the same defense). Adversarially reviewed by a fresh subagent; findings addressed: narrowed an overclaim that this also covers a package's own separate downloads (e.g. Playwright/Puppeteer fetching browser binaries via CDN, which NPM_CONFIG_CACHE does not touch), and closed the absolute-path-command gap. Full task check clean. The identical, arguably-worse instance in internal/app/agentworker/mcp_providers.go (every per-task ephemeral container, not just daemon restarts) needs real new infra -- a persistent Docker volume bind-mounted into task containers, which doesn't exist yet -- so it's filed separately as archie-core-qk8m rather than folded into this scoped fix. --- _Imported from beads `archie-core-1786637490923-43-d4bb914b` · GitHub #64 · type task · priority P2 · created 2026-08-08 · closed 2026-08-18_
sam added the mediumtask labels 2026-10-27 13:36:52 +00:00
sam self-assigned this 2026-10-27 13:36:52 +00:00
sam closed this issue 2026-10-27 13:36:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#572