Safe Ssh Mcp

io.github.Areso由 GitHub 帳號 Areso 發布v0.2.3更新於 Nov 17, 2026

A secured scoped SSH MCP server for executing safe read-only diagnostic DevOps / SysOps commands

概覽

AI 產生的概覽

一個受限的 SSH MCP 伺服器,讓助理在遠端 Linux 主機上執行精選的唯讀診斷指令,用於 DevOps 與 SysOps 排障。

可以做什麼
  • 檢視遠端主機的磁碟、檔案系統與掛載使用情況
  • 讀取 CPU、記憶體、壓力、程序與 vmstat 指標
  • 檢查 systemd 單元、journal 錯誤、dmesg、失敗登入與 coredump
  • 檢視網路狀態:監聽埠、路由、DNS 查詢與 TCP 連通性
  • 檢視 Docker 容器、日誌與統計,以及 Kubernetes 事件、Pod 日誌與 crictl 狀態
  • 回報作業系統版本、已安裝套件以及執行中程序對應的檔案
適用情境
適合在不給助理通用 shell 的前提下診斷遠端 Linux 伺服器:例如排查服務為何失敗、磁碟被什麼佔滿、埠是否可達,或容器與 Pod 輸出了什麼日誌。
執行需求
以本機 Python 程序執行(PyPI 套件 safe-ssh-mcp,已在 Python 3.11-3.14 測試,僅限桌面端)。需要能連線目標主機的網路以及 SSH 憑證:透過工具傳入帳號密碼、以 key_path 指定無密碼金鑰,或透過 SSH_KEY_PASSPHRASE 環境變數或 macOS 鑰匙圈/ssh-agent(SSH_AUTH_SOCK)提供有密碼金鑰。密碼來源在 mcp_config.ini 中設定。
安裝前請注意
此伺服器涉及 SSH 憑證:密碼會傳給工具,SSH_KEY_PASSPHRASE 或 ssh-agent 身分可存取遠端主機,應限制程序存取權限,並避免把金鑰寫進原始碼倉庫或 shell 歷史紀錄。指令會以 SSH 使用者身分在正式系統上執行;雖然工具集設計為唯讀,README 明確表示不保證指令輸出不會被外部代理濫用。程序對應檔、套件清單與日誌等輸出會回傳給助理。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Safe Ssh Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Safe SSH MCP Server

A secure and scoped SSH MCP server for executing read-only diagnostic commands over SSH.
In this project, "safe" refers specifically to host safety: the server is designed to prevent modifications to the remote system and reduce the risk of operational harm. It does NOT attempt to guarantee that command output cannot be misused by external agents.

Badges

Snyk Vulnerability Database report - security check
[PyPI Downloads]

Overview

The core philosophy behind this MCP server is safety first. Instead of providing an AI agent with an unrestricted bash shell, this server exposes only carefully curated, read-only commands for system diagnostics and monitoring.

Feedback

Hi there! Using safe-ssh-mcp? I'd love to hear from you.

Whether you're using it with Claude Code, Codex, Ollama, or another MCP client, please tell me what works and what doesn't. Even a two-sentence report is valuable.

Share it in GitHub Discussions.

Available Tools (Partial List)

A few examples from each group; <...> marks a validated parameter.

Start here

  • get_host_overview : a first look in one call: identity, uptime, CPU, memory, pressure, disks, mount problems, failed units, top processes, listening sockets, journal errors. Each section is exactly the output of an existing tool; facts only, no thresholds or findings

Disk and filesystems

  • get_disk_free : df -h
  • get_disk_usage : find <path> -mindepth 1 -maxdepth 1 -exec du -sh -- {} + 2>/dev/null | sort -rh | head -n 20
  • get_mounts : findmnt (or cat /proc/mounts)
  • get_fstab : cat /etc/fstab
  • get_mount_problems : fstab against /proc/mounts and /proc/swaps (not mounted, read-only, swap off), then findmnt --verify

CPU, memory and processes

  • get_top : top -b -n 2 -d 1 -c -w 512, second sample, first 30 lines
  • get_vmstat : vmstat 1 5
  • get_mpstat : mpstat -P ALL 1 3 (per-core CPU), or computed from /proc/stat without sysstat
  • get_iostat : iostat -x -m -y 1 3 (per-disk await and %util), or computed from /proc/diskstats without sysstat
  • get_pressure : cat /proc/pressure/{cpu,io,memory}
  • get_cpu_info : lscpu (without flags), or a summary of /proc/cpuinfo where lscpu is missing

Systemd and logs

  • get_systemd_list_failed : systemctl list-units --state=failed --no-pager
  • get_systemd_status : systemctl status <daemon>
  • get_journal_errors : journalctl -p warning -n <lines> --no-pager
  • get_journalctl_disk_usage : journalctl --disk-usage
  • get_dmesg : dmesg

Network

  • get_listening_sockets : ss -tulpn
  • get_ip_route : ip route show and ip -6 route show
  • get_dns_lookup : getent ahosts <name> or dig <name> <record_type>
  • check_tcp_connect : nc -vz -w 3 <target_host> <target_port>

