Skip to main content
Glama
mcp-agent-hub

mcp-agent-hub

by LianXia233

mcp-agent-hub

让多个 Agent 客户端(Claude Code、Cursor、MiMo、Aider 等,可 2 个以上)在本机或局域网互通协作的 MCP 服务。

协作模型:手动设主 + 其余全是子代理

  • 手动指定一个主理人(master):在某个客户端启动时 --role-type master,或调用 set_master

  • 其余全部是子代理(subagent):数量不限;入网时自动挂靠到当前主理人

  • 支持本地(多个 stdio 进程共享一个 SQLite)和局域网(Streamable HTTP,多客户端接入同一 Hub)

                ┌─────────────────────┐
                │  主理人 master       │  ← 手动指定(--role-type master / set_master)
                │  拆解 · 派单 · 盯进度 │
                └──────────┬──────────┘
           dispatch_task   │   report / escalate
        ┌──────────────────┼──────────────────┐
        ▼                  ▼                  ▼
 ┌────────────┐     ┌────────────┐     ┌────────────┐
 │ 子代理 A    │     │ 子代理 B    │     │ 子代理 C    │  ← 可任意多个
 │ coder      │     │ reviewer   │     │ tester     │
 └────────────┘     └────────────┘     └────────────┘
        │                  │                  │
        └──────────────────┼──────────────────┘
                           ▼
              共享黑板 remember/recall
              任务看板 · 消息收件箱 (SQLite)

Related MCP server: Project Relay

安装

依赖:Python 3.12+,推荐 uv。

git clone <repo-url> mcp-agent-hub
cd mcp-agent-hub
uv sync
# 或仅运行时
uv pip install -e .

快速开始(Linux 示例)

场景 1:本机多客户端(stdio + 共享 DB)

所有客户端指向同一个 AGENT_HUB_DB 即可互通。主理人手动设在其中一个客户端上。

export AGENT_HUB_DB=/tmp/agent-hub.db

# ① 手动设主:这一端是主理人
mcp-agent-hub stdio --name boss --role-type master --role orchestrator

# ② 其余全是子代理(可开任意多个)
mcp-agent-hub stdio --name coder-1    --role-type subagent --role implementer --capabilities code,test
mcp-agent-hub stdio --name reviewer-1 --role-type subagent --role reviewer    --capabilities review,docs
mcp-agent-hub stdio --name tester-1   --role-type subagent --role tester      --capabilities test

主理人客户端配置(examples/01-master.json):

{
  "mcpServers": {
    "agent-hub": {
      "command": "mcp-agent-hub",
      "args": ["stdio", "--name", "boss", "--role-type", "master", "--role", "orchestrator"],
      "env": { "AGENT_HUB_DB": "/tmp/agent-hub.db" }
    }
  }
}

子代理客户端配置(换 --name / --role 即可再开 N 个,见 examples/02-04):

{
  "mcpServers": {
    "agent-hub": {
      "command": "mcp-agent-hub",
      "args": ["stdio", "--name", "coder-1", "--role-type", "subagent", "--role", "implementer", "--capabilities", "code,test"],
      "env": { "AGENT_HUB_DB": "/tmp/agent-hub.db" }
    }
  }
}

场景 2:局域网 / 跨机器(Streamable HTTP)

一台机器起 Hub,其他机器的 Agent 客户端都连上来:

mcp-agent-hub serve --host 0.0.0.0 --port 8765 --db /var/lib/agent-hub/hub.db
# 或
./scripts/run-serve.sh 0.0.0.0 8765

客户端配置:

{
  "mcpServers": {
    "agent-hub": {
      "url": "http://192.168.1.10:8765/mcp"
    }
  }
}

HTTP 模式下多个客户端共享一个服务进程。各方先 join_hub 登记身份(主理人可 set_master),工具也可带 agent 参数指定身份。

手动设主的两种方式

  1. 启动时指定:mcp-agent-hub stdio --name boss --role-type master

  2. 运行时指定:任意 Agent 调用 set_master(name="boss")(exclusive=true 会把其他人降为子代理,并改挂汇报线)

之后 join_hub(role_type="subagent") 的新 Agent 会自动挂靠到当前主理人。

协作流程(1 主 + N 子)

步骤

主理人

子代理(×N)

1. 设主

--role-type master 或 set_master

join_hub(role_type=subagent) 自动挂靠

2. 派单

dispatch_task(title, assignee=coder-1)

收到 order 消息

3. 领会

—

my_assignments / read_inbox

4. 执行

team_status 看全员负载

report_progress(task_id, 50, note)

5. 同步

broadcast / send_message

send_message / escalate

6. 沉淀

remember / recall

remember / recall

7. 交付

收到 report

complete_task(task_id, result)

多个子代理可同时干活;任务池模式用 claim_task 抢占,避免重复劳动。

MCP 工具一览

分组

工具

说明

身份

whoami / join_hub / list_agents / set_status

登记与在场

设主

set_master

手动指定谁是主理人

主理人

dispatch_task / team_status

派单、盯全员负载

子代理

my_assignments / claim_task / report_progress / complete_task / escalate

领活、认领、汇报、交付、上报

任务

create_task / list_tasks / update_task

看板与改派(支持 parent_id 子任务树)

消息

send_message / broadcast / read_inbox / mark_read

点对点、全员广播、房间

房间

create_room / join_room / list_rooms

频道协作

黑板

remember / recall / forget

跨 Agent 共享记忆(带版本)

诊断

hub_stats / activity_log

总览与事件流

环境变量

变量

默认

说明

AGENT_HUB_DB

./agent-hub.db

SQLite 路径(多客户端务必同一文件)

AGENT_NAME

—

默认 Agent 名(也可用 --name)

AGENT_ROLE_TYPE

subagent

master 或 subagent(主理人请设为 master)

AGENT_ROLE

—

职责描述

AGENT_CAPABILITIES

—

能力标签,逗号分隔

AGENT_REPORTED_TO

—

子代理汇报的主理人名字(不填则自动挂靠)

开发

uv sync
uv run ruff check src tests
uv run ruff format src tests
uv run pyright src
uv run pytest
uv run python tests/e2e_mcp_handshake.py

设计说明

  • 手动设主:--role-type master / set_master / join_hub(role_type=master) 三种入口。

  • 自动挂靠:子代理入网时若未指定 reported_to,自动指向当前主理人。

  • 派单:dispatch_task 建任务并给子代理发 order 消息;可派给任意多个子代理。

  • 回报:report_progress / complete_task 自动给主理人发 report;escalate 标 blocked 并发 escalation。

  • 抢占:claim_task 事务内抢占,失败会提示当前持有者。

  • 存储:SQLite + WAL,多进程/多客户端并发安全。

  • 传输:stdio(本机多客户端共享 DB);serve(局域网 Streamable HTTP)。

参考与联调示例(Reference)

本仓库 reference/ 目录收录真实联调中沉淀的问题总结与可直接复用的客户端测试脚本,覆盖通讯、派发、执行、响应、深度探针等完整链路:

  • reference/hub-integration-reference.md — 安装与联调问题总结:dispatch_task 的 assignee 注册前置约束、streamable_http 客户端 API 差异、轮询按 task_id 精确匹配、真实客户端行为修正、serve 进程生命周期、stdio 与 serve 为独立 Hub 等。

  • reference/test_comm.py — 双客户端 HTTP 全链路通讯(派单→领活→回报→共享黑板 remember/recall→私信)。

  • reference/test_dispatch.py — 向真实子代理派单并验证 order 派令抵达;结束自动取消清理。

  • reference/test_exec.py — 受控子代理 执行→响应 闭环 + 真实客户端轮询。

  • reference/test_probe.py — 针对真实客户端的派发+响应深度探针(order / 私信 / 广播三种触发)。

  • reference/test_dowork.py — 「响应 + 实际做任务」终验:受控子代理真实计算并回报真实产出;真实客户端执行并回报。

