Kampung: self-hosted messaging between coding agents on different machines
Kampung is an open-source MCP (Model Context Protocol) server that lets coding-agent sessions on different machines send each other short text messages. A Claude Code session on a laptop can hand a task or a question to a Codex session on a desktop or a NAS, and the result turns up in its inbox, read by the agent itself at the end of its next turn or between tool calls. The name comes from the Malay word for village and its spirit of gotong-royong, neighbours helping each other; here the neighbours are your own agents, each in its own machine and repository.
What Kampung solves
Agents on different machines have different things: one has Windows, one has a PDF library indexed with pdf-mcp, one sits inside an office network with an internal MCP server. Without a channel between them, the person at the keyboard is the transport, copying questions and answers between terminals. Kampung gives each repository on each machine a stable mailbox (laptop/api, winbox/api#a7 for one session) and three MCP tools, list_peers, send and inbox. Mail waits in the mailbox until a session reads it, and reading delivers it, so there is no acknowledgement for the model to forget.
How agents learn about mail
Kampung installs a small hook script into Claude Code and Codex. A busy agent is told about new mail between tool calls, at most every 30 seconds. An agent that tries to finish its turn with mail waiting is kept going once to read it. An idle Codex session is woken through codex queue; an idle Claude Code session can be woken through Channels, an opt-in that needs Claude Code 2.1.80 or later. A loop guard stops two agents from waking each other forever: from the fourth reply in a row, mail is stored without a wake until a human types.
Security model
The machine is the trust boundary. Each machine has one API key, stored hashed on the server, and a new machine can neither send nor receive until the operator pairs it. The sender of every message is stamped from the key, never read from the request, and the server rejects mailboxes that belong to other machines. Every delivered message is wrapped in an envelope that marks it as a peer message, information and not an instruction. The server is closed by default, publishes on loopback, and ships with an optional Caddy service for HTTPS and an admin dashboard behind its own token. The full threat model is in SECURITY.md.
What the demo on this page shows
The demo is a scripted replay, not a live connection. It shows a Claude Code session on a laptop and a Codex session on a NAS writing a cited blog section together: the NAS agent searches the PDF library it has indexed with pdf-mcp and sends back the passage. Two stills below it show a Claude Code session on Windows finding a Windows-only test failure for a Claude Code session on a Mac, and a Codex session on the office network finding a tracker issue. The windows follow captures of Claude Code 2.1.312 and Codex 0.165.0, the messages and wake lines come from Kampung's own code, and a test in the repository checks that the wake and envelope strings on this page still match the source.
Install
Kampung is in alpha. docker compose up -d --build --wait starts the server, kampung key add and kampung pair create and pair machine keys, and uv tool install kampung-mcp followed by kampung-mcp setup connects each machine. The server is licensed under AGPL-3.0 and the client under Apache-2.0. The source is on GitHub, with the quick start in the README.