Skip to main content
Glama
spranab

truenas-mcp

by spranab

truenas-mcp

npm npm downloads

将 NAS 接入 AI 助手通常意味着为每个操作注册一个 MCP 工具。要完整覆盖 TrueNAS SCALE,需要 50-80 个工具模式——在模型读取你的问题之前,每次请求都会消耗约 28,000 个 token 的上下文窗口,无论你是否涉及存储。

truenas-mcp 将 18 个类别的 278 个操作——整个 TrueNAS SCALE REST API——封装在一个分层工具后面,仅需约 200 个 token。模型先询问存在哪些类别,深入所需的类别,然后调用操作。破坏性操作在未提供 confirm: true 时拒绝执行。

安装(60 秒)

# No install needed
TRUENAS_URL=https://truenas.local TRUENAS_API_KEY=1-abc123 npx truenas-mcp

Claude Code:

claude mcp add truenas -- npx -y truenas-mcp   --env TRUENAS_URL=https://truenas.local   --env TRUENAS_API_KEY=1-your-api-key-here

从 TrueNAS 界面获取 API 密钥:设置 > API 密钥 > 添加

Related MCP server: Proxmox MCP Server

效果预览

你:“我的存储池健康吗?你能为媒体数据集创建一个 NFS 共享吗?”

→ truenas({ category: "storage", action: "pool_list" })
  tank — ONLINE, 68% used, 0 errors

→ truenas({ category: "sharing", action: "nfs_share_create",
            params: { path: "/mnt/tank/media", comment: "Media share" } })

模型通过先调用 truenas({ category: "sharing" }) 发现了 nfs_share_create——它的提示中从未包含那 36 个共享操作。

为什么用一个工具而不是 278 个

truenas-mcp

典型的 NAS MCP 服务器

操作

278

5-80

Token 占用

~200 token(1 个工具)

5,000-30,000 token(50-80 个工具)

发现方式

分层——按需查询

扁平——所有内容预先加载

MCP 资源

12 个只读仪表盘

0

安装

npx truenas-mcp

从源码构建 / pip

安全性

破坏性操作需要 confirm: true

各不相同

完整配置

# Using npx (no install needed)
TRUENAS_URL=https://truenas.local TRUENAS_API_KEY=1-abc123 npx truenas-mcp

# Or install globally
npm install -g truenas-mcp

环境变量

变量

必需

描述

TRUENAS_URL

TrueNAS 实例 URL(例如 https://truenas.local

TRUENAS_API_KEY

来自 TrueNAS 界面的 API 密钥:设置 > API 密钥 > 添加

TRUENAS_VERIFY_SSL

设置为 false 以跳过 SSL 验证(自签名证书)

Claude Desktop 配置

添加到你的 claude_desktop_config.json

{
  "mcpServers": {
    "truenas": {
      "command": "npx",
      "args": ["-y", "truenas-mcp"],
      "env": {
        "TRUENAS_URL": "https://truenas.local",
        "TRUENAS_API_KEY": "1-your-api-key-here",
        "TRUENAS_VERIFY_SSL": "false"
      }
    }
  }
}

Claude Code

claude mcp add truenas -- npx -y truenas-mcp \
  --env TRUENAS_URL=https://truenas.local \
  --env TRUENAS_API_KEY=1-your-api-key-here \
  --env TRUENAS_VERIFY_SSL=false

工作原理——分层工具设计

该服务器没有注册 278 个单独的工具(这将在 LLM 系统提示中消耗约 3 万 token),而是暴露了一个名为 truenas 的工具,具有三种使用模式:

1. 发现类别

truenas()

返回所有 18 个类别及其描述和操作数量(约 200 token)。

2. 浏览类别

truenas({ category: "storage" })

返回该类别中的所有操作及其必需/可选参数。

3. 执行操作

truenas({ category: "storage", action: "pool_list" })
truenas({ category: "storage", action: "dataset_create", params: { name: "tank/media", compression: "LZ4" } })

这意味着 LLM 只需为其实际使用的内容支付 token 成本。

类别

类别

操作数

涵盖内容

system

24

系统信息、配置、服务、邮件、API 密钥、NTP

storage

32

存储池、数据集、快照、定期快照任务

sharing

36

SMB/CIFS、NFS 导出、iSCSI 目标/扩展/门户/启动器

network

15

接口、全局配置、静态路由、IPMI、暂存更改

account

16

用户、组、权限/角色

disk

7

物理磁盘、SMART 测试、温度

vm

16

虚拟机、VM 设备(磁盘、网卡、显示、PCI)

app

17

Docker 应用、容器运行时配置

update

14

系统更新、引导环境、引导池

certificate

8

TLS 证书、ACME/Let's Encrypt、DNS 验证器

alert

10

警报、通知服务(Slack、电子邮件、PagerDuty)

data_protection

49

复制、云同步、云备份、cron、rsync、初始化脚本、SSH 密钥

filesystem

7

stat、listdir、mkdir、权限、ACL、chown

reporting

3

指标配置、图表、时间序列数据

directory

8

Active Directory、LDAP、Kerberos

service_config

12

SSH、FTP、SNMP、UPS、系统可调参数

audit

3

审计日志、审计配置

api

1

任意端点的原始 API 逃生舱

MCP 资源(12)

用于仪表盘的只读资源——无需调用工具:

资源

URI

描述

系统信息

truenas://system/info

版本、主机名、运行时间、硬件

存储池

truenas://storage/pools

所有存储池及其容量和健康状态

数据集

truenas://storage/datasets

所有数据集及其属性

服务

truenas://services

服务状态概览

警报

truenas://alerts

当前系统警报

网络

truenas://network/summary

接口、IP、DNS、网关

共享

truenas://sharing

所有 SMB、NFS 和 iSCSI 共享

虚拟机

truenas://vms

虚拟机及其状态

应用

truenas://apps

已安装的应用程序

磁盘

truenas://disks

物理磁盘信息

引导环境

truenas://boot/environments

引导环境

更新

truenas://system/update

更新配置

示例对话

“我有哪些存储池?它们健康吗?”

→ truenas({ category: "storage", action: "pool_list" })

“为 /mnt/tank/media 创建一个 NFS 共享”

→ truenas({ category: "sharing", action: "nfs_share_create", params: { path: "/mnt/tank/media", comment: "Media share" } })

“检查系统更新”

→ truenas({ category: "update", action: "update_check" })

“sda 上运行过哪些 SMART 测试?”

→ truenas({ category: "disk", action: "disk_smart_test_list", params: { disk: "sda" } })

安全性

所有破坏性操作都要求参数中包含 confirm: true

  • 存储池创建/导出/磁盘更换

  • 数据集/快照删除、快照回滚

  • 虚拟机删除、应用删除/回滚

  • 系统重启/关机、应用更新

  • 磁盘擦除、引导磁盘挂载/卸载

  • 证书删除、引导环境删除

  • 目录服务离开、ACL 设置

如果没有 confirm: true,这些操作将返回一条错误消息,说明将会发生什么。

API 兼容性

专为 TrueNAS SCALE REST API v2.0 构建。兼容 TrueNAS SCALE 22.x 至 25.x。

开发

git clone https://github.com/spranab/truenas-mcp
cd truenas-mcp
npm install
npm run build
npm run dev  # watch mode

相关项目

同一作者构建的其他 MCP 服务器和代理基础设施:

  • mcpier — 为你的家庭实验室提供自托管 MCP 控制平面;避免 API 密钥暴露在客户端。

  • saga-mcp — 基于 SQLite 的项目跟踪器,确保代理在会话之间不会丢失计划。

  • yantrikdb-mcp — 为 Claude Code、Cursor 和 Windsurf 提供持久化认知记忆。

  • swarmcode — 不同机器上 Claude Code 实例之间的实时通道。

  • brainstorm-mcp — 将多模型辩论作为 MCP 工具。

许可证

MIT

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
23dResponse time
Release cycle
Releases (12mo)
Commit activity
Issues opened vs closed

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    Enables Claude to monitor and manage homelab infrastructure including Docker containers, OPNsense firewall, and TrueNAS storage with configurable capability levels from read-only monitoring to full management control.
    13
    39
    6
  • A
    license
    C
    quality
    D
    maintenance
    Enables management of Proxmox VE infrastructure through natural language, providing 120+ tools to control virtual machines, containers, storage, cluster resources, users, and network configurations via the Proxmox API.
    100
    17
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to manage VMware vSphere virtual infrastructure through comprehensive operations including VM power control, snapshot management, resource monitoring, performance analytics, and bulk operations with built-in safety confirmations for destructive actions.
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with Dell PowerScale (Isilon) OneFS clusters through over 2,400 tools generated from the REST API specification. It supports managing storage protocols, snapshots, networking, and cluster configurations using natural language.
    2
    MIT

View all related MCP servers

Related MCP Connectors

  • Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • SaaS intelligence for AI agents. 5 unified tools cover 1,000+ services with 91-96% token savings.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/spranab/truenas-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server