Skip to main content
Glama

unas-mcp

MCP server for the Ubiquiti UNAS Pro 8 NAS (10.0.40.4), the primary store for all media in the homelab. It covers health, storage and disk inventory, NFS export visibility, read-only file inspection, and a few confirmation-gated actions. 18 tools. It runs as a container on VM 102 (http://10.0.40.25:8490/mcp) and is registered by the homelab repo's .mcp.json.

The owner does not run this code; Claude sessions do. This README is written for them.

Design

Two transports, each used only for what it alone can answer:

  • SSH (root@<host>, key only, ssh.py): /proc/mdstat, lsblk, smartctl, df, rpcinfo, showmount, exportfs, journalctl, ls, du. Every remote command runs under set -o pipefail, so a broken stage is an error, not an empty answer.

  • UniFi Drive API (api.py, unofficial; notes in docs/drive-api-findings.md): physical bay numbers (slotId), vendor healthScore/riskReasons, and per-RAID-group protection. The health verdict never depends on it.

No drive list in code. Drives are discovered on every call (drives.py, from lsblk: SATA/SAS disks only, so the USB boot stick and flash partitions are skipped). Completeness is checked against an independent source: every member drive md lists in /proc/mdstat must have a SMART verdict, or the summary says unknown, never healthy. Filling bay 8 later needs no code or config change. A new drive outside the array is listed as unassigned_drives and is still SMART-checked.

Act on bay and serial, never on sdX. Device letters are kernel discovery order. Every drive record carries bay (from the Drive API, null with a note if the API is down), serial and device.

Device arguments are checked twice before reaching a root shell: the name must be well-formed (sd plus 1-2 letters, safety.validate_device), and it must be a drive the NAS reports right now (drives.resolve, whose error lists what is present).

Tolerant but honest parsing: a field missing from a live reply is null (or raises, for the fields the verdict depends on). It is never defaulted to a value that reads as healthy.

Related MCP server: unifi-mcp

Tools

Tool

Gate

What it returns

unas_health_summary

read

healthy / unhealthy / unknown with problems in plain words: arrays, SMART for every member drive, capacity (≥85%), NFS serving

unas_array_status

read

Each md array: members, failed members, [total/active], operation (recovery = rebuild after a failure; reshape = restructuring such as an expansion; resync/check = parity pass) and progress

unas_smart_status

read

SMART for every discovered drive with bay and serial; array_members_without_smart must be empty

unas_smart_details

read

Full SMART record for one drive

unas_capacity

read

Media volume bytes total/used/free and used % (df -B1)

unas_nfs_state

read

serving is true only when nfsd and mountd are registered AND a /volume/ path is exported

unas_uptime_boot

read

up_since and the boots the journal still holds (a few days only)

unas_system_info

read

UniFi OS firmware, unifi-drive and unifi-core versions, kernel, Debian release

unas_service_status

read

Names of every running systemd service

unas_smart_test_start

none

Start a short (~2 min) or long (~38 h on these drives) self-test; data is untouched

unas_smart_test_status

read

A drive's self-test log

unas_reboot

confirm

Reboots the NAS; all media is down for about 10-14 minutes. Scheduled 5 s out, so a clean return means it will happen. Then poll unas_nfs_state until serving

unas_pool_status

read

Pool status, capacity, scrub state, per-RAID-group protection

unas_disk_inventory

read

Every bay: slotId, model, serial, state, temperature, healthScore (read with state; an empty bay reads 0), error counters

unas_nfs_exports

read

Each exported path with every client IP and that client's own options

unas_fix_permissions

confirm

Recursive chown 977:988 (the NFS squash user) at or below a share's .data root

unas_list_dir

read

ls -lah inside a share's .data root

unas_disk_usage_by_dir

read

du -h to a depth of 0-10 inside a share's .data root (180 s limit)

confirm tools require confirm="yes"; anything else raises PermissionError and runs nothing. The model fills that argument itself, so the human gate is Claude Code's permission prompt: the homelab repo's .claude/settings.json lists unas_reboot and unas_fix_permissions under permissions.ask.

Absent by design: write file operations (NFS clients already cover that, and a second write path only adds ways to corrupt data), NFS allow-list edits (only the Drive UI can make them stick), and every pool, array or disk lifecycle action (create, destroy, format, expand, reshape). Absence is the protection. tests/test_health_tools.py::test_registers_exactly_the_expected_tool_names pins the exact tool set, so a new tool fails it until someone adds it on purpose. It checks names only: review what a new tool actually runs.

Environment

Variable

Purpose

UNAS_HOST

NAS address (default 10.0.40.4)

UNAS_SSH_KEY

SSH private key for root on the NAS (default /keys/id_ed25519)

UNAS_API_KEY

UniFi Drive API key (X-API-Key)

MCP_PORT

Listen port (default 8490)

Tests

python3 -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/pytest -q                       # unit tests, fixtures captured live

Live check, read-only: run after every UNAS firmware or Drive-app update and after any change here. It would have caught both the hard-coded six-drive list and the three tools UniFi OS 6.0 broke. From the workstation:

K=$(ssh vm-102-monitoring "grep -m1 '^UNAS_API_KEY=' ~/docker-compose/.env | cut -d= -f2-")
UNAS_LIVE=1 UNAS_SSH_KEY=$HOME/.ssh/id_ed25519 UNAS_API_KEY="$K" .venv/bin/pytest -q tests/test_live.py

All 9 must pass. A failure means an update changed something this server reads.

Deploy

CI (.github/workflows/build-and-push.yaml) runs the unit tests on every push to main, then builds and pushes ghcr.io/lefty3382/unas-mcp:latest. On VM 102:

ssh vm-102-monitoring "cd ~/docker-compose && docker compose pull unas-mcp && docker compose down unas-mcp && docker compose up -d unas-mcp"

Restarting it affects only this tool; media and Kuma alerting do not use it. Then run the live check.

  • Kuma alerting does not use this server: automation/scripts/kuma-unas-health/ in the homelab repo pages through its own forced-command SSH key, so a failing drive pages even when this container is down.

  • Appliance facts and quirks: docs/reference/unas-pro-8-capabilities.md (homelab repo).

  • Design review, 2026-11-08: docs/reviews/2026-11-08-independent-review.md.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A safety-first MCP server for managing UniFi networks, exposing 17 tools for telemetry, diagnostics, and guarded mutations with dry-run previews and confirm requirements.
      16
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      MCP server for UniFi Network Controller enabling AI assistants to manage UniFi infrastructure via natural language. It supports firewall rules, IPv6, and uses lazy/eager tool modes to minimize context usage.
      7
      Mozilla Public 2.0
    • A
      license
      A
      quality
      D
      maintenance
      MCP server providing typed, safety-gated access to UniFi Network consoles via the official API, enabling management of devices, clients, networks, WiFi, firewall policies, and more.
      16
      36 npm
      2
      MIT