mcp-agent-collaboration

mcp-agent-collaboration

In-memory MCP server for cooperative collaboration between separate agents, enabling topic-based messaging and coordination via tools like create_topic, join_topic, send_message, read_messages, and check_in.

Category
访问服务器

README

MCP Agent Collaboration

In-memory MCP server for cooperative collaboration between separate agents.

The intended workflow is:

  1. A coordinator/main agent starts this MCP server as a dedicated Streamable HTTP process.
  2. The coordinator creates a topic and joins it.
  3. Secondary agents join the same topic with friendly names such as builder or reviewer.
  4. Agents exchange direct and broadcast messages through MCP tools.
  5. Idle agents long-poll with read_messages.
  6. Working agents use check_in to report progress and read messages in one call.

Messages are held only in memory. Restarting the server clears all topics, members, and messages. After a restart, old join_token values are invalid and agents must re-join.

Install

python3 -m venv .venv
. .venv/bin/activate
pip install -e .

Run

mcp-agent-collaboration --host 127.0.0.1 --port 8000

The MCP endpoint is:

http://127.0.0.1:8000/mcp

For Codex, add a Streamable HTTP MCP server in config.toml:

[mcp_servers.agent_collaboration]
url = "http://127.0.0.1:8000/mcp"
tool_timeout_sec = 600

Set tool_timeout_sec high enough for your preferred long-poll duration. The server itself does not impose a maximum wait; the MCP client/tool runtime may still have its own timeout.

Codex Autostart

For Codex, the preferred setup is the stdio autostart proxy. Codex launches the proxy as a normal stdio MCP server; the proxy starts the shared Streamable HTTP server on localhost if it is not already running, then forwards tool calls to it.

From this source checkout:

codex mcp add agent_collaboration \
  --env PYTHONPATH=/home/vkolotoff/projects/mcp-agent-collaboration/src \
  -- python3 -m mcp_agent_collaboration.autostart_stdio

After installing the package, this shorter form is enough:

codex mcp add agent_collaboration -- mcp-agent-collaboration-stdio

Defaults:

  • MCP_AGENT_COLLAB_HOST=127.0.0.1
  • MCP_AGENT_COLLAB_PORT=8000
  • MCP_AGENT_COLLAB_PATH=/mcp
  • MCP_AGENT_COLLAB_LOG=/tmp/mcp-agent-collaboration.log

Override them with --env only when needed.

To install the package into your user-level Python environment:

python3 -m pip install --user /home/vkolotoff/projects/mcp-agent-collaboration
codex mcp add agent_collaboration -- mcp-agent-collaboration-stdio

codex mcp add writes to the global Codex MCP config by default, so the server is available to future Codex sessions after restart.

Tools

create_topic

Create a topic by string name.

{
  "topic": "build-123"
}

join_topic

Join a topic with a friendly agent name. The returned join_token is required for message operations.

{
  "topic": "build-123",
  "agent_name": "reviewer",
  "role": "secondary",
  "create_if_missing": true
}

Agent names are unique within a topic. The literal name all is reserved for broadcast messages.

send_message

Send a direct message to one agent or a broadcast to all agents currently joined.

{
  "join_token": "opaque-token",
  "recipient": "reviewer",
  "body": {
    "type": "review_request",
    "task_id": "task-001",
    "summary": "Implementation is ready for review."
  }
}

Use "recipient": "all" for broadcast. Broadcast recipients are snapshotted at send time, so agents who join later do not receive older broadcasts. The sender receives its own broadcast by default because it is also a joined agent; set include_self to false to opt out.

Compact output is the default:

{
  "id": "msg_123",
  "stored": true
}

Pass "verbosity": "full" only when you need topic, sender, and recipient metadata.

read_messages

Read and consume pending messages for the joined agent.

{
  "join_token": "opaque-token",
  "timeout_ms": 600000,
  "max_messages": 20
}

Compact output is the default:

{
  "timed_out": false,
  "messages": [
    {
      "id": "msg_123",
      "from": "reviewer",
      "body": {
        "type": "review_result",
        "status": "approved"
      }
    }
  ]
}

Pass "verbosity": "full" only when you need topic, recipient, timestamp, or broadcast snapshot metadata.

Long-poll behavior:

  • If messages are already pending, return immediately.
  • If no messages are pending and timeout_ms > 0, hold the request open until a relevant message arrives or the requested timeout elapses.
  • If timeout_ms is 0, return immediately with pending messages or an empty timeout response.
  • The server does not impose its own maximum timeout.
  • Returned messages are consumed.

Deletion behavior:

  • Direct messages are deleted after the recipient reads them.
  • Broadcast messages are deleted after every send-time recipient has read them.
  • If an agent leaves a topic, it is removed from unread recipient sets so old broadcasts can be cleaned up.

check_in

Optionally send a message and read pending messages in one tool call. This is the preferred work-loop tool for secondary agents because it avoids a separate send_message call followed by read_messages.

{
  "join_token": "opaque-token",
  "timeout_ms": 0,
  "recipient": "coordinator",
  "body": {
    "type": "progress",
    "task_id": "task-001",
    "done": "Added compact read tests.",
    "next": "Update docs.",
    "blockers": []
  }
}

Compact output:

{
  "sent": {
    "id": "msg_123",
    "stored": true
  },
  "timed_out": true,
  "messages": []
}

Omit body to use check_in as a compact read. Use a long timeout_ms when idle, and timeout_ms: 0 or a short timeout between work chunks. body: null is treated the same as omitting body, so it cannot be used as a sent message payload. If body is provided with a large timeout_ms, the send confirmation is returned only when the read side wakes or times out; use timeout_ms: 0 for fire-and-return progress updates.

leave_topic

Leave a topic and stop receiving future messages.

{
  "join_token": "opaque-token"
}

list_topics

List topics with member and pending-message counts.

list_topic_members

List members in a topic.

Collaboration Contract

This MCP does not forcibly interrupt running agents. Messages wake agents that are currently blocked in read_messages; agents that are actively working see messages at their next check-in.

Secondary agents must:

  • Join with a clear role name.
  • Send a readiness message to the coordinator.
  • Work in bounded chunks.
  • Use check_in to send progress to the coordinator and read messages at reasonable intervals.
  • Always poll after completing a work chunk, after sending a review result, and after reporting task completion.
  • Treat urgent or cancellation messages as priority instructions when seen.
  • Send task_complete when done.
  • Ask the coordinator for more work, then enter idle long-poll mode.

The coordinator must:

  • Start the server.
  • Create the topic.
  • Join as coordinator or another clear main-agent name.
  • Assign tasks to secondary agents.
  • Watch progress, blockers, completion messages, and requests for more work.
  • Poll after sending assignments, clarifications, cancellations, or follow-up work so queued replies are not missed.

Recommended message body types:

  • presence
  • task_assignment
  • progress
  • task_complete
  • request_more_work
  • review_request
  • review_result
  • cancel_task
  • interrupt

interrupt is cooperative. It is not forced preemption.

Test

python3 -m unittest discover -s tests

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选