Agent Comm

io.github.keshrath由 GitHub 帳號 keshrath 發布v1.3.12更新於 Oct 25, 2026

Agent intercommunication - messaging, channels, shared state, and real-time events

概覽

AI 產生的概覽

一個在本機執行的 Node.js MCP 伺服器,讓多個 AI 程式代理註冊、互相傳訊息、共用鍵值狀態並即時協調檔案編輯。

可以做什麼
註冊代理的名稱、能力與技能,並進行列出、探索、心跳、設定狀態或註銷,以及建立、加入、列出、封存頻道並查看成員與歷史。傳送直接、頻道、廣播、回覆和轉送訊息,支援重要性等級,依條件讀取收件匣和對話串,並可阻塞等待新訊息。讀寫具命名空間的共用鍵值儲存,包括用於鎖和旗標的原子比較交換。記錄和查看活動事件、偵測卡住的代理,並透過本機網頁儀表板和 REST/WebSocket 介面檢視全部內容。
適用情境
適合多個 AI 程式代理同時處理同一份程式碼庫時使用,讓它們互相探索、分工、避免重複修改和合併衝突,並在工作階段之間傳遞上下文。也適合希望透過工具呼叫前的鉤子強制執行檔案鎖和提交保護、而不是依賴模型自行協調的情境。
執行需求
透過 npx 或全域安裝 agent-comm 作為本機程序執行,需要 Node.js。儀表板和 REST 介面預設監聽本機 3421 埠,可透過 AGENT_COMM_PORT、AGENT_COMM_HOST 和 AGENT_COMM_RETENTION_DAYS 設定。資料儲存在本機 SQLite 資料庫中。若要自動協調,需在宿主設定中安裝隨附的鉤子指令碼。
安裝前請注意
伺服器會寫入、修改和刪除共用資料:訊息、狀態項目、代理以及清理操作都可能透過工具和 REST 介面被清除。鉤子指令碼會攔截檔案編輯以及 git commit、git push、npm install、npm test 等指令,並可能將其阻擋。將 AGENT_COMM_HOST 設為 0.0.0.0 會使儀表板和介面暴露到本機之外。首次 MCP 連線時會自動啟動儀表板。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Agent Comm,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

agent-comm

[License: MIT] [Node.js] [Tests] [MCP Tools] [REST Endpoints]

Agent-agnostic intercommunication system. Lets AI coding agents — Claude Code, Codex CLI, Gemini CLI, Aider, or any custom tool — talk to each other, share state, and coordinate work in real time.

Light ThemeDark Theme
[Overview][Dark Theme]

Why

When you run multiple AI agents on the same codebase — code review in one terminal, implementation in another, testing in a third — they have no idea the others exist. They duplicate work, create merge conflicts, and miss context.

Without agent-commWith agent-comm
DiscoveryAgents don't know others existAgents register with skills, discover by capability
CoordinationEdit the same file, create conflictsLock files/regions, divide work
CommunicationNone — each agent works blindMessages, channels, broadcasts
State sharingDuplicate work, missed contextShared KV store with atomic CAS
VisibilityNo idea what's happeningReal-time dashboard + activity feed shows everything

agent-comm gives them a shared communication layer:

  • Agents register with a name, capabilities, and skills so others can discover them
  • They discover each other by skill or tag for dynamic task routing
  • They exchange messages (direct, broadcast, or channel-based) to coordinate, with importance levels (low/normal/high/urgent) and optional ack
  • They poll their inbox with a blocking wait (comm_poll) so mid-flight peer signals are consumed without busy-looping
  • They share state (a key-value store with atomic CAS) for locks, flags, and progress
  • They log activity events (commits, test results, file edits) to a shared feed
  • They detect stuck agents — alive (heartbeat OK) but not making progress
  • They serialize file edits via the system-layer file-coord hook (see below) so parallel agents on shared files cannot clobber each other
  • A web dashboard shows everything in real time, including an Activity Feed tab

It works with any agent that supports MCP (stdio transport) or can make HTTP requests (REST API).

Why hooks, not just MCP tools

The MCP tools (comm_state, etc.) give agents the primitives to coordinate, but they don't enforce coordination — the agent has to remember to call them. Our bench measured what happens when you rely on the model's discretion: even with strict procedural prompting, Claude follows the protocol on the first claim cycle then drifts back to "be helpful, finish the task." Soft coordination is unreliable.

The fix is a pair of PreToolUse hooks shipped in scripts/hooks/: file-coord intercepts every Edit/Write/MultiEdit and claims the file via REST POST /api/state/file-locks/<path>/cas (blocks the edit if another agent holds the lock); bash-guard intercepts git commit, git push, npm install, npm test, builds, migrations, and dev-server starts and blocks/warns when they would conflict with another session's WIP. The protocol becomes infrastructure, not a prompt the agent might ignore.

The bench's headline pilot is multi-term-commit — directly modeling the daily pain of two terminal sessions on the same project. Session A edits two files but doesn't commit. Session B then edits two other files and runs git commit -am "my work". Without the hook, B's commit silently includes A's WIP. With the hook, B's commit is blocked at the bash layer with an actionable message, and B reacts (selective staging, restore, or coordinate). Bench result:

naive (no hook)with hooks
Commit purityMIXED — bar.js, baz.js, foo.js, qux.jsPURE — baz.js, qux.js
Wall time91.0s78.8s (-13%)
Total cost$0.774$0.591 (-24%)
OutcomeA's WIP silently committed under B's nameclean commit, no clobber

The hook is faster AND cheaper, not just safer. Reason: when agents lack coordination on shared workspaces, they read stale state, get confused mid-task, retry, and re-think. Serializing access and surfacing the conflict early removes that wasted thinking. Run npm run setup to install both hooks automatically; see Setup → File Coordination for manual install on Claude Code, OpenCode, or any custom MCP client. See bench/README.md for the measurement methodology.

How agent-comm fits together

agent-comm is a single Node process that exposes three transports — MCP stdio (for AI hosts), REST + WebSocket (for hooks, dashboards, custom scripts) — backed by a SQLite database in WAL mode. Hooks installed in your Claude Code (or other host) settings call the REST endpoint at localhost:3421 to claim file locks, query who-edited-what, and broadcast presence. The dashboard UI at the same port is a live view of every agent, message, channel, and shared-state entry. Multiple AI hosts can connect simultaneously and see the same world.

mermaid
graph TD    A["Agent A<br/>(Claude Code)"] -->|MCP stdio| COMM    B["Agent B<br/>(Codex CLI)"] -->|MCP stdio| COMM    C["Agent C<br/>(Custom script)"] -->|REST API| COMM    HK["PreToolUse hooks<br/>(file-coord, bash-guard)"] -->|REST cas| COMM
    subgraph COMM["agent-comm"]        D["Agents<br/>Register, discover, heartbeat"]        E["Messages<br/>Direct, broadcast, channels, threads"]        F["State<br/>Namespaced KV with CAS"]        G["Events<br/>Real-time pub/sub"]        D --> DB["SQLite DB<br/>WAL mode, FTS5 search"]        E --> DB        F --> DB        DB --> WS["WebSocket"]    end
    WS --> UI["Dashboard UI<br/>http://localhost:3421"]

Quick start

Install from npm

bash
npm install -g agent-comm

Or clone from source

bash
git clone https://github.com/keshrath/agent-comm.gitcd agent-commnpm installnpm run build

Option 1: MCP server (for any MCP-compatible AI host)

agent-comm runs as a stdio MCP server, so any MCP-compatible host can use it. Tested hosts include Claude Code, Cline, OpenCode, Cursor (read-only state), Windsurf, Codex CLI, Aider, and Continue.dev. Adapter recipes for each are in docs/SETUP.md.

Generic MCP config:

json
{  "mcpServers": {    "agent-comm": {      "command": "npx",      "args": ["agent-comm"]    }  }}

Add this to your host's MCP config file (the path varies by host — ~/.claude.json for Claude Code, ~/.config/opencode/config.json for OpenCode, ~/.cursor/config.json for Cursor, etc. — see the per-host sections in docs/SETUP.md).

The dashboard auto-starts at http://localhost:3421 on the first MCP connection regardless of which host is connected.

Option 2: Standalone server (for REST/WebSocket clients)

bash
node dist/server.js --port 3421

Option 3: Automated setup (Claude Code)

bash
npm run setup

Registers the MCP server in ~/.claude.json, installs the hook scripts (lifecycle + file-coord + bash-guard), and configures permissions. Other hosts: see docs/SETUP.md for the per-host integration recipes — every host that supports pre-tool-call hooks can use the same file-coord.mjs script unchanged.

MCP tools (7)

ToolDescription
comm_registerRegister with name, capabilities, metadata, skills, and auto-join channels
comm_agentsAgent management — actions: list, discover, whoami, heartbeat, status, unregister
comm_sendSend messages — direct (to), channel, broadcast, reply (reply_to), forward (forward)
comm_inboxRead inbox (direct + channel messages, unread filter, importance filter, thread view via thread_id)
comm_pollBlock until a new inbox message arrives (supports timeout_ms and importance filter)
comm_channelChannel management — actions: create, list, join, leave, archive, update, members, history
comm_stateShared key-value state — actions: set, get, list, delete, cas

REST API

All endpoints return JSON. Loopback only: foreign Host/Origin headers get 403, request bodies must be application/json, no wildcard CORS. See full API reference for details.

