@@ -42,9 +42,10 @@ suite("MCP Config Manager Tests", () => {
4242 assert . strictEqual ( fs . existsSync ( configPath ) , true ) ;
4343
4444 const saved = JSON . parse ( fs . readFileSync ( configPath , "utf8" ) ) as {
45- servers ?: Record < string , { command ?: string ; args ?: string [ ] } > ;
45+ servers ?: Record < string , { command ?: string ; args ?: string [ ] ; env ?: Record < string , string > } > ;
4646 } ;
4747 assert . strictEqual ( saved . servers ?. scheduler ?. command , expectedEntry . command ) ;
48+ assert . deepStrictEqual ( saved . servers ?. scheduler ?. env ?? { } , expectedEntry . env ?? { } ) ;
4849 assert . strictEqual (
4950 fs . existsSync ( getWorkspaceMcpLauncherPath ( workspaceRoot ) ) ,
5051 true ,
@@ -101,12 +102,13 @@ suite("MCP Config Manager Tests", () => {
101102 const expectedEntry = buildSchedulerMcpServerEntry ( workspaceRoot ) ;
102103
103104 const saved = JSON . parse ( fs . readFileSync ( configPath , "utf8" ) ) as {
104- servers ?: Record < string , { command ?: string ; args ?: string [ ] } > ;
105+ servers ?: Record < string , { command ?: string ; args ?: string [ ] ; env ?: Record < string , string > } > ;
105106 metadata ?: { owner ?: string } ;
106107 } ;
107108 assert . strictEqual ( saved . metadata ?. owner , "tests" ) ;
108109 assert . strictEqual ( saved . servers ?. existing ?. args ?. [ 0 ] , "existing-server.js" ) ;
109110 assert . strictEqual ( saved . servers ?. scheduler ?. command , expectedEntry . command ) ;
111+ assert . deepStrictEqual ( saved . servers ?. scheduler ?. env ?? { } , expectedEntry . env ?? { } ) ;
110112 assert . strictEqual (
111113 saved . servers ?. scheduler ?. args ?. [ 0 ] ,
112114 getWorkspaceMcpLauncherPath ( workspaceRoot ) ,
@@ -225,9 +227,10 @@ suite("MCP Config Manager Tests", () => {
225227 const expectedEntry = buildSchedulerMcpServerEntry ( workspaceRoot ) ;
226228
227229 const repaired = JSON . parse ( fs . readFileSync ( configPath , "utf8" ) ) as {
228- servers ?: Record < string , { command ?: string ; args ?: string [ ] } > ;
230+ servers ?: Record < string , { command ?: string ; args ?: string [ ] ; env ?: Record < string , string > } > ;
229231 } ;
230232 assert . strictEqual ( repaired . servers ?. scheduler ?. command , expectedEntry . command ) ;
233+ assert . deepStrictEqual ( repaired . servers ?. scheduler ?. env ?? { } , expectedEntry . env ?? { } ) ;
231234 assert . strictEqual (
232235 repaired . servers ?. scheduler ?. args ?. [ 0 ] ,
233236 getWorkspaceMcpLauncherPath ( workspaceRoot ) ,
@@ -240,19 +243,20 @@ suite("MCP Config Manager Tests", () => {
240243 }
241244 } ) ;
242245
243- test ( "falls back to the user's interactive login shell on macOS when node is not directly discoverable " , ( ) => {
246+ test ( "prefers the VS Code runtime with ELECTRON_RUN_AS_NODE when the extension host is not plain node " , ( ) => {
244247 const launch = resolveNodeLaunchCommand ( {
245248 platform : "darwin" ,
246249 execPath : "/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper" ,
247250 env : {
248251 PATH : "" ,
249252 SHELL : "/bin/zsh" ,
250253 } ,
251- fileExists : ( filePath : string ) => filePath === "/bin/zsh " ,
254+ fileExists : ( filePath : string ) => filePath === "/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper " ,
252255 } ) ;
253256
254- assert . strictEqual ( launch . command , "/bin/zsh" ) ;
255- assert . deepStrictEqual ( launch . argsPrefix , [ "-ilc" ] ) ;
257+ assert . strictEqual ( launch . command , "/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper" ) ;
258+ assert . deepStrictEqual ( launch . argsPrefix , [ ] ) ;
259+ assert . deepStrictEqual ( launch . env ?? { } , { ELECTRON_RUN_AS_NODE : "1" } ) ;
256260 } ) ;
257261
258262 test ( "prefers an absolute node executable when one is available on macOS" , ( ) => {
@@ -267,6 +271,7 @@ suite("MCP Config Manager Tests", () => {
267271
268272 assert . strictEqual ( launch . command , "/opt/homebrew/bin/node" ) ;
269273 assert . deepStrictEqual ( launch . argsPrefix , [ ] ) ;
274+ assert . strictEqual ( launch . env , undefined ) ;
270275 } ) ;
271276
272277 test ( "builds a shell command that resolves node before launching the MCP server" , ( ) => {
0 commit comments