Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(mcp): preserve configured Python launcher
vastsaa7d20ac11ac0
diff --git a/apps/desktop/electron/main/mcp-stdio-launch.ts b/apps/desktop/electron/main/mcp-stdio-launch.tsindex 42f6c6665..c847a3f65 100644--- a/apps/desktop/electron/main/mcp-stdio-launch.ts+++ b/apps/desktop/electron/main/mcp-stdio-launch.ts@@ -314,7 +314,7 @@ function isWindowsAppsDir(dir: string, paths: nodePath.PlatformPath): boolean {* the real interpreter.*/export function discoverWindowsPython(- options: Pick<McpStdioLaunchOptions, "hostEnv" | "fs">,+ options: Pick<McpStdioLaunchOptions, "hostEnv" | "fs"> & { launcher: "python" | "python3" },): { command: string; args: string[] } | undefined {const hostEnv = options.hostEnv ?? process.env;const fs = options.fs ?? defaultFs();@@ -324,7 +324,10 @@ export function discoverWindowsPython(.split(paths.delimiter).filter((dir) => dir && !isWindowsAppsDir(dir, paths)).join(paths.delimiter);- for (const name of ["python3", "python"]) {+ // Preserve the configured launcher when both names are available (for+ // example, a virtual environment's `python.exe` before a system `python3`).+ const names = options.launcher === "python" ? ["python", "python3"] : ["python3", "python"];+ for (const name of names) {const found = lookOnPath(name, dirs, paths, exts, fs.isFile);if (found) return { command: found, args: [] };}@@ -534,7 +537,7 @@ export function resolveMcpStdioLaunch(options: McpStdioLaunchOptions): McpStdioLlaunchCommand = uv;}} else if (win32 && PYTHON_LAUNCHERS[name] && !/[\\/]/.test(command)) {- const python = discoverWindowsPython({ hostEnv, fs });+ const python = discoverWindowsPython({ hostEnv, fs, launcher: name === "python" ? "python" : "python3" });if (python) {launchCommand = python.command;launchArgs = [...python.args, ...args];diff --git a/apps/desktop/test/mcp-stdio-launch.test.mjs b/apps/desktop/test/mcp-stdio-launch.test.mjsindex ce974fc18..ffc451a54 100644--- a/apps/desktop/test/mcp-stdio-launch.test.mjs+++ b/apps/desktop/test/mcp-stdio-launch.test.mjs@@ -306,10 +306,10 @@ const winUser = win.join("C:", "Users", "zhao");const windowsApps = win.join(winUser, "AppData", "Local", "Microsoft", "WindowsApps");const pythonOrg = win.join(winUser, "AppData", "Local", "Programs", "Python", "Python311");-function pythonLaunch(files, pathDirs, extraEnv = {}) {+function pythonLaunch(files, pathDirs, extraEnv = {}, command = "python3") {const hostEnv = { PATH: pathDirs.join(";"), ...extraEnv };return resolveMcpStdioLaunch({- command: "python3",+ command,args: ["-m", "ictrp_mcp.server"],env: { PATH: hostEnv.PATH },platform: "win32",@@ -329,6 +329,19 @@ test("Windows python3 skips the Store alias for a real python.exe", () => {assert.deepEqual(launch.args, ["-m", "ictrp_mcp.server"]);});+test("Windows python prefers the requested python.exe over a later python3", () => {+ const activePython = win.join("C:", "venvs", "project", "Scripts", "python.exe");+ const unrelatedPython3 = win.join("C:", "Program Files", "Python312", "python3.exe");+ const launch = pythonLaunch(+ [activePython, unrelatedPython3],+ [win.dirname(activePython), win.dirname(unrelatedPython3)],+ {},+ "python",+ );+ assert.equal(launch.command, activePython);+ assert.deepEqual(launch.args, ["-m", "ictrp_mcp.server"]);+});+test("Windows python3 falls back to the py launcher with -3", () => {const systemRoot = win.join("C:", "Windows");const py = win.join(systemRoot, "py.exe");