You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP server: prevent nested npx version mismatch in sequant_run #389
In #372, sequant_run calls spawnSync("npx", ["sequant", "run", ...]). When the MCP server itself was started via npx sequant serve, this creates a nested npx invocation that may resolve to a different cached version.
Goal
Ensure sequant_run invokes the same sequant binary that's running the MCP server.
Acceptance Criteria
sequant_run uses the current process's binary path instead of npx sequant
Works correctly when started via npx sequant serve, global install, and local node dist/bin/cli.js serve
Version consistency verified in tests
Approach
Use process.argv[0] + process.argv[1] or resolve the CLI path relative to __dirname instead of calling npx.
sequant_run uses current process binary instead of npx sequant
✅ Implemented
AC-2
Works for npx, global install, and local node dist/bin/cli.js serve
✅ Implemented
AC-3
Version consistency verified in tests
✅ Implemented
Key Changes
src/mcp/tools/run.ts: Added resolveCliBinary() function that resolves the CLI binary path using process.argv[0] + process.argv[1], with fallback to __dirname-relative resolution and npx as last resort
src/mcp/server-extended.test.ts: Added 7 tests — 4 direct unit tests for resolveCliBinary() and 3 MCP integration tests verifying spawn behavior
Clean, focused fix with thorough test coverage. All 3 ACs met. The resolveCliBinary() function correctly resolves the CLI binary from process.argv with sensible fallbacks, eliminating the nested npx version mismatch.
Documentation
CHANGELOG entry added
N/A — No new features/flags requiring README updates
Verdict confidence: High — the merge conflict is mechanically verifiable via git merge-tree
Verdict: AC_NOT_MET
The resolveCliBinary() implementation is well-designed and the approach is correct, but the PR is based on pre-#388 code that used spawnSync. Main has since been refactored to async spawn (PR #400). All three changed files have merge conflicts. The fix needs to be rebased and adapted to the async API.
Next Steps
Rebase onto main:git fetch origin && git rebase origin/main
Resolve conflicts in src/mcp/tools/run.ts:
Keep resolveCliBinary() function (add resolve, dirname, existsSync imports)
Apply binary resolution to spawnAsync(command, args, ...) instead of spawnSync
Likely failure mode: If process.argv[1] is empty/undefined in a novel runtime (e.g., compiled binary). Mitigated by the __dirname fallback and npx last-resort.
Verdict confidence: High — small, focused change with thorough test coverage, cleanly rebased onto current main
Verdict: READY_FOR_MERGE
Clean, focused fix rebased onto current main (#388 async spawn). All 3 ACs met. resolveCliBinary() correctly resolves the CLI binary from process.argv with sensible fallbacks, eliminating the nested npx version mismatch. No regressions — all existing #388 async tests pass unchanged.
Documentation
CHANGELOG entry added
N/A — No new features/flags requiring README updates
Added troubleshooting entry: "Workflow uses a different sequant version than expected" — explains the version mismatch scenario, notes that v1.21+ handles this automatically, and provides workarounds for older versions
This is a bug fix to the existing MCP server, not a new feature. The existing mcp-server.md is the canonical reference — adding a troubleshooting entry there is where users will look.
Activity
fix(#389): use current process binary instead of npx in MCP sequant_run
admarble commentedon Mar 23, 2026
Exec Phase — Progress Update
AC Coverage
sequant_runuses current process binary instead ofnpx sequantnode dist/bin/cli.js serveKey Changes
src/mcp/tools/run.ts: AddedresolveCliBinary()function that resolves the CLI binary path usingprocess.argv[0]+process.argv[1], with fallback to__dirname-relative resolution andnpxas last resortsrc/mcp/server-extended.test.ts: Added 7 tests — 4 direct unit tests forresolveCliBinary()and 3 MCP integration tests verifying spawn behaviorQuality Gates
npm run buildnpm run lintnpm testPR
PR #406: #406
Quality Plan Alignment: N/A — No quality plan in issue
admarble commentedon Mar 23, 2026
QA Review for Issue #389
AC Coverage
sequant_runuses current process binary instead ofnpx sequantresolveCliBinary()returns[process.argv[0], [process.argv[1]]]— verified in code (run.ts:24-31) and 4 unit tests + 3 integration testsnode dist/bin/cli.js serveprocess.argvcovers npx/global/local, (2)__dirname-relative for bundled, (3)npxfallback.__dirnamepath verified:dist/src/mcp/tools → dist/bin/cli.jsresolveCliBinary()unit tests + 3 MCP integration tests verifying spawn args. All 22 MCP tests passCoverage: 3/3 AC items fully met
Quality Plan Verification
N/A — No quality plan found in issue comments
CI Status
No CI checks returned from
gh pr checks— CI may not be configured or PR checks haven't started.Quality Metrics
any)Cache Status
N/A — No caching configured
Build Verification
N/A — Build passed (
tscclean)Test Coverage Analysis
src/mcp/tools/run.tssrc/mcp/server-extended.test.tsCHANGELOG.mdCoverage: 1/1 changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
resolveCliBinary()is a pure, exported, testable functionnpxfallback preserves backward compatibility for edge casesIssues:
Suggestions:
Test Quality Review
existsSyncandspawnSyncmocked (external I/O only)Anti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected in changed files. No hardcoded secrets, no await-in-loops, no empty catch blocks.
Call-Site Review
New exported functions detected: 1
resolveCliBinary()src/mcp/tools/run.ts:85Findings: Single call site, called exactly where needed, no guard required.
Execution Evidence
N/A — No scripts/CLI entrypoints modified (change is in library code)
Skill Command Verification
N/A — No skill files changed
CLI Registration Verification
N/A — No option interface changes
Smoke Test
Not Required — No workflow-affecting changes (library-internal binary resolution only)
Self-Evaluation
process.argv[1]is somehow empty/undefined in a novel runtime (e.g., compiled binary). Mitigated by the fallback chain.CHANGELOG Verification
Result: CHANGELOG requirements met
Verdict: READY_FOR_MERGE
Clean, focused fix with thorough test coverage. All 3 ACs met. The
resolveCliBinary()function correctly resolves the CLI binary fromprocess.argvwith sensible fallbacks, eliminating the nested npx version mismatch.Documentation
Next Steps
/docs 389if documentation is desired (optional for bug fix)admarble commentedon Mar 23, 2026
QA Review for Issue #389
Stale Branch Check
Branch is 4 commits behind main. Critical: #388 (async spawn refactor) landed on main and directly conflicts with this PR.
AC Coverage
sequant_runuses current process binary instead ofnpx sequantresolveCliBinary()is correct but patchesspawnSync— main now usesspawnAsync(#388). Merge conflict confirmed.node dist/bin/cli.js servespawnAsync()call, notspawnSync().spawnSyncbut main now mocksspawn. All 7 new tests will break after merge.Coverage: 0/3 AC items met
Quality Plan Verification
N/A — No quality plan found in issue comments
CI Status
No CI checks configured/running for PR #406.
Quality Metrics
any)Build Verification
N/A — Build passes on feature branch (but against stale base)
Test Coverage Analysis
src/mcp/tools/run.tssrc/mcp/server-extended.test.tsCHANGELOG.mdCoverage: 1/1 changed source files have tests
Critical paths without tests: None (but tests target wrong API after rebase)
Code Review
Strengths:
resolveCliBinary()is a clean, well-documented, pure function with good JSDoc__dirnamepath resolution verified:dist/src/mcp/tools/ → dist/bin/cli.js✅Issues:
spawnSyncwith asyncspawn(PR feat(#388): replace spawnSync with async spawn in MCP sequant_run #400, commits9aba881..908f323). This PR still usesspawnSync. Three files conflict:src/mcp/tools/run.ts—spawnSyncimport/usage vsspawn/spawnAsyncsrc/mcp/server-extended.test.ts—vi.mock("child_process")mocksspawnSyncvsspawnCHANGELOG.md— competing[Unreleased]entriesSuggestions:
resolveCliBinary()to thespawnAsync("npx", args, ...)callspawn(notspawnSync) and usecreateMockProcesspattern from MCP server: replace spawnSync with async spawn for sequant_run #388 testsTest Quality Review
existsSyncandspawnSyncmockedNote: Test quality is good, but mocks target
spawnSyncwhich no longer exists on main.Anti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected. No hardcoded secrets, no await-in-loops, no empty catch blocks.
Call-Site Review
New exported functions detected: 1
resolveCliBinary()run.ts:85Execution Evidence
N/A — No scripts/CLI entrypoints modified
Skill Command Verification
N/A — No skill files changed
CLI Registration Verification
N/A — No option interface changes
Smoke Test
Not Required — No workflow-affecting changes
CHANGELOG Verification
Self-Evaluation
resolveCliBinary()logic verified manuallyspawnSyncwhich no longer exists on mainspawnSyncimport would revert the async spawn refactor from MCP server: replace spawnSync with async spawn for sequant_run #388, breaking MCP server responsiveness.git merge-treeVerdict: AC_NOT_MET
The
resolveCliBinary()implementation is well-designed and the approach is correct, but the PR is based on pre-#388 code that usedspawnSync. Main has since been refactored to asyncspawn(PR #400). All three changed files have merge conflicts. The fix needs to be rebased and adapted to the async API.Next Steps
git fetch origin && git rebase origin/mainsrc/mcp/tools/run.ts:resolveCliBinary()function (addresolve,dirname,existsSyncimports)spawnAsync(command, args, ...)instead ofspawnSync[...prefixArgs, "run", ...issues.map(String)]src/mcp/server-extended.test.ts:spawn(notspawnSync) usingcreateMockProcesspattern from MCP server: replace spawnSync with async spawn for sequant_run #388resolveCliBinaryunit tests (they don't depend on spawn mock)[Unreleased]/qa 389after rebasefix(#389): use current process binary instead of npx in MCP sequant_run
admarble commentedon Mar 23, 2026
QA Review for Issue #389 (Re-run after rebase)
Stale Branch Check
Branch rebased cleanly onto main (includes #388 async spawn refactor).
AC Coverage
sequant_runuses current process binary instead ofnpx sequantresolveCliBinary()returns[process.argv[0], [process.argv[1]]]— verified in code (run.ts:27-31) and 4 unit tests + 3 MCP integration testsnode dist/bin/cli.js serveprocess.argvcovers npx/global/local, (2)__dirname-relative for bundled (dist/src/mcp/tools → dist/bin/cli.js— verified), (3)npxfallbackresolveCliBinary()unit tests + 3 MCP integration tests verifying spawn args. Uses asyncspawnmock pattern from #388. All 29 MCP-related tests pass (22 extended + 7 async integration)Coverage: 3/3 AC items fully met
Quality Plan Verification
N/A — No quality plan found in issue comments
CI Status
No CI checks configured for this repository.
Quality Metrics
any)Cache Status
N/A — No caching configured
Build Verification
N/A — Build passed (
tscclean,eslintclean)Test Coverage Analysis
src/mcp/tools/run.tssrc/mcp/server-extended.test.tsCHANGELOG.mdCoverage: 1/1 changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
resolveCliBinary()is a pure, exported, independently testable functionspawnAsync()— no regression to syncmockedExistsSyncinbeforeEachensures all existing MCP tests get correct binary resolution without needing per-test setupIssues:
Suggestions:
Test Quality Review
existsSyncandspawnmocked (external I/O)Anti-Pattern Detection
Dependency Audit
N/A — No dependency changes
Code Patterns
No anti-patterns detected. No hardcoded secrets, no await-in-loops, no empty catch blocks.
Call-Site Review
New exported functions detected: 1
resolveCliBinary()run.ts:103Execution Evidence
N/A — No scripts/CLI entrypoints modified (library-internal binary resolution)
Skill Command Verification
N/A — No skill files changed
CLI Registration Verification
N/A — No option interface changes
Smoke Test
Not Required — No workflow-affecting changes
CHANGELOG Verification
Self-Evaluation
process.argv[1]is empty/undefined in a novel runtime (e.g., compiled binary). Mitigated by the__dirnamefallback andnpxlast-resort.Verdict: READY_FOR_MERGE
Clean, focused fix rebased onto current main (#388 async spawn). All 3 ACs met.
resolveCliBinary()correctly resolves the CLI binary fromprocess.argvwith sensible fallbacks, eliminating the nested npx version mismatch. No regressions — all existing #388 async tests pass unchanged.Documentation
Next Steps
test(#389): add test for __dirname fallback resolution success path
docs(#389): add version mismatch troubleshooting to MCP server docs
admarble commentedon Mar 23, 2026
Documentation Updated
File:
docs/features/mcp-server.md(updated existing doc)Changes:
Why update, not new file:
This is a bug fix to the existing MCP server, not a new feature. The existing
mcp-server.mdis the canonical reference — adding a troubleshooting entry there is where users will look.Ready to merge!
fix(#389): prevent nested npx version mismatch in MCP sequant_run (#406)
fix(#391): merge main and resolve async spawn + structured output con…
fix(#394): merge main and resolve conflicts with #389 and #391