A Model Context Protocol (MCP) server for executing commands in Windows Subsystem for Linux (WSL) environments. This server provides secure command execution with built-in safety features and validation.
- 🔒 Secure command execution in WSL environments
- ⚡ Built-in safety features:
- Dangerous command detection
- Command confirmation system
- Path traversal prevention
- Command sanitization
- 📁 Working directory support
- ⏱️ Command timeout functionality
- 🔍 Detailed command output formatting
- ❌ Error handling and validation
- 🛡️ Protection against shell injection
This server requires configuration through your MCP client. Here are examples for different environments:
Add this to your Cline MCP settings:
{
"mcpServers": {
"mcp-wsl-exec": {
"command": "npx",
"args": ["-y", "mcp-wsl-exec"]
}
}
}
Add this to your Claude Desktop configuration:
{
"mcpServers": {
"mcp-wsl-exec": {
"command": "npx",
"args": ["-y", "mcp-wsl-exec"]
}
}
}
The server implements two MCP tools:
Execute a command in WSL with safety checks and validation.
Parameters:
command
(string, required): Command to executeworking_dir
(string, optional): Working directory for command executiontimeout
(number, optional): Timeout in milliseconds
Confirm execution of a dangerous command that was flagged by safety checks.
Parameters:
confirmation_id
(string, required): Confirmation ID received from execute_commandconfirm
(boolean, required): Whether to proceed with the command execution
The server maintains a list of potentially dangerous commands that require explicit confirmation before execution, including:
- File system operations (rm, rmdir, mv)
- System commands (shutdown, reboot)
- Package management (apt, yum, dnf)
- File redirections (>, >>)
- Permission changes (chmod, chown)
- And more...
All commands are sanitized to prevent:
- Shell metacharacter injection
- Path traversal attempts
- Home directory references
- Dangerous command chaining
- Clone the repository
- Install dependencies:
pnpm install
- Build the project:
pnpm build
- Run in development mode:
pnpm dev
The project uses changesets for version management. To publish:
- Create a changeset:
pnpm changeset
- Version the package:
pnpm changeset version
- Publish to npm:
pnpm release
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.
- Built on the Model Context Protocol
- Designed for secure WSL command execution