指挥-多点连接协议(或“主控-多点控制协议”,具体翻译可能根据上下文调整)
一个用于后台进程管理的模型上下文协议(MCP)服务器。commander-mcp 用 Rust 编写,提供了通过 MCP 协议使用 PMDaemon 运行、监控和管理后台进程的强大工具。
特点/功能
- MCP协议支持基于官方构建 Rust MCP SDK(Minecraft协议兼容SDK,或根据具体上下文可译为“Rust版Minecraft协议客户端SDK”) (v0.7)
- PMDaemon 集成内置监控和日志管理的强大流程管理功能
- 流程管理工具运行、终止、重启和监控进程
- 持久日志进程输出被保存到文件中,可以随时读取
- 跨平台在Linux、Windows和macOS上均可运行
- 标准输入输出传输通过标准输入/输出进行通信,便于集成
- 异步运行时基于Tokio构建,实现高性能异步操作
- 类型安全利用Rust的类型系统提高可靠性
快速入门
先决条件
- Rust 1.70 或更高版本(用于从源代码构建)
- Cargo(随 Rust 附带)
安装
使用安装脚本(推荐)
安装commander-mcp最简单的方法是使用安装脚本:
curl -fsSL https://raw.githubusercontent.com/towry/commander-mcp/main/install.sh | bash或者先下载并检查脚本:
curl -fsSL https://raw.githubusercontent.com/towry/commander-mcp/main/install.sh -o install.sh
chmod +x install.sh
./install.sh支持的平台:
- macOS Apple Silicon(M1/M2/M3)- aarch64-apple-darwin
- Linux x86_64 - x86_64-unknown-linux-gnu 翻译为中文是:“Linux x86_64 架构 - x86_64 未知 Linux GNU 系统”。不过,通常我们简化为“Linux x86_64(x86_64-unknown-linux-gnu)”或直接说“Linux x86_64 系统”,因为“x86_64-unknown-linux-gnu”更多是编译器或构建系统中用来指定目标平台的标识,实际表述时并不常提及
该脚本将:
- 自动检测您的平台
- 下载最新发布的二进制文件
- 将其安装到
/usr/local/bin - 验证安装
从源代码构建
# Clone the repository
git clone https://github.com/towry/commander-mcp.git
cd commander-mcp
# Build the project
cargo build --release
# Run the server
cargo run --release使用方法
MCP服务器通过标准输入/输出使用MCP协议进行通信。您可以使用以下方法对其进行测试: MCP 检测器:
# Install MCP Inspector (requires Node.js)
npm install -g @modelcontextprotocol/inspector
# If installed via install script
npx @modelcontextprotocol/inspector commander-mcp
# If running from source
npx @modelcontextprotocol/inspector cargo run --release与Claude Desktop一起使用
要在Claude Desktop中使用此MCP服务器,请在您的Claude Desktop配置文件中添加以下内容:
macOS(苹果电脑操作系统): ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"commander": {
"command": "/usr/local/bin/commander-mcp"
}
}
}或者如果从源代码运行:
{
"mcpServers": {
"commander": {
"command": "cargo",
"args": ["run", "--release", "--manifest-path", "/path/to/commander-mcp/Cargo.toml"]
}
}
}可用工具
跑
在后台执行命令。
描述在后台运行一个命令。工具在启动后等待1秒以检测早期故障。返回进程ID,该ID可用于其他工具,并附带初始日志。
参数:
command(字符串):要运行的命令
示例:
{
"command": "npm run dev"
}回应 (JSON):
{
"process_id": "npm_run",
"command": "npm run dev",
"message": "Started process 'npm_run'",
"logs": "... initial log output (if available) ..."
}错误响应 (如果过程立即失败):
{
"error": "Process 'npm_run' failed to start. Logs:\n... error logs ..."
}注释:
- 该工具在启动过程后等待1秒以检测早期故障
- 如果在此时间内进程进入错误状态或停止状态,则返回错误
- 当有可用信息时,响应中会包含初始日志(最多100行)
- 这有助于检测诸如“地址已被使用”等问题,而无需调用
read单独使用工具
杀死
通过进程ID终止一个之前启动的进程。
参数:
process_id(字符串):要终止的进程ID
示例:
{
"process_id": "npm_run"
}回应 (JSON): (可翻译为)(JSON格式):
{
"process_id": "npm_run",
"message": "Stopped process 'npm_run'"
}“kill_all”可以翻译为“全部杀死”或“全部终止”。这个短语通常用于计算机或编程领域,表示终止所有相关的进程或实例
终止所有正在运行的进程。
参数无
示例调用时无需参数即可停止所有进程。
回应 (JSON): (JSON格式)
{
"stopped_count": 3,
"message": "Stopped 3 process(es)"
}阅读
通过进程ID读取其标准输出(stdout)的内容。
描述返回最近的日志输出(默认:最后1000行)。
参数:
process_id(字符串):要从中读取输出的进程IDlines(数字,可选):要返回的最大日志行数(默认:1000)
示例:
{
"process_id": "npm_run",
"lines": 500
}回应 (JavaScript 对象表示法):
{
"process_id": "npm_run",
"logs": "... log output here ..."
}重启
通过进程ID重启之前运行的进程。
参数:
process_id(字符串):要重启的进程ID
示例:
{
"process_id": "npm_run"
}回应 (JSON):
{
"process_id": "npm_run",
"message": "Restarted process 'npm_run'"
}列表
列出所有当前正在运行或已停止的进程。
参数无
回应 (JSON): (表示“JSON格式”)
{
"processes": [
{
"name": "npm_run",
"status": "running",
"pid": 12345,
"started_at": "2025-10-03 17:14:55 UTC",
"uptime_seconds": 120,
"restarts": 0,
"cpu_usage": 2.5,
"memory_mb": 45
}
]
}返回一个包含所有进程及其状态、进程ID(PID)、启动时间戳、运行时间、CPU使用率、内存使用率和重启次数的列表。
它是如何工作的
- 流程管理使用了用Rust编写的高性能进程管理器PMDaemon
- 进程ID基于命令关键字自动生成(例如。,
npm run dev→npm_run) - 持久日志所有处理输出均保存到日志文件中,可随时查看
- 实时监控跟踪CPU、内存使用情况以及进程状态
- 跨平台原生支持 Linux、Windows 和 macOS
主要特点
- 持续日志管理日志被保存到文件中,可以随时读取(而不仅仅是实时输出)
- 按进程访问日志可以读取特定进程的日志
- 无外部依赖PMDaemon 是一个 Rust 库,无需外部二进制文件
- 跨平台原生支持Windows、macOS和Linux系统
- 内置监控包含CPU和内存追踪功能
- 直接API通过Rust API进行程序化控制
发展
运行测试
# Run all tests
cargo test --all-features --verbose
# Run tests with output
cargo test -- --nocapture代码质量
这个项目遵循了Rust的最佳实践,并使用了常规提交规范来实现自动化发布。
# Format code (REQUIRED before committing)
cargo fmt --all
# Check formatting
cargo fmt --all -- --check
# Run linting
RUSTFLAGS="-D warnings" cargo clippy --workspace --all-targets --all-features --verbose仅使用命令
这个项目包括一个 justfile 便于开发:
# Format, lint, and test
just check
# Format code
just format
# Run linting
just lint
# Run tests
just test
# Build release binary
just build项目结构
commander-mcp/
├── src/
│ ├── main.rs # Entry point with MCP server setup
│ ├── process_server.rs # MCP tools implementation
│ └── process_manager.rs # PMDaemon wrapper for process management
├── Cargo.toml # Project dependencies and metadata
└── README.md # This file相关的
- PMDaemon(可译为“性能监控守护进程”或根据具体上下文调整,如“性能监控服务”等) - 为这个服务器提供支持的进程管理器库
- MCP协议 - 模型上下文协议规范
- Rust MCP SDK(注:MCP通常指“Modding Console Protocol”或类似含义,但具体含义可能根据上下文有所不同,此处保留原缩写形式) - Rust官方MCP SDK

