agent-bridge
A local MCP relay that enables two or more MCP-speaking agent CLIs to communicate through shared channels by posting and reading messages.
README
agent-bridge
A tiny local MCP relay that lets two (or more) MCP-speaking agent CLIs — e.g. Claude Code and Grok Build — talk to each other through shared channels, instead of a human copy-pasting between two terminals.
Both CLIs already speak MCP, so the "bridge" is just a shared MCP server they both connect to. This is that server. It's generalized: any future MCP CLI (Cursor, Codex, etc.) can join the same channel with zero changes here.
- Transport: stdio (each CLI spawns its own copy of the server).
- Storage: local append-only JSONL, one file per channel, in
./data/. Nothing leaves your disk. Survives restarts. - Deps:
@modelcontextprotocol/sdk,zod. Node 18+.
Tools it exposes
| Tool | Purpose |
|---|---|
bridge_post(channel, from, body) |
Append a message to a channel |
bridge_read(channel, since?, limit?) |
Read messages with seq > since |
bridge_wait(channel, since, timeout_ms?) |
Block until a newer message lands — event-driven, wakes the instant the other agent posts |
bridge_channels() |
List channels + last seq |
Each message gets a monotonic seq per channel. Remember the highest seq you
saw and pass it as since next time so you only get new messages.
Watch mode — get "triggered" on every message
An MCP server is request/response: it can't push a new turn into an idle CLI
session, so there's no way to wake a session that's just sitting there. The way
to make a session react the instant a message arrives is to keep it parked in
bridge_wait, which is now event-driven (fs.watch) and returns within
milliseconds of a post — no busy-polling.
There are two ways to do this.
A) In an interactive session (no extra process)
Tell your agent to loop:
Watch the
zero-ui-debatechannel. Callbridge_wait(channel="zero-ui-debate", since=<lastSeq>). When it returns with messages, handle them andbridge_postyour reply, then immediately callbridge_waitagain withsinceset to the highest seq you just saw. If it returnstimedOut, just call it again. Keep looping until I say stop.
The session now wakes and acts on every new message on its own — the human only
starts the loop once. (Each bridge_wait blocks up to timeout_ms, default
60s, max 10min; the loop simply re-arms it, so the watch is continuous.)
B) As a background daemon — watch.js
watch.js encodes the trigger so you don't paste a loop prompt: it fs.watches
a channel and runs a command of your choice for every new message. Point that
command at a headless agent and you get a hands-off auto-responder.
# Whenever someone other than "claude" posts to zero-ui-debate,
# spawn a headless Claude to read context and post a reply:
node watch.js zero-ui-debate --from claude -- ./examples/respond-with-claude.sh
--from <me>skips your own posts, so the responder never triggers on its own replies (no infinite loop). Always set it.- Each fire gets the message via env (
BRIDGE_CHANNEL,BRIDGE_SEQ,BRIDGE_FROM,BRIDGE_BODY,BRIDGE_TS) and as JSON on stdin. - Messages are handled one at a time (next waits for the current command to
exit), and progress is persisted next to the channel, so a restart resumes
instead of replaying. Use
--replayto process existing history first.
examples/respond-with-claude.sh is a ready template that calls claude -p with
this server attached so it can bridge_post the reply itself — adapt the prompt,
model, or swap in grok for the other side.
Note the boundary: a daemon spawning a fresh responder per message is the closest you can get to "trigger the session." An MCP server still cannot inject a turn into an already-running, idle interactive session — nothing can, for a generic CLI. Option A keeps one session live; option B starts a worker per message.
Setup (one time)
cd /Users/prakshaljain/OS-1/agent-bridge
npm install
node smoke-test.mjs # optional: verifies post/read round-trip
Then add the server to both CLIs. The entry is in .mcp.json.example:
{
"mcpServers": {
"agent-bridge": {
"command": "node",
"args": ["/Users/prakshaljain/OS-1/agent-bridge/server.js"]
}
}
}
- Claude Code:
claude mcp add agent-bridge -- node /Users/prakshaljain/OS-1/agent-bridge/server.js(or paste the block into a project.mcp.json/~/.claude.json), then restart the session. - Grok Build: it reads
.mcp.json/claude_desktop_config.jsonautomatically — add the same block and restart. (grok.com/connectorsworks for the web app too.)
After both restart, each CLI will have bridge_post / bridge_read / bridge_wait / bridge_channels.
How the debate loop runs
- Claude posts its position to channel
zero-ui-debate(from: "claude"). (Already seeded — seedebate/.) - In the Grok terminal, paste
debate/GROK-BRIEF.md. Grok reads the channel, readsdebate/STRATEGY-POSITION.md, and posts its rebuttal (from: "grok"). - Claude calls
bridge_wait(channel="zero-ui-debate", since=<lastSeq>), reads Grok's turn, and replies. Repeat until converged. - Both write article drafts into
articles/.
No human relay needed once both are connected — each side parks in bridge_wait
(see Watch mode) and is triggered
the moment the other posts.
Folders
server.js— the MCP relaywatch.js— background daemon that runs a command on every new message (watch mode B)examples/— ready-to-edit responder templates forwatch.jsdata/— channel logs (gitignored)debate/— the briefing prompt + the seeded strategy positionarticles/— shared drafting workspace for the campaign deliverables
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。