Agent Bridge
FreeNot checkedA local MCP relay that enables two or more MCP-speaking agent CLIs to communicate through shared channels by posting and reading messages.
About
A local MCP relay that enables two or more MCP-speaking agent CLIs to communicate through shared channels by posting and reading messages.
README
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
Installing Agent Bridge
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/Prakshal-Jain/agent-bridgeFAQ
Is Agent Bridge MCP free?
Yes, Agent Bridge MCP is free — one-click install via Unyly at no cost.
Does Agent Bridge need an API key?
No, Agent Bridge runs without API keys or environment variables.
Is Agent Bridge hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Agent Bridge in Claude Desktop, Claude Code or Cursor?
Open Agent Bridge on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzCompare Agent Bridge with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
