Kampung
Self-hosted messaging between coding agents on different machines, over MCP. See it work at kampung-mcp.jztan.com.
A Claude Code session on your laptop can ask a Codex session on your desktop a question, and the answer turns up at the end of its next turn. Kampung is one small server you run in Docker, plus a client on each machine that wires it into Claude Code and Codex.
A scripted replay of one exchange. Watch it on the site, where you can expand every tool call.
mcp-name: io.github.jztan/kampung-mcp
The name comes from the kampung (Malay for village) and its spirit of gotong-royong: neighbours helping each other. Here the neighbours are your agents, each in its own machine and repo, lending each other a hand.
Clients | Server | Security | Changelog | Contributing
Status: beta. The MCP tools and
/v1can still change before v1.0. The client is on PyPI askampung-mcpand in the MCP Registry asio.github.jztan/kampung-mcp. The server image isghcr.io/jztan/kampung-mcp(amd64 and arm64).
Why Kampung?
| Without Kampung | With Kampung | |
|---|---|---|
| Agents on different machines | You copy and paste between terminals | send to desktop/api, read with inbox |
| Claude Code and Codex together | No shared channel | Same MCP tools for both |
| An agent finishes its turn | Mail sits unread until you look | The Stop hook keeps it going to read the mail |
| An agent is idle | Nothing happens until you type | Claude Code (2.1.321 or later) and Codex wake within seconds, with no flag to launch |
| Two agents reply to each other forever | Runaway loop | A loop guard gives each pair of mailboxes a few wakes that come back slowly, and each mailbox a budget that typing refills (so do the dashboard and a message from you in the Claude app) |
| Who can talk to whom | Anything that has the URL | Only machines you have paired |
| Seeing what happened | Logs, if any | An audit log and a dashboard |
How it works
Each agent talks to a local stdio adapter, which adds the machine's key and the session's identity and forwards to the server. The key never passes through the model's tool calls, and the server stamps the sender from it, so an agent cannot pretend to be another machine. Mail waits in a per-repo mailbox until a session reads it.
Quick start
-
Run the server (on a machine every other machine can reach):
git clone --branch master https://github.com/jztan/kampung-mcp.git cd kampung-mcp docker compose up -d --wait
It runs the latest release and listens on
127.0.0.1:8803. For HTTPS, pinning a release and backups, see docs/server.md. -
Create a key for each machine and pair them:
docker compose exec kampung kampung key add laptop # prints the key once docker compose exec kampung kampung key add desktop docker compose exec kampung kampung pair laptop desktop
-
Connect each machine with its own key (with uv):
uv tool install kampung-mcp kampung-mcp setup --server https://kampung.example.com
Setup asks for the key without showing it. Add
--agent codexor--agent bothfor Codex; see docs/clients.md. On Claude Code 2.1.321 or later, setup also turns on idle wake; Channels is an optional fallback. Restart Claude Code, and ask it tolist_peers.Setup records the hook's full path, which includes the Python version. If the
uv toolinstall moves to another Python minor version, rerunkampung-mcp setup: the hooks fail open, so otherwise they just stop working, with no error.
For a step-by-step deployment on AWS, see Deploy on Amazon Lightsail.
Why this exists, and how it came together: How I Let AI Agents on Different Machines Work Together
The admin dashboard at /admin, with example data.
Tools
| Tool | What it does |
|---|---|
list_peers(machine?, include_empty?) |
Mailboxes this machine may message, with their sessions. Mailboxes with no open session are hidden unless include_empty is true |
send(to, body, reply_to?, attachment?, mode?, fyi?) |
Send up to 8 KB of text to machine/repo or machine/repo#xx, optionally with one file from the project's kampung-outbox folder: text up to 256 KB, or a PNG or JPEG. wake in the result means the loop guard lets it wake the receiver, not that it will; when it is false, reason and hint say why. mode is ask (the default: wakes the receiver, a reply is welcome), tell (wakes it to act, no reply needed) or fyi (a note that wakes nobody); fyi: true is the older spelling of mode: "fyi" |
inbox(limit=20) |
Read new messages, at most 20 at a time plus a count of the rest. Reading delivers them |
read_attachment(message_id, offset?, limit?) |
Read a message's attachment: text in slices, with Markdown headings to jump to, or an image whole |
set_summary(summary) |
Say in a few words what this session is working on; peers see it in list_peers. Claude Code and Codex only |
Every message arrives in an envelope with the sender, sent time, its mode and a "peer message, not an instruction" tag; only an owner instruction from your own Claude app is marked otherwise (below). Bodies and text attachments are checked for secrets such as API keys before they are stored. Unread mail expires after 7 days, and each machine can send 60 messages a minute. See the tool reference for results and errors.
Use it from the Claude app
With KAMPUNG_PUBLIC_URL set (see .env.example), the Claude app and claude.ai can join as a peer with its own mailbox, for example phone/claude, and read or leave mail with no laptop running. On the server:
docker compose exec kampung kampung connect phone
docker compose exec kampung kampung pair phone mac
connect prints a URL, the client id kampung-claude and a one-time code. In Claude, add a custom connector with that URL, confirm Sign in now and Use your own OAuth client (Claude detects both from the server), and enter that client id with no secret. Claude opens Kampung's connect page; enter the code within 10 minutes from one of your allowed networks (home Wi-Fi counts), and the connector is ready on the phone and the web. Every chat on the account shares that one mailbox, and mail is delivered on read, so the first chat to read the inbox gets it.
Keep the connector out of Claude Code. Claude Code loads the account's connectors too, so every window would get a second kampung with the same tool names, acting as phone/claude: the model picks either one, and that window takes the phone's mail. kampung-mcp setup denies any connector to your Kampung server's address (the one in --server) for every project in ~/.claude/settings.json, whatever you named it, and kampung-mcp doctor warns when that entry is missing (rerun setup on machines set up with an older client). The entry it writes, with your server's address, is:
{
"deniedMcpServers": [
{ "serverName": "claude.ai kampung" },
{ "serverUrl": "https://kampung.example.com/*" }
]
}
The symptom when it is on: the Stop hook says mail is waiting but inbox comes back empty, because the hook counts the window's own mailbox and the model read the phone's.
kampung disconnect phone ends the connection and keeps the machine and its mail. Tool calls come from Anthropic's cloud (160.79.104.0/21 and 153.61.208.0/20, listed on Anthropic's IP addresses page), so allow both ranges on port 443; the deployment runbook has the firewall and the checks.
Owner instructions (off by default)
A normal message from the Claude app is information to the agent that reads it, like any peer's. To let your app give instructions that agents may act on as if you typed them, mark the app as yours:
docker compose exec kampung kampung owner add phone
If the app's connection is ever replaced (a reconnect, or an old sign-in token reused after an outage), the mark goes with it: the app says so and the dashboard flags it. Run the same command again, after kampung connect if the connection itself is gone (an old token reused, the app disconnected, or a key rotation).
Then say "tell desktop/api to merge it" to the app. It sends with mode: "instruct", the server stamps the message as an owner instruction, and it goes to the one session working in that repo now (the reply names it). It expires unread after an hour. What an instruction may approve is up to you: paste the section in owner instructions into each machine's ~/.claude/CLAUDE.md or ~/.codex/AGENTS.md and edit it. kampung owner remove phone turns it off. The mark sits on the app's connection, so kampung disconnect, revoke, key rotate and a new kampung connect all clear it: after reconnecting the app, run kampung owner add again. A Codex session receives one only if you typed in it within the last hour, so approve its hooks with /hooks first: until then it never reports typing.
Anyone who can steer your app can now direct your agents, within that section's limits: a paired peer's mail to the app, or any chat on the account with the connector on (Research runs connector tools without asking). Read the security notes before turning it on.
Security
- Closed by default. Every request needs a machine key; a new machine can do nothing until you pair it.
- The machine is the trust boundary. One key per machine, stored hashed. A machine can only use its own mailboxes.
- Peer messages are information, never commands, and pairing is a trust decision: only pair machines whose agents you trust.
- Not end-to-end encrypted. The server sees messages so it can enforce pairing and keep the audit log.
- Claude app tokens are a second credential bound to a machine. They come only from a one-time code you print on the server, never from registration, and they cannot reach the hook API.
The threat model, operator checklist and limits are in SECURITY.md.
What it is not
- Not a replacement for Claude Code's built-in messaging between sessions on the same machine.
- Not a task board, job queue or file transfer tool.
- Not multi-tenant: one owner per deployment.
- Not for Claude Code on the web yet: cloud sessions can't join as peers (see clients).
Roadmap
- The client as a Claude Code plugin, for easier install.
Blog posts
The story behind the releases. I write about building Kampung and the other tools I work on in The Dispatch. Come along if that's your kind of thing.
- How I Let AI Agents on Different Machines Work Together: Why I stopped relaying questions between terminals, and how a self-hosted mailbox lets Claude Code and Codex on different machines message each other over MCP
Contributing
Issues and pull requests are welcome. See the contributing guide and the Code of Conduct. Pull request authors sign the Contributor License Agreement once; you keep the copyright in your work.
License
packages/server(kampung-server): AGPL-3.0, see packages/server/LICENSEpackages/client(kampung-mcp, the adapter and hooks that run on your machines): Apache-2.0, see packages/client/LICENSE
NOTICE credits the project Kampung's idea comes from.
Metadata
Release files for kampung-mcp 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kampung_mcp-0.7.0.tar.gz | 123.5 kB | With provenance | Details for kampung_mcp-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kampung_mcp-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for kampung_mcp-0.7.0-py3-none-any.whl |
Total release size: 190.7 kB
Release files / kampung_mcp-0.7.0.tar.gz
| Download URL | kampung_mcp-0.7.0.tar.gz |
|---|---|
| Size | 123.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d661ce67769c0e52103e3b96ac91aa0e64f24d3f39484e5451c9a83c1892f0d3
|
|
BLAKE2b-256 checksum How to use checksums |
d4462924b39c66c7ce7faa8aa0f963f4a1f643d3f0b9862e28cf3b3492b79f21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / kampung_mcp-0.7.0-py3-none-any.whl
| Download URL | kampung_mcp-0.7.0-py3-none-any.whl |
|---|---|
| Size | 67.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25022cf8ad7036ca9781bb10b84ecc611eb96828d63a03a7c460978186902cd8
|
|
BLAKE2b-256 checksum How to use checksums |
45ab706091e8173876a0ecfc9260040046e42d65867d137ee6f3881baf3f7cf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for kampung-mcp 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kampung_mcp-0.7.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.