Remote Command MCP Server

MIT License
  • Linux

Integrations

  • Enables execution of Chocolatey commands for Windows package management through the remote command interface

  • Provides ability to execute Git commands remotely with support for repository operations like status checks and working directory specification

  • Supports execution of Linux-specific commands with automatic command normalization between Windows and Unix-like systems

远程命令 MCP 服务器

一个模型上下文协议 (MCP) 服务器,支持跨不同操作系统执行远程命令。该服务器提供统一的接口来执行 Shell 命令,自动处理 Windows 和类 Unix 系统之间的平台特定差异。

特征

  • 跨平台命令执行
  • Windows 和 Unix 之间的自动命令规范化
  • 内置错误处理和输出流
  • 工作目录规范支持
  • 特定于平台的 shell 选择

安装

  1. 克隆存储库:
git clone https://github.com/deepsuthar496/Remote-Command-MCP cd remote-command-server
  1. 安装依赖项:
npm install
  1. 构建服务器:
npm run build
  1. 在您的设置文件中配置 MCP 服务器:

对于 VSCode Cline 扩展( cline_mcp_settings.json ):

{ "mcpServers": { "remote-command": { "command": "node", "args": ["path/to/remote-command-server/build/index.js"], "disabled": false, "autoApprove": [] } } }

用法

该服务器提供了一个名为execute_remote_command的工具,它可以在主机上执行任何有效的shell命令。其中包括:

  • 系统命令
  • 包管理器命令(apt、yum、chocolatey 等)
  • 开发工具(git、npm、python等)
  • 文件操作
  • 网络命令
  • 服务管理
  • 以及系统上可用的任何其他 CLI 命令

工具:execute_remote_command

参数:

  • command (必需):可以在主机操作系统上执行的任何有效 shell 命令
  • cwd (可选):命令执行的工作目录

示例

  1. 系统信息:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "systeminfo" // Windows // or "uname -a" // Linux } </arguments> </use_mcp_tool>
  1. 包管理:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "npm list -g --depth=0" // List global NPM packages } </arguments> </use_mcp_tool>
  1. 网络运营:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "netstat -an" // Show all network connections } </arguments> </use_mcp_tool>
  1. Git操作:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "git status", "cwd": "/path/to/repo" } </arguments> </use_mcp_tool>
  1. 文件操作:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "ls -la", // List files with details "cwd": "/path/to/directory" } </arguments> </use_mcp_tool>
  1. 流程管理:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "ps aux" // List all running processes (Unix) // or "tasklist" // Windows equivalent } </arguments> </use_mcp_tool>
  1. 服务控制:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "systemctl status nginx" // Check service status (Linux) // or "sc query nginx" // Windows equivalent } </arguments> </use_mcp_tool>

安全注意事项

由于此服务器可以执行任何系统命令,请考虑以下安全措施:

  1. 访问控制:仅限受信任的用户访问 MCP 服务器
  2. 命令验证:在应用程序逻辑中执行命令之前验证命令
  3. 工作目录:使用cwd参数将命令执行限制在特定目录中
  4. 环境:谨慎使用修改系统设置或敏感文件的命令
  5. 权限:使用适当的用户权限运行 MCP 服务器

跨平台命令处理

服务器自动处理特定于平台的差异:

  1. 命令翻译:
    • lsdir (根据平台自动转换)
    • 适合每个平台的正确管道运算符格式
  2. 外壳选择:
    • Windows:使用cmd.exe
    • Unix/Linux:使用/bin/sh

错误处理

服务器提供详细的错误消息,并在响应中包含 stdout 和 stderr。如果命令失败,您将收到一条错误消息,其中包含有关错误的详细信息。

错误响应示例:

{ "content": [ { "type": "text", "text": "Command execution error: Command failed with exit code 1" } ], "isError": true }

发展

项目结构

remote-command-server/ ├── src/ │ └── index.ts # Main server implementation ├── package.json ├── tsconfig.json └── README.md

建筑

npm run build

这将编译 TypeScript 代码并在build目录中创建可执行文件。

贡献

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/amazing-feature
  3. 提交您的更改( git commit -m 'Add some amazing feature'
  4. 推送到分支( git push origin feature/amazing-feature
  5. 打开拉取请求

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议服务器,支持跨不同操作系统远程执行 shell 命令,自动处理 Windows 和类 Unix 系统之间的平台特定差异。

  1. Features
    1. Installation
      1. Usage
        1. Tool: execute_remote_command
        2. Examples
        3. Security Considerations
        4. Cross-Platform Command Handling
        5. Error Handling
      2. Development
        1. Project Structure
        2. Building
      3. Contributing
        1. License
          ID: mshw9wfbs6