-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Description
The Codacy MCP (Model Context Protocol) server fails to execute when running inside a WSL (Windows Subsystem for Linux) environment. The server attempts to run the wsl command from within WSL itself, which is not supported and causes the operation to fail.
Environment
Operating System: WSL2 (Arch Linux)
VS Code: Running in WSL environment
MCP Server: Codacy MCP Server
Shell: zsh
Steps to Reproduce
Set up WSL2 environment (any Linux distribution)
Install and configure VS Code in WSL
Configure Codacy MCP server in VS Code Copilot MCP settings
Attempt to use any Codacy MCP tool/function through GitHub Copilot
Observe the error
Expected Behavior
The Codacy MCP server should detect it's running in a WSL environment and use native Linux commands instead of trying to invoke wsl.
Actual Behavior
The MCP server fails with an error related to the wsl command not being available or functioning properly inside the WSL environment itself.
Error Pattern:
MCP server attempts to execute wsl command
Command fails because you cannot run wsl from within WSL
This breaks all Codacy MCP functionality
Root Cause Analysis
The issue appears to be in the MCP server's environment detection logic:
Incorrect Environment Detection: The server likely detects Windows as the host OS but fails to recognize it's running inside WSL
Command Path Resolution: The server tries to use Windows-style command invocation (wsl) instead of direct Linux commands
Missing WSL Context Awareness: No fallback mechanism when wsl command is not available/functional
Impact
Complete MCP Functionality Loss: All Codacy MCP tools become unusable in WSL environments
Development Workflow Disruption: Forces users to either:
Switch to native Windows (losing Linux dev environment benefits)
Manually install and configure Codacy CLI as workaround
Abandon Codacy integration entirely
Workaround
Manual installation of Codacy CLI binary:
Suggested Fix
The MCP server should implement proper WSL detection:
Environment Detection Logic
The server should check for:
version containing "Microsoft" or "WSL"
$WSL_DISTRO_NAME environment variable
c directory existence
wsl.exe availability vs functionality
Additional Context
This affects all WSL distributions (Ubuntu, Arch, Debian, etc.)
Issue is specific to MCP server architecture, not Codacy CLI itself
Manual CLI installation works perfectly in same environment
Problem is reproducible across different WSL setups
Priority
High - This completely breaks Codacy MCP functionality for WSL users, which represents a significant portion of the development community using VS Code.