# Letting Claude Code sessions on different hosts work together directly

Published 2026-11-22 · Updated 2026-11-26 · [Canonical URL](https://zhanwei.wang/en/posts/peers-cross-host-claude-code/)

> peers lets Claude Code sessions on different hosts, owned by the same person or by different people, work together over a direct connection: each looks at its own host in place, the hosts exchange only requests, conclusions and evidence, messages pass through no third-party server, and people set trust and visibility explicitly.

## What peers is

[peers](https://github.com/wangzw/peers) is an open source tool that lets Claude Code sessions on different hosts discover each other and exchange messages. It runs a Broker on each host, a long-running background service, and a session joins the Broker on its own host through MCP tools. Once the Brokers of two hosts are paired with a one-time pairing key, sessions in the same topic can see each other. Messages travel directly between the two paired Brokers and arrive at the receiver as a Claude Code cross-session message. The two hosts can belong to the same person or to different people.

```mermaid
flowchart LR
  subgraph web["web-server"]
    A["Claude Code session Alice"] --- BA["Broker"]
  end
  subgraph api["api-server"]
    BB["Broker"] --- B["Claude Code session Bob"]
  end
  BA <-->|"direct after pairing, plain text only"| BB
```

## Investigating a 503 across two hosts

The two hosts in the diagram come from a peers demo. The checkout service on web-server gets 503 responses when it calls api-server, and web-server's log records each failed request with only "503 from api-server". The cause is on the other host: the order service on api-server has its connection limit set to 2 and refuses every request over the limit, and the refusals are written to api-server's own log. The user on web-server asks the session Alice to read the local log first and then ask the session Bob on api-server. Having read the local log, Alice can only establish that the problem is on the other side, so it sends Bob a message through peers asking for a check on the api-server side. Bob finds the connection limit in api-server's local configuration and log and sends the evidence back to Alice. Nobody logs in to api-server at any point, and nothing on that host is changed. The demo uses two containers as the two hosts, each running a real Claude Code session; the order service and the fault were set up in advance for the demo. The recording is on the [peers home page](https://peers.zhanwei.wang/).

Without peers, there are roughly three ways to run this kind of investigation. The first is for a person to log in to api-server and look, which requires an account on that host, and the conclusion still has to be carried back to the session on web-server. The second is to give the session on web-server SSH access or credentials for api-server and let it investigate remotely, which extends what that session can do to a second host; if it is hit by prompt injection or makes a mistake, the damage reaches that host too. The third is to open a session on each host and have a person copy and paste between them, choosing what to pass across and carrying every question and answer back and forth by hand.

The demo works differently. The information on api-server can only be read in place by a session on api-server, so that session looks locally and sends back its conclusion and evidence as text. Bob never uses any credential of web-server, and Alice never gets access to api-server.

Generalized, the approach in this example is what peers argues for: Claude Code sessions on different hosts, owned by the same person or by different people, should be able to work together directly, each looking at its own host in place, with the hosts exchanging only requests, conclusions and evidence. That takes a few more things: the receiving session acts on a request by itself, so no person has to relay messages; sending a request does not grant permissions; people set explicitly who can see whom and which hosts to trust, and the defaults are narrow; and messages travel only directly between paired hosts, with no third-party server in between.

## The receiving session acts on its own

Bob starts investigating as soon as the request arrives, and nobody types anything at api-server's terminal. A message peers delivers enters the receiving session as a Claude Code cross-session message: an idle session starts processing it without user input, and a busy session reads it between steps of its current work. This delivery is designed for sessions that do not know peers exists, and the delivery step needs no cooperation from the receiving session.

If messages could not enter a session on their own, the session on the other host would not know anyone was waiting for it, and a person would have to go to its terminal and type the request in. Every round of request and reply would then need a person to act on both sides, and with nobody at the other host, the work would stop there.

## A request is not an authorization

When a session on another host hands work to a session on this host, the first question is permissions. When peers designed its delivery, it considered another approach: delivering messages from other hosts into the session as if they came from a trusted local program. Sessions running with permission confirmation skipped would then no longer hold those messages, even though text from another host is untrusted input and should not be treated like a local program.

What peers does instead is deliver without presenting Claude Code's authentication token, so the receiver's inbound controls and permission confirmations apply as usual. The inbound policy a user sets for a session, whether accept, hold for approval or refuse, applies to messages from peers as well; any file Bob wants to read or command Bob wants to run on api-server is still confirmed under api-server's own permission settings.

The instructions peers gives a session also require the model to treat received content as the other side's words rather than the user's instructions, and to relay it to the user and get consent before acting on it. This constrains the model's behavior, and the project documentation states plainly that it is not a system guarantee; the real boundary remains inbound controls and tool confirmation.

## By default, only the same project is visible

Two hosts often each run several sessions doing unrelated work, some of them in sensitive repositories. peers uses topics to define visibility: only sessions in the same topic can see each other and exchange messages.

The peers design rejected two approaches. One makes every session visible to every other and has the user exclude them one by one, so safety depends on whether the user remembers to exclude the sensitive sessions. The other has no default scope, so sessions join by hand on every start and both sides have to agree on a name in advance.

When a project declares no topic in `.peers.yaml`, the default topic comes from the address of the repository's `origin`, and both `git@github.com:org/repo.git` and `https://github.com/org/repo` normalize to `github.com/org/repo`. Clones of the same repository therefore join the same topic automatically, whichever host they are on and whoever owns it, and unrelated sessions cannot see each other. The project documentation gives an example: the session api-worker on hostA messages the session frontend on hostB that an interface has changed; frontend is idle, starts working on it by itself and then replies. Both sides work in the same repository, and nobody performs any topic operation at any point.

## Two hosts pair directly

For establishing trust between hosts, the peers design considered several common approaches and adopted none of them. A team certificate authority needs a facility to issue and distribute certificates first, and a new host has to request a certificate before it joins. A central service needs a separately deployed component. With relaying through a third host, A and C have never paired, so A cannot authenticate C's messages relayed through B.

peers has two hosts pair directly. One host generates a one-time pairing key, a piece of copyable text that a person hands to the user of the other host through a channel outside peers, and during pairing the two sides bind each other's public key fingerprints. Pairing establishes trust only between those two hosts: A pairing with B and B pairing with C does not mean A trusts C. Messages travel only directly between the two paired Brokers, through no third-party server, so the only Brokers that can send messages to a local session are ones the user has paired personally. On the network side, only one host needs to reach port 17443 on the other; the other can be behind NAT.

## Existing approaches

There are already several ways to let multiple agents or sessions communicate, each with a different idea behind it.

Claude Code has built-in [cross-session messaging](https://code.claude.com/docs/en/cross-session-messaging), which carries plain text between one user's Claude Code sessions. A session lists the sessions it can reach with the `ListAgents` tool and addresses them by session name. Between sessions on the same machine, a message goes over each session's own socket, a named pipe on native Windows, and does not pass through Anthropic's servers; on macOS and Linux the socket is open only to the session's operating-system user. The user's sessions on other machines and in the cloud are listed only while the session is connected to Remote Control; messages to them are relayed through Anthropic's servers and require a claude.ai sign-in. A received message never counts as the user's consent, and the receiver can be set to accept, hold or refuse. [Agent teams](https://code.claude.com/docs/en/agent-teams), from the same documentation, take another form: a lead session starts a group of teammates, the teammates find each other by reading the member list in the team configuration, and messages are written to each teammate's mailbox file on the local machine.

The [A2A (Agent2Agent) protocol](https://a2a-protocol.org/latest/specification/) is for applications or agents that call remote agents. A remote agent publishes an Agent Card at `https://{server_domain}/.well-known/agent-card.json`, and a client reads it to discover the agent's capabilities and how to connect. Requests go over HTTP directly to the remote agent, and the specification defines three bindings: JSON-RPC, gRPC and HTTP/REST. The Agent Card declares the authentication schemes it accepts, including API key, HTTP authentication, OAuth 2.0, OpenID Connect and mutual TLS; the client obtains credentials outside the protocol and puts them in the headers or metadata of every request.

[ACP (Agent Communication Protocol)](https://github.com/i-am-bee/acp), started by IBM, is an open protocol for communication between agents, applications and people. An agent offers its service through HTTP endpoints and describes its capabilities for discovery in an Agent Manifest. ACP has since [merged into A2A under the Linux Foundation](https://lfaidata.foundation/communityblog/2025/08/29/acp-joins-forces-with-a2a-under-the-linux-foundations-lf-ai-data/).

The open source project [claude-peers-mcp](https://github.com/louislva/claude-peers-mcp) lets multiple Claude Code sessions on the same machine message each other. When the first session starts, it launches a local broker that listens on `localhost:7899` and stores its data in SQLite. A session calls `list_peers` to find other sessions, optionally scoped by machine, directory or repository. Each session's MCP server polls the broker once a second and pushes messages into the session through Claude Code's channel mechanism. Its README states that everything stays on localhost and that a claude.ai sign-in is required, because channels need it.

Setup steps are in the documentation at [peers.zhanwei.wang](https://peers.zhanwei.wang/), the code is at [github.com/wangzw/peers](https://github.com/wangzw/peers), and it is licensed under Apache-2.0.
