Skip to content

Conversation

fbricon
Copy link
Contributor

@fbricon fbricon commented Sep 11, 2025

My nodejs versions are managed by asdf. Continue fails to resolve npx to launch MCPs because it doesn't pass the proper system environment variables (basically, just process.env.PATH is passed):

Screenshot 2025-09-11 at 14 44 03

The proposed fix merges options.transport.env with all process.env variables before launching the MCP. I can't see a reason why other env vars would be ignored by default. But, if that is an issue, we could get away with adding env.HOME and maybe a couple other variables.


Summary by cubic

Fixes MCP launch failures caused by missing env vars. MCP processes now inherit the full process.env, so tools like npx resolve correctly with asdf and similar managers.

  • Bug Fixes
    • Pass all process.env values to stdio transports and merge with options.transport.env.
    • Keep using PATH from the user shell on non-Windows when available.
    • Prevent failures from incomplete environments (e.g., asdf-managed Node).

@fbricon fbricon requested a review from a team as a code owner September 11, 2025 12:49
@fbricon fbricon requested review from RomneyDa and removed request for a team September 11, 2025 12:49
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 11, 2025
const env = {
...processEnv,
...(options.transport.env ?? {}),
};
Copy link
Contributor

@panyamkeerthana panyamkeerthana Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to pass every environment variable to the subprocess or just a few important ones?

@RomneyDa
Copy link
Collaborator

RomneyDa commented Sep 25, 2025

@fbricon @panyamkeerthana merging this has been delayed because of security concerns (i.e. @panyamkeerthana's comment). Just want to reduce the chance a rogue MCP goes haywire on users.

I'd +1 to getting 80% of the way there with HOME and other common vars that are usually safe

@fbricon would any vars specifically fix your case? Would that be transferable to most users?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants