The mcp-wsl-exec server allows for secure execution of commands within Windows Subsystem for Linux (WSL) environments with built-in safety features and validation.
- Execute Commands: Run commands in WSL with optional timeout and working directory settings
- Security Features: Implement dangerous command detection, command sanitization, path traversal prevention, and shell injection protection
- Confirmation System: Manage execution of flagged commands requiring confirmation
- Error Handling: Provide validation and detailed output formatting
mcp-wsl-exec
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.
Features
- 🔒 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
Configuration
This server requires configuration through your MCP client. Here are examples for different environments:
Cline Configuration
Add this to your Cline MCP settings:
Claude Desktop Configuration
Add this to your Claude Desktop configuration:
API
The server implements two MCP tools:
execute_command
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_command
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
Safety Features
Dangerous Command Detection
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...
Command Sanitization
All commands are sanitized to prevent:
- Shell metacharacter injection
- Path traversal attempts
- Home directory references
- Dangerous command chaining
Development
Setup
- Clone the repository
- Install dependencies:
- Build the project:
- Run in development mode:
Publishing
The project uses changesets for version management. To publish:
- Create a changeset:
- Version the package:
- Publish to npm:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see the LICENSE file for details.
Acknowledgments
- Built on the Model Context Protocol
- Designed for secure WSL command execution
local-only server
The server can only run on the client's local machine because it depends on local resources.
A secure MCP server for Windows Subsystem for Linux environments, facilitating safe command execution with extensive validation and protection against vulnerabilities like shell injection and dangerous commands.
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.Last updated -174PythonMIT License
- AsecurityAlicenseAqualityAn enhanced Windows CLI MCP server providing unrestricted system access capabilities, designed for trusted environments with full system access requirements.Last updated -43503TypeScriptMIT License
- AsecurityAlicenseAqualityAn MCP server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface for LLMs.Last updated -1058PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.Last updated -9350105JavaScriptMIT License