这是一个强大的模型上下文协议(MCP)服务器,可让 Claude Desktop 在 Windows 系统的任何 WSL2 Linux 发行版中执行 bash 命令和脚本。该服务器具备通用的 Linux 兼容性、智能的发行版检测功能以及全面的安全措施。
# 1. 克隆仓库
git clone https://github.com/yourusername/linux-bash-mcp-server.git
cd linux-bash-mcp-server
# 2. 运行自动设置脚本
npm run fix
# 3. 重启 Claude Desktop
# 4. 开始在 Claude 中使用 Linux 命令!
| 工具 | 描述 | 示例用法 |
|---|---|---|
execute_bash_command |
运行单个 bash 命令 | ps aux | grep nginx |
execute_bash_script |
带参数执行 bash 脚本 | 运行监控脚本 |
create_bash_script |
创建新的 bash 脚本 | 生成自动化脚本 |
list_directory |
列出目录内容 | 浏览文件系统 |
get_system_info |
获取全面的系统信息 | 检查操作系统、内存、磁盘使用情况 |
check_wsl_status |
检查 WSL 和发行版状态 | 验证连接性 |
git clone https://github.com/yourusername/linux-bash-mcp-server.git
cd linux-bash-mcp-server
npm run fix
# 安装依赖
npm install
# 运行交互式设置
npm run setup
# 测试功能
npm test
# 检查问题
npm run debug
# 验证配置
npm run check-config
服务器会自动检测您的 WSL 发行版并进行自我配置。您也可以在 config.json 中进行手动配置:
{
"wslDistribution": "auto-detect",
"defaultTimeout": 30000,
"scriptTimeout": 60000,
"maxBufferSize": 10485760,
"debugMode": false
}
| 命令 | 描述 |
|---|---|
npm run fix |
自动修复常见问题并进行设置 |
npm run setup |
交互式配置向导 |
npm run debug |
详细诊断 |
npm run test |
测试所有功能 |
npm run check-config |
验证配置 |
npm start |
启动 MCP 服务器 |
配置完成后,您可以在 Claude Desktop 中使用以下命令:
npm run fix # 自动解决常见问题
npm run debug # 详细诊断
未找到 WSL
wsl --install
wsl --install -d Ubuntu
缺少依赖项
npm install
配置问题
npm run check-config
npm run setup
服务器无法启动
npm run debug
详细解决方案请参阅 TROUBLESHOOTING.md。
该服务器可与以下服务器无缝协作:
linux-bash-mcp-server/
├── src/
│ └── index.js # 主 MCP 服务器
├── test/
│ └── test.js # 全面测试
├── examples/
│ ├── system_info.sh # 示例监控脚本
│ └── file_operations.sh # 示例文件操作脚本
├── config.json # 服务器配置
├── setup.js # 交互式设置
├── debug.js # 诊断工具
├── quick-fix.js # 自动修复工具
├── check-config.js # 配置检查器
└── README.md # 本文件
欢迎贡献代码!请按照以下步骤进行:
本项目采用 MIT 许可证,请参阅 LICENSE 文件获取详细信息。
为 Claude Desktop 和 Linux 社区用心打造 ❤️
⭐ 如果您觉得这个仓库有用,请给它加星!