Skip to content

feat(#793): pin generated MCP config to installed version instead of @latest - #794

Merged
admarble merged 1 commit into
mainfrom
feature/793-reconsider-sequant-latest-pinning-in-generated
Jul 19, 2026
Merged

admarble merged 1 commit into
mainfrom
feature/793-reconsider-sequant-latest-pinning-in-generated

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Fixes #793. The generated .mcp.json launched the MCP server with sequant@latest, which forces npx to re-resolve and reinstall the package on the first MCP reconnect after every release — the exact moment a corrupted npx cache (npm ENOTEMPTY) turns into an opaque Failed to reconnect to sequant: -32000. This implements the issue's recommended Option 1: pin to a concrete version so reconnects stop reinstalling, and let the MCP server track releases when the user runs sequant update (mirroring how the plugin cache already pins).

Design: sources track HEAD, distributed artifacts are pinned

File Pin? Why
getSequantMcpConfig() output (user's .mcp.json via init/update) pinned sequant@<installed version>, refreshed by sequant update
Plugin marketplace .mcp.json (via prepare-marketplace) pinned at build time stamped with the release version; picks up new versions on plugin update
templates/mcp.json, root .mcp.json (source) stays @latest portable HEAD-tracking sources; contributors rely on the npx fallback

Changes

  • src/lib/mcp-config.ts — getSequantMcpConfig() emits sequant@<version> via getVersion(), falling back to @latest if the version can't be resolved (never writes a bogus [email protected]). New syncSequantMcpPin() re-pins an existing .mcp.json to the installed version — no-ops on missing file, no sequant entry, a local-binary override (no sequant@… arg), or an already-current pin; --dry-run previews without writing.
  • src/commands/update.ts — calls syncSequantMcpPin() before the "everything up to date" short-circuit, so a version-only upgrade still refreshes the pin. init/setup already write the pin through createProjectMcpJson.
  • scripts/prepare-marketplace.ts — stamps the plugin .mcp.json with the release version at build time (this step already runs on every release path, so no release-script edits) and validates the output is a concrete pin, not @latest. This addresses the observed incident, which was plugin-side (/plugin reconnect).
  • Tests — mcp-config, init, and the mcp-serve integration test assert the pin; added a syncSequantMcpPin suite (stale/@latest→pin, already-current no-op, absent file, no entry, local-binary override, dry-run).
  • Docs — mcp-server.md (new "Version pinning" note + examples), plugin-distribution.md, mcp-integrations.md (cross-ref), the three mirrored setup/SKILL.md, and the troubleshooting -32000 entry now explain the pin and how the server tracks releases.

Acceptance Criteria

  • AC-1 Decide whether to pin — yes, pin (Option 1), confirmed with the maintainer.
  • AC-2 getSequantMcpConfig emits the installed version; setup/update (re)write it; tests updated (mcp-config.test.ts, init.test.ts).
  • AC-3 Docs (mcp-server.md, mcp-integrations.md) explain the pin and release tracking.
  • AC-4 Cross-references the troubleshooting -32000 / ENOTEMPTY entry.

Beyond the literal AC (flagged)

AC-2 scopes the change to the generator, but the reported incident was plugin-side. Rather than leave plugin users unfixed, I also pin the plugin's marketplace .mcp.json via build-time stamping — DRY, auto-tracks releases, and requires no changes to the release scripts. Source templates/mcp.json and the repo's own root .mcp.json intentionally stay @latest; a maintainer wanting the dev-repo config pinned can run sequant update.

Verification

  • npm run build ✅ npm run lint ✅ (0 warnings)
  • Targeted tests: 140 passed (mcp-config, version-check, init, update)
  • npm run prepare:marketplace stamps [email protected] into the plugin config and the pin-validation passes.

Risk assessment

  • Likely failure mode: if getVersion() ever resolves the wrong package.json, the pin could target an unintended version — mitigated by the @latest fallback and the existing name-guarded lookup.
  • Not tested: the release-time bump of the plugin marketplace pin is verified via a manual prepare:marketplace run, not an automated release e2e.

🤖 Generated with Claude Code

…latest

The generated `.mcp.json` launched the server with `sequant@latest`, forcing
npx to re-resolve and reinstall on the first MCP reconnect after every release
— the moment a corrupted npx cache (npm ENOTEMPTY) surfaces as an opaque
`Failed to reconnect to sequant: -32000`. Pin to a concrete version so
reconnects stop reinstalling; the MCP server tracks releases when the user runs
`sequant update`, matching the plugin-cache pinning model.

- getSequantMcpConfig() emits `sequant@<installed version>` via getVersion(),
  falling back to `@latest` if the version can't be resolved (never a bogus
  `@0.0.0` pin). init/setup write the pin.
- New syncSequantMcpPin(): update/sync re-pins an existing `.mcp.json` to the
  installed version (no-ops on missing file, no sequant entry, a local-binary
  override, or an already-current pin; --dry-run previews without writing).
  Wired into `update` before the "up to date" short-circuit so a version-only
  upgrade still refreshes the pin.
- prepare-marketplace stamps the plugin `.mcp.json` with the release version at
  build time (fixes the plugin-side incident) and validates the output is a
  concrete pin, not @latest. Source `templates/mcp.json` + root `.mcp.json`
  stay @latest as portable HEAD-tracking sources.
- Tests: mcp-config, init, mcp-serve integration updated to assert the pin;
  added syncSequantMcpPin coverage.
- Docs: mcp-server, plugin-distribution, mcp-integrations, setup SKILL (x3),
  and the troubleshooting -32000 entry explain the pin and release tracking.
@admarble
admarble merged commit 78375de into main Jul 19, 2026
8 checks passed
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.

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

1 participant