Skip to main content
Glama

OctSSH

δΈ­ζ–‡ README

XEnvManager V1.0

I was just VibeCoding and suddenly thought: Why can't I just let my agent deploy code to the server for me?

So, I built OctSSH.

OctSSH is an MCP server that gives LLMs safe, controllable, and stateful access to shell environments.

Note

By default (stdio mode), OctSSH only connects to machines already configured in your local ssh_config for passwordless login.


TIP

So... what makes OctSSH special?

Async Support

OctSSH provides a complete set of async tools to prevent LLMs from timing out on long-running tasks:

Tool

Description

exec(machine, command, confirm_code?)

Run short commands synchronously

sudo-exec(machine, command, confirm_code?)

Run synchronously as root (sudo -n)

exec-async(machine, command, confirm_code?)

Run long tasks in background (screen)

exec-async-sudo(...)

Run background tasks as root

write-stdin(session_id, data, append_newline?)

Write to stdin of a running async task

get-result(session_id, lines?)

Inspect async task output

grep-result(session_id, pattern, ...)

Search task logs

cancel(session_id)

Terminate a task

sleep(time)

Pause (useful for polling)

Note: In HTTP Serve mode, these tools operate directly on the local machine, and the machine parameter is omitted.

Related MCP server: SSH MCP Server

Security Design

OctSSH features a Virtual Mode and Confirm Code verification flow:

πŸ”’ Safety Mechanism: Virtual Mode

We don't want AI to become a world-ending terminator, so we designed Virtual Mode. When the AI attempts the following, OctSSH will not execute immediately, but instead returns a confirm_code:

  • πŸ“ File Overwrite: Uploading to a path that already exists.

  • πŸ’€ High-Risk Commands: rm -rf and similar "delete everything" commands.

  • πŸ” Regex Blocklist: Custom sensitive patterns defined in config.

Execution Flow Example:

  1. AI calls exec("web", "rm -rf /var/www/html")

  2. πŸ›‘ OctSSH intercepts: Recursive delete detected -> Returns confirm_code: a1b2c3 + file impact preview.

  3. πŸ‘€ User reviews and tells AI: "Confirm execution".

  4. βœ… AI calls exec("web", "rm -rf /var/www/html", "a1b2c3") -> Actually executes.

Quick Start

Installation

npm install -g @aliyahzombie/octssh
octssh init

Usage Modes

1. Default Client Mode (stdio)

Runs locally and controls remote machines via SSH (reads ~/.ssh/config):

octssh
Remote command shell

Remote commands use sh -lc by default. Set OCTSSH_REMOTE_SHELL on the OctSSH process to use another remote shell for synchronous, sudo, and async commands:

export OCTSSH_REMOTE_SHELL=bash
octssh

The value may be an executable name or path, such as bash, /bin/bash, or zsh. The selected shell must exist on every target machine and support the -lc options. This setting only affects SSH client mode; HTTP Serve mode uses OCTSSH_SHELL instead.

2. Streamable HTTP Server Mode (Local Control)

Install this on the target server. It exposes the server to LLMs via a secure HTTP interface. In this mode, OctSSH controls the local machine directly (no outbound SSH).

octssh serve
  • Default Listen: 127.0.0.1:8787 (Override via OCTSSH_SERVE_HOST / OCTSSH_SERVE_PORT)

  • Auth: Prints a random key on startup. Clients must send header X-OctSSH-Key: <key>.

    • Set fixed key: export OCTSSH_SERVE_KEY="my-secret"

  • Tool Changes: Tools run on this machine. machine parameter is omitted. SSH transfer tools (upload/download) are disabled.

Windows notes (serve mode)

On Windows, OctSSH serve will auto-select a local shell in this order:

  1. sh (if available, e.g. Git-Bash/MSYS)

  2. pwsh

  3. powershell

  4. cmd

Override with:

set OCTSSH_SHELL=powershell

Tool Prefix (optional)

To avoid tool name collisions when you run multiple OctSSH instances, you can prefix all exposed tools:

export OCTSSH_TOOL_PREFIX="us1_"

Example: list becomes us1_list.

write-stdin (async interactive input)

write-stdin lets you send input to a running exec-async session.

Typical flow:

  1. Start a long-running command that reads stdin (via exec-async)

  2. Send data with write-stdin(session_id, data)

  3. Poll output with get-result(session_id)

Notes:

  • Default append_newline is true.

  • Max payload is 64KiB per call.

  • This is a streaming stdin: EOF is not sent. If the program exits on EOF, cancel the session instead.

  • If you set OCTSSH_TOOL_PREFIX, tool names are prefixed too (e.g. us1_write-stdin).

MCP Client Configuration

General (stdio)

Add to your MCP client config:

{
  "mcpServers": {
    "octssh": {
      "command": "octssh",
      "args": [],
      "env": {
        "OCTSSH_REMOTE_SHELL": "bash"
      }
    }
  }
}

Claude Code CLI

claude mcp add octssh -- octssh

OpenCode CLI

{
  "mcp": {
    "octssh": {
      "type": "local",
      "command": "octssh",
      "args": [],
      "enabled": true
    }
  }
}

Or:

opencode mcp add octssh --command octssh
CAUTION

This project connects to real servers (or executes on the local machine). Please carefully review LLM operations. Using this project means you agree that the developer is not responsible for any accidental damage.

Available Tools

15 tools
cancelCancel Async SessionB

Terminate a running async session by session_id (signal is optional).

Inputs: session_id (required), signal.

downloadDownload Files/DirectoryA

Download a file or directory from the remote machine. Never overwrites local files; on conflict, you must choose a new local directory.

Inputs: machine (required), localPath (required), remotePath (required).

download-asyncDownload AsyncB

Async download. Only creates a session if the transfer actually starts. Never overwrites local files.

Inputs: machine (required), localPath (required), remotePath (required).

execExecute CommandB

Execute a command on a machine (no sudo).

Inputs: command (required), machine (required), confirm_code.

exec-asyncExecute AsyncB

Execute a long-running command in background (remote screen session).

Inputs: command (required), machine (required), confirm_code.

exec-async-sudoExecute Async (sudo)C

Execute a long-running command in background using passwordless sudo.

Inputs: command (required), machine (required), confirm_code.

get-resultGet Async ResultB

Get async command status; optionally tail last N lines from logs.

Inputs: session_id (required), lines.

grep-resultSearch Async LogsC

Search async stdout/stderr logs by pattern.

Inputs: pattern (required), session_id (required), maxMatches, contextLines.

infoMachine InfoA

Get cached (or refreshed) extended info for a machine via SSH.

Inputs: machine (required), refresh.

listList SSH HostsA

List configured SSH hosts from local ssh_config. Optionally return cached extended fields.

Inputs: no named parameters.

sleepSleepA

Sleep for a duration (ms).

Inputs: time (required).

sudo-execExecute Command (sudo)B

Execute a command on a machine using passwordless sudo (sudo -n).

Inputs: command (required), machine (required), confirm_code.

uploadUpload Files/DirectoryA

Upload a file or directory to the remote machine. Refuses to overwrite unless confirm_code is provided after a conflict preview.

Inputs: machine (required), localPath (required), remotePath (required), confirm_code.

upload-asyncUpload AsyncB

Async upload. Only creates a session if the transfer actually starts. Uses the same overwrite confirmation logic as upload.

Inputs: machine (required), localPath (required), remotePath (required), confirm_code.

write-stdinWrite to Async stdinB

Write data to a running async session stdin. Works for exec-async sessions (remote screen).

Inputs: data (required), session_id (required), append_newline.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 15 tools

    Disambiguation4/5

    Most tools are clearly distinct: exec vs exec-async vs sudo variants separate sync/async and privilege. A few pairs could cause confusion, such as list vs info (both fetch host data) and get-result vs grep-result (both inspect async logs), but descriptions clarify their different purposes.

    Naming Consistency4/5

    Tool names consistently use lowercase hyphenated words (exec-async, upload-async, get-result, write-stdin). However, the placement of 'sudo' varies: sudo-exec puts it first while exec-async-sudo puts it last, which is a minor inconsistency.

    Tool Count5/5

    15 tools is well-scoped for an SSH server, covering synchronous/async execution, sudo variants, file transfer, session management, and host info. Each tool serves a clear purpose without feeling bloated or sparse.

    Completeness4/5

    The domain of remote SSH operations is fairly complete: exec, sudo, upload/download (sync and async), session status/log retrieval, and host listing. Minor gaps include no file-browsing or interactive shell, but core workflows are well covered.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables LLMs to interact with remote servers via SSH, supporting command execution, file upload/download, and directory listing.
      7
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to securely execute commands, transfer files, and manage port forwarding on remote servers via SSH.
      158 npm
      38
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to securely execute commands on remote hosts via SSH and SFTP, with persistent shells, file transfers, screenshots, and an audit log.
      5
      MIT