0

Using VScode with WSL trying to configure custom MCP servers, the vscode server itself runs a non-interactive shell. A non-interactive login shell means using bash -c or similar.

A non-interactive shell should run ~/.profile and ~/.bash_profile (if present). HOWEVER vscode server for the stdio shell execute (via WSL remote) does not seem to run .profile, .bash_profile, etc. instead it completely creates a shell and it strictly sets a bunch of VSCODE_* and WSL_* type variables and it's own PATH. The path it uses is completely stupid, it's a transmuted windows path including spaces which obviously are handled & undesired in Bash/Unix.

I want to add a MCP Server and call something like "npx", "bunx" or "uvx" which is installed as a user in a ~/.local/bin or similar (ex: ~/.bun/bin, ~/.cargo/bin, ~/.nvm/versions/node/v22.15.0/bin) .. I don't want to specify the full path to my home directory.

it's not clear how to modify the $PATH of VScode, it'd also be bonus if I could do something like stripping the injected windows paths with spaces since they aren't going to work.

# this will remove Windows paths with spaces in them
export PATH=$(echo "$PATH" | tr ':' '\n' | grep -v '^/mnt/c' | paste -sd ':' -)

According to the docs VSCode server WSL automatically inherits the windows path(s), in the MCP settings, it is possible to override the path, but the ${env:PATH} interpolation happens in Windows and ends up with C:\blabla

        "mcp": {
            "servers": {
                "testenv": {
                    "command": "/usr/bin/env",
                    "env": {
                        "PATH":"~/.local/bin:${env:PATH}"
                    },
                    "type": "stdio"
                }

Fwiw, I am able to run bunx by specifying ~/.bun/bin/bunx in the cmd so that's my solution for now. I'm just curious how to customize the vscode server or customize it's enviroment initialization.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.