Skip to content

fix(#389): prevent nested npx version mismatch in MCP sequant_run - #406

Merged
admarble merged 3 commits into
mainfrom
feature/389-mcp-server-prevent-nested-npx-version-mismatch-in-
Mar 23, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/389-mcp-server-prevent-nested-npx-version-mismatch-in-

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Replace spawnSync("npx", ["sequant", "run", ...]) with resolveCliBinary() that uses the current process's binary path
  • Resolves CLI binary from process.argv[0] + process.argv[1] to ensure the same version is invoked
  • Falls back to __dirname-relative dist/bin/cli.js, then npx as last resort
  • Added 7 tests covering binary resolution (direct unit tests + MCP integration tests)

Pre-PR AC Verification

AC Description Status Evidence
AC-1 sequant_run uses current process binary instead of npx sequant ✅ Implemented src/mcp/tools/run.ts:24-41 — resolveCliBinary()
AC-2 Works for npx, global install, and local node ✅ Implemented Priority chain: argv[1] → __dirname-relative → npx fallback
AC-3 Version consistency verified in tests ✅ Implemented server-extended.test.ts — 7 new tests verify binary resolution

Test plan

  • npm run build — passes
  • npm run lint — passes
  • npm test — 1764 tests pass (75 test files)
  • Unit tests verify resolveCliBinary() returns process.argv (not npx) when script exists
  • Unit tests verify npx fallback when no paths resolve
  • Integration tests verify spawnSync is called with resolved binary, not npx

Closes #389

🤖 Generated with Claude Code

Resolves nested npx version mismatch when MCP server is started via
`npx sequant serve` and sequant_run spawns `npx sequant run`.

Uses process.argv[0]+argv[1] to invoke the same binary that's running,
with fallback to __dirname-relative resolution and npx as last resort.

Entire-Checkpoint: 642927b9261b
@admarble
admarble force-pushed the feature/389-mcp-server-prevent-nested-npx-version-mismatch-in- branch from 0d1b0fb to 1854dea Compare March 23, 2026 22:28
The existing tests verified that the __dirname-relative path was
checked, but never tested the case where it succeeds (argv[1] absent
but dist/bin/cli.js exists). This closes the last untested branch in
resolveCliBinary().
Add troubleshooting entry for the nested npx version mismatch scenario
that this fix addresses, with workarounds for older versions.
@admarble
admarble merged commit 18930c5 into main Mar 23, 2026
3 of 5 checks passed
@admarble
admarble deleted the feature/389-mcp-server-prevent-nested-npx-version-mismatch-in- branch March 23, 2026 22:34
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.

MCP server: prevent nested npx version mismatch in sequant_run

1 participant