fix(runtime): pass HOME/TMP/TEMP to stdio MCP servers on all platforms

Node/npx-backed stdio MCP servers (Gmail, AgentMail, Exa, etc.) need a
usable HOME directory for npm cache and temp-file scratch space. Without
it, npm errors with EACCES on /nonexistent or silently falls over when
trying to write cache entries.

Previously these three variables were only passed on Windows. Linux and
macOS hosts launching stdio MCP servers through npx would get an empty
env for HOME/TMP/TEMP, breaking most community MCP servers.

Move the HOME/TMP/TEMP passthrough above the cfg!(windows) block so it
applies to every platform. Remove the now-redundant entries from the
Windows-only list.
This commit is contained in:
Scott Turnbull
2026-04-20 12:24:33 -04:00
parent e6bab993ae
commit e97eb6fff3
+7 -3
View File
@@ -247,6 +247,13 @@ impl McpConnection {
if let Ok(path) = std::env::var("PATH") {
cmd.env("PATH", path);
}
// Some stdio MCP servers launched via node/npx require a usable home
// directory even when they do not declare any explicit secret env vars.
for var in &["HOME", "TMP", "TEMP"] {
if let Ok(val) = std::env::var(var) {
cmd.env(var, val);
}
}
// On Windows, npm/node need extra vars
if cfg!(windows) {
for var in &[
@@ -254,9 +261,6 @@ impl McpConnection {
"LOCALAPPDATA",
"USERPROFILE",
"SystemRoot",
"TEMP",
"TMP",
"HOME",
"HOMEDRIVE",
"HOMEPATH",
] {