运行前置

pip install "mcp[cli]"      # 提供 mcp.client.streamable_http
python reference/test_comm.py

提示:脚本默认 URL="http://127.0.0.1:8765/mcp",需先 mcp-agent-hub serve --host 0.0.0.0 --port 8765 起 Hub。dispatch_task 要求 assignee 已 join_hub 注册(详见 reference/hub-integration-reference.md 第一节)。

License

MIT

Available Tools

27 tools
activity_logC

查看最近协作事件流(派单、认领、汇报等)。

Inputs: limit, action. Returns: result

broadcastB

向全部 Agent 广播一条消息(一对多通知)。kind 可用 announce/order/report 等。

Inputs: content (required), kind, agent, task_id. Returns: object

claim_taskA

子代理:认领 open/blocked 任务,避免重复劳动。已有负责人则会失败并提示持有者。

Inputs: task_id (required), agent. Returns: object

complete_taskB

完成任务并附交付说明。会自动给主理人发一条 report 消息。

Inputs: task_id (required), agent, result. Returns: object

create_roomC

创建协作房间(频道)并自动加入。

Inputs: name (required), agent, description. Returns: object

create_taskB

创建任务(不指定负责人则进入 open 池,供子代理 claim_task 认领)。

Inputs: title (required), tags, agent, assignee, +3 more. Returns: object

dispatch_taskB

主理人专用:向子代理派发任务(工作单)。会创建任务并自动给子代理发一条 order 消息。可传 parent_id 挂到父任务下形成子任务树。

Inputs: title (required), assignee (required), tags, agent, +3 more. Returns: object

escalateA

子代理专用:遇到阻塞时上报主理人。会把任务标为 blocked(若提供 task_id)并给 master 发一条 escalation 消息。

Inputs: message (required), agent, task_id. Returns: object

forgetC

删除共享黑板上的某个 key。

Inputs: key (required), agent. Returns: object

hub_statsB

Hub 总览:Agent/任务/消息/黑板计数与 DB 路径。

Inputs: no named parameters. Returns: object

join_hubB

登记或更新 Agent 身份。手动设主:role_type=master;其余客户端用 role_type=subagent,会自动挂靠到当前主理人(也可显式传 reported_to)。支持任意多个子代理同时在线。

Inputs: name (required), role, metadata, role_type, +2 more. Returns: object

join_roomC

加入协作房间。

Inputs: room (required), agent. Returns: object

list_agentsB

列出已登记 Agent。可按 role_type(master/subagent)或 status 过滤。

Inputs: status, role_type, include_offline. Returns: result

list_roomsC

列出房间及成员。

Inputs: no named parameters. Returns: result

list_tasksB

列出任务。可按 status/assignee/tag/parent_id 过滤。status ∈ ('open', 'claimed', 'in_progress', 'blocked', 'done', 'cancelled')。

Inputs: tag, limit, status, assignee, +2 more. Returns: result

mark_readB

标记消息已读。不传 message_ids 则标记全部已可见消息。

Inputs: agent, message_ids. Returns: object

my_assignmentsB

子代理:查看分配给自己的任务(默认不含已完成)。

Inputs: agent, include_done. Returns: result

read_inboxB

读取收件箱。默认返回发给自己、广播和已加入房间的消息。unread_only=true 只看未读;kinds 可过滤消息类型;task_id 可只看某任务相关。

Inputs: room, agent, kinds, limit, +3 more. Returns: result

recallB

读取共享黑板。可按精确 key、key 前缀或 tag 查询。

Inputs: key, tag, limit, prefix. Returns: result

rememberB

写入共享黑板(跨 Agent 记忆)。同一 key 会递增 version 并保留历史。

Inputs: key (required), value (required), tags, agent, +1 more. Returns: object

report_progressA

子代理:向主理人汇报任务进度(0-100)。会自动给 master 发一条 report 消息。可同时更新 status(如 in_progress/blocked)。

Inputs: task_id (required), progress (required), note, agent, +1 more. Returns: object

send_messageB

发送消息。to 可为 Agent 名/'*'(广播),room 为频道名;kind 可用 ('message', 'order', 'report', 'question', 'answer', 'announce', 'handoff', 'escalation', 'system')(order=派令,report=汇报)。task_id 可关联任务。

Inputs: content (required), to, kind, room, +3 more. Returns: object

set_masterA

手动指定某个 Agent 为唯一主理人。exclusive=true 时把其他 master 降为 subagent,并把子代理的汇报线改到新的主理人。用法:set_master(name='boss')。

Inputs: name (required), exclusive. Returns: object

set_statusC

设置自己的在线状态:('online', 'away', 'busy', 'offline')。

Inputs: status (required), note, agent. Returns: object

team_statusA

查看全体 Agent(多个主理人 + 全部子代理/peer)及其当前任务负载,以及 Hub 统计。适合主理人总览,也适合任何 Agent 看队伍在干什么。

Inputs: no named parameters. Returns: object

update_taskC

更新任务字段(status/description/result/assignee/priority)。主理人可用来改派。

Inputs: task_id (required), agent, result, status, +3 more. Returns: object

whoamiB

查看当前默认身份,以及 Hub 中已注册的主理人/子代理概况。

Inputs: agent. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 27 tools

    Disambiguation3/5

    Most tools target distinct resources, but several boundaries overlap: broadcast vs send_message with '*', team_status vs list_agents vs hub_stats, and report_progress vs update_task vs complete_task vs escalate. The descriptions help clarify intended use, but an agent could still misselect among these related coordination tools.

    Naming Consistency4/5

    Tool names consistently use snake_case and are mostly readable verb_noun patterns such as create_room, dispatch_task, send_message, and complete_task. A few names are noun-only or phrase-like (whoami, team_status, hub_stats, my_assignments), which is a minor deviation rather than a structural inconsistency.

    Tool Count2/5

    At 27 tools, the surface is heavy for a single MCP server and exceeds the typical 3-15 well-scoped range. Some tools are convenience wrappers or overlapping views that could be consolidated, especially broadcast/send_message and team_status/list_agents/hub_stats.

    Completeness4/5

    The server covers the core multi-agent lifecycle: rooms, shared memory, agent identity, tasks, messaging, escalation, and stats. Minor gaps remain, such as leaving/deleting rooms, deregistering agents, or fetching a single task by ID, but agents can mostly work around these.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables agents and users to collaborate across rooms with shared tasks, messages, blackboards, documents, search, plugin registration, visualizations, OAuth helpers, and quantum-circuit simulation plus collaborative model training. It runs over STDIO by default, with optional HTTP/SSE deployment for container-based hosting.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding agents in different editors and MCP clients to share messages, project context, notes, task ownership, handoffs, and advisory file claims through a local SQLite-backed coordination server. Supports MCP stdio, MCP Streamable HTTP, a JSON HTTP API, and a local CLI for multi-project agent collaboration.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding-agent sessions on the same machine to collaborate locally and durably by exchanging requests, replies, and task results through an authenticated loopback server with SQLite-backed storage, joined via CLI or an MCP stdio bridge. It also handles message delivery by priority and wait time, deduplicates idempotent sends, enforces task versioning, and preserves artifacts by content hash.
      22 npm
      Apache 2.0
    • A
      license
      B
      quality
      B
      maintenance
      Lets multiple AI agents and parallel coding sessions share one memory and task ledger, so they can claim work instead of duplicating it, resume each other's handoffs and reasoning, and use credentials without ever seeing the keys. Connects assistants such as Claude Code, Codex, Cursor, Gemini, ChatGPT and custom agents over MCP, backed by a single local SQLite file or a self-hosted Postgres hub.
      41
      MIT