Skip to main content
Glama
mcp-wsl-exec
by spences10

mcp-wsl-exec

用于在 Windows 的 Linux 子系统 (WSL) 环境中执行命令的模型上下文协议 (MCP) 服务器。此服务器通过内置的安全功能和验证来提供安全的命令执行。

特征

  • 🔒 在 WSL 环境中安全执行命令

  • ⚡ 内置安全功能:

    • 危险命令检测

    • 指令确认系统

    • 路径遍历预防

    • 命令清理

  • 📁 工作目录支持

  • ⏱️ 命令超时功能

  • 🔍 详细的命令输出格式

  • ❌错误处理和验证

  • 🛡️ 防止 shell 注入

Related MCP server: Windows CLI MCP Server

配置

此服务器需要通过您的 MCP 客户端进行配置。以下是不同环境的示例:

克莱恩配置

将其添加到您的 Cline MCP 设置中:

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

Claude桌面配置

将其添加到您的 Claude Desktop 配置中:

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

API

服务器实现了两个 MCP 工具:

执行命令

在 WSL 中执行带有安全检查和验证的命令。

参数:

  • command (字符串,必需):要执行的命令

  • working_dir (字符串,可选):命令执行的工作目录

  • timeout (数字,可选):超时时间(以毫秒为单位)

确认命令

确认执行安全检查标记的危险命令。

参数:

  • confirmation_id (字符串,必需):从execute_command收到的确认ID

  • confirm (布尔值,必需):是否继续执行命令

安全功能

危险命令检测

服务器维护着一个潜在危险的命令列表,这些命令在执行前需要明确确认,包括:

  • 文件系统操作(rm、rmdir、mv)

  • 系统命令(关机、重启)

  • 包管理(apt、yum、dnf)

  • 文件重定向(>、>>)

  • 权限更改(chmod、chown)

  • 还有更多...

命令清理

所有命令都经过清理以防止:

  • Shell元字符注入

  • 路径遍历尝试

  • 主目录引用

  • 危险的命令链

发展

设置

  1. 克隆存储库

  2. 安装依赖项:

pnpm install
  1. 构建项目:

pnpm build
  1. 以开发模式运行:

pnpm dev

出版

该项目使用变更集进行版本管理。要发布:

  1. 创建变更集:

pnpm changeset
  1. 对包进行版本控制:

pnpm changeset version
  1. 发布到 npm:

pnpm release

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

执照

MIT 许可证 - 有关详细信息,请参阅LICENSE文件。

致谢

Available Tools

7 tools
confirm_commandConfirm dangerous command executionC
Destructive

Confirm dangerous command execution

Inputs: confirmation_id (required), confirm (required).

execute_commandExecute a command in WSL (use read-only tools when possible)C
Destructive

Execute a command in WSL (use read-only tools when possible)

Inputs: command (required), working_dir, timeout.

get_directory_infoGet directory contents and infoC
Read-only

Get directory contents and info

Inputs: path, details.

get_disk_usageGet disk space informationC
Read-only

Get disk space information

Inputs: path.

get_environmentGet WSL environment variablesC
Read-only

Get WSL environment variables

Inputs: filter.

get_system_infoGet WSL system informationC
Read-only

Get WSL system information

Inputs: no named parameters.

list_processesList running processes in WSLC
Read-only

List running processes in WSL

Inputs: filter.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: confirm_command handles safety checks, execute_command runs commands, get_directory_info lists files, get_disk_usage shows storage, get_environment retrieves variables, get_system_info provides system details, and list_processes shows running processes. There is no overlap or ambiguity between these functions.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case (e.g., confirm_command, execute_command, get_directory_info). The naming is uniform throughout, using 'get_' for retrieval operations and clear action-object pairs.

    Tool Count5/5

    With 7 tools, the server is well-scoped for WSL execution and system monitoring. Each tool serves a specific and necessary function, covering command execution, file management, system diagnostics, and process handling without being overly sparse or bloated.

    Completeness4/5

    The toolset provides strong coverage for WSL operations, including command execution, file system inspection, system monitoring, and environment management. A minor gap exists in file manipulation (e.g., create/delete files) or network-related tools, but core workflows are well-supported.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A secure MCP server for executing whitelisted shell commands with resource and timeout controls, designed for integration with Claude and other MCP-compatible LLMs.
      20
      389 npm
      7
      MIT
    • A
      license
      B
      quality
      F
      maintenance
      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.
      9
      419 npm
      265
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.
      9
      68 npm
      23
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      A secure MCP server for shell operations, terminal management, and process control, enabling AI assistants to safely execute commands and manage interactive sessions.
      13
      158 npm
      6
      MIT