
SSH Session MCP
io.github.Zw-awa由 GitHub 账号 Zw-awa 发布v2.7.1更新于 Oct 24, 2026
Shared SSH PTY runtime for MCP clients with viewer, input lock, async tracking, and policy rules.
概览
让助手获得共享的 SSH 终端会话,并带有浏览器查看器、输入锁、异步命令跟踪和策略规则。
- 可以做什么
- 运行一个用户与助手共享的持久 SSH PTY,使远程命令保持状态而非一次性执行。工具涵盖连接目标、执行命令并捕获退出码、发送原始输入或控制键、按偏移读取缓冲输出与历史、调整终端大小、轮询长时间运行的命令、重试不稳定命令,以及查看或修改会话策略规则。本地浏览器查看器显示实时终端,输入锁可防止助手在用户输入时抢占。
- 适用场景
- 适合在远程 Linux 板卡和 SSH 主机上进行 AI 辅助工作,尤其是需要真实交互终端的场景,例如嵌入式、ROS、训练或部署机器。也适合希望助手帮忙但保留可见性和手动控制权的用户。
- 运行要求
- 需要本地 Node.js 运行时,通常通过 npx 或全局 npm 安装运行,也可使用 Docker 镜像。需要 SSH 目标信息(主机、端口、用户),可通过旧版环境变量或配置文件提供,并需要密码或私钥凭据。浏览器查看器默认绑定本机地址;分布式模式还需要 Redis 和公开基础 URL。
安装
在 SourceWeft 中
- 打开 控制台中的 SSH Session MCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
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.
来源:README.md,提交 01e5039
工具
0版本历史
1- v2.7.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分