spences10

mcp-wsl-exec

Community spences10
Updated

A secure Model Context Protocol (MCP) server for executing commands in Windows Subsystem for Linux (WSL) with built-in safety features and validation

mcp-wsl-exec

A Model Context Protocol (MCP) server for executing commands inWindows Subsystem for Linux (WSL) environments. This server providessecure 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 areexamples 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 commandexecution
  • timeout (number, optional): Timeout in milliseconds

confirm_command

Confirm execution of a dangerous command that was flagged by safetychecks.

Parameters:

  • confirmation_id (string, required): Confirmation ID received fromexecute_command
  • confirm (boolean, required): Whether to proceed with the commandexecution

Safety Features

Dangerous Command Detection

The server maintains a list of potentially dangerous commands thatrequire 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

MCP Server ยท Populars

MCP Server ยท New

    TalkToHumans

    LinkedIn MCP Server

    Safe LinkedIn MCP server for Claude, ChatGPT, Cursor & Codex. Your Agents read LinkedIn DMs, search your network, enrich profiles and draft messages you send.

    Community TalkToHumans
    bex-co

    Beancount.io Backend

    ๐Ÿ’ฐ Double-entry bookkeeping made easy โ€” plain-text accounting for humans and AI agents. Polished iOS & Android app built with React Native + Expo.

    Community bex-co
    nkapila6

    mcpsurfr

    Local web search MCP server, formerly mcp-local-rag. Multi-engine deep research with on-device re-ranking. โœจ no API keys โœจ

    Community nkapila6
    convex

    mcp.ts

    The open-source reactive database for app developers

    Community convex
    convex

    convex-backend

    The open-source reactive database for app developers

    Community convex