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?

@RomneyDa
Copy link
Collaborator

@fbricon wondering if just need to add asdf to the getEnvPathFromUserShell utility?

const command = ${process.env.SHELL} -l -c 'for f in ~/.zprofile ~/.zshrc ~/.bash_profile ~/.bashrc; do [ -f "$f" ] && source "$f" 2>/dev/null; done; echo $PATH';

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Sep 30, 2025
@fbricon fbricon changed the title fix: use all process.env values to launch MCP fix: use common process.env values to launch MCP Sep 30, 2025
@fbricon
Copy link
Contributor Author

fbricon commented Sep 30, 2025

I switched to using common ENV vars. That should be enough for most MCPs hopefully.
I don't think asdf requires special treatment.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Oct 1, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 1, 2025
@RomneyDa
Copy link
Collaborator

RomneyDa commented Oct 6, 2025

@fbricon I have a feeling that eventually we'll end up just doing your original full pass through implementation, but while we wrap our heads around MCP security this should work. Thanks for the contribution

@RomneyDa RomneyDa merged commit 2883f91 into continuedev:main Oct 6, 2025
51 of 54 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Oct 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2025
@sestinj
Copy link
Contributor

sestinj commented Oct 8, 2025

🎉 This PR is included in version 1.27.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor

sestinj commented Oct 12, 2025

🎉 This PR is included in version 1.24.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor

sestinj commented Oct 15, 2025

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer released size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants