Implementation:20000419 Fauxnix resolveMcpLaunchTuple
| Knowledge Sources | |
|---|---|
| Domains | Install, Spawn_Safety, MCP |
| Last Updated | 2026-10-26 00:00 GMT |
Overview
Concrete resolver that produces the spawn-safe absolute launcher tuple (Node executable + built entry path) written into every harness MCP config so CreateProcess-based MCP clients can always start the server.
Description
The resolveMcpLaunchTuple function (src/mcp-launch.ts) returns { command: <absolute node.exe>, args: [<absolute dist/index.js>, 'mcp'] }. A bare fauxnix shim is an extension-less npm script on Windows that direct-spawn MCP clients cannot execute via CreateProcess; the absolute tuple is immune to PATH and shim-resolution differences on every platform. The function validates that both the Node executable and the built entry are absolute and exist, returning a { ok: true, value } result or { ok: false, reason } with an actionable message. sameMcpLaunchTuple compares an existing config entry against the expected tuple; isLegacyFauxnixCommand detects the pre-#252 { command: 'fauxnix' } form for safe upgrade.
Usage
Called once by runInstall before patching any harness config. A failure to locate Node or the built entry aborts the whole install rather than writing a config that cannot start. Also used by collectDoctorReport (via install/doctor) to validate existing configs.
Code Reference
Source Location
- Repository: fauxnix
- File: src/mcp-launch.ts
- Lines: resolveMcpLaunchTuple L15-33; sameMcpLaunchTuple L35-44; isLegacyFauxnixCommand L46-51; McpLaunchTuple type L5
Signature
export type McpLaunchTuple = { command: string; args: string[] };
export function resolveMcpLaunchTuple():
| { ok: true; value: McpLaunchTuple }
| { ok: false; reason: string };
export function sameMcpLaunchTuple(value: unknown, expected: McpLaunchTuple): boolean;
export function isLegacyFauxnixCommand(value: unknown): boolean;
Import
import { resolveMcpLaunchTuple, sameMcpLaunchTuple, isLegacyFauxnixCommand, type McpLaunchTuple } from './mcp-launch.js';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | — | — | Reads process.execPath and resolves ../dist/index.js relative to the module URL |
Outputs
| Name | Type | Description |
|---|---|---|
| ok result | { ok: true; value: McpLaunchTuple } | Absolute node.exe + [entry, 'mcp'] |
| failure result | { ok: false; reason: string } | Actionable error when a path is missing/not absolute |
Usage Examples
Resolve Before Install
import { resolveMcpLaunchTuple } from './mcp-launch.js';
const launch = resolveMcpLaunchTuple();
if (!launch.ok) {
console.error(launch.reason);
process.exitCode = 1;
return;
}
// launch.value → { command: "C:\\Program Files\\nodejs\\node.exe", args: ["C:\\...\\dist\\index.js", "mcp"] }
Check an Existing Config
const existing = config.mcpServers.fauxnix;
if (sameMcpLaunchTuple(existing, launch.value)) {
console.log('already configured with an absolute launcher');
}
if (isLegacyFauxnixCommand(existing)) {
// upgrade the pre-#252 bare-shim form
}