Docker

  • get_docker_ps_all : docker ps --all
  • get_docker_logs : docker logs --tail <lines> <container>
  • get_docker_stats : docker stats --no-stream

Kubernetes

  • get_kubectl_events : kubectl get events --sort-by=.lastTimestamp
  • get_kubectl_logs : kubectl logs --tail=<lines> --namespace=<namespace> <pod>
  • get_crictl_ps : crictl ps --all

System, logins and crashes

  • get_distroname_version : cat /etc/os-release
  • get_installed_packages : dpkg-query -W (with source package), rpm -qa --qf (with epoch and source RPM) or /lib/apk/db/installed (with origin)
  • get_process_files : /proc/<pid>/exe and /proc/<pid>/maps of every process, with the package that owns each file
  • get_failed_logins : lastb -F -n <lines>
  • get_coredumps : coredumpctl list --no-pager
  • get_cron_jobs : /etc/crontab, /etc/cron.d/* and every user's crontab (secrets redacted), with a check that a cron daemon runs

Click to open full list of available tools

Example of invocation

okay, could u check disk usage on /root/ path with help of safe-ssh-mcp server on a remote myserver.mydomain.pro using root and /Users/myUser/.ssh/id_rsa to login?

Means of connection

The server supports SSH account-password authentication and private-key authentication. Configure the private-key passphrase source in mcp_config.ini:

ini
# ENV_VAR (SSH_KEY_PASSPHRASE) or KEYCHAIN (ssh-agent)ssh_key_passphrase_method=ENV_VAR
  1. SSH account password: provide password to the MCP tool. Do not use this for a private-key passphrase.

  2. Unprotected SSH key: use key_path. The default ENV_VAR setting also supports unprotected keys; SSH_KEY_PASSPHRASE is not required.

  3. Passphrase-protected SSH key from an environment variable: leave ssh_key_passphrase_method=ENV_VAR, set SSH_KEY_PASSPHRASE in the environment that starts the MCP server, and provide key_path.

    bash
    export SSH_KEY_PASSPHRASE='your-key-passphrase'safe-ssh-mcp
  4. macOS Keychain / SSH agent: set ssh_key_passphrase_method=KEYCHAIN, then unlock the key in the same user session that starts the MCP server. The server receives SSH signatures from ssh-agent; it does not read the key passphrase or the key_path.

    bash
    ssh-add --apple-use-keychain ~/.ssh/id_ed25519
    # Optional: make the loaded identity expire after one hour.ssh-add -t 1h ~/.ssh/id_ed25519
    # Remove one identity, or clear every loaded identity.ssh-add -d ~/.ssh/id_ed25519ssh-add -D
  5. Cursor launched from the macOS Dock: use KEYCHAIN (recommended). You can run ssh-add from any Terminal window; it updates the SSH agent for your macOS login session, so Cursor does not need to be started from that Terminal.

    bash
    ssh-add --apple-use-keychain ~/.ssh/id_ed25519ssh-add -l

    After changing mcp_config.ini, restart the MCP server in Cursor (or fully quit and reopen Cursor). When invoking a tool in KEYCHAIN mode, omit key_path; the agent selects from its loaded identities.

    If you must use ENV_VAR, set it in the macOS launchd session before opening Cursor from the Dock, then fully quit and reopen Cursor:

    bash
    launchctl setenv SSH_KEY_PASSPHRASE 'your-key-passphrase'

    This value lasts only for the current login session, and putting a passphrase directly in a command may save it in shell history. Prefer KEYCHAIN.

For KEYCHAIN, the MCP server must inherit SSH_AUTH_SOCK from that user session. This is normally automatic for a stdio server started from a desktop application. ENV_VAR stores the passphrase in the server process environment, so restrict access to the process and avoid putting it in source control.

Changelog

Project Contents

  1. mcp_ssh.py - the SSH MCP server
  2. mcp_config.ini - the server's config
  3. check_health_sse.py - check the server's tools and either it's up (sse transport)
  4. check_health_stdio.py - check the server's tools and either it's up (stdio transport)

Compatibility

Tested manually on Python3.11 running on MacOS against remote Ubuntu server
Autotested with Python 3.11 3.12 3.13 3.14 3.15

The MCP Registry

mcp-name: io.github.Areso/safe-ssh-mcp

The License

This project is licensed under the GNU AGPLv3 License.

Why AGPL?

This server acts as core infrastructure and contains no business logic. By using the AGPL license, we ensure that any security improvements, bug fixes, or new diagnostic tools added to the server are shared back with the open-source community.

Note for Client Developers

Because MCP clients communicate with this server via standard Inter-Process Communication (IPC) or network protocols (like HTTP/SSE), the AGPL license does not "infect" or restrict the client applications connecting to it.
You can safely connect proprietary, closed-source, or permissively licensed (e.g., MIT, Apache 2.0) AI agents to this server without violating the license terms.

來源:README.md,提交 492608e

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

4
  1. v0.2.3最新Nov 17, 2026
  2. v0.2.1Nov 15, 2026
  3. v0.2.0Nov 13, 2026
  4. v0.1.15Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分