GET  /health                              Server status + uptimeGET  /api/agents                          List online agentsGET  /api/agents/:id                      Get agent by ID or nameGET  /api/agents/:id/heartbeat             Agent liveness (status + heartbeat age)GET  /api/channels                        List active channelsGET  /api/channels/:name                  Channel details + membersGET  /api/channels/:name/members          Channel member listGET  /api/channels/:name/messages         Channel messages (?limit=50)GET  /api/messages                        List messages (?limit=50&from=&to=&offset=)GET  /api/messages/:id/thread             Get threadGET  /api/search?q=keyword                Full-text search (?limit=20&channel=&from=)GET  /api/state                           List state entries (?namespace=&prefix=)GET  /api/state/:namespace/:key           Get state entryGET  /api/feed                              Activity feed events (?agent=&type=&since=&limit=50)GET  /api/overview                        Full snapshot (agents, channels, messages, state)GET  /api/export                          Full database export as JSON
POST   /api/messages                      Send a message (body: {from, to?, channel?, content})POST   /api/state/:namespace/:key         Set state (body: {value, updated_by})POST   /api/state/:namespace/:key/cas     Atomic compare-and-swap (file-coord hook uses this)DELETE /api/messages                       Purge all messagesDELETE /api/messages                       Delete messages by filterDELETE /api/messages/:id                   Delete a message (body: {agent_id})DELETE /api/state/:namespace/:key          Delete state entryDELETE /api/agents/offline                 Purge offline agentsPOST   /api/cleanup                       Trigger manual cleanupPOST   /api/cleanup/stale                 Clean up stale agents and old messagesPOST   /api/cleanup/full                  Full database cleanup

Agent visibility and status

comm_agents with action: "heartbeat" accepts an optional status_text parameter, letting agents update their visible status in the same call that keeps them online:

jsonc
// MCP call — heartbeat + status update in onecomm_agents({ "action": "heartbeat", "status_text": "implementing auth module" })
// Clear status text (pass null)comm_agents({ "action": "heartbeat", "status_text": null })
// Plain heartbeat — status text unchangedcomm_agents({ "action": "heartbeat" })

Hosts that support lifecycle hooks (Claude Code, OpenCode, future Cursor/Codex when they ship hook APIs) get automatic heartbeats, registration, and status via the lifecycle hook scripts shipped in scripts/hooks/. Subagents spawned by the Agent tool inherit the same registration via SubagentStart, so they appear on the dashboard alongside the main session. Hosts without hook support (Cursor, Windsurf, Aider as of 2025) can still use the MCP tools — agents must call comm_register and comm_agents heartbeat from the host's instructions file. Custom MCP clients or scripts can call the REST endpoints or use comm_heartbeat directly to show live progress.

The REST endpoint GET /api/agents/:id/heartbeat returns agent liveness info (status, heartbeat age in ms/s, status text) for external monitoring.

Communication patterns

Direct messaging

mermaid
sequenceDiagram    participant A as Agent A    participant S as agent-comm    participant B as Agent B
    A->>S: comm_send(to B, content review PR 42)    Note over S: Store in SQLite, emit event    B->>S: comm_inbox()    S-->>B: message from A    B->>S: comm_reply(message_id 1, LGTM merging)

Shared state with CAS (distributed locking)

mermaid
sequenceDiagram    participant A as Agent A    participant S as agent-comm    participant B as Agent B
    A->>S: comm_state(action cas, key deploy-lock, new agent-a)    S-->>A: swapped true    B->>S: comm_state(action cas, key deploy-lock, new agent-b)    S-->>B: swapped false    Note over B: Lock held by agent-a, back off

Dashboard

[Messages View]

The web dashboard auto-starts at http://localhost:3421 and shows agents, messages, channels, shared state, and the activity feed in real time. See the Dashboard Guide for all views and features.


Testing

bash
npm test              # 288 tests across 16 filesnpm run test:watch    # Watch modenpm run test:e2e      # E2E tests onlynpm run test:coverage # Coverage reportnpm run check         # Full CI: typecheck + lint + format + test

Environment variables

VariableDefaultDescription
AGENT_COMM_PORT3421Dashboard HTTP/WebSocket port
AGENT_COMM_HOST127.0.0.1Dashboard bind address (0.0.0.0 exposes it to the network)
AGENT_COMM_RETENTION_DAYS7Days before auto-purge of old data (1-365)

Documentation

  • Setup Guide — installation, client setup (Claude Code, OpenCode, Cursor, Windsurf), hooks
  • Architecture — source structure, design principles, database schema
  • Dashboard — web UI views and features
  • Changelog

License

MIT — see LICENSE

來源:README.md,提交 113b14d

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v1.3.12最新Oct 1, 2026
  2. v1.3.11Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分