mcp-wsl-exec

Integrations

  • Allows execution of commands in Windows Subsystem for Linux (WSL) environments with security features

  • Provides protection against shell injection and secure command execution with safety features

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:

{ "mcpServers": { "mcp-wsl-exec": { "command": "npx", "args": ["-y", "mcp-wsl-exec"] } } }

Claude Desktop Configuration

Add this to your Claude Desktop configuration:

{ "mcpServers": { "mcp-wsl-exec": { "command": "npx", "args": ["-y", "mcp-wsl-exec"] } } }

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 execute
  • working_dir (string, optional): Working directory for command execution
  • timeout (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_command
  • confirm (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

  1. Clone the repository
  2. Install dependencies:
pnpm install
  1. Build the project:
pnpm build
  1. Run in development mode:
pnpm dev

Publishing

The project uses changesets for version management. To publish:

  1. Create a changeset:
pnpm changeset
  1. Version the package:
pnpm changeset version
  1. Publish to npm:
pnpm release

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

Acknowledgments

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

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.

  1. Features
    1. Configuration
      1. Cline Configuration
      2. Claude Desktop Configuration
    2. API
      1. execute_command
      2. confirm_command
    3. Safety Features
      1. Dangerous Command Detection
      2. Command Sanitization
    4. Development
      1. Setup
      2. Publishing
    5. Contributing
      1. License
        1. Acknowledgments

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            An MCP server to run commands.
            Last updated -
            2
            204
            104
            JavaScript
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            A 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 -
            1
            68
            Python
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            A secure MCP server for executing whitelisted shell commands with resource and timeout controls, designed for integration with Claude and other MCP-compatible LLMs.
            Last updated -
            20
            143
            2
            TypeScript
            MIT License
          • A
            security
            A
            license
            A
            quality
            A 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 -
            9
            350
            105
            JavaScript
            MIT License

          View all related MCP servers

          ID: wv6df94kb8