ssh-mcp-server
A structured SSH management service that exposes command execution, file transfer, background jobs, GPU monitoring, systemd operations, and port forwarding as MCP tools with strict security and explicit input schemas.
README
SSH MCP Server
English | 简体中文
A structured SSH management service for Codex and other MCP clients. It exposes command execution, file transfer, background jobs, GPU monitoring, systemd operations, and port forwarding as MCP tools with explicit input schemas, structured outputs, and accurate safety annotations.
Features
- Connects only to explicit
Hostaliases declared in~/.ssh/config. - Strictly verifies
known_hostsby default and rejects unknown or changed host keys. - Reuses AsyncSSH connections and rebuilds stale connections automatically.
- Transfers files and directories over SFTP without invoking an external
scpcommand. - Runs background jobs in isolated process groups with persistent identity, logs, exit status, status discovery, safe cancellation, and cleanup.
- Calculates remote file growth rate, progress, and estimated completion time.
- Reports NVIDIA GPU metrics, system resources, systemd service state, and journal logs.
- Binds SSH tunnels only to the local loopback address,
127.0.0.1. - Applies MCP safety annotations to arbitrary commands, file overwrites, and service control.
Quick Start
Requirements
- Python 3.11 or later
- uv
- An OpenSSH
configfile and a verifiedknown_hostsfile
Install and Run
git clone https://github.com/yuyi-clip/ssh-mcp-server.git
Set-Location ssh-mcp-server
uv sync --locked
uv run ssh-mcp-server
Configure an SSH Host
The server accepts explicit aliases, not arbitrary IP addresses or hostnames:
# description: GPU inference server
# environment: development
# tags: gpu,video
Host gpu-01
HostName 192.0.2.10
User operator
IdentityFile ~/.ssh/id_ed25519
Port 22
192.0.2.10 is a documentation-only address. Replace it with your server address, verify the
host fingerprint through a trusted channel, and add it to ~/.ssh/known_hosts before connecting.
Connect from Codex
Register the stdio MCP server with the Codex CLI:
codex mcp add ssh -- uv --directory "D:\path\to\ssh-mcp-server" run ssh-mcp-server
Alternatively, add it to ~/.codex/config.toml manually:
[mcp_servers.ssh]
command = "uv"
args = [
"--directory",
"D:\\path\\to\\ssh-mcp-server",
"run",
"ssh-mcp-server",
]
startup_timeout_sec = 20
tool_timeout_sec = 120
default_tools_approval_mode = "writes"
Restart Codex after editing the configuration and use /mcp to verify the server status.
Tool Overview
| Category | Tools |
|---|---|
| Hosts and commands | ssh_list_servers, ssh_check, ssh_execute |
| File transfer | ssh_upload, ssh_download |
| Background jobs | ssh_start_job, ssh_job_status, ssh_job_list, ssh_cancel_job, ssh_job_cleanup |
| Download monitoring | ssh_file_progress |
| Host monitoring | ssh_gpu_status, ssh_system_status |
| systemd and journal | ssh_service_status, ssh_service_control, ssh_read_journal |
| Tunnels | ssh_tunnel_start, ssh_tunnel_list, ssh_tunnel_stop |
See the tool reference for parameters, safety properties, and usage guidance.
Optional Environment Variables
| Variable | Purpose |
|---|---|
SSH_MCP_CONFIG |
Use a custom OpenSSH config path |
SSH_MCP_KNOWN_HOSTS |
Use a custom known_hosts path |
SSH_MCP_ALLOW_UNKNOWN_HOSTS=1 |
Temporarily allow unknown hosts; not recommended |
SSH_MCP_PASSWORD_<ALIAS> |
Supply a temporary password for one alias |
Non-alphanumeric characters in an alias are converted to underscores and the result is
uppercased. For example, gpu-01 maps to SSH_MCP_PASSWORD_GPU_01. Prefer key authentication
and avoid long-lived password environment variables.
Documentation
The detailed documents are currently maintained in Chinese. English documentation can be added incrementally without changing the tool interfaces described here.
Development and Verification
uv sync --locked
uv run ruff format --check .
uv run ruff check .
uv run pytest -q
The test suite covers configuration parsing, input validation, tool registration, connection behavior, background job lifecycle, and a real MCP stdio initialization handshake. Linux CI also executes the real process-group lifecycle test.
Current Limitations
- Remote shell and systemd workflows target Unix-like hosts, with full background-job support requiring Linux.
- SFTP transfers do not yet support resume or progress events.
- Background jobs require Linux
/proc,sh,setsid,nohup,tail, and common Coreutils. - Jobs created by older versions can still be inspected, but cannot be safely cancelled because they lack process identity files.
- Tunnel state exists only in the current MCP process and is closed when the process exits.
- Direct server-to-server transfer and batch cluster execution are not implemented.
License
This repository does not currently declare an open-source license. Public visibility does not grant permission to copy, modify, or distribute the code; contact the maintainer before reuse.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。