remote-agents
A unified MCP-compatible system for controlling fleets of remote machines through AI agents.
README
Remote Agents
A unified, MCP-compatible system for controlling fleets of remote machines through AI agents (Claude, opencode). Agents connect outbound to a relay; an MCP server lets the AI run commands, manage files, drive git, schedule tasks, and orchestrate the whole fleet — all over end-to-end-encrypted channels.
Features
- Single Rust binary (
remote-agent) — runs as an agent daemon (run), an MCP stdio server (mcp), or installs itself as a service (install). - End-to-end encryption (AES-GCM-256) on by default; the relay forwards only ciphertext.
- Safety modes per host —
plan(read-only),edit(writes with backups),bypass,disabled— with path/command allow- & deny-lists. - Fleet as one computer — run any operation (
exec/read/write/git) across all agents, by tags, or by OS family; results aggregated per host. - Distributed MapReduce — partition data across the fleet, map with a shell command, reduce the outputs, with per-partition retry.
- Autonomous mode — delegate AI tasks to a host that runs them with its own credentials (token-saving orchestration).
- Two interchangeable relays — Cloudflare Workers (Durable Objects) or a
self-hosted Rust WebSocket relay; switch by changing
relay_url. - Direct UDP data channel with hole-punching and WebSocket fallback.
Architecture
┌──────────────────────────────────────────────────────────────┐
│ opencode / Claude Desktop │
│ remote-agent mcp (Rust binary, MCP stdio server) │
└───────────────────────────────┬──────────────────────────────┘
│ wss:// (CF Worker or self-hosted relay)
▼
┌───────────────────────────────────┐
│ Relay (rooms route by token) │
└───────────────────────────────────┘
▲ ▲ ▲
│ wss │ wss │ wss
┌──────┴─────┐ ┌──────┴─────┐ ┌──────┴─────┐
│ Agent │ │ Agent │ │ Agent │
│ (daemon) │ │ (daemon) │ │ (daemon) │
└────────────┘ └────────────┘ └────────────┘
Workspace layout
| Crate / dir | Purpose |
|---|---|
crates/shared |
Wire protocol, AES-GCM crypto, UDP channel types |
crates/mcp-server |
The remote-agent binary: agent, MCP server, executors |
crates/relay |
Self-hosted Rust WebSocket relay (remote-agents-relay) |
worker/ |
Cloudflare Worker relay (Durable Objects) |
Install
# Via npm (downloads the prebuilt binary for your platform)
npm install -g remote-agents # then: remote-agents --help
# or run on demand:
npx remote-agents mcp --help
# From source
cargo build --release --workspace
cargo install --path crates/mcp-server # → ~/.cargo/bin/remote-agent
Prebuilt binaries for macOS / Linux / Windows are also attached to each GitHub release.
Running: one binary, two ways
remote-agents is one binary that behaves the same whether you launch it
directly with flags or an AI host (opencode / Claude) starts it as an MCP
server. Connection settings resolve identically in both cases:
CLI flag > REMOTE_AGENTS_* env var > config.toml > default.
It is a flat peer network — there are no controller/agent roles. Every node
joins a relay room as an equal peer: visible to all, able to dispatch work, and
(unless --no-agent) able to execute commands from others.
| Mode | Command | The node… |
|---|---|---|
run |
remote-agents run … |
is a headless full peer (executes + dispatches), no local AI |
mcp |
remote-agents mcp … |
is a full peer plus an MCP server for a local AI (opencode / Claude) |
hybrid |
remote-agents hybrid … |
alias for mcp (kept for compatibility) |
Every mode is a full peer that accepts commands by default. Add --no-agent
to make a node send-only (stays visible and dispatches work, but never runs
others' commands — for prod controllers or browser dashboards). --no-agent
also works in an MCP env block as REMOTE_AGENTS_* config.
Common flags: --relay <wss://host> --room <name> --token <secret>
--name <id> --tags a,b --no-agent.
Keeping a host always online
A mcp node lives only as long as the AI host (opencode / Claude) keeps it
running — close the session and the node leaves the room. For a host that should
stay in the fleet 24/7, independent of any AI session, install it as a
background service running run:
remote-agents install --room dev --token <secret> --relay wss://<your-relay-host>
# systemd user service (Linux) / launchd LaunchAgent (macOS); auto-starts,
# survives logout/reboot, auto-restarts. Remove with: remote-agents uninstall
A machine has one persistent identity (agent-id), and the relay keys peers
by id, so don't run both a run service and an mcp session on the same machine
with the same id — they'd evict each other. Typical topology: target hosts run
the run service (always online); the workstation that drives the fleet runs
mcp per session.
Quick start
1. Run an agent on a remote host (with flags)
# Install once (downloads the prebuilt binary for your platform):
npm install -g remote-agents
# Run as a peer agent:
remote-agents run --relay wss://<your-relay-host> --room dev --token <secret> \
--name web-1 --tags backend
# ...or install it as an auto-starting user service (systemd / launchd):
remote-agents install --room dev --token <secret> --relay wss://<your-relay-host>
2. Choose a relay
Self-hosted (Rust):
remote-agents-relay --bind 0.0.0.0:8080
# agents/MCP then use relay_url = ws://<host>:8080
# optional: --token <secret> to gate room access at the relay;
# --idle-timeout-secs <n> to reap silently-dead sockets (default 90, 0 disables)
# monitoring: GET /health, /api/rooms (all active rooms + counts),
# /api/room/:room (one room's agents)
Cloudflare Worker:
cd worker
npm install
CLOUDFLARE_API_TOKEN=<token> npx wrangler deploy
# → wss://<your-worker-subdomain>.workers.dev
3. Install as an MCP server for Claude Desktop / opencode
After npm install -g remote-agents, point your AI host at the same binary in
mcp mode (stdio). The machine joins the room as a full peer (executes commands
from others) — add "--no-agent" to the args if it should be a send-only
controller instead:
{
"mcpServers": {
"remote-agents": {
"command": "remote-agents",
"args": [
"mcp",
"--relay", "wss://<your-relay-host>",
"--room", "myroom",
"--token", "<secret>"
]
}
}
}
(opencode uses the same shape under its own mcp config key — see
~/.config/opencode/opencode.json.)
Connection settings are resolved as CLI flag > env var > config.toml >
default, so you can instead supply them via env in the MCP config:
{
"mcpServers": {
"remote-agents": {
"command": "remote-agents",
"args": ["mcp"],
"env": {
"REMOTE_AGENTS_RELAY": "wss://<your-relay-host>",
"REMOTE_AGENTS_ROOM": "myroom",
"REMOTE_AGENTS_TOKEN": "<secret>"
}
}
}
}
Without any relay/room/token the server runs locally only (no remote agent control); nothing points at a hosted endpoint by default.
One-command client registration
Instead of hand-editing each agent's config, let the binary write it. The connection flags are baked into the registered server's args:
remote-agents install-mcp --client cursor \
--relay wss://<your-relay-host> --room myroom --token <secret>
# ✓ Registered MCP server 'remote-agents' for Cursor (created ~/.cursor/mcp.json)
remote-agents install-mcp # no --client: list supported clients
Supported: claude-desktop, claude-code, cursor, cline, roo, kilo,
windsurf, zed, opencode (config merged in place, preserving any servers
you already have) and continue, goose (YAML — a ready-to-paste snippet is
printed). Add --server-name, --name, --tags, or --no-agent to customize
the registered entry.
MCP tools
| Tool | Description |
|---|---|
exec |
Run a shell command (locally or on a remote agent via agent_id) |
read_file / write_file / list_dir |
File operations (write requires Edit/Bypass) |
get_info / set_mode |
Inspect / change an agent's mode at runtime |
git_status / git_pull / git_commit / git_push |
Git operations |
schedule_add / schedule_remove / schedule_list |
Cron-style tasks on a host |
task_dispatch / task_get / task_list / task_wait |
Autonomous AI tasks run with the host's own credentials |
list_agents |
List agents connected to the relay room |
fleet_exec / fleet_read / fleet_write / fleet_git / fleet_search |
Run an operation across the fleet — target = all | tag1,tag2 | os:<family> |
file_search / file_stat / send_file / transfer_get |
Find files on a host, and move a file host→host (UDP, SHA-256 verified) |
tunnel_start / tunnel_list / tunnel_stop |
Expose a host's local port at a public *.trycloudflare.com URL via a Cloudflare quick tunnel (cloudflared auto-downloaded; Edit/Bypass) |
mapreduce |
Distributed map/reduce over the fleet (shell map/reduce functions) |
Each agent advertises platform metadata (OS family, distro, kernel, shell) and is aware of its peers, so the orchestrator can target hosts by OS and tailor commands per platform.
File search, download & transfer
Find and move files across the fleet — over the same end-to-end-encrypted channel:
- Search a host's files by name, content, or images-only (
file_search, with sensible default roots: home + Pictures/Documents/Downloads/Desktop). When a deterministic search comes up empty, the host's AI can locate the file. - Preview & download to the browser: images get a host-generated thumbnail; any file downloads via a binary-safe, chunked pull through the relay (each chunk is its own request, staying under the relay's frame limit — no UDP needed in the browser).
- Host↔host transfer:
send_filestreams a file from one host to another over the direct UDP data channel (a channel is opened on demand, with automatic relay fallback), verified end-to-end with SHA-256. Receiving writes to disk and requires Edit/Bypass mode on the destination.
The browser panel (fleet-chat) exposes all of this: a 📁 Files view to search,
preview photos in chat, download, and move files between hosts with live
progress.
It also surfaces each host's local AI-chat history, labelled by host and
provider. Resumable providers (claude, opencode) can be continued from the
panel; the VS Code agents (cline, roo, kilo) and zed are imported
read-only — their transcripts are shown for browsing but have no headless resume.
Security modes
| Mode | Behavior |
|---|---|
plan |
Read-only (read, ls, git status, safe exec) |
edit |
Writes allowed, with automatic backups |
bypass |
Unrestricted |
disabled |
Agent rejects all operations |
Command payloads are encrypted end-to-end (AES-GCM-256) with a key derived from
the room token (or an explicit encryption_key); the relay only ever sees
ciphertext. A hard deny-list applies even in bypass mode.
Development
cargo test --workspace # unit + integration tests
cargo clippy --workspace --all-targets -- -D warnings
cargo run --release -p remote-agents-relay -- --bind 127.0.0.1:8080
(cd worker && npx tsc --noEmit -p .) # worker typecheck
# Fuzzing (nightly + cargo-fuzz)
cargo +nightly fuzz run <target> --fuzz-dir crates/mcp-server/fuzz
CI (.github/workflows/ci.yml) runs the test suite, Clippy (deny-warnings), and
the worker typecheck on every push and pull request.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。