Linux系统工具MCP服务器

mcpd是一个将100多种Linux系统管理工具暴露为MCP(模型上下文协议)服务器的服务,适用于需要通过代理进行集中管理的Linux系统环境。

  • by felixlheureux
  • Rust
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 cortexd-labs/mcpd

使用说明

微软认证专业开发人员

Linux MCP服务器 --将100多种Linux系统管理工具作为 主控程序 (模型上下文协议)服务器。

mcpd仅在标准输入/输出上运行(stdio)并且被设计为通过以下方式执行 神经元 (联邦代理),不直接暴露于网络。


建筑

┌──────────────────────────────────────┐
│  mcpd (stdio)                        │
│                                      │
│  ┌────────────┐  ┌────────────────┐  │
│  │            │  │  tools/        │  │
│  │ server.rs  │  │                │  │
│  │ (Router)   │  │  system.rs     │  │
│  │            │  │  network.rs    │  │
│  └────────────┘  │  file.rs       │  │
│                  │  container.rs  │  │
│  ┌────────────┐  │  package.rs    │  │
│  │ linux/     │  │  identity.rs   │  │
│  │            │  │  storage.rs    │  │
│  │ systemd.rs │  │  schedule.rs   │  │
│  │ network.rs │  │  security.rs   │  │
│  │ desktop.rs │  │  ...           │  │
│  └────────────┘  └────────────────┘  │
└──────────────────────────────────────┘
         ▲
         │ stdio
         │
    neurond (federation proxy)
  • server.rs --MCP服务器核心,通过stdio本地处理路由请求
  • tools/ --每个工具域一个模块。输入验证,纯Rust逻辑
  • linux/ --低级操作系统访问:D-Bus代理(systemd、桌面)、Netlink、, /proc 和 /sys 解析
  • types.rs --键入 #[derive(Serialize)] 所有工具的响应结构(编译时字段安全)
  • daemon.rs --PID文件管理和优雅的SIGTERM/SIGINT关闭
  • deploy/mcpd.service --用于独立测试和记录预期安全上下文的systemd单元

工具

域 工具 描述
system.* 信息、重启、sysctl、环境、正常运行时间 系统信息和控制
process.* 列表、检查、杀死、信号、顶部、树、nice 流程管理
service.* 列表、状态、启动、停止、重新启动、日志、启用 systemd单元控制
log.* 尾部、搜索、流、单位 日志访问
network.* 接口、端口、连接、dns、防火墙、路由 网络堆栈
file.* 读、写、信息、搜索、mkdir、chmod、tail 文件操作
container.* 列表、检查、日志、执行、启动、停止 Docker容器
package.* 列表、搜索、信息、安装、删除、更新 APT包管理
identity.* 用户、组、whoami 用户/组信息
storage.* 磁盘、装载、使用、智能 磁盘和smart
schedule.* 列表、添加、删除 Crontab管理
security.* certs、open_ports、suid 安全检查
hardware.* pci、usb 硬件枚举
desktop.* 通知、剪贴板、媒体、窗口、设置、应用程序 桌面集成
time.* 信息,同步 NTP时间信息

安全

  • 工具隔离 --设计为在代理后面运行,如 neurond 它处理mTLS、身份验证和策略检查。
  • 输入验证 --外壳元字符被拒绝。路径遍历被规范化阻塞。
  • 路径满负荷 --文件操作仅限于安全前缀。敏感文件始终被阻止。
  • 仅限本地主机 --通过stdio在本地执行。从不直接接触网络。

入门指南

先决条件

  • 带systemd的Linux(Debian 12/Ubuntu 22.04+)
  • 锈蚀1.75+
  • D-Bus系统插座(systemd主机上的标准配置)
  • 对于容器工具:Docker守护进程
  • 对于桌面工具:D-Bus会话套接字

构建与运行

git clone https://github.com/cortexd-labs/mcpd.git
cd mcpd
cargo build --release

# Run locally (uses stdio transport)
cargo run

服务器直接通过以下方式进行通信 stdio.

测试

cargo test          # 198 tests
cargo clippy -- -D warnings

使用标准MCP检验员进行测试:

npx -y @modelcontextprotocol/inspector
# Choose stdio transport, select mcpd binary path

相关项目

  • 神经元 --在命名空间前缀下聚合mcpd和其他MCP服务器的联合代理
  • 皮质 --舰队指挥(计划中)

许可证

麻省理工学院