Skip to main content
Glama

You have a session open on the workstation that knows the engine, and another on the laptop working on the interface. When one needs something from the other, you end up copying context between two terminals by hand. With remote-sessions you just ask:

you    Ask the remote session Engine which commit the build is on.

       ● remote_send → "Engine" (Codex on linux-ws), delivered into the chat
       ● answer: main @ 4f2c91a, build is green

agent  The build is on commit 4f2c91a of main and it is green.

Table of Contents


Related MCP server: claude-peers

About

remote-sessions is a small MCP server that connects coding-agent sessions running on different computers of the same network.

You address a session by the name you gave it. The message lands in the live chat with that name on the other computer, the agent there works on it with everything it already knows, and its answer comes back to the session that asked. The two sessions can run different tools and different models.

There is nothing to host: every session starts its own copy of the server, the machines find each other on the local network, and everything they exchange is encrypted with a key that only your machines have.

It is meant for sessions on other machines. Sessions on the same computer are left out unless you ask for them, so it does not overlap with what the tools already do locally.

Typical moments when it helps:

  • The session that knows the answer is on another machine: ask it, instead of explaining everything again to a new one.

  • A workstation runs the long job (a build, a training run) and the laptop session checks on it.

  • You want a second opinion from a different model without leaving your chat.

  • Two halves of a project live in two sessions, and they need to agree on an interface.


Features

Feature

What it gives you

Sessions addressed by name

No addresses or ports to remember: you use the name you already gave the session.

Delivery into the open chat

The message appears in the session you have open, with its context and history, not in a hidden copy of the agent.

Any mix of tools and models

A Claude Code session can consult a Codex one, which can ask an OpenCode one. Each keeps its own model.

Ask and wait, or notify

Wait for the answer, collect it later, or send a one-way notice that needs no answer.

One name, several machines

If more than one machine has a session with that name, each receives the message and each answer is reported separately.

No server in the middle

No service to host, no account, no cloud relay: the sessions talk directly to each other.

Encrypted with your key

Machines without the shared key are ignored and cannot read anything.

Remote only by default

Sessions on the same machine are included only on request.

One-command setup

install registers the server in the three tools; doctor tells you what is wrong when something is.

Nothing to build

Plain Node.js with no dependencies.


Tech Stack

  • Node.js 18+, plain JavaScript, no dependencies: only the modules that ship with Node.

  • Model Context Protocol over standard input/output, implemented directly as JSON-RPC.

  • UDP multicast and broadcast (dgram) for discovery, TCP (net) for messages.

  • AES-256-GCM with a key derived by scrypt (crypto) for every frame on the wire.

  • node:test for the test suite, run by GitHub Actions on Linux, macOS and Windows.


Architecture

Each session starts its own copy of the server and talks to it over MCP. The servers talk to each other directly.

What happens when one session asks another:

sequenceDiagram
    participant A as Frontend (machine A)
    participant B as Engine (machine B)
    A->>B: who has a session named "Engine"? (multicast and broadcast on the LAN)
    B-->>A: I do
    A->>B: the message, encrypted
    Note over B: it appears in the open chat,<br/>the agent works on it
    B-->>A: the answer, matched by request id

Getting a message into an open chat is the part every tool does differently, so the server uses what each one offers:

Tool

How the message enters the chat

Where the session name comes from

Claude Code

a channel event (needs a start-up option, see Getting Started)

-n / /rename

Codex

Codex's own message queue

the thread name

OpenCode

a small companion plugin, installed for you

the session title

any other MCP client

it cannot: the session reads its inbox

RSC_SESSION_NAME

When live delivery is not available, the message is stored on the destination machine and the session is told about it the next time it uses one of the tools.


Project Structure

bin/
  remote-sessions.js            command line: serve, init, key, install, list, doctor
src/
  server.js                     the MCP server: tools, routing of requests and answers
  net.js                        discovery (UDP) and message exchange (TCP)
  crypto.js                     key derivation and frame encryption
  store.js                      per-machine state: key, identity, pending requests
  install.js                    registration in the three tools
  util.js                       shared helpers
  drivers/
    claude.js                   Claude Code: session identity, delivery by channel
    codex.js                    Codex: thread identity, delivery through its queue
    opencode.js                 OpenCode (through the plugin) and any other client
opencode/
  remote-sessions-plugin.js     companion plugin that runs inside OpenCode
test/                           test suite
test-support/                   minimal MCP client used by the tests
docs/                           images
.github/workflows/tests.yml     tests on Linux, macOS and Windows

Supporting a new tool means adding a driver: it says which sessions the server answers for and how a message is put into their chat.


Getting Started

You need Node.js 18 or newer on every machine, and the machines on the same local network.

1. Get the code and set it up (on each machine):

git clone https://github.com/terrordrummer/remote-session-connect-mcp.git
cd remote-session-connect-mcp

node bin/remote-sessions.js init            # first machine only: creates the shared key and prints it
node bin/remote-sessions.js key <the key>   # every other machine: stores that same key

node bin/remote-sessions.js install all     # registers the server in Claude Code, Codex and OpenCode
node bin/remote-sessions.js doctor          # checks this machine and shows which others answer

install also accepts claude, codex or opencode alone. Add --allow to let the tools of this server run in Claude Code and Codex without asking for approval: you want it on a machine where nobody is sitting, so that its sessions can answer on their own.

2. Name your sessions and open them:

Tool

Name the session with

To receive messages in the chat

Claude Code

claude -n Engine or /rename Engine

start it with claude --dangerously-load-development-channels server:remote-sessions

Codex

/rename Engine

nothing else; the thread needs at least one exchange

OpenCode

the session title

restart OpenCode once after installing

Sessions that were already open before the installation must be restarted. The first time, allow Node.js through the firewall on your private network (see Configuration).

3. Try it. In a session on another machine:

Which remote sessions are there?

Ask the remote session Engine to reply with the word "pong", and wait for the answer.

  • A session is not found. Run doctor on both machines. Same key fingerprint? Is a session open there, started after the installation? If neither machine sees the other it is the firewall or the network (try RSC_PEERS).

  • The message is "stored, not yet seen". Live delivery is not active on the destination: Claude Code was started without the channel option, or OpenCode without the plugin. Ask that session to check its remote inbox, or restart it properly.

  • Codex says "not confirmed open". On Windows the server cannot see which thread a Codex window has open until that thread uses one of its tools; the message is queued for the most recent thread with that name in the same folder.

  • No answer. The remote agent may be busy or waiting for a permission prompt on its machine. The request id lets you keep waiting.

  • Clocks. Frames older than ten minutes are refused: keep the machines' clocks roughly in sync.


Usage

Say that the session is remote: the agent is told to use these tools only in that case.

You say

What happens

"Which remote sessions are there?"

lists the sessions, with tool and machine

"Ask the remote session Engine … and wait for the answer"

the message goes into that chat, the answer comes back here

"Consult the agent in the remote session Engine about …"

same, and the two agents can go back and forth

"Tell the remote session Engine the deploy is done, no answer needed"

a one-way notice

"Send it to Engine on linux-ws"

only that machine, when several have a session with that name

If an answer is slow, the agent can keep waiting for it; one that arrives after the agent stopped waiting is shown in the chat that asked.

Tool

Purpose

remote_list

sessions reachable on other machines

remote_send

send a message to a named session and wait for the answer

remote_wait

keep waiting for an answer

remote_inbox

read the messages received from remote sessions

remote_reply

answer a received message

remote_whoami

how this session is seen by the others, state of the link; can set the name by hand

Run them as node bin/remote-sessions.js <command> from the project folder.

Command

Purpose

init

create the shared key on this machine and print it

key [value]

print the key fingerprint, or store the key created elsewhere

install <claude|codex|opencode|all> [--allow]

register the server in the tools

list [--local]

look for sessions on the network

doctor

check the configuration of this machine

serve

run the server (what the tools launch)

Does it work over the internet? It is made for a local network. Across subnets or a VPN it works by listing the other machines in RSC_PEERS.

Does the remote agent see my conversation? No. It receives only the message your agent writes for it, so your agent is told to include the context that is needed.

What if nobody is at the other machine? The remote agent answers on its own, as long as it does not stop at a permission prompt. install --allow lets the tools of this server run in Claude Code and Codex without prompting; everything else the agent does still follows the permissions of that session.

Can two sessions on the same machine use it? Yes, when you ask for it explicitly. By default they are left out.


Configuration

Everything works with the defaults. These environment variables change them:

Variable

Meaning

Default

RSC_KEY

shared key, instead of the key file

key file

RSC_HOME

state folder (key, machine identity, pending requests)

~/.remote-session-connect

RSC_PORT

UDP discovery port; message ports are the 100 ports after it

47821

RSC_PEERS

comma-separated addresses to ask directly when broadcast does not pass (VPN, separate subnets)

none

RSC_MACHINE_NAME

name of this machine shown to the others

host name

RSC_SESSION_NAME

fixed session name, for tools that do not provide one

none

RSC_DEFAULT_WAIT

seconds to wait for an answer when the agent does not say

300 in Claude Code, 45 elsewhere

RSC_MAX_WAIT

longest wait an agent can ask for, in seconds

900

RSC_CLAUDE_CHANNEL

1/0 to state whether the Claude Code channel option is active, instead of detecting it

detected

RSC_CODEX_BIN

path of the codex executable to use for queueing

detected

RSC_LOG

file to append the server log to

none

Each machine must accept, from the local network, UDP 47821 (discovery) and TCP 47822–47921 (messages; each session takes the first free port of the range).

  • Windows: at the first start Windows asks whether to allow Node.js on private networks: allow it. By hand, from an administrator prompt: netsh advfirewall firewall add rule name="remote-sessions" dir=in action=allow program="C:\Program Files\nodejs\node.exe" profile=private

  • macOS: if the firewall is on, allow incoming connections for node when asked.

  • Linux (ufw): sudo ufw allow proto udp from 192.168.1.0/24 to any port 47821 and sudo ufw allow proto tcp from 192.168.1.0/24 to any port 47822:47921 (adjust the network).

On different subnets or behind a VPN, where broadcast does not pass, set RSC_PEERS to the addresses of the other machines.

Claude Code

Registers the server for all projects:

claude mcp add --scope user remote-sessions -- node /absolute/path/to/remote-session-connect-mcp/bin/remote-sessions.js serve

With --allow it also adds "mcp__remote-sessions" to permissions.allow in ~/.claude/settings.json.

To receive messages in the live chat, start Claude Code with the channel option:

claude --dangerously-load-development-channels server:remote-sessions

Claude Code asks for a confirmation at each start (press Enter). Pushing messages into a chat is a preview feature of Claude Code reserved to approved servers, and this long option is how it lets you load your own; put it in an alias or in your launcher script. Without it the session can still send messages and receive answers, but it reads incoming messages only when it checks its inbox.

Codex

Appends this to ~/.codex/config.toml:

[mcp_servers.remote-sessions]
command = "node"
args = ["/absolute/path/to/remote-session-connect-mcp/bin/remote-sessions.js", "serve"]
# Waiting for a remote answer takes longer than the default tool timeout.
tool_timeout_sec = 660
# Written only with --allow: lets the session answer remote messages
# without asking for approval each time.
default_tools_approval_mode = "approve"

[mcp_servers.remote-sessions.env]
RSC_DEFAULT_WAIT = "600"

No start-up option is needed: messages enter the chat through codex queue.

OpenCode

Copies a companion plugin to ~/.config/opencode/plugins/remote-sessions.js. The plugin registers the server, so no configuration file is edited, and delivers incoming messages into the chat. OpenCode does not need to be started with a network port.

Without the plugin you can add the server by hand under mcp in opencode.json:

"remote-sessions": { "type": "local", "command": ["node", "/absolute/path/to/remote-session-connect-mcp/bin/remote-sessions.js", "serve"] }

but then incoming messages wait until the session reads its inbox, and the name must be set with RSC_SESSION_NAME.


Security

A message from another session is an instruction to an agent that may be able to run commands, so the project is closed by default:

  • Nothing works without the shared key. Only machines that hold it can find sessions, send or read messages. Treat it like a password.

  • Every frame is encrypted and authenticated (AES-256-GCM, key derived with scrypt), time-stamped, accepted once and valid only for the session it was written for: captured traffic cannot be read, replayed or redirected. An answer is accepted only by the session that sent the matching request.

  • The state folder (key, pending messages) is accessible to its owner only.

  • An incoming message is presented to the agent as a request from a collaborating agent: the receiving session keeps its own rules and permission settings.

If you change the code, these are the rules that keep it that way:

  • No frame is acted upon before it has been decrypted, checked for age and repetition, and found to be addressed to this session.

  • Text that comes from the network is never placed on a command line that a shell interprets, and identifiers that come from the network are checked before they become file names or arguments.

  • Everything written to the state folder is private to the owner.

  • New behaviour that reaches another session goes through the same request-and-answer path, so that it stays tied to a request id.

Found a vulnerability? Please report it privately through GitHub security advisories rather than in a public issue.


How to Contribute?

Issues and pull requests are welcome.

  • A problem: open an issue with the output of node bin/remote-sessions.js doctor from both machines, the tools and operating systems involved, and what you asked the agent.

  • A change: keep it dependency-free, add or update a test in test/, and make sure npm test passes. The suite starts several servers as separate machines on one host, so it exercises the real network code.

  • A new tool: add a driver in src/drivers/ (see Project Structure) and say how you tried it.

Reports from Windows and from networks with unusual setups (VPNs, several interfaces, strict firewalls) are especially useful.


What's Next?

Where the project stands: version 0.1. It has been exercised on macOS with open sessions of all three tools, in both directions (Claude Code and Codex with their own models, OpenCode with a scripted stand-in model). The test suite runs on Linux, macOS and Windows with Node 18 and 22 at every change.

Planned:

  • Try live delivery with real sessions on Windows, where so far only the network and protocol parts have been run.

  • Remove the confirmation Claude Code asks at each start, as soon as the tool offers a way to approve a local channel permanently.

  • Installation without cloning, through npx.

  • In OpenCode, name the exact session that sends a message (today it is the most recently active one of that window).

  • A short recording of two machines talking, for this page.

Known limits today:

  • Claude Code needs the channel option at each start for live delivery.

  • A Codex thread is reachable once it has a name and at least one exchange. A message queued for a closed thread is processed when that thread is opened again.


License

Released under the MIT License.


Acknowledgements


Author

Roberto Sartori · @terrordrummer

Questions, ideas or a setup that does not work: open an issue.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables peer-to-peer communication, discovery, shared state, and file coordination between AI coding agents across machines and sessions.
      28 npm
      17
      Elastic 2.0
    • A
      license
      A
      quality
      C
      maintenance
      Enables local messaging between Claude Code, Codex, Pi, and other coding-agent sessions on the same machine, allowing them to discover each other, send updates, ask questions, and reply.
      8
      23 npm
      3
      AGPL 3.0