# SSH Session MCP [Health: Active]

**Category:** 🖥️ Command Line  
**Repository:** https://github.com/Zw-awa/ssh-session-mcp  
**GitHub Stars:** 4  
**npm Downloads (last month):** 317  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/ssh-session-mcp

## Description
Shared SSH PTY runtime for MCP clients with viewer, input lock, async tracking, and policy rules.

## Tools
Capabilities this server exposes over MCP:

- **ssh-quick-connect** — Connect or reuse the default target and optionally open the viewer
- **ssh-run** — Execute a command with completion detection and exit-code capture
- **ssh-status** — Inspect sessions, viewer state, and operation mode
- **ssh-command-status** — Poll async command progress
- **ssh-retry** — Retry flaky commands with backoff
- **ssh-session-policy-list** — Inspect inherited defaults and current session custom policy rules
- **ssh-session-policy-upsert** — Add or update a session-level custom policy rule
- **ssh-session-policy-remove** — Remove a session-level custom policy rule
- **ssh-session-policy-reset** — Reset session custom rules back to inherited defaults
- **ssh-session-open** — Open a session with explicit SSH parameters
- **ssh-session-send** — Send raw PTY input
- **ssh-device-list** — List configured devices and defaults
- **ssh-session-read** — Read buffered terminal output by offset
- **ssh-session-watch** — Long-poll for output and dashboard changes
- **ssh-session-history** — Read line-numbered mixed terminal history
- **ssh-session-control** — Send control keys such as `ctrl_c`, arrows, or `tab
- **ssh-session-resize** — Resize the PTY
- **ssh-session-list** — List tracked sessions
- **ssh-session-diagnostics** — Inspect lock state, warnings, running command state, and viewer health
- **ssh-session-set-active** — Choose the default session
- **ssh-viewer-ensure** — Open or reuse the local viewer
- **ssh-viewer-list** — List tracked viewer processes
- **ssh-session-close** — Close a session cleanly

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "ssh-session-mcp": {
    "command": "npx",
    "args": ["-y","ssh-session-mcp"],
    "env": {
      "SSH_HOST": "",
      "SSH_PORT": "",
      "SSH_USER": "",
      "SSH_PASSWORD": "",
      "SSH_KEY": "",
      "VIEWER_PORT": "",
      "AUTO_OPEN_TERMINAL": "",
      "SSH_MCP_MODE": ""
    }
  }
}
```

**Requires environment variables:** `SSH_HOST`, `SSH_PORT`, `SSH_USER`, `SSH_PASSWORD`, `SSH_KEY`, `VIEWER_PORT`, `AUTO_OPEN_TERMINAL`, `SSH_MCP_MODE` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What SSH Session MCP MCP server does

SSH Session MCP MCP server manages persistent terminal sessions over SSH rather than treating every command as an isolated request. An MCP client can connect to a configured device, reuse the active target, execute commands, inspect their progress, and interact with the remote PTY. The human operator can view the same session through a local browser terminal and intervene when needed.

The runtime supports a default target as well as named device profiles. It can also start in local mode, which provides a local shell for demonstrations, offline testing, and prompt development without connecting to an SSH host.

## How it works

The server maintains tracked SSH sessions and buffers terminal output for later reading. Commands can be run with completion detection and exit-code capture, while asynchronous operations can be polled or watched for output and dashboard changes. Retry support adds backoff for commands that fail intermittently.

Human and agent input share the PTY. An input lock is available to prevent the agent from typing over a person, and diagnostic tools expose lock state, warnings, command status, and viewer health. Session controls cover raw input, control keys such as `ctrl_c`, terminal resizing, active-session selection, clean closure, and line-numbered history.

The SSH Session MCP MCP server also applies execution policy. It can inherit configured defaults, add or update rules for an individual session, remove custom rules, or reset a session to inherited defaults. Safe and full operation modes are part of the runtime configuration.

## Setup and configuration

For MCP clients, the documented installation path is `npx -y ssh-session-mcp --viewerPort=auto`. A global npm installation is also supported with `npm install -g ssh-session-mcp`. The server communicates through stdio; Claude Code and Codex examples are provided in the project documentation.

A simple target can be configured with environment variables such as `SSH_HOST`, `SSH_PORT`, `SSH_USER`, `SSH_PASSWORD`, or `SSH_KEY`. The viewer can be configured with `VIEWER_PORT`, and `SSH_MCP_MODE` selects the operation mode. For several devices, use `ssh-session-mcp.config.json` with a default device, device IDs, connection details, authentication references, terminal dimensions, and viewer defaults.

Configuration discovery checks an explicitly supplied path, the workspace configuration, a user-global configuration, and then the legacy `.env` fallback. Passwords should be supplied through an environment variable or a key path rather than stored directly in tracked JSON. Docker images and Compose examples are also documented for pinned or container-based deployments.

## Tools and capabilities

The exposed tools cover:

- Connecting, opening, listing, selecting, inspecting, and closing SSH sessions.
- Running commands, checking asynchronous progress, retrying commands, and reading buffered output.
- Watching output changes, reading mixed terminal history, sending PTY input, control keys, and resize events.
- Listing configured devices and viewer processes, then opening or reusing the local viewer.
- Inspecting, adding, removing, and resetting session-level policy rules.
- Diagnosing locks, warnings, running commands, and viewer health.

## Limitations and notes

The project requires Node.js 18 or newer. Configuration lookup depends on the MCP process working directory, so a configuration file may not be found if the client launches the process elsewhere. The server is designed around SSH targets and terminal sessions; local mode is provided as a separate testing and demonstration path.

Authentication secrets should remain in the parent environment or `.env` files rather than repository-tracked configuration. Docker deployments that expose the viewer need corresponding port and host configuration. The SSH Session MCP MCP server includes client setup examples for Claude Code and Codex, while other MCP clients require their own stdio registration format.

_Full upstream README: https://allmcps.com/mcp/ssh-session-mcp/readme_

