mcp-ssh-persistent
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| MCP_SSH_CONFIG | No | Path of the config file (leading `~/` expanded). | ~/.mcp-ssh-persistent/config.json |
| MCP_SSH_CRED_BACKEND | No | Windows only: `powershell` forces the PowerShell Credential Manager backend instead of `@napi-rs/keyring`. The old name `MCP_SSH_WCM_BACKEND` is still accepted; the new name wins if both are set. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Persistent SSH to servers by alias. "ssh " / "on " means use these tools with server: "". Aliases: (none configured).
Tools: ssh_exec for one-off commands (stdout, "--- stderr ---", [exit: N]). ssh_stream_start/write/read/stop for stateful or interactive shells (footer [state: prompt | awaiting_input(sudo|password|confirm) | timeout | running | closed]); stop streams when done. ssh_read_remote_file / ssh_write_remote_file for files (no shell escaping), ssh_upload / ssh_download for SFTP (local paths limited to tmp + localPathRoots).
SECURITY (mandatory):
NEVER put a password in any tool argument or command (no "echo pass | sudo -S", no password in ssh_stream_write).
Sudo on non-root aliases: one-off -> ssh_exec { sudo: true } (password from OS credential store). Interactive -> stream; call ssh_sudo_auth only when the footer shows awaiting_input(sudo) right after a command you typed starting with sudo. Root aliases: run commands directly, no sudo flag.
If the sudo password is missing, ask the user to run it themselves: "npx -p mcp-ssh-persistent mcp-ssh-persistent-set-sudo-password " (or "npm run set-sudo-password -- " in a repo checkout).
"HOST KEY MISMATCH": stop and tell the user; only after they verify the new key, delete the entry named in the error from known-hosts.json.
Confirm with the user before destructive or service-affecting commands (restarts, rm, DB writes, firewall changes) unless explicitly told to proceed.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| ssh_execA | Run a command on a server via an exec channel (stateless, fresh environment per call; connects lazily). Returns stdout, a "--- stderr ---" section only when stderr is non-empty, and [exit: N]. Output is capped (head+tail kept). Exit 1 is not flagged as an error. Use ssh_stream_* for stateful/interactive work. |
| ssh_stream_startA | Open a stateful interactive shell (own channel, history disabled) on a server, bound to stream_id; later stream calls use stream_id only. Optional command runs like ssh_stream_write but waits only 2000 ms by default, so long-running commands (tail -f, pm2 logs) return early with [state: timeout]. stream_id must be unique across servers; max 4 streams per server by default. |
| ssh_stream_readB | Read buffered output of a stream since the last read/write. Footer [state: ...] shows prompt / awaiting_input(kind) / running. |
| ssh_stream_writeA | Write data verbatim to a stream shell (include a real newline to press Enter) and wait until the command finishes (shell prompt), an input prompt appears, or wait_ms elapses. Footer: [state: prompt | awaiting_input(sudo|password|confirm) | timeout]; timeout means the command may still run (use ssh_stream_read). Unread output from before the write is reported, not silently dropped. |
| ssh_sudo_authA | Answer a pending sudo password prompt in a stream with the password stored in the OS credential store (Windows Credential Manager / macOS Keychain / Linux Secret Service); never pass it yourself. Only acts when the stream shows exactly "[sudo] password for :" or the sudo-rs prompt "[sudo: authenticate] Password:" (state awaiting_input(sudo)); other prompts (ssh, su, mysql, Password:) are refused and nothing is sent. Call it right after a command you typed that starts with sudo. Waits like ssh_stream_write. |
| ssh_stream_stopA | Stop one stream: sends Ctrl+C, then closes only the shell channel of that stream. |
| ssh_statusB | Status of pooled SSH sessions (alias, host, user, connected, host-key fingerprint, streams). |
| ssh_disconnectB | Disconnect one server session, or all sessions when server is omitted. |
| ssh_uploadA | Upload a local file to a server via SFTP (parallel fastPut). local_path must lie under os.tmpdir() or a configured localPathRoots dir; key dirs, ~/.ssh, ~/.claude, the MCP server repo/config and any .claude/.git dir, .mcp.json or CLAUDE.md are always refused. Returns one line: path, bytes, ms. |
| ssh_downloadA | Download a remote file via SFTP (parallel fastGet to a .part file, then renamed over the target: no half files). Same local path policy as ssh_upload. Returns one line: path, bytes, ms. |
| ssh_write_remote_fileA | Write content to a remote file via SFTP (no shell escaping). Atomic: writes a temp file in the same dir, keeps the existing file mode/owner, then renames over the target. Falls back to an in-place write (with a warning) when the dir is not writable. |
| ssh_read_remote_fileA | Read a remote text file via SFTP. Returns "# ( bytes)" then the raw content. Files above limits.maxReadFileBytes (default 2 MB) or binary files are refused (use ssh_exec with head/tail/sed -n, or ssh_download). |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 12 tools
The set cleanly separates three modes of work: stateless exec (ssh_exec), stateful interactive shells (ssh_stream_*), and SFTP (ssh_upload/ssh_download/ssh_read_remote_file/ssh_write_remote_file). Descriptions explicitly steer between the closest pairs (exec vs stream_write, upload vs write_remote_file, read_remote_file vs download). The only real overlap is ssh_exec versus ssh_stream_start's optional command, which the 2000 ms timeout note clarifies but does not fully eliminate.
All twelve names use snake_case with a uniform ssh_ prefix and mostly verb-led forms (exec, start, read, write, stop, download, upload, disconnect). Minor deviations: ssh_status is a bare noun, and compound tails vary in ordering (write_remote_file vs upload, sudo_auth as noun+verb). Still highly predictable and readable.
Twelve tools is well within a healthy range and each maps to a distinct capability: exec, four stream lifecycle/IO operations, two transfer directions, two remote file read/write, sudo auth, plus status and disconnect. Nothing feels padded, and no obvious capability is crammed into an overloaded tool.
The surface covers connection pooling, exec, interactive shells with stop, bidirectional file transfer, exact-content remote writes, sudo escalation, and session inspection/teardown — a coherent lifecycle. Gaps are minor: no explicit directory listing, delete, or mkdir (workable via ssh_exec), and sudo auth only applies to stream prompts, not exec calls.