Repository navigation
Description
Follow-up to #1084. #1084 fixed the shadowing-by-npx exposure (a local node_modules/sequant in the open project silently running instead of the pinned version, killing the MCP handshake with CONNECTION_CLOSED) for the plugin's own .mcp.json — the file plugin users get via the marketplace source: "./" path — by inlining scripts/mcp-launch.mjs as a node -e launcher with no ${...} placeholders.
Two sibling sites were explicitly out of scope for #1084 and still carry the original exposure:
getSequantMcpConfig()(src/lib/mcp-config.ts) — used bysequant init --mcp,createProjectMcpJson,addSequantToMcpConfig, andbuildOpencodeMcpConfig. It still builds{ command: "npx", args: ["-y", "sequant@<pin>", "serve"] }, whichnpxruns from whatever cwd the client (Claude Code, Cursor, VS Code+Continue, opencode) launches it with — the project directory in every case. A stalesequantdevDependency in that project reproduces fix(mcp): plugin MCP server dies with CONNECTION_CLOSED when the open project has an older sequant in node_modules — npx ignores the pin and runs the local copy #1084's exact symptom.templates/mcp.json— the source templateprepare-marketplace.tspins and copies into the official-plugin-directory submission'sdist/marketplace/external_plugins/sequant/.mcp.json(a separate distribution path from the marketplacesource: "./"file fix(mcp): plugin MCP server dies with CONNECTION_CLOSED when the open project has an older sequant in node_modules — npx ignores the pin and runs the local copy #1084 fixed). Also stillnpx-direct.
Suggested fix
Reuse #1084's inline-launcher approach: have getSequantMcpConfig() (or a new variant) embed scripts/mcp-launch.mjs via scripts/generate-mcp-launch-inline.mjs instead of building a bare npx command, and have prepare-marketplace.ts stamp templates/mcp.json with the same inline form it now produces for the root .mcp.json. Needs its own design pass — getSequantMcpConfig() is also used for non-Claude-Code clients (Cursor, VS Code+Continue) whose cwd/env handling differs from the plugin case, and SEQUANT_PROJECT_DIR currently relies on process.cwd() at launcher-spawn time, which holds for .mcp.json-launched processes but needs re-checking for cwd-clients that pass an explicit cwd.
Scope
Out of scope: anything already covered by #1084 (the plugin's own shipped .mcp.json). This issue is limited to getSequantMcpConfig()'s callers and templates/mcp.json.
Design pass (2026-09-28, owner-approved)
Observed:
getSequantMcpConfig()has four consumers, not three. The fourth isgetPhaseMcpServersConfig: the sequant server injected into every phase agent, with cwd set to the worktree. It carries the same exposure.scripts/is not in package.jsonfiles, so runtime code cannot readscripts/mcp-launch.mjs. That makes the inlinenode -eform (the fix(mcp): plugin MCP server dies with CONNECTION_CLOSED when the open project has an older sequant in node_modules — npx ignores the pin and runs the local copy #1084 shape) the only robust one. Today's inline source is 7,940 bytes.servehonorsSEQUANT_PROJECT_DIR(src/commands/serve.ts:39). The launcher derives that value fromprocess.cwd(). Clients that take an explicitcwd(Claude Desktop, Continue) spawn in the project dir, so they get the same value and need no change.prepare-marketplace.ts:287rejects every.mcp.jsonwhose command is notnpx, so the validator enforces the vulnerable shape.- In the field,
matcha-mapsandportfolio-2025.mcp.jsonare stillnpx -y [email protected] serve.syncSequantMcpPinonly re-pins; it never migrates the shape.
Decisions:
- D-1: a committed, generated
src/lib/mcp-launch-inline.generated.tsexportsMCP_LAUNCHER_INLINE_SOURCE.scripts/generate-mcp-launch-inline.mjs --writewrites it, and also rewrites the root.mcp.jsonandtemplates/mcp.json. A drift gate test keeps it honest.- Rejected: generating it into
distat build time (the build is tsc-only, so this adds a build step and an untracked artifact). - Rejected: a file-path launcher (no stable path once installed through npx).
- Rejected: generating it into
- D-2:
getSequantMcpConfig()returns{ command: "node", args: ["-e", SOURCE, spec] }. The cwd/env logic is unchanged, and all four consumers inherit the new shape. - D-3 (owner: yes):
syncSequantMcpPin, theupdate/syncpath, migrates exactly the legacy generated shape (npxwith["-y", "sequant@X", "serve"]) to the inline form. It also refreshes a stale inline source, and leaves every other shape alone, including local-binary overrides. It reports this with a new result reason,migrated. - D-4:
templates/mcp.jsonbecomes the inline flat form. Theprepare-marketplace.tsvalidator accepts thenode -eshape and still requires a concrete pin. - Owner accepted that a committed project
.mcp.jsongrows by about 8 KB and changes whenever the launcher changes. The plugin's own.mcp.jsonalready works this way.
Acceptance criteria
- AC-1:
getSequantMcpConfig()returnscommand: "node",args[0] === "-e",args[1] === MCP_LAUNCHER_INLINE_SOURCEand the pinned spec as the last arg, for no clientType and for every McpClientType — Evidence:npx vitest run src/lib/mcp-config.test.ts - AC-2: running the command/args
getSequantMcpConfig()returns, with cwd = a project whosenode_modules/.bin/sequantshadows the package and a fakenpxon PATH, spawns npx from a directory outside the project with the pinned spec — Evidence:npx vitest run scripts/mcp-launch.integration.test.tsnew case, mutation-verified (reverting getSequantMcpConfig to the npx form fails it) - AC-3:
src/lib/mcp-launch-inline.generated.tsequalsgenerateInlineLauncherSource()output, andtemplates/mcp.jsonargs[1] equals it too — Evidence:npx vitest run scripts/plugin-mcp-pin.test.tsgate case, mutation-verified - AC-4:
syncSequantMcpPinmigrates a legacynpx -y sequant@X serveentry to the inline form (reasonmigrated), refreshes a stale inline source, and leaves a local-binary entry byte-identical — Evidence:npx vitest run src/lib/mcp-config.test.ts - AC-5:
templates/mcp.jsonis the inline flat form andnpm run prepare:marketplacevalidates and pins it — Evidence:npm run prepare:marketplaceoutput contains✅ .mcp.json (MCP server config, pinned sequant@ - AC-6:
buildOpencodeMcpConfig()returnscommand: ["node", "-e", MCP_LAUNCHER_INLINE_SOURCE, <spec>]— Evidence:npx vitest run src/lib/mcp-config.test.ts - AC-7:
npm run build && npm testgreen — Evidence: CItestjob
Non-Goals
- The plugin's own root
.mcp.json(fixed by fix(mcp): plugin MCP server dies with CONNECTION_CLOSED when the open project has an older sequant in node_modules — npx ignores the pin and runs the local copy #1084). It is regenerated by the same script but must not change except through that generator. - Changing how cwd-clients (Claude Desktop, Continue) set
cwd, orserve'sSEQUANT_PROJECT_DIRhandling. - [unverified] Cursor's spawn cwd for project
.cursor/mcp.json. Behavior is unchanged either way, because the launcher usesprocess.cwd()exactly as npx did.
Activity
fix(#1089): plugin-install workflow requires the inline launcher; dec…
fix(#1089): lint scripts/**/*.mts with the scripts tsconfig project
test(#1089): mcp-serve integration asserts the inline launcher shape
fix(#1089): generated MCP configs launch through the inline node -e l…