CMD Executor
这是一个基于 mcp.server 框架的 Windows CMD 命令执行工具,允许通过 MCP 协议远程执行 CMD 命令。
功能特性
- 远程命令执行: 通过
mcp.server提供的接口,安全地执行 Windows CMD 命令。 - 可配置的工作目录:
- 在调用
execute方法时,显式地传入cwd参数。 - 如果未指定
cwd参数,则优先使用项目根目录下的.env文件中定义的SANDBOX_PATH环境变量。
- 在调用
- UTF-8 JSON 响应: 返回的 JSON 响应使用 UTF-8 编码,直接包含 Unicode 字符。
- 错误处理: 详细的错误处理和日志记录,方便问题排查。
依赖
- python-dotenv:用于加载
.env文件中的环境变量。 - fast-mcp:
mcp.server的一个快速实现。
您可以使用 requirements.txt 文件来安装所有依赖:
pip install -r requirements.txt
安装步骤
-
克隆仓库: 将此仓库克隆到您的本地计算机。
-
安装依赖: 运行
pip install -r requirements.txt安装所有依赖。 -
配置
.env(建议): 在项目根目录下创建一个.env文件,并设置SANDBOX_PATH环境变量,以指定默认的工作目录:SANDBOX_PATH=Your_Desired_Path
配置说明
在您的 MCP 客户端的配置文件中添加或修改以下内容,以注册此服务器:
{
"mcpServers": {
"name": {
"type": "stdio",
"command": "your-path/python.exe",
"args": [
"your-program-path/main.py"
]
}
}
}
注意:
- 请将
your-path/python.exe替换为您的 Python 解释器的实际路径。 - 请将
your-program-path/main.py替换为main.py文件的实际路径。 name字段可以替换为您喜欢的任何名称。
安全声明
请务必注意:
- 本工具具有潜在的安全风险。 允许远程执行 CMD 命令意味着攻击者可能利用此工具执行恶意操作,例如修改系统文件、安装恶意软件等。
- 请勿在生产环境中使用。 本工具主要用于学习和演示目的,请勿在生产环境中使用。
- 请采取必要的安全措施。 如果您必须使用此工具,请确保采取必要的安全措施,例如限制访问权限、使用强密码、定期审查日志等。
- 您将承担所有风险。 使用本工具所产生的一切后果由您自行承担,作者不承担任何责任。
许可
本项目使用 MIT 许可证。
Recommend MCP Servers 💡
deepsource-mcp-server
An MCP server that integrates with DeepSource to provide AI assistants with access to code quality metrics, issues, and analysis results
i18n-mcp-server
MCP server for managing internationalization by translating JSON-based language files using language models via stdio transport
sqlite-explorer
An MCP server that provides safe, read-only access to SQLite databases through Model Context Protocol (MCP). This server is built with the FastMCP framework, which enables LLMs to explore and query SQLite databases with built-in safety features and query validation.
postmancer
An experimental MCP server Rest Client intended to be a replacement of tools postman & insomnia
mcp-system-health
Provides real-time health and performance metrics for remote Linux servers via SSH, integrating with AI assistants like Claude through the MCP protocol.
mcp-server-notify
Send system notification when Agent task is done.