
SSH Session MCP
io.github.Zw-awaPublished by GitHub account Zw-awav2.7.1Updated Oct 24, 2026
Shared SSH PTY runtime for MCP clients with viewer, input lock, async tracking, and policy rules.
Overview
A local MCP server that gives the assistant and the user one shared SSH terminal session, with a browser viewer, input lock and command policy rules.
- What you can do
- Connect to configured SSH devices or a legacy single target, and open, list, switch and close sessions
- Run commands with completion detection and exit codes, poll async progress, and retry flaky commands
- Send raw terminal input, control keys and resizes, and read buffered output, history and long-poll updates
- Inspect session diagnostics, lock state and viewer health, and open or list browser viewers
- List, add, remove and reset session-level policy rules that block risky commands
- When to use it
- Useful when an assistant should help on a remote Linux host, board or deployment machine through a real terminal while the user keeps visibility and can take over. Also handy for long-running remote work that needs tracked state instead of one-off commands.
- Requirements
- Runs locally via npx or a global npm install (Node.js). Needs either a device profile config file or legacy SSH_HOST, SSH_USER and SSH_PORT, plus authentication via SSH_PASSWORD, SSH_KEY, or passwordEnv/keyPath in the config. Optional settings include SSH_MCP_MODE, VIEWER_PORT, VIEWER_HOST and SSH_MCP_INSTANCE.
Installation
In SourceWeft
- Open SSH Session MCP in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
ssh-session-mcp
中文 | English
[License: Apache%202.0] [Node.js Version] [TypeScript] [npm version]
Persistent shared-terminal runtime for MCP clients over SSH.
ssh-session-mcp gives the user and the AI the same SSH PTY session, adds a browser viewer, tracks who typed what, and makes long-running remote work manageable instead of stateless.
Contents
- Install At A Glance
- Project Structure
- Quick Start
- Docker Status
- MCP Tools
- Configuration Summary
- Security
- Docs
- Development
Install At A Glance
- Normal users do not need to
git clonethis repository. - Preferred install path for MCP clients:
npx -y ssh-session-mcp --viewerPort=auto - Preferred install path for human operators who want local binaries:
npm install -g ssh-session-mcp - Official container distribution can be published to a public registry such as
docker.io/zwawa/ssh-session-mcp git cloneis only for contributors, source builds, and local development.- For the common desktop MCP workflow,
npxor a global npm install is still the lowest-friction path. Docker is mainly useful when you want a pinned runtime, container-based deployment, or registry-backed distribution.
Why It Exists
Most SSH-oriented MCP servers can execute commands, but they do not manage terminal state well enough for real collaboration.
ssh-session-mcp focuses on the missing runtime layer:
- One shared PTY for both the human and the AI
- Browser terminal for live inspection and manual intervention
- Input lock so the AI does not type over the user
- Safe/full execution modes for risky commands
- Configurable default policy rules plus session-level custom rule overrides
- Async command tracking for long-running remote work
- Multi-device and multi-connection profile support
- Local debug mode for demos, offline testing, and prompt iteration
Best Fit
- AI-assisted remote development on Linux boards and SSH servers
- Embedded, ROS, training, and deployment hosts that need a real terminal
- Users who want the AI to help, but do not want to surrender the terminal
- MCP Marketplace listings where the install and demo path must be clear
Project Structure
Key directories and files:
Quick Start
1. Agent-First Install (Auto-download on first run)
If the goal is to let Claude Code, Codex, or OpenCode install the server automatically, prefer npx -y ssh-session-mcp in the MCP command instead of a prior global install.
For Cline Marketplace and other agent installers, see llms-install.md. This repo is structured to be one-click installable through an npx -y ssh-session-mcp --viewerPort=auto command.
Claude Code
Windows note from the Claude Code docs: native Windows users should wrap npx with cmd /c for stdio MCP servers.
Codex
OpenCode
OpenCode's opencode mcp add flow is interactive. Choose a local MCP server and use this command:
If you prefer config instead of the interactive flow:
This is the closest thing to "automatic installation" for stdio MCP servers today: the MCP client stores the command, and npx -y downloads the package automatically the first time it runs.
2. Fastest Local Demo
This starts a local shell instead of SSH and opens the browser terminal, which is the easiest way to test the MCP runtime before touching a real server.
3. Register As An MCP Server
Use the MCP server binary directly when wiring a client:
If you prefer npx instead of a global install:
4. Connect To A Real SSH Target
Create .env from .env.example:
Then launch:
5. Multi-Device Config
For multiple boards or named targets, create ssh-session-mcp.config.json:
Discovery order:
--config=/path/to/config.json- Workspace
ssh-session-mcp.config.json - User-global config
- Legacy
.envfallback
Important:
- Config discovery is based on the MCP process working directory.
auth.passwordis intentionally unsupported. Useauth.passwordEnvorauth.keyPath.- Secrets belong in
.envor the parent environment, not in repo-tracked JSON.
6. Docker Status
Public Docker images should be distributed through Docker Hub, with GitHub Container Registry as an optional secondary registry:
Recommended container launch for a real SSH target:
Export the password in your shell first instead of placing it directly on the command line.
Recommended launch for profile-based config:
Equivalent Compose example:
See docker-compose.yml for a ready-to-run example that mounts ssh-session-mcp.config.json, publishes the viewer on 8793, and uses SSH_KEY_DIR when set or falls back to a dedicated ./keys directory.
For the full Docker guide, including the legacy .env compose variant and MCP client config snippets, see docs/docker.md.
For a container-oriented profile example, see docs/examples/ssh-session-mcp.config.docker.example.json.
Container-specific notes:
- The image defaults
VIEWER_PORTto8793when unset so the browser viewer can be published reliably. - The image defaults
VIEWER_HOSTto0.0.0.0inside the container so the mapped port is reachable from the host. AUTO_OPEN_TERMINALdefaults tofalsein the container because browser auto-open from inside a container is usually not useful.- Mount config files or SSH keys read-only when possible.
- Prefer mounting SSH keys from a directory outside the repo root.
- In
docker-compose.yml,SSH_KEY_DIRoverrides the default key mount path. If it is unset, Compose falls back to./keys, not the repo root. - Avoid putting passwords directly on the command line. Prefer exported env vars, Compose
.env, or--env-file. - For stdio MCP clients, Docker is viable, but host-native
npxis still simpler unless your client explicitly prefers containerized commands.
Docker-based MCP client command examples:
For JSON-based MCP clients, the same pattern works by using docker as the command and passing the remaining run ... docker.io/zwawa/ssh-session-mcp:latest tokens as args.
This is useful when:
- The primary workflow is a local stdio MCP server command, not a long-lived network service.
- You want a pinned Node/runtime environment without a local install.
- You need registry-based distribution for a team or managed host.
- You want container-level isolation for the MCP server process.
For many users, publishing to npm and recommending npx -y ssh-session-mcp --viewerPort=auto is still the lower-friction install path.
Viewer And Collaboration Model
The browser viewer is not decorative. It is part of the workflow:
- The user can see exactly what the AI did.
- The AI can pause when the user takes over.
- Password prompts, pagers, and editors become visible state instead of hidden failure modes.
- Session diagnostics and history turn terminal debugging into something inspectable.
Marketplace-Friendly Flow
For users:
For agents:
Use AGENT.md when you want the AI to install, inspect config, connect devices, and help the user end-to-end. Compatibility notes for older agent setups remain in AI_AGENT_GUIDE.md.
Core Differences From A Stateless MCP SSH Wrapper
- Shared PTY instead of one-off command execution
- Actor-aware transcript markers for user, system, and agent input
- Terminal-state checks before dangerous or nonsensical writes
- Auto cleanup for sessions and viewer processes
- Session-scoped browser viewer with diagnostics and history
- Local debug mode with
--localfor offline testing
Operation Modes
Each session now owns its own safe / full mode. Switching one browser terminal to full does not change other sessions.
The default rule set can be customized if needed. Custom rules now support:
error: block the commandwarning: allow but surface a warninglog: allow and annotate only
Rule precedence is error > warning > log, and within the same level, earlier rules win.
Lock Policy
The browser terminal UI lets the operator choose one of these input policies:
When the terminal is not available for agent input, tools such as ssh-run, ssh-session-send, and ssh-session-control return a blocked response instead of forcing input into the PTY.
MCP Tools
Recommended Daily Tools
Full Tool Catalog
Local Operator Commands
These helpers are for humans on the workstation that owns the viewer:
Default rule library management for operators:
Equivalent repo-local commands also exist:
Configuration Summary
Key environment variables:
Distributed v0
Distributed v0 intentionally implements a narrow boundary:
- Supported runtime modes:
single-nodeanddistributed - Distributed mode shares control-plane state only: node heartbeat, session metadata, binding metadata, command metadata, and viewer access policy
- When the current replica is not the owner, HTTP APIs return
REMOTE_OWNER, HTML pages render a remote-owner error page, and websocket attaches close with code4009 - Cross-node PTY migration is not supported
- Transparent cross-node HTTP or websocket proxying is not supported
Distributed v0 requires Redis for real multi-node deployments. SSH_MCP_STORE=memory only exists for local skeleton testing and does not provide a shared store across replicas.
Distributed configuration:
Recommended distributed env example:
Proxy auth is most useful in distributed mode behind a trusted reverse proxy. The built-in role mapping is:
viewer_read: pages, session list/read endpoints, history, diagnostics, health, readiness, metricsviewer_write: attach input, resize, controlsession_admin: mode changes, policy updates, close, set-active, debug-agent actions, local debug session creation
Macro / Environment Variable Reference
Use these variables according to your installation path:
Minimum Required Settings
Choose one of these minimum configuration sets:
- Local demo:
SSH_MCP_LOCAL=trueandVIEWER_PORT=auto - Legacy SSH with password:
SSH_HOST,SSH_USER,SSH_PASSWORD - Legacy SSH with key:
SSH_HOST,SSH_USER,SSH_KEY - Profile-based mode:
ssh-session-mcp.config.json, plus anypasswordEnvvariables referenced by that config - Docker Compose profile mode:
ssh-session-mcp.config.json, optionalSSH_KEY_DIR, optionalSSH_SESSION_MCP_IMAGE
Container Runtime Notes
- Container defaults now set
SSH_MCP_LOG_MODE=stderrso logs go to the container runtime without corrupting stdio MCP transport. - Mount
SSH_MCP_STATE_DIRpersistently when you want viewer policy, server info, and state files to survive container restarts. - Distributed multi-node deployments need Redis plus a routable
SSH_MCP_PUBLIC_BASE_URLper replica. - Distributed v0 does not provide cross-node PTY migration or transparent cross-node proxying. Route requests to the owner node when you receive
REMOTE_OWNER. - Health endpoints:
/livezfor process liveness/readyzfor readiness checks/metricsfor Prometheus text metrics
- Example single-instance Kubernetes baseline: docs/examples/ssh-session-mcp.k8s.single-instance.yaml
- Example distributed Kubernetes baseline: docs/examples/ssh-session-mcp.k8s.distributed.example.yaml
- Primary Kubernetes installation path:
deploy/helm/ssh-session-mcp
Example config file: docs/examples/ssh-session-mcp.config.example.json
Security
- The package never requires raw passwords inside tracked JSON config.
.envis ignored by git and npm.- Viewer HTTP binds to localhost by default.
- The MCP server treats terminal mode and input lock as first-class safety signals.
- CI runs Trivy filesystem and container-image scans against high and critical vulnerabilities.
- CI installs a pinned Trivy CLI release with checksum verification instead of relying on a floating third-party action tag.
- Release builds generate a CycloneDX SBOM for the published GHCR image digest and attach it to the GitHub release.
- Release builds sign the published GHCR image digest with keyless Cosign.
- GHCR digest is the primary verification path. Docker Hub remains a distribution path, not the main signature-verification target.
See SECURITY.md for the full policy.
Platform Notes
- Windows 10/11: first-class host environment
- Linux: strong fit for headless MCP + browser viewer workflows
- macOS: standard Node.js path supported
- Remote Linux hosts: first-class target
More detail: docs/platform-compatibility.md
Docs
- AGENT.md
- AI_AGENT_GUIDE.md
- llms-install.md
- docs/contracts.md
- docs/failure-taxonomy.md
- docs/acceptance-scenarios.md
- docs/docker.md
- docs/kubernetes.md
- docs/ingress-proxy-auth.md
- CHANGELOG.md
Development
Clone the repo only if you want to modify the source, run tests locally, or build release artifacts.
GitHub Actions included in this repo can:
- run CI on push and pull request
- deploy a GitHub Pages landing page from
dist/ - build a tagged GitHub Release with the npm package tarball attached
License
Apache-2.0. See LICENSE.
Source: README.md at commit 01e5039
Tools
0Version history
1- v2.7.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts