Skip to main content
Glama

rhost

Operate SSH-reachable Linux hosts from coding agents or scripts over standard OpenSSH.

CI Release License: BSD-3-Clause

rhost gives coding agents (Claude Code, Codex, or any stdio MCP client) and CLI scripts local-like execution semantics over your existing OpenSSH setup: foreground commands, recoverable background Runs, compare-and-swap file edits with rollback, and persistent tmux sessions—backed by one capability layer (CLI, schema-v8 JSON, and stdio MCP), with zero remote daemon and zero remote Python.

Claude Code / Codex / CLI / JSON (schema v8)
  -> local OpenSSH (~/.ssh/config, ssh-agent, host keys, ControlMaster)
     -> standalone C99 remote helper / tmux (recoverable Runs, CAS files, PTYs)

Why it's built this way

  • OpenSSH instead of a custom SSH stack: Reuses ~/.ssh/config (aliases, ProxyJump, Match), ssh-agent, strict host-key verification, and ControlMaster (ControlPersist=15m). rhost never prompts for passwords, stores keys, or weakens host-key checks.

  • Survives disconnects and timeouts: Long-running jobs (run start / rhost_run) execute under a standalone remote monitor with durable state under ~/.local/state/rhost/v5 (RHOST_REMOTE_STATE). Client timeouts or cancellations only stop local observation, and uncertain submissions deduplicate safely.

  • Bounded reads and safe file edits: File reads default to 8 KiB (8192 bytes) and Run/session log previews default to 4 KiB (4096 bytes) with byte cursors (run watch follows both streams) instead of flooding agent context. File replacements verify whole-file SHA-256 and record changesets for rollback (fs undo).

  • C99 helper instead of remote Python: Native file operations and recoverable Runs run through a standalone C99 binary (helper/) cached privately at ~/.cache/rhost/helper/. Preparation reuses a valid cache, compiles with an existing remote C99 cc, or uploads a SHA-256-verified static Linux musl release binary (linux-x86_64, linux-aarch64), with no remote daemon and no package installs.

Related MCP server: cokacremote

Install

Release binaries (macOS and Linux on amd64/arm64; requires local Python 3.11+, verifies SHA-256 before atomic replacement):

curl -fsSL https://raw.githubusercontent.com/starfield17/rhost/main/scripts/install.sh | bash

Use RHOST_VERSION to pin a release or RHOST_INSTALL_DIR to set the binary directory (defaults to ~/.local/bin, or an existing writable standalone rhost / Homebrew bin on macOS PATH). Run rehash or hash -r if an open shell cached a prior path.

From source (Rust 1.88.0+):

git clone https://github.com/starfield17/rhost.git
cd rhost
make build-release
install -m 755 target/release/rhost ~/.local/bin/rhost

make build-release runs cargo build --locked --release --bin rhost and stamps commit/build date into rhost version --json; make build builds the debug binary.

Connect an agent

Ensure noninteractive OpenSSH works first using an SSH alias, user@example-host, or hostname:

claude mcp add --transport stdio --scope local rhost -- rhost mcp
codex mcp add rhost -- rhost mcp

Generic stdio clients launch rhost with ["mcp"] (use an absolute path if a GUI client's PATH differs). Filter advertised tools at startup with rhost mcp --tools runs,files (default all; groups: runs, files, sessions, diagnostics).

Install the optional Agent Skill to load workflow and recovery guidance on demand:

npx skills add starfield17/rhost --skill rhost

plugin.json and .codex-plugin/plugin.json package skills/rhost/SKILL.md; they require the rhost CLI separately and do not register MCP. See MCP setup guide for client configuration, SSH_AUTH_SOCK, tool schemas, and cancellation semantics.

Quick examples

# Inspect host readiness (read-only) and read or patch a remote file with CAS protection
rhost brief gpu --json
rhost fs read gpu ~/work/project/config.toml --json
rhost fs patch gpu ~/work/project/config.toml --from - --json <<'EOF'
{"edits":[{"old_text":"batch_size = 16","new_text":"batch_size = 32"}]}
EOF

# Start a recoverable background Run and follow output across reconnects
rhost run start gpu --cwd '~/work/project' --command 'cargo test --locked' --json
rhost run watch gpu <run_id> --json

# Device Mode: push a local tree, run remotely, and pull artifacts without remote Git
rhost push ./project gpu --name demo
rhost run --at demo --hosts gpu --command 'make test'
rhost pull gpu output.json ./output.json --at demo

# Foreground command execution
rhost exec gpu --cwd '~/work/project' --command 'uname -a'

Single closed JSON requests (schema_version: 8, matching MCP structuredContent) work via stdin:

rhost request --from - <<'EOF'
{"schema_version":8,"operation":"fs.read","host":"gpu","params":{"path":"~/work/project/config.toml","max_bytes":4096}}
EOF

Operations and references

Need

Interface

Reference

Bounded read/search, CAS edit, changesets

CLI, JSON, MCP rhost_read, rhost_find, rhost_edit

FILES.md

Recoverable work surviving CLI/MCP exit

CLI, JSON, MCP rhost_run

RUNS.md

Stateful shell, REPL, debugger (tmux)

CLI, JSON, MCP rhost_term

SESSIONS.md

Foreground command, transfers, Device Mode, tunnels

CLI (exec, fs put/get/sync/mirror, push/pull, tunnel)

CLI.md

Host brief, aliases, diagnosis, MCP setup

CLI, JSON, MCP

MCP.md

Helper cache/build policy, error.code recovery, safety

Policy & recovery tables

NATIVE.md, RECOVERY.md, SAFETY.md

  • Diagnosis vs. preparation: rhost doctor probes shell tools and resolved command -v paths (ok:true means the probe completed; inspect capabilities). Native fs.* and run.* prepare the C99 helper automatically; rhost helper prepare returns generation, remote_time_unix, and helper identity explicitly (rhost helper status reads an existing namespace without creating one).

  • Remote requirements: exec and doctor require /bin/sh, bash, ps, base64, and either setsid or Perl with POSIX::setsid. session requires bash, tmux, flock (session attach is refused with USAGE_ERROR); resumable/checksum transfers require rsync; native fs.* and run.* require only POSIX sh utilities to bootstrap the C99 helper (no remote Python or tmux).

  • Schema and boundaries: Public JSON uses schema v8 (v7.1.0+); branch on error.code and error.recovery, not prose. See state discovery and retention for run.list, fs.changeset.list, state.list, state.usage, and state.prune. rhost does not manage SSH credentials, system packages, Git branches/worktrees, or job scheduling.

Docs, schemas, and verification

make test-smoke   # offline Rust black-box suite (no network)
make check        # fmt, clippy, unit/contract/structure/portability/packaging checks

# Manual pre-release real-SSH suites (require an explicit target)
RHOST_TEST_HOST=<user>@<host> RHOST_BIN=./target/debug/rhost make test-live
RHOST_TEST_HOST=<user>@<host> RHOST_BIN=./target/debug/rhost make test-live-session
RHOST_TEST_HOST=<user>@<host> RHOST_BIN=./target/debug/rhost make test-live-all

make test-smoke and make check run offline; CI builds the shipping Linux helpers and verifies them against disposable strict-host-key sshd fixtures. Real-host test-live* and test-live-helper runs are optional manual pre-release verification; see Maintenance policy.

License

rhost is released under the BSD 3-Clause License.

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
      C
      maintenance
      Remote Linux operations via SSH, exposed as an MCP server, with tools for filesystem, systemd, Docker, network, and more, using per-user AD authentication and optional sudo elevation.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding agents to treat a remote Linux host over SSH as a local working tree, exposing editor-semantics operations, background job management, artifact transfer, and guard hooks through MCP.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to list SSH hosts, test reachability, retrieve Linux resource metrics, index and search project files, and run remote SSH commands when allowed, with local-first and safety-focused operations.
      MIT