Token导航 LogoToken导航TokenDH.com
Cluster Execution MCP Server logo
运维云端stdio官方级别未说明来源级核验

Cluster Execution MCP Server

MCP Server

一个用于在AGI代理集群中分布式执行命令的服务,支持自动任务路由、多节点支持和并行执行等功能。

工具数

4

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude集群管理Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

marc-shade

提供方

marc-shade

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -e .

详细介绍

集群执行MCP服务器

集群感知命令执行,用于跨AGI代理集群的分布式任务路由。

版本: 0.2.0

特性

  • 自动任务路由:根据负载、能力和要求将命令路由到最佳节点
  • 多节点支持:macpro51(Linux x86_64)、mac studio(macOS ARM64)、macbook air(macOS ARM六十四)、推理节点
  • 动态IP解析:mDNS、DNS和带缓存的回退方法
  • 加强安保:无shell注入、基于环境的配置、命令验证
  • SSH连接验证:具有可配置超时的重试逻辑
  • 并行执行:跨集群分发命令以实现最大吞吐量

安装

cd /mnt/agentic-system/mcp-servers/cluster-execution-mcp
pip install -e .

# For development:
pip install -e ".[dev]"

配置

Claude代码配置

添加到 ~/.claude.json:

{
  "mcpServers": {
    "cluster-execution": {
      "command": "/mnt/agentic-system/.venv/bin/python3",
      "args": ["-m", "cluster_execution_mcp.server"]
    }
  }
}

环境变量

所有配置都通过环境变量外部化:

变量默认值描述
CLUSTER_SSH_USERmarcssh远程执行的SSH用户名
CLUSTER_SSH_TIMEOUT5SSH连接超时(秒)
CLUSTER_SSH_CONNECT_TIMEOUT2初始SSH连接超时(秒)
CLUSTER_SSH_RETRIES2SSH重试次数
CLUSTER_CPU_THRESHOLD40卸载的CPU使用率百分比阈值
CLUSTER_LOAD_THRESHOLD4卸载的平均负载阈值
CLUSTER_MEMORY_THRESHOLD80卸载的内存使用百分比阈值
CLUSTER_CMD_TIMEOUT300命令执行超时(秒)
CLUSTER_STATUS_TIMEOUT5状态检查超时(秒)
CLUSTER_IP_CACHE_TTL300IP分辨率缓存TTL(秒)
CLUSTER_GATEWAY192.168.1.1用于路由检测的网关IP
CLUSTER_DNS8.8.8.8用于IP检测的DNS服务器
AGENTIC_SYSTEM_PATH/mnt/agentic-system数据库的基本路径

节点配置

节点主机名和IP可以自定义:

变量默认值描述
CLUSTER_MACPRO51_HOSTmacpro51.localMac Pro主机名
CLUSTER_MACPRO51_IP192.168.1.2Mac Pro回退IP
CLUSTER_MACSTUDIO_HOSTMarcs-Mac-Studio.localMac Studio主机名
CLUSTER_MACSTUDIO_IP192.168.1.6Mac Studio回退IP
CLUSTER_MACBOOKAIR_HOSTMarcs-MacBook-Air.localMacBook Air主机名
CLUSTER_MACBOOKAIR_IP192.168.1.7MacBook Air后备IP
CLUSTER_INFERENCE_HOSTserver.local推理节点主机名
CLUSTER_INFERENCE_IP192.168.1.8推理节点回退IP

MCP工具

工具说明
cluster_bash使用自动集群路由执行bash命令
cluster_status获取当前集群状态和负载分布
offload_to明确地将命令路由到特定节点
parallel_execute跨节点并行运行多个命令

用法示例

自动路由

# Heavy commands auto-route to least loaded node
result = await cluster_bash("make -j8 all")

# Simple commands run locally
result = await cluster_bash("ls -la")

部队特定要求

# Force Linux execution
result = await cluster_bash("docker build .", requires_os="linux")

# Force x86_64 architecture
result = await cluster_bash("cargo build", requires_arch="x86_64")

显式节点路由

# Run on Linux builder
result = await offload_to("podman run -it ubuntu:22.04", node_id="macpro51")

# Run on Mac Studio
result = await offload_to("swift build", node_id="mac-studio")

并行执行

# Run tests across cluster
results = await parallel_execute([
    "pytest tests/unit/",
    "pytest tests/integration/",
    "pytest tests/e2e/"
])

群集状态

# Get cluster health before heavy operations
status = await cluster_status()
# Returns:
# {
#   "local_node": "macpro51",
#   "nodes": {
#     "macpro51": {"cpu_percent": 15.2, "memory_percent": 45.3, ...},
#     "mac-studio": {"cpu_percent": 8.1, "memory_percent": 32.1, ...},
#     ...
#   }
# }

集群节点

节点操作系统架构功能特性
macpro51Linuxx86_64docker、podman、raid、nvme、编译、测试、tpu编译、测试,容器化,基准测试
mac-studiomacOSARM64编排、协调、时态、mlx gpu、arduino编排、协作、监控
macbook-airmacOSARM64研究、文档、分析研究、文件、移动
inferencemacOSARM64ollama,推理,模型服务,llm-apiollama推理,模型服务器

卸载模式

与这些模式匹配的命令会自动卸载:

  • 构建: make, cargo, npm, yarn, pnpm
  • 测试: pytest, jest, mocha, test
  • 编译: gcc, g++, clang
  • 集装箱: docker, podman, kubectl
  • 文件操作: rsync, scp, tar, zip, find, grep -r

本地命令:

  • 简单: ls, pwd, cd, echo, cat, head, tail, which, type

安全

壳体防喷

所有命令都使用 subprocess.run() 在可能的情况下使用列表参数:

# SAFE: List arguments
subprocess.run(["ssh", "-o", "ConnectTimeout=5", f"{user}@{ip}", command])

# Complex shell commands are validated before execution

命令验证

针对危险模式验证命令:

  • rm -rf /
  • rm -rf /*
  • > /dev/sda
  • 叉式炸弹
  • 还有更多。..

SSH配置

  • StrictHostKeyChecking=accept-new -接受新主机,但验证返回的主机
  • BatchMode=yes -脚本编写的非交互模式
  • 可配置的超时和重试

发展

运行测试

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# With coverage
pytest tests/ --cov=cluster_execution_mcp --cov-report=html

项目结构

cluster-execution-mcp/
├── src/cluster_execution_mcp/
│   ├── __init__.py      # Package exports
│   ├── config.py        # Configuration, validation, node definitions
│   ├── router.py        # Task routing and IP resolution
│   └── server.py        # FastMCP server and tools
├── tests/
│   ├── conftest.py      # Pytest fixtures
│   ├── test_config.py   # Config module tests (29 tests)
│   ├── test_router.py   # Router module tests (21 tests)
│   └── test_server.py   # Server and tool tests (21 tests)
└── pyproject.toml       # Package configuration

CLI接口

# Submit a command
cluster-router submit "make -j8 all"

# Check task status
cluster-router status 

# Show cluster status
cluster-router cluster-status

监控

操作前检查群集运行状况:

User: "Show me cluster status"

Claude Code: cluster_status tool

Output:
  macpro51:
    CPU: 45.2%
    Memory: 18.3%
    Load: 3.21
    Status: healthy

  mac-studio:
    CPU: 22.1%
    Memory: 54.7%
    Load: 2.15
    Status: healthy

  macbook-air:
    CPU: 12.8%
    Memory: 38.2%
    Load: 1.03
    Status: healthy

故障排除

MCP服务器未加载:

# Check config
cat ~/.claude.json | jq '.mcpServers["cluster-execution"]'

# Test server import
python3 -c "from cluster_execution_mcp.server import main; print('OK')"

节点不可达:

# Test SSH connectivity
ssh marc@macpro51.local hostname
ssh marc@Marcs-Mac-Studio.local hostname

# Check with fallback IP
ssh marc@192.168.1.183 hostname

命令超时:

# Increase timeout via environment
export CLUSTER_CMD_TIMEOUT=600  # 10 minutes
export CLUSTER_SSH_TIMEOUT=10   # 10 seconds

更新日志

v0.2.0版本

  • 新功能:

- 使用pyproject.toml进行适当的包结构 - 基于环境的配置(无硬编码凭据) - 具有验证功能的共享配置模块 - SSH连接的重试逻辑 - 带TTL的IP解析缓存 - 推理节点支持

  • 安全改进:

- 消除了shell注入漏洞 - 危险模式的命令验证 - IP验证拒绝环回/Docker/本地链接 - SSH主机密钥处理(接受新密钥)

  • 代码质量:

- 整个代码库中的完整类型提示 - 除特定例外条款外,其余条款均已替换 - 添加了全面的日志记录 - 71个模拟单元测试

  • 错误修复:

- 修复了darwin/macos操作系统别名处理问题 - SSH操作中的正确超时处理 - 针对失败操作的更好错误消息

v0.1.0

  • 具有基本集群执行的初始版本

许可证

麻省理工学院

______________________________________________________________________

AGI代理系统的一部分

另请参见:

  • 节点聊天MCP-节点间通信
  • 增强内存MCP-带RAG的持久内存
  • 代理运行时MCP-目标和任务队列

目录标签

目录标签

PythonClaude集群管理分布式计算本地部署任务路由SSH执行并行处理

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP