Ugnas Mcp

io.github.Omodaka9375由 GitHub 账号 Omodaka9375 发布v0.1.2更新于 Oct 27, 2026

Generic MCP server for UGREEN NAS (UGOS) over SSH — 39 tools with dry-run safety.

概览

AI 生成的概览

通过 SSH 连接 UGREEN NAS 的 MCP 服务器,提供 39 个工具,涵盖系统、Docker、文件、备份与网络操作,并带 dry-run 确认机制。

可以做什么
  • 查看连接与系统状态:状态、信息、存储池与阵列
  • 管理 Docker:容器、镜像、网络的列出、检查、日志、启停、删除与 compose
  • 浏览与改动文件:列表、用量、查找、缩略图、建目录、复制、移动、删除、上传、下载、rsync 同步
  • 执行备份:创建、列出、校验、恢复与定时任务
  • 查看网络接口、路由与端口
  • 所有写操作先返回 dry-run 计划与确认令牌,确认后才执行
适用场景
适合拥有运行 UGOS 的 UGREEN NAS、希望让助手远程查看或操作设备的用户,例如检查存储健康、管理容器、搬运文件或执行备份,且无需写死主机或共享目录名。
运行要求
以本地进程运行,通过 npx 或全局 npm 安装(需 Node.js)。NAS 需开启 SSH,并提供 ~/.ugnas-mcp/config.json 配置或 UGNAS_* 环境变量:主机、用户名,以及 SSH 密钥路径(UGNAS_KEY_PATH)或密码(UGNAS_PASSWORD)。容器工具要求 SSH 用户属于 docker 组,定时备份需要 crontab;rsync 可选,仅 files.sync 使用。
安装前请注意
需要 SSH 凭据:私钥路径或密码会放在配置文件或环境变量中,应妥善保护该文件。写操作会改动 NAS 上的容器、文件、备份和 cron 任务,虽需单次有效的确认令牌,仍应逐次审阅 dry-run 计划后再确认。可选的 HTTP 传输没有身份验证,非回环地址默认被拒绝,除非设置 UGNAS_HTTP_ALLOW_REMOTE=1。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Ugnas Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

ugnas-mcp

[CI] [npm] [License: MIT]

bash
npx -y ugnas-mcp

A generic MCP (Model Context Protocol) server for UGREEN NAS devices running UGOS, talking to the NAS over SSH (with SFTP for file transfers).

Unlike most existing UGREEN NAS integrations, nothing here is hard-coded — no fixed IPs, subnets, usernames, or share names. Every target-specific value comes from your config, so the same server works for anyone's NAS.

What it does

Organized the way a NAS owner actually thinks about daily operations:

GroupToolsMutating?
Connection & systemsystem.status, system.info, system.poolsread-only
Dockerdocker.containers.* (list/inspect/logs/start/stop/restart/remove), docker.images.* (list/pull/remove), docker.networks.* (list/inspect/create/remove/connect/disconnect), docker.composestart/stop/restart/pull/remove/create/compose are gated
Files & datafiles.list, files.usage, files.find, files.thumbnail, files.mkdir, files.copy, files.move, files.remove, files.upload, files.download, files.syncthumbnail/mkdir/copy/move/remove/upload/download/sync are gated
Backupbackup.create, backup.list, backup.verify, backup.restore, backup.schedulecreate/restore/schedule are gated
Networksnetwork.interfaces, network.routes, network.portsread-only

39 tools total. system.pools reports mdadm array + degradation state, LVM volume/logical/physical volumes, btrfs devices, block devices, and filesystems.

files.find searches a directory tree by name glob and/or extension (returns path, size, modified time). files.thumbnail renders a preview of an image or a video frame with ffmpeg on the NAS and downloads it locally — read-only with respect to your NAS data (only a /tmp scratch file is written and removed), but writing the thumbnail to the local machine is gated: the first call returns a dry-run plan, and you confirm with the token to write the local file. Requires ffmpeg on the NAS (present on UGOS by default).

files.list and files.find prefer GNU coreutils flags (ls --time-style=long-iso, find -printf); when those are unavailable (BusyBox), they fall back to ls -1p and find -exec stat so they keep working — with size/mtime zeroed out for plain ls where BusyBox can't report them.

files.sync and the rsync fallback

files.sync uses rsync for fast, resumable NAS↔NAS copies, with --delete mirroring and an rsync --dry-run pre-flight. rsync is not installed on UGOS by default, so:

  • Default (fallback: "refuse") — if rsync is missing, the dry-run plan still shows the rsync command but adds a note telling you how to install rsync (Entware: opkg install rsync) or how to turn on the fallback. Nothing runs until you confirm.
  • Opt in (fallback: "cp") — the tool instead falls back to a built-in cp -a copy. The plan's note explains this, and warnings call out what the fallback can't do: no --delete mirroring, no rsync --dry-run, and extraArgs are ignored.

So you opt in per call by passing fallback: "cp". Nothing changes unless you ask for it.

Safety model — dry-run first, then confirm

Every mutating tool has two phases:

  1. Call without a token → returns a dry-run plan: the exact shell commands it would run, a human summary, any warnings, and a short-lived confirmationToken.
  2. Call again with confirmToken → the token is validated (action-bound, single-use, expires in 10 minutes) and the exact commands captured at plan time are executed.

Read-only tools never need a token. This makes "copy my data", "pull this image", or "restart that container" reviewable before anything changes.

All user-supplied values (paths, container names, image tags) are POSIX-shell-quoted before being interpolated into a remote command, so they cannot break out into arbitrary command execution.

At confirm time, the arguments of the confirming call are cross-checked against the plan-time arguments captured in the token: if they differ, the tool refuses and asks you to re-run for a fresh plan (so a stale token can never execute a differently-argued action).

Configuration

The server reads a JSON config from ~/.ugnas-mcp/config.json (override with the UGNAS_MCP_CONFIG environment variable). See config.example.json.

json
{  "name": "home-nas",  "host": "192.168.1.50",  "port": 22,  "username": "admin",  "auth": { "type": "key", "privateKeyPath": "~/.ssh/id_ed25519" },  "defaultShare": "/volume1",  "commandTimeoutMs": 60000}
FieldRequiredNotes
hostyesIP or hostname of the NAS.
portnoSSH port, default 22.
usernameyesSSH user.
authyes{ "type": "key", "privateKeyPath": "..." } (recommended, supports passphrase) or { "type": "password", "password": "..." }. privateKeyPath may also be raw inline PEM.
defaultSharenoBase directory for relative tool paths, default /volume1.
sftpRootnoThe directory the SFTP subsystem is rooted at. On UGOS, SFTP is chrooted to the share root, so an exec path like /volume1/docker/x must be requested over SFTP as /docker/x; set this to the chroot root (defaults to defaultShare). Use "/" if your NAS does not chroot SFTP.
hostKeySha256noWhen set, the SSH host key is pinned and enforced (e.g. SHA256:...). Compare is padding-insensitive, so the canonical fingerprint from ssh-keygen -lf works as-is.
commandTimeoutMsnoPer-command timeout, default 60000.

Environment-variable overrides

Useful for CI or secret injection. Env values win over the file:

bash
UGNAS_HOST=192.168.1.50UGNAS_PORT=22UGNAS_USER=adminUGNAS_KEY_PATH=~/.ssh/id_ed25519      # or UGNAS_AUTH_TYPE=password + UGNAS_PASSWORDUGNAS_DEFAULT_SHARE=/volume1UGNAS_HOST_KEY_SHA256=SHA256:...

Relative vs absolute paths

File/backup tools accept either. An absolute path is used as-is; a relative path is joined onto defaultShare:

files.list("media")  ->  /volume1/mediafiles.list("/mnt/x")  ->  /mnt/x

Install & run

Published on npm as ugnas-mcp. Run it directly — no clone, no build:

bash
npx ugnas-mcp# or install it once:npm install -g ugnas-mcpugnas-mcp

That starts the stdio MCP server. It reads its config from ~/.ugnas-mcp/config.json (or UGNAS_MCP_CONFIG / UGNAS_* env vars — see Configuration).

Wiring it into an MCP client

Point your client at the official package (stdio):

json
{  "mcpServers": {    "ugnas": {      "command": "npx",      "args": ["-y", "ugnas-mcp"],      "env": { "UGNAS_MCP_CONFIG": "/absolute/path/to/config.json" }    }  }}

Or, if you installed it globally, "command": "ugnas-mcp" with no args.

Optional HTTP transport

The server is stdio by default. Set UGNAS_HTTP_PORT to also expose a streamable HTTP transport (both run side by side):

bash
UGNAS_HTTP_HOST=127.0.0.1 UGNAS_HTTP_PORT=4110 ugnas-mcp
  • POST http://127.0.0.1:4110/mcp — JSON-RPC (stateless; a fresh session per request, max 1 MiB body).
  • GET http://127.0.0.1:4110/health — liveness + target host.

It binds to loopback by default. UGNAS_HTTP_HOST=0.0.0.0 (or any non-loopback address) is refused unless UGNAS_HTTP_ALLOW_REMOTE=1 is also set — the /mcp endpoint has no authentication, and confirmation tokens are process-wide, so only opt in if the port is secured by something else (reverse proxy with auth, VPN, etc.).

Prerequisites on the NAS

  • SSH enabled (UGOS: Control Panel → Terminal & SNMP).
  • The SSH user can run docker (be in the docker group) and, for scheduled backups, use crontab.
  • tar, df, du, ip, ss are present on UGOS — these are standard.
  • backup.schedule job names must be plain words ([A-Za-z0-9._-]) — they are embedded in a generated shell script and a crontab line, so anything else is rejected up front.
  • rsync is optional, used only by files.sync. If it's missing you get a note explaining how to install it or how to enable the built-in cp fallback (files.sync { fallback: "cp" }); every other file tool works without rsync.

License

MIT — see LICENSE. Contributing, architecture, and the dev/release toolchain live in DEVELOPMENT.md.

来源:README.md,提交 7e89906

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.2最新Oct 17, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分