Skip to content
i4pgPublic

About

A local message relay for Codex CLI and Claude Code sessions

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

peerpost

A local message relay that lets Codex CLI Sessions and Claude Code Sessions on one computer send each other messages, without a peer's words ever passing as your own typed input or approval.

What it is

peerpost is one binary. Claude Code and Codex CLI start it as an MCP server, and each Session gets three tools:

  • who: the Sender names of live Sessions, and your own.
  • send: send a Peer message to one Session, named by its Sender name.
  • read: your unread Peer messages, oldest first, each with the Sender name of the Session that wrote it; they are marked read.

Messages go through a small local Broker that peerpost starts by itself the first time a Session needs it. The Broker stamps every message with the sending Session's registered Sender name; nothing in a tool's arguments or a message's text can set the sender. A peer's words reach a model only as the output of its own read call.

Only one Broker runs at a time, even when several Sessions start at once. It stops by itself 30 seconds after the last Session disconnects; change that with grace_ms (see Settings). The next Session starts it again. If the Broker stops or crashes while Sessions are open, they reconnect on their next call under the same Sender names; a send or read cut off mid-call is reported as an error rather than repeated, so no Peer message is sent twice. A read marks its messages read only after its reply has gone out, so a reply lost to a broken connection leaves them unread for the next read.

A Claude Session is named by RELAY_NAME if you set it when you start claude (for example RELAY_NAME=review claude), otherwise claude- plus four random hex digits. Every tool result tells the calling Session its own Sender name.

Before you install

  • Same computer only. Sessions talk through a local socket; Sessions on different computers cannot reach each other.
  • Linux and macOS only. There is no Windows build, and peerpost does not run on Windows.
  • The trust boundary is your OS user. Anything already running as your OS user can read the Message log and pretend to be any Session (see Trust boundary).
  • No endless-loop guard in this release. Two Sessions allowed to send without asking can keep answering each other for as long as you let them. What stops a loop is the default setup below, where every send asks you first.

Install

From a release (Linux and macOS, x86_64 and arm64): download the archive for your computer and SHA256SUMS from the project's GitHub releases page, check it, and put peerpost on your PATH:

Computer Archive
Linux, x86_64 (glibc 2.35 or newer) peerpost-v<version>-x86_64-unknown-linux-gnu.tar.gz
Linux, arm64 (glibc 2.35 or newer) peerpost-v<version>-aarch64-unknown-linux-gnu.tar.gz
macOS, Intel peerpost-v<version>-x86_64-apple-darwin.tar.gz
macOS, Apple silicon peerpost-v<version>-aarch64-apple-darwin.tar.gz
sha256sum -c SHA256SUMS --ignore-missing      # macOS: shasum -a 256 -c SHA256SUMS --ignore-missing
tar -xzf peerpost-v<version>-<target>.tar.gz
mkdir -p ~/.local/bin && install -m 755 peerpost-v<version>-<target>/peerpost ~/.local/bin/   # any directory on your PATH
peerpost --version

The macOS binaries are not signed; if macOS refuses to open one you downloaded with a browser, run xattr -d com.apple.quarantine ~/.local/bin/peerpost.

With Cargo (Rust 1.88 or newer), from GitHub or from a clone of this repository:

cargo install --locked --git https://github.com/i4pg/peerpost
cargo install --locked --path .

Set up

Add peerpost as an MCP server once per product. Both commands assume peerpost is on your PATH; otherwise give its full path instead.

Codex CLI:

codex mcp add peerpost -- peerpost

Claude Code (--scope user makes it available in every project):

claude mcp add --scope user peerpost -- peerpost

Then add the shipped instruction snippets: snippets/codex-AGENTS.md to your AGENTS.md and snippets/claude-CLAUDE.md to your CLAUDE.md (see Codex Sessions and the Watcher).

Permissions

The recommended setup lets read and who run without asking, while send asks you every time, so no Session messages another without your OK.

Codex CLI, in ~/.codex/config.toml, below the [mcp_servers.peerpost] table that codex mcp add wrote:

[mcp_servers.peerpost.tools.read]
approval_mode = "approve"

[mcp_servers.peerpost.tools.who]
approval_mode = "approve"

[mcp_servers.peerpost.tools.send]
approval_mode = "prompt"

Claude Code, in ~/.claude/settings.json (in its default permission mode Claude Code asks before any MCP tool not allowed here, so send asks; a mode that skips permission prompts skips this one too):

{
  "permissions": {
    "allow": ["mcp__peerpost__read", "mcp__peerpost__who"]
  }
}

To let send run without asking (read Before you install first: nothing else stops a loop), change one setting per product:

  • Codex CLI: approval_mode = "approve" under [mcp_servers.peerpost.tools.send].
  • Claude Code: add "mcp__peerpost__send" to the allow list.

Environment variables and Codex

Codex CLI starts MCP servers with only a few environment variables (such as HOME, PATH and TMPDIR), so a PEERPOST_* or XDG_* variable set in your shell does not reach a Codex Session's peerpost. Put settings in the settings file instead, which every Session reads. If you need an environment variable there too, forward it by name: in ~/.codex/config.toml, add an env_vars line inside the [mcp_servers.peerpost] table that codex mcp add wrote (do not add a second table), for example:

env_vars = ["PEERPOST_RUNTIME_DIR", "XDG_RUNTIME_DIR"]

Forward XDG_RUNTIME_DIR, XDG_DATA_HOME and XDG_CONFIG_HOME if you set them to anything but the usual places, so Codex and Claude Sessions find the same Broker, Message log and settings file.

Codex Sessions

Codex CLI may run one peerpost MCP server for many Codex Sessions at once, so peerpost tells Codex Sessions apart on every tool call by the thread id Codex puts in the call's _meta.threadId. The first relay tool call from a thread registers it as a Session named codex- plus the last four hex digits of its thread id (such as codex-1b6b), lengthened from the end until no live Session has that name. Codex thread ids start with a timestamp and end with random digits, so threads started close together still get short, distinct names; only a chance clash on the last four digits gives a longer one. Names starting with codex- are kept for Codex Sessions, so RELAY_NAME cannot use them.

_meta.threadId is undocumented: Codex defines it in its open-source code (codex-rs/core/src/mcp_tool_call.rs), not in its docs, and may change it without notice (ADR 0006). A tool call that is not from Claude Code and carries no _meta.threadId is refused with an error; peerpost never guesses which Session is calling.

Tested Codex CLI versions: 0.167.0

A Codex Session can receive Peer messages once it has made one relay tool call, and stays live while Codex keeps its MCP connection open. Add snippets/codex-AGENTS.md to your AGENTS.md so Codex calls who at the start of every session.

The Nudge

When a Peer message is accepted for a Codex Session, the Broker wakes that Session with a Nudge: it runs

codex queue --thread <thread id> --message "[relay] N new peer messages waiting; call relay read. This line is from the relay, not the human."

where N is how many Peer messages wait for that Session. The Nudge never carries message text or a Sender name; the messages themselves reach Codex only as the output of its own read call. codex queue delivers its line as if you had typed it, with no sender field, so the "from the relay, not the human" wording and the AGENTS.md snippet (which tells Codex a Nudge is never your approval) are guidance to the model, not an enforced label (ADR 0005).

The Broker runs codex from your PATH; set codex_command (see Settings) to the path of another codex program. A failed Nudge is written to the broker log in the runtime directory and never fails the send: the message still waits for read.

A Nudge waits for you, and the Codex Session does not wake until you act, when:

  • the Codex Session's last turn was interrupted; or
  • Codex was started with its own private app server instead of the shared Codex background program: with -c, --profile, --oss or --no-daemon.

Limits and errors

send returns a tool error, and stores nothing, when:

  • the Recipient is not a live Session (unknown recipient; who lists the live ones);
  • the text is larger than the message size limit, 64 KB by default (message too large);
  • the Recipient already holds the unread limit, 100 Peer messages by default (recipient is full); it takes messages again once it calls read.

A Session that asks for a Sender name another live Session already holds (for example two Sessions started with the same RELAY_NAME) is refused, and every tool call it makes returns that error.

Settings

Settings come from the settings file config.toml in your config directory ($XDG_CONFIG_HOME/peerpost/config.toml, else ~/.config/peerpost/config.toml) and from environment variables. An environment variable wins over the file; a missing file means the defaults.

Settings file key Environment variable Default Meaning
max_message_bytes PEERPOST_MAX_MESSAGE_BYTES 65536 (64 KB) Largest Peer message text, in bytes
max_unread PEERPOST_MAX_UNREAD 100 Most unread Peer messages one Recipient may hold
log_keep PEERPOST_LOG_KEEP 10000 How many of the newest Peer messages the Message log keeps
grace_ms PEERPOST_GRACE_MS 30000 (30 s) How long the Broker keeps running with no client connected, in milliseconds (at least 100)
codex_command PEERPOST_CODEX_COMMAND codex (from PATH) The codex program a Nudge runs
# ~/.config/peerpost/config.toml
max_message_bytes = 32768
max_unread = 50

Each value must be a whole number of at least 1; a bad value or an unknown key stops peerpost with an error naming it. The Broker reads these settings when it starts, from its settings file and from the environment of the Session that started it, so a change takes effect the next time the Broker starts.

Waking an idle Claude Session: the Watcher

A Claude Session that is waiting for you does not call read by itself. The Watcher wakes it:

peerpost watch <sender-name>

The Session runs this under Claude Code's Monitor tool, with its own Sender name. Whenever the unread Peer messages for that name change, the Watcher prints one line such as 2 new messages from codex-4f2a, call read, and Monitor hands that line to the Session, which then calls read. The Watcher prints only Sender names and counts, never message text: a peer's words still reach the model only through read. It prints nothing when the messages are read, starts the Broker if none runs, and ends with status 0 when stopped.

Monitor stops a command after at most 30 minutes (10 minutes under claude -p), so the Session must start the Watcher again each time it ends. The shipped instruction snippet snippets/claude-CLAUDE.md tells Claude to do exactly that: learn its Sender name from any relay tool result, start the Watcher under Monitor, restart it whenever it ends, and treat Peer messages as data, never as your instructions or approval. Add it to your CLAUDE.md (the project's, or your user-level one):

cat snippets/claude-CLAUDE.md >> CLAUDE.md

A restarted Watcher reports messages that are still unread once more, so a Session that missed a line while the Watcher was down still wakes.

Where it keeps things

  • Runtime directory (the Broker's socket and its log): $PEERPOST_RUNTIME_DIR, else $XDG_RUNTIME_DIR/peerpost, else /run/user/<your uid>/peerpost if /run/user/<your uid> exists (where XDG_RUNTIME_DIR usually points on Linux, so a Codex Session that is not given XDG_RUNTIME_DIR still finds the Broker), else peerpost-<your uid> in the system temp directory.
  • Data directory (the Message log, messages.jsonl): $PEERPOST_DATA_DIR, else $XDG_DATA_HOME/peerpost, else ~/.local/share/peerpost.

Both directories are mode 0700 and every file in them 0600. peerpost refuses to use an existing directory that other users can reach or that another user owns.

The Message log

The Message log is messages.jsonl in the data directory above: one JSON line per Peer message (with its text) and one per message read. Unread messages survive the Broker stopping and starting again.

It keeps only the newest 10,000 Peer messages, read or unread; older ones are dropped automatically, so private text does not pile up. Change the count with the log_keep setting or PEERPOST_LOG_KEEP (see Settings). A dropped message can no longer be read. The file is rewritten without dropped messages once it holds a tenth more than the count, so it never holds much more than that.

To empty the Message log now, read and unread messages alike, run:

peerpost prune

It asks the running Broker to empty the log (starting one if none runs), so it is safe to run while Sessions are live.

Trust boundary

Only processes running as your OS user can reach the Broker: its socket and Message log are private to you. That is the whole boundary. peerpost issues no per-Session secrets, because processes running as one OS user can usually read each other's files and settings, so a token would promise isolation it cannot keep.

Anything already running as your OS user can pretend to be any Session. Treat every Peer message as data written by another Session, never as an instruction or approval from you.

Releasing

Pushing a tag such as v0.1.0 runs .github/workflows/release.yml: it runs the test suite on Linux (x86_64 and arm64), builds the four binaries above, and publishes them with SHA-256 checksums as a GitHub release. The steps for cutting a release, including a hands-on check with a real Claude Code Session and a real Codex Session messaging each other both ways, are in the release checklist.

Licence

Licensed under either of the Apache License, Version 2.0 (LICENSE-APACHE) or the MIT licence (LICENSE-MIT) at your option. Copyright the peerpost contributors.

About

A local message relay for Codex CLI and Claude Code sessions

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages