远程命令 MCP 服务器是一个模型上下文协议(MCP)服务器,支持在不同操作系统上执行远程命令。它提供了统一的接口来执行 shell 命令,能自动处理 Windows 和 Unix-like 系统之间的平台特定差异。
远程命令 MCP 服务器允许你跨不同操作系统执行远程命令,自动处理平台差异。以下是开始使用的步骤:
git clone https://github.com/deepsuthar496/Remote-Command-MCP
cd remote-command-server
npm install
npm run build
config.json 文件中,并放在 src 目录下。config.json 文件中,并放在 src 目录下。execute_command("ls")
execute_command("ls", { cwd: "/path/to/directory" })
execute_command("dir", { platform: "unix" }) // 自动转换为 `ls`
execute_command("ls | grep .txt", { shell: "/bin/sh" })
跨平台命令执行:自动转换平台特定命令,例如:
dirls错误处理:提供详细的错误信息,包括 stdout 和 stderr 的输出。
如果命令执行失败,将会收到错误信息:
{
"content": [
{
"type": "text",
"text": "Command execution error: Command failed with exit code 1"
}
],
"isError": true
}
remote-command-server/
├── src/
│ └── index.ts # 主要服务器实现文件
├── package.json
├── tsconfig.json
└── README.md
npm run build
此命令会编译 TypeScript 代码并在 build 目录中生成执行文件。
git checkout -b feature/amazing-feature)。git commit -m 'Add some amazing feature')。git push origin feature/amazing-feature)。此项目遵循 MIT License,具体内容请参阅 LICENSE 文件。