Blog

Bridging Windows PyCharm MCP Server into WSL

When running projects inside WSL while using PyCharm on the Windows host, MCP clients executing in Linux cannot spawn the host executable because the Windows path (e.g., C:\Program Files\...) is treated in Linux as a single filename with no POSIX path separators. Furthermore, Windows environment variables do not automatically cross the boundary.

1. Create the Local Executable Shim

Create a wrapper script in your user binary directory (~/.local/bin/) whose literal filename matches the path string the MCP runner attempts to invoke.

 

mkdir -p "$HOME/.local/bin"

cat << 'EOF' > "$HOME/.local/bin/C:\Program Files\JetBrains\PyCharm 2026.2.2\bin\pycharm64.exe"
#!/bin/sh
# Expose the PyCharm MCP listener port to the Windows binary via WSLENV
export IJ_MCP_SERVER_PORT=64462
export WSLENV="IJ_MCP_SERVER_PORT:$WSLENV"

# Delegate execution to the Windows binary via WSL interop
exec "/mnt/c/Program Files/JetBrains/PyCharm 2026.2.2/bin/pycharm64.exe" "$@"
EOF

chmod +x "$HOME/.local/bin/C:\Program Files\JetBrains\PyCharm 2026.2.2\bin\pycharm64.exe"

 

2. Ensure ~/.local/bin Precedes Other Paths in WSL $PATH

Ensure $HOME/.local/bin is in your shell environment so exec.LookPath finds the shim:

 

# Add to ~/.bashrc or ~/.zshrc if not already present
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

 

3. Set the Port on the Windows Host (Fallback / Persistence)

If the MCP server in PyCharm binds to port 64462, persist it in the Windows user environment:

  1. Open PowerShell on Windows:

    [Environment]::SetEnvironmentVariable("IJ_MCP_SERVER_PORT", "64462", [EnvironmentVariableTarget]::User) 
  2. Restart PyCharm so the IDE process inherits the updated environment table.

4. Verification

Test the bridge directly from inside WSL:

 

which "C:\Program Files\JetBrains\PyCharm 2026.2.2\bin\pycharm64.exe"
# Expected: /home/<user>/.local/bin/C:\Program Files\JetBrains\PyCharm 2026.2.2\bin\pycharm64.exe

"$HOME/.local/bin/C:\Program Files\JetBrains\PyCharm 2026.2.2\bin\pycharm64.exe" --version
# Expected: Returns PyCharm version without "executable file not found in $PATH" or missing port errors