Skip to content

Reconsider sequant@latest pinning in generated MCP config (forces npx reinstall every release; surfaces as -32000) #793

Closed

Description

@admarble

Problem

The generated project MCP config (src/lib/mcp-config.ts, written into every user's .mcp.json) launches the server with:

"command": "npx", "args": ["-y", "sequant@latest", "serve"]

The -y + @latest combination forces npx to re-resolve and reinstall the package whenever the published latest version changes. In practice that means the first MCP reconnect after every sequant release triggers a fresh npx install. That reconnect is the exact moment a half-written or interrupted npx cache turns into a hard, opaque failure that surfaces to the user only as Failed to reconnect to sequant: -32000 (a generic JSON-RPC transport error that names neither npx nor the real cause).

Observed incident (2026-07-18, v2.9.0 release)

Immediately after publishing 2.9.0, /plugin reconnect failed with -32000. Running the launch command by hand surfaced the real error, an npm atomic-rename collision with a leftover temp dir:

npm error code ENOTEMPTY
npm error syscall rename
npm error ENOTEMPTY: directory not empty, rename
  '.../_npx/<hash>/node_modules/sequant' -> '.../_npx/<hash>/node_modules/.sequant-XXXXXXXX'

Because the failure happens inside npx, before sequant serve executes, sequant cannot catch or self-heal it. Cleared the stale temp dir and it reconnected fine. Troubleshooting steps are now documented under "MCP Server Issues" in docs/troubleshooting.md.

Why this is a design question, not just a cache bug

The ENOTEMPTY corruption is an upstream npm issue and out of our control. What is in our control is how often we force an npx reinstall. @latest maximizes that frequency (every release), which maximizes exposure to any npx cache fragility — amplified on machines with multiple node prefixes (fnm/nvm + Homebrew) sharing one ~/.npm/_npx cache.

Options to weigh

  1. Pin to the installed version. setup/update writes sequant@<version> instead of sequant@latest, and rewrites it on the next update. Reconnects stop reinstalling on every release; the MCP server tracks releases only when the user runs update — matching the plugin-cache pinning model. Trade-off: MCP server no longer auto-tracks new releases.
  2. Keep @latest, improve diagnosability. Can't catch the npx failure in-process, but we could document more loudly / add a preflight in setup that runs the launch command once and reports a cache problem clearly. Weaker fix.
  3. Prefer a local binary when present. setup detects a global/linked sequant and writes sequant serve; else falls back to npx. Trade-off: static JSON can't branch per-machine, so this is a write-time decision that can go stale, and the committed .mcp.json must stay on the portable npx form for other contributors.

Recommendation

Lean toward Option 1 (pin to installed version) as the most robust default — it removes the release-triggered reinstall entirely and is consistent with how the plugin cache already pins. Needs a decision on the auto-track-vs-determinism trade-off before implementing.

Acceptance Criteria

  • Decide whether the generated .mcp.json should pin the MCP server to a concrete version instead of @latest
  • If pinning: getSequantMcpConfig emits the installed version; setup and update (re)write it; tests updated (mcp-config.test.ts, init.test.ts currently assert sequant@latest)
  • Docs updated (docs/features/mcp-server.md, docs/guides/mcp-integrations.md) to explain the pin and how the MCP server tracks releases
  • Cross-reference the troubleshooting entry added for the -32000 / ENOTEMPTY case

Notes

  • Not fixing the npm ENOTEMPTY bug itself — that's upstream and unreachable from our code.
  • The troubleshooting doc entry (portable version of the manual fix) already landed; this issue is only about the config-design decision.

Activity

  1. admarble commented on Jul 19, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete → PR #794

    Decision (AC-1): Pin to the installed version (Option 1), confirmed with the maintainer as best practice — @latest in a committed, auto-launched command is non-reproducible and re-resolves on every release, which is what surfaced as -32000.

    AC Coverage

    • AC-1 MET — decided to pin.
    • AC-2 MET — getSequantMcpConfig emits sequant@<version>; init/setup write it and update re-pins via new syncSequantMcpPin(); tests updated.
    • AC-3 MET — mcp-server.md + mcp-integrations.md (and plugin-distribution.md, setup SKILL ×3) explain the pin and release tracking.
    • AC-4 MET — cross-references the troubleshooting -32000 / ENOTEMPTY entry.

    Beyond literal AC (flagged for review)

    The observed incident was plugin-side. prepare-marketplace now stamps the plugin .mcp.json with the release version at build time (no release-script changes needed) so plugin users are actually fixed. Source templates/mcp.json + root .mcp.json intentionally stay @latest as portable HEAD-tracking sources.

    Quality

    • Build ✅ · Lint ✅ (0 warnings) · 140 targeted tests ✅
    • prepare:marketplace stamps + validates a concrete pin (rejects @latest).

    Risk

    • Likely failure mode: getVersion() resolving the wrong package.json → mitigated by the @latest fallback and name-guarded lookup.
    • Not automated: release-time plugin-pin bump verified via manual prepare:marketplace run.

    Verdict: READY_FOR_MERGE — awaiting human review.

  2. added a commit that references this issue on Jul 19, 2026
  3. added a commit that references this issue on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions