Skip to main content

claude-code-bridge

A small MCP server that lets one coding-agent session message another machine's session over plain SSH, and get the reply back. No cloud relay, no shared account, no extra API keys.

The internal name is cc-peer; this repository is its public home. It is published on PyPI as claude-code-bridge-mcp.

 ┌────────────────────┐      stdio (MCP)      ┌────────────┐      ssh      ┌──────────────────┐
 │  agent (host)      │ ◄───────────────────► │  cc_peer.py│ ────────────► │  agent -p        │
 │  list_peers /      │                       │  (local)   │ [--resume]    │  (remote machine)│
 │  send_message      │                       └────────────┘               └──────────────────┘
 └────────────────────┘

Why

Cross-session messaging between machines is often tied to a cloud account or a shared login. SSH is usually already set up and needs neither. So this server just uses SSH.

Each peer keeps its own conversation history: the bridge stores the remote session id and resumes it on the next message. It only starts a fresh session when the old one is provably gone. A network error never silently drops the history.

Install

pipx install claude-code-bridge-mcp==1.0.0

or run it without installing:

uvx claude-code-bridge-mcp==1.0.0

Pin the version in client configs and bump it deliberately. To audit exactly what you run, install from source: python cc_peer.py.

Features

  • MCP over stdio - works with any MCP-capable client. Single file, Python standard library only.
  • list_peers - shows the configured peers and whether each is reachable.
  • send_message - sends a message, returns the reply, and keeps the conversation going across calls.
  • Session resume with stale-session detection and safe retry.
  • Windows-aware - correct quoting for both POSIX (sh) and Windows (cmd) peers.
  • Built-in self-test: cc-peer --self-test.

Quickstart

Requirements: Python 3.11+, the same agent CLI on both machines, and SSH key auth to the peer (BatchMode-friendly).

  1. Create ~/.cc-peer.json (or start from examples/cc-peer.example.json):
{
  "peers": {
    "my-server": {
      "ssh": "my-server",
      "shell": "sh",
      "cwd": "",
      "command": "agent",
      "args": [],
      "ssh_args": ["-o", "BatchMode=yes", "-o", "ConnectTimeout=10"],
      "timeout": 600
    }
  }
}
  • ssh - a ~/.ssh/config host (recommended) or user@host.
  • shell - sh for Linux/macOS peers, cmd for Windows peers.
  • cwd - optional: run the remote command from a different directory.
  • command - the remote CLI to run. It must accept -p, --session-id <id> and --resume <id>.
  • args - optional extra arguments for that command.
  1. Register the server with your MCP client. With uvx:
{
  "mcpServers": {
    "cc-peer": {
      "command": "uvx",
      "args": ["claude-code-bridge-mcp==1.0.0"]
    }
  }
}

After pipx install, use "command": "cc-peer" with no args instead.

  1. Try it from the client:
list_peers()
send_message(peer="my-server", message="What is in your working directory?")

Session ids are stored in ~/.cc-peer-state.json - never commit it.

How it works

send_message runs ssh <peer> <command> -p --resume <session-id> and pipes the message to stdin. The remote session's stdout is the reply. Session ids are kept per peer in a small state file; if the remote reports that the conversation no longer exists, the bridge retries once with a fresh session id. Any other failure (timeout, unreachable host) is returned as an error without touching the stored session.

Safety notes

  • Authenticate with SSH keys and BatchMode=yes. The bridge never handles passwords and stores no secrets.
  • Everything you send becomes input to the remote session - do not pass credentials through it.
  • The bridge adds no permission-bypass flags on its own. If you add one via args, that is an explicit choice on your side.

Troubleshooting

  • ssh not found on PATH - on Windows the server falls back to the Git for Windows and Windows OpenSSH locations; if both are missing, install OpenSSH or put ssh.exe on PATH.
  • Remote replies look garbled on Windows peers - set "shell": "cmd"; quoting differs between sh and cmd.
  • No conversation found - the stored session is gone; the bridge retries once with a fresh session automatically. If it keeps happening, the remote CLI is rejecting --session-id/--resume.

Limitations

  • Both machines need the same agent CLI on PATH (the server falls back to common Windows install locations for ssh only).
  • No streaming: you receive the remote reply when the remote command finishes.
  • One conversation per peer (a single stored session id), not per topic.
  • The state file has no concurrency guard - run one bridge process per user account.
  • Deliberately small: this is a bridge, not an agent framework.

License

MIT

Metadata

Release files for claude-code-bridge-mcp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-code-bridge-mcp 1.0.0
File Size Uploaded
claude_code_bridge_mcp-1.0.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-code-bridge-mcp 1.0.0
File Interpreter ABI Platform
claude_code_bridge_mcp-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / claude_code_bridge_mcp-1.0.0.tar.gz

Download URL claude_code_bridge_mcp-1.0.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e10206a2d32c8f6260cad7f000c91a751850795c4395676cc2147e5022c8f506
BLAKE2b-256 checksum
How to use checksums
6ed9789990283af424b7410b0be7017d77b37fb27cca8eb6eccd3794efb2bba5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 17, 2026.

Transparency log

Release files / claude_code_bridge_mcp-1.0.0-py3-none-any.whl

Download URL claude_code_bridge_mcp-1.0.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05fa96ca0bc48b7a60420fe63bc478274aed323c31682dc7798b162c0e074529
BLAKE2b-256 checksum
How to use checksums
b5c98c18c7db5110b03645938b9a33b1fff45e3c93cb75b076b77454668ad420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page