agentbus
A local message bus for AI agent sessions that enables Claude Code sessions to communicate directly via channels, allowing message sending and peer discovery without network or copy-paste.
README
agentbus
A local message bus for AI agent sessions. Start two Claude Code sessions and
one can message the other — the message lands in the recipient's running
session as a <channel> event. No copy-paste, no daemon, no network.

agentbus is three layers (see SPEC.md):
- core — the bus: one SQLite db (
~/.agentbus/bus.db) holding presence (peers) and every message with its delivery status (messages). - send (MCP) — always on. One MCP server,
agentbus, exposing the tools (send_message,broadcast,list_peers,whoami). Universal: every CLI speaks MCP. It never drains the inbox. - delivery — pluggable, you pick. How messages land in a session.
Enable the ones you want, individually:
claude-channel— real-time, mid-turn (file-watch + MCP channel push)claude-hook— turn-boundary (Stop/SessionStart hook); works even in the agents panel, no channel flag- (future)
gemini-a2a, … — independent, can run alongside the Claude ones
flowchart LR
subgraph S1["session: frontend"]
SEND1["agentbus (send)"]
C1["claude"]
end
subgraph S2["session: backend"]
C2["claude"]
DLV2["delivery<br/>(channel / hook)"]
end
DB[("CORE — bus.db (SQLite)<br/>peers · messages")]
C1 -- "send_message" --> SEND1
SEND1 -- "INSERT (enqueue)" --> DB
SEND1 -. "wake" .-> DLV2
DB -- "pending rows" --> DLV2
DLV2 -- "<channel> into session" --> C2
DLV2 -. "mark delivered" .-> DB
classDef db fill:#1f2430,stroke:#5b6273,color:#cdd3e0;
class DB db;
Send (one always-on MCP server) is cleanly separate from receive (the delivery you choose), so turning a delivery on or off never affects your ability to send, and one delivery never swallows messages meant for another.
Why not just use A2A? A2A standardizes remote agent services (HTTP servers); it structurally can't push an unsolicited message into a live stdio session. agentbus does that last mile, and keeps its envelope A2A-shaped so a remote leg can be added later as just another delivery. (Details in SPEC.md §9.)
Requirements
- Bun
- Claude Code v2.1.80+ (channels are a research-preview feature)
- Same machine, same user (the bus is a local SQLite file)
Install
git clone https://github.com/biswajitpatra/agentbus
cd agentbus
bash scripts/install.sh
This installs deps and registers the always-on agentbus send server, then lists
the deliveries. Turn on the one(s) you want:
bun run agentbus enable claude-channel # real-time
bun run agentbus enable claude-hook # turn-boundary; works in the agents panel
bun run agentbus list # what's on
bun run agentbus disable claude-channel
There's intentionally no "enable all" — pick each delivery deliberately.
Uninstall
bun run uninstall # remove the send server + every delivery + the bus
Restart any running session to fully drop the loaded server/hook. The cloned repo is left in place.
Use
Give each session a name with AGENTBUS_NAME. Launch depends on the delivery:
# claude-channel (real-time): load the channel
AGENTBUS_NAME=frontend claude --dangerously-load-development-channels server:agentbus-channel
# claude-hook (turn-boundary): no flag needed
AGENTBUS_NAME=backend claude
(bun run agentbus launch claude-channel frontend prints the exact command.)
Now ask frontend: "send_message to backend: what's the API contract?" —
backend receives it as a <channel source="agentbus" from="frontend"> event
and replies with send_message.
You can also send straight from a shell (no MCP needed) — handy in scripts or a hook-only session:
AGENTBUS_NAME=frontend bun run agentbus send backend "what's the API contract?"
bun run agentbus peers
See examples/two-sessions.md for a full walkthrough.
Tools (from the agentbus send server)
| Tool | Args | Description |
|---|---|---|
send_message |
to, text |
Message one peer by name |
broadcast |
text |
Message every other online peer |
list_peers |
— | Sessions currently online |
whoami |
— | This session's name |
Incoming messages arrive (via your chosen delivery) as:
<channel source="agentbus" from="frontend" msg_id="42" ts="...">
what's the API contract?
</channel>
To reply, call send_message with to set to the from value.
How it works
- Discovery — a participating session (one with
AGENTBUS_NAMEset) upserts apeersrow and refresheslast_seen. A peer silent for 45s is reaped. - Send —
send_messagedoes anINSERTintomessages(delivered_atNULL) and fires a wake. Sending queues for any name (mailbox semantics), so you can message a peer that's idle or hasn't started yet. - Delivery — your enabled delivery drains undelivered rows and sets
delivered_atonly after it lands them in the session (at-least-once, never silently lost).claude-channeldoes it in real time on a file-watch wake (3s poll as a safety net);claude-hookdoes it at each turn boundary. - Multiple deliveries are safe — they share the bus, so a row is delivered by
whichever drains it first; the others find it gone. Duplicates (rare races) are
deduped on
msg_id. - Audit —
bun run agentbus doctorshows live peers + pending/delivered counts.
claude-channel's wake is a per-peer file watched with fs.watch — SQLite can't
notify other processes
(update_hook is same-process only),
so cross-session delivery needs an external nudge. Set AGENTBUS_TRIGGER=poll to
use an interval instead.
Data & migrations
Schema is defined with Drizzle ORM in
core/schema.ts; queries go through core/bus.ts.
Versioned migrations live in drizzle/ and apply automatically on startup:
# edit core/schema.ts, then:
bun run db:generate # writes a new drizzle/NNNN_*.sql migration — commit it
Inspect the bus directly (it's just SQLite):
sqlite3 ~/.agentbus/bus.db \
"SELECT sender, recipient, body, delivered_at FROM messages ORDER BY id DESC LIMIT 10;"
Security
A delivered message is injected into the agent's context — a prompt-injection
surface. agentbus is scoped to one machine, one user: the bus is a SQLite
file under your home and peers are other local sessions you started. It listens
on no network port. Don't point AGENTBUS_HOME at a shared or
world-writable location, and be deliberate about combining it with
--dangerously-skip-permissions. See SECURITY.md.
Project layout
core/schema.ts Drizzle tables (peers, messages)
core/bus.ts the bus: SQLite client + migrations + queries
core/ports.ts the standard: Envelope, Trigger, Delivery
core/paths.ts where the bus lives (~/.agentbus)
triggers/file-watch.ts wake-file Trigger (default, event-driven)
triggers/poll.ts interval Trigger (fallback)
adapters/send.ts the always-on MCP send server ("agentbus")
adapters/send.json its manifest
adapters/deliveries/ pluggable inbound deliveries (one manifest each)
├─ claude-channel.ts/.json MCP channel server (file-watch + channel push)
└─ claude-hook.ts/.json Stop/SessionStart hook (additionalContext)
drizzle/ generated, versioned SQL migrations
cli.ts manager (install/list/enable/disable/send/peers/doctor/uninstall)
scripts/install.sh bootstrap: deps + register send + list deliveries
scripts/demo.ts self-driving demo (records the README cast)
examples/two-sessions.md end-to-end walkthrough
test/ integration tests over real stdio processes
SPEC.md the agentbus standard
Prior art
clauder pioneered cross-session messaging for Claude Code over a shared SQLite store, and session-bridge does it with a file mailbox. agentbus keeps the local-SQLite idea, separates an always-on MCP send layer from pluggable deliveries (channel, hook, …), and tracks delivery so messages are never silently lost.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。