Skip to content

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

Open
Streamweaver wants to merge 1 commit intoRightNow-AI:mainfrom
Streamweaver:fix/mcp-stdio-env-passthrough-linux
Open

fix(runtime): pass HOME/TMP/TEMP to stdio MCP servers on all platforms#1095
Streamweaver wants to merge 1 commit intoRightNow-AI:mainfrom
Streamweaver:fix/mcp-stdio-env-passthrough-linux

Conversation

@Streamweaver
Copy link
Copy Markdown

Problem

stdio MCP servers launched via npx (Gmail, AgentMail, Exa, and community servers generally) fail or misbehave on Linux and macOS because HOME, TMP, and TEMP are not passed through to the child process. npm, node, and npx need a writable HOME for the npm cache and TMP for scratch files; without them they error with EACCES against /nonexistent or fall over silently.

The existing code passes these three variables only inside a cfg!(windows) guard, so Linux/macOS hosts running stdio MCP servers via npx hit the failure.

Fix

Move the HOME/TMP/TEMP passthrough above the cfg!(windows) guard so it applies on every platform, and remove the now-redundant entries from the Windows-only list.

Test notes

Verified locally on WSL2 (Ubuntu, rustc 1.95.0) by rebuilding against this branch and confirming three npx-backed stdio MCP servers initialize cleanly from a fresh spawn:

  • @gongrzhe/server-gmail-autoauth-mcp — 19 tools
  • agentmail-mcp — 11 tools
  • exa-mcp-server — 3 tools

All three would fail on the parent branch without this patch (npm cache write errors against a non-existent HOME).

Windows behavior is unchanged — the same three variables are still passed, just via the universal block instead of the Windows-only block.

Scope

Pure runtime fix, one file, 10 lines. No API surface changes, no new dependencies, no behavioral change on Windows.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant