多代理服务器任务委托

一个MCP服务器,用于将任务委托到隔离的Proxmox虚拟机中执行,适用于不信任的代码运行、构建/测试管道和代理编排。

  • by EricGrill
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 EricGrill/mcp-multi-agent-server-delegation

使用说明

MCP多代理服务器委派

将任务委托给隔离的Proxmox VM,以实现安全的沙盒执行

快速开始 | 工具目录 | 代理类型 | 配置 | 建筑


这是什么?

将任务委托给隔离的Proxmox VM的MCP(模型上下文协议)服务器。通过自动清理和HTTP回调状态报告,在完全隔离的情况下运行不受信任的代码、长版本或用户提交的作业。

非常适合:

  • 不受信任的代码执行 -沙盒虚拟机隔离
  • 建造/测试管道 -每次清洁环境
  • 代理编排 -在隔离的虚拟机中生成Claude或自定义代理

需要 mcp proxmox管理员 用于VM管理。


快速开始

1.添加到克劳德代码:

{
  "mcpServers": {
    "delegation": {
      "command": "node",
      "args": ["/path/to/dist/index.js"],
      "env": {
        "CALLBACK_PORT": "8765",
        "PROXMOX_ADMIN_PATH": "/path/to/mcp-proxmox-admin/dist/index.js"
      }
    }
  }
}

2.或手动安装:

git clone https://github.com/EricGrill/mcp-multi-agent-server-delegation.git
cd mcp-multi-agent-server-delegation
npm install && npm run build
node dist/index.js

为什么使用这个?

特性 描述
完全VM隔离 每个作业都在自己的Proxmox VM中运行-完全沙盒化
代理灵活性 运行Claude、shell脚本或自定义二进制文件
自动清理 作业完成后临时VM被销毁
状态回调 通过VM的HTTP webhooks进行实时更新
超时保护 超时时作业被终止,虚拟机被销毁

工具目录

工具 说明
submit_job 提交作业清单以在隔离的VM中执行
get_job_status 检查作业的当前状态、进度和时间安排
get_job_result 从已完成的作业中检索输出、工件和错误
cancel_job 取消正在运行的作业并销毁其虚拟机
list_jobs 列出所有具有可选状态筛选器的作业

所有工具

作业提交

工具 参数 返回
submit_job manifest (任务、代理类型、文件、环境、资源、超时) job_id

作业监控

工具 参数 返回
get_job_status job_id 状态、进度、时间戳
get_job_result job_id 输出、伪影、持续时间、错误
list_jobs status? (筛选器) 作业摘要数组

作业控制

工具 参数 返回
cancel_job job_id 确认书

代理类型

类型 命令 用例
claude Claude CLI 人工智能驱动的任务执行
script Bash/Python 构建脚本,自动化
custom 任何二进制 专用工具、编译器

示例:克劳德代理人

{
  "task": "Review this codebase and create a summary",
  "agentType": "claude",
  "files": [
    { "path": "/workspace/code.py", "content": "base64..." }
  ],
  "timeout": 600
}

示例:脚本代理

{
  "task": "npm test",
  "agentType": "script",
  "agent": { "command": "bash -c 'cd /workspace && npm install && npm test'" },
  "timeout": 300
}

配置

环境变量

变量 描述 默认值
CALLBACK_PORT HTTP回调服务器的端口 8765
CALLBACK_HOST 回调URL的主机/IP 0.0.0.0
PROXMOX_ADMIN_PATH mcp-proxmox管理员的路径 --
DEFAULT_VM_TEMPLATE Proxmox模板名称 agent-template
DEFAULT_TIMEOUT 作业超时(秒) 3600
DEFAULT_CPU VM CPU内核 2
DEFAULT_MEMORY VM内存 2G
DEFAULT_DISK VM磁盘大小 10G
HEARTBEAT_THRESHOLD_SECONDS 过期作业检测 120
CLEANUP_INTERVAL_SECONDS 清理检查间隔 30

作业清单架构

interface JobManifest {
  task: string;                    // What to do
  agentType: 'claude' | 'script' | 'custom';
  agent?: {
    command?: string;              // For script/custom
    claudeModel?: string;          // For claude
  };
  files?: Array<{ path: string; content: string }>;
  env?: Record<string, string>;
  resources?: { cpu?: number; memory?: string; disk?: string };
  timeout?: number;
  lifecycle?: 'ephemeral' | 'persistent';
  statusMode?: 'simple' | 'detailed' | 'streaming';
}

建筑

┌─────────────────────────────────────────────────────────────────┐
│                        Claude / Agent                           │
└─────────────────────────────┬───────────────────────────────────┘
                              │ MCP Protocol
┌─────────────────────────────▼───────────────────────────────────┐
│                 MCP Delegation Server                           │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────────┐  │
│  │ Job Manager │  │ Status Store│  │ Callback HTTP Server    │  │
│  └─────────────┘  └─────────────┘  └─────────────────────────┘  │
└─────────────────────────────┬───────────────────────────────────┘
                              │ MCP Protocol
┌─────────────────────────────▼───────────────────────────────────┐
│                    mcp-proxmox-admin                            │
└─────────────────────────────┬───────────────────────────────────┘
                              │
┌─────────────────────────────▼───────────────────────────────────┐
│                     Proxmox VMs                                 │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐          │
│  │   Job VM 1   │  │   Job VM 2   │  │   Job VM 3   │          │
│  │  → Agent     │  │  → Agent     │  │  → Agent     │          │
│  │  → Callback  │  │  → Callback  │  │  → Callback  │          │
│  └──────────────┘  └──────────────┘  └──────────────┘          │
└─────────────────────────────────────────────────────────────────┘

工作生命周期

submit_job → pending → provisioning → running → success/failed/timeout
                                         ↓
                              VM destroyed (if ephemeral)

VM模板要求

您的Proxmox VM模板应包括:

  • 基本操作系统:Ubuntu/Debian最小
  • 包裹: curl, jq, bash
  • Claude CLI:为 claude 代理类型
  • Python/节点:用于脚本执行
  • 网络:访问回调服务器URL

发展

npm run dev      # Run in development mode
npm test         # Run tests
npm run build    # Build for production

项目结构

src/
├── index.ts           # Entry point
├── server.ts          # MCP server with tools
├── store.ts           # In-memory job store
├── callback-server.ts # HTTP callback receiver
├── proxmox-client.ts  # Proxmox MCP client wrapper
├── types.ts           # TypeScript types
├── schemas.ts         # Zod validation schemas
└── config.ts          # Configuration loader

安全注意事项

保护 实施
VM隔离 每个作业都在单独的Proxmox VM中
网络分段 隔离VLAN中的虚拟机(在Proxmox中配置)
超时 超时时自动终止作业
短暂的虚拟机 默认完成后销毁
资源限制 通过Proxmox实现CPU/内存/磁盘配额

相关项目


许可证

麻省理工学院