Skip to main content
Glama

Remote Command MCP Server

远程命令 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

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

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

  1. 特征
    1. 安装
      1. 用法
        1. 工具:execute\_remote\_command
        2. 示例
        3. 安全注意事项
        4. 跨平台命令处理
        5. 错误处理
      2. 发展
        1. 项目结构
        2. 建筑
      3. 贡献
        1. 执照

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            A secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
            Last updated -
            1
            74
            Python
            MIT License
            • Apple
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.
            Last updated -
            Python
          • A
            security
            A
            license
            A
            quality
            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.
            Last updated -
            9
            350
            105
            JavaScript
            MIT License
          • A
            security
            F
            license
            A
            quality
            A Model Context Protocol server implementation that enables secure remote command execution via SSH, with features for managing and using SSH credentials.
            Last updated -
            5
            3
            JavaScript

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/deepsuthar496/Remote-Command-MCP'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server