WSL Exec MCP server

Provides secure command execution in WSL with built-in safety features like path validation, timeouts, and error handling.
Back to servers
Setup instructions
Provider
Scott Spence
Release date
Jan 23, 2025
Language
TypeScript
Package
Stats
3.9K downloads
15 stars

The Model Context Protocol (MCP) server for Windows Subsystem for Linux enables Claude Desktop users on Windows to interact with their WSL environments. This tool provides both read-only information gathering about your WSL system and secure command execution capabilities with built-in safety features.

Installation

To use the MCP-WSL-Exec server, you'll need to configure it through your MCP client. The setup process is straightforward:

Claude Desktop Configuration

Add the following configuration to your Claude Desktop settings:

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

Cline Configuration

If you're using Cline, add this to your MCP settings:

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

Available Tools

The server provides several MCP tools divided into two categories:

Read-Only Information Tools

These tools provide context about your WSL environment without making changes:

get_system_info

Retrieves system information including OS version, kernel, and hostname.

Parameters: None

get_directory_info

Lists directory contents and file information.

Parameters:

  • path (string, optional): Directory path (defaults to current directory)
  • details (boolean, optional): Show detailed information (permissions, sizes, etc.)

get_disk_usage

Displays disk space information.

Parameters:

  • path (string, optional): Specific path to check (defaults to all filesystems)

get_environment

Shows environment variables.

Parameters:

  • filter (string, optional): Filter pattern to search for specific variables

list_processes

Lists running processes.

Parameters:

  • filter (string, optional): Filter by process name

Command Execution Tools

These tools allow you to run commands and make changes to your WSL environment:

execute_command

Executes 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

Note: Potentially dangerous commands will require confirmation.

confirm_command

Confirms 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

The server includes several safety mechanisms to protect your system:

Dangerous Command Detection

The server identifies potentially dangerous commands that require explicit confirmation before execution, including:

  • File system operations (rm, rmdir, mv)
  • System commands (shutdown, reboot)
  • Package management operations (apt, yum, dnf)
  • File redirections (>, >>)
  • Permission changes (chmod, chown)
  • And others

Command Sanitization

All commands are sanitized to prevent:

  • Shell metacharacter injection
  • Path traversal attempts
  • Home directory references
  • Dangerous command chaining

This ensures safer operation when executing commands in your WSL environment.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-wsl-exec" '{"command":"npx","args":["-y","mcp-wsl-exec"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later