| Crates.io | truenas-master-mcp |
| lib.rs | truenas-master-mcp |
| version | 0.1.11 |
| created_at | 2026-01-23 09:54:28.017363+00 |
| updated_at | 2026-01-24 17:38:33.162182+00 |
| description | Official MCP server for TrueNAS API access |
| homepage | |
| repository | https://github.com/hongkongkiwi/truenas-master-mcp |
| max_upload_size | |
| id | 2063981 |
| size | 740,369 |
A Model Context Protocol (MCP) server for managing TrueNAS systems through AI assistants.
This MCP server provides access to TrueNAS API functionality including:
# Clone the repository
git clone https://github.com/hongkongkiwi/truenas-master-mcp.git
cd truenas-master-mcp
# Build the project
cargo build --release
# The binary will be at target/release/truenas-master-mcp
The server is configured via environment variables:
| Variable | Required | Description | Default |
|---|---|---|---|
TRUENAS_SERVER_URL |
Yes | TrueNAS server URL | http://localhost |
TRUENAS_API_KEY |
No* | API key for authentication | - |
TRUENAS_USERNAME |
No* | Username for basic auth | - |
TRUENAS_PASSWORD |
No* | Password for basic auth | - |
TRUENAS_VERIFY_SSL |
No | Verify SSL certificates | true |
TRUENAS_TIMEOUT |
No | Request timeout in seconds | 30 |
TRUENAS_VERSION |
No | TrueNAS version (scale/core) | scale |
*Either TRUENAS_API_KEY OR both TRUENAS_USERNAME and TRUENAS_PASSWORD must be provided.
The server also supports command-line options:
| Option | Description | Default |
|---|---|---|
-t, --transport |
Transport type: stdio, http, sse | stdio |
-h, --host |
Host to bind to (http/sse only) | 127.0.0.1 |
-p, --port |
Port to bind to (http/sse only) | 3000 |
--truenas-version |
TrueNAS version: scale or core | scale |
--readonly |
Enable readonly mode | false |
-c, --config-file |
Path to config file (JSON/YAML) | - |
-l, --log-level |
Log level: debug, info, warn, error | info |
-v, --verbose |
Enable verbose output | false |
--insecure-ssl |
Disable SSL certificate verification | false |
--timeout |
API request timeout in seconds | 30 |
--pretty |
Enable JSON pretty printing | false |
# Using API key
TRUENAS_SERVER_URL=https://truenas.local
TRUENAS_API_KEY=your-api-key-here
# OR using username/password
TRUENAS_SERVER_URL=https://truenas.local
TRUENAS_USERNAME=admin
TRUENAS_PASSWORD=your-password
# Optional settings
TRUENAS_VERIFY_SSL=true
TRUENAS_TIMEOUT=30
# Load environment variables from .env file
export $(cat .env | xargs)
# Run the server
cargo run
The server communicates via stdio, which is the standard for MCP servers.
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"truenas": {
"command": "/path/to/truenas-master-mcp",
"env": {
"TRUENAS_SERVER_URL": "https://truenas.local",
"TRUENAS_API_KEY": "your-api-key-here"
}
}
}
}
The server implements the standard Model Context Protocol. Refer to your MCP client's documentation for how to connect servers.
Once connected to an MCP client like Claude Desktop, you can manage your TrueNAS system:
# List all storage pools
list_pools()
# Get details of a specific dataset
get_dataset(dataset_id_or_path="tank/data/mydata")
# Create a new user
create_user(username="newuser", email="user@example.com", full_name="New User")
# List all VMs and start one
list_vms()
start_vm(vm_id=1)
# Check system alerts
get_alerts()
This section provides examples for AI assistants on how to effectively use the TrueNAS MCP tools.
# Get comprehensive system overview
system_info = get_system_info()
alerts = get_alerts()
pools = list_pools()
disk_health = get_disk_health()
# Check for critical issues
if alerts and len(alerts) > 0:
critical_alerts = [a for a in alerts if a.get("severity") == "CRITICAL"]
if critical_alerts:
# Take action on critical alerts
for alert in critical_alerts:
print(f"Alert: {alert['message']}")
# Find datasets with low space
datasets = list_datasets()
for ds in datasets:
if ds.get("available", 0) < ds.get("size", 0) * 0.1:
print(f"Low space: {ds['name']} ({ds['available']} remaining)")
# Create a new dataset for backups
create_dataset(pool_name="tank", dataset_name="backups")
# Take a snapshot before major changes
create_snapshot(dataset="tank/data", snapshot_name="pre-update-$(date +%Y%m%d)")
# Check app status and health
apps = list_apps()
for app in apps:
if app.get("state") != "RUNNING":
print(f"App not running: {app['name']} - {app.get('error', 'Unknown error')}")
# Scale a deployment
scale_app(app_name="my-app", replica_count=3)
# Upgrade an app with available update
upgrade_app(app_name="my-app", upgrade_version="1.2.3")
# Find and stop unused VMs
vms = list_vms()
for vm in vms:
if vm.get("state") == "RUNNING" and vm.get("uptime", 0) > 86400 * 7:
# VM has been running for more than 7 days
print(f"Consider restarting: {vm['name']}")
# Clone a VM before testing
clone_vm(vm_id=1, name="vm-test-clone")
# Get and categorize alerts
alerts = get_alerts()
for alert in alerts:
severity = alert.get("severity", "INFO")
source = alert.get("source", "unknown")
message = alert.get("message", "")
if severity == "CRITICAL":
# Immediately notify and potentially take action
print(f"CRITICAL: {message}")
if "disk" in source.lower():
# Check disk health
disk = get_disk(disk_name=extract_disk_name(message))
print(f"Disk SMART status: {disk.get('smart_status')}")
# Dismiss resolved alerts
dismiss_alert(alert_id="alert-123")
# Clear all old alerts
clear_alerts()
# Execute multiple operations in sequence
operations = [
{"name": "list_pools", "arguments": {}},
{"name": "list_apps", "arguments": {}},
{"name": "get_alerts", "arguments": {}},
]
results = batch(operations=operations)
For remote access or web-based MCP clients:
# Run in HTTP/SSE mode on port 8080
TRUENAS_SERVER_URL=https://truenas.local TRUENAS_API_KEY=your-key \
truenas-master-mcp --transport=sse --port=8080
The server will be available at:
http://localhost:8080/ssehttp://localhost:8080/messageslist_users - List all usersget_user - Get user by IDget_user_by_username - Get user by usernamelist_pools - List all storage poolsget_pool_status - Get status of a specific poolscrub_pool - Start a scrub on a storage poollist_datasets - List all datasetsget_dataset - Get details of a specific datasetcreate_dataset - Create a new datasetdelete_dataset - Delete a datasetlist_smb_shares - List all SMB sharescreate_smb_share - Create a new SMB sharedelete_smb_share - Delete an SMB sharelist_nfs_exports - List all NFS exportscreate_nfs_export - Create a new NFS exportdelete_nfs_export - Delete an NFS exportlist_snapshots - List all ZFS snapshotscreate_snapshot - Create a new snapshotdelete_snapshot - Delete a snapshotlist_iscsi_targets - List all iSCSI targetscreate_iscsi_target - Create a new iSCSI targetdelete_iscsi_target - Delete an iSCSI targetlist_apps - List all applicationsget_app - Get details of a specific applicationstart_app - Start an applicationstop_app - Stop an applicationrestart_app - Restart an applicationcreate_app - Create a new application from catalogupdate_app - Update an application configurationdelete_app - Delete an applicationrollback_app - Rollback an application to previous versionget_app_config - Get application configurationget_app_upgrade_options - Get available upgrade optionsupgrade_app - Upgrade an applicationscale_app - Scale application replica countlist_catalog_items - List available catalog itemsget_catalog - Get catalog detailsget_catalog_trains - Get catalog train versionsget_catalog_item - Get specific catalog item detailslist_chart_releases - List deployed chart releasesget_chart_release - Get chart release detailsget_chart_release_resources - Get chart release resourcesget_system_info - Get system informationget_alerts - Get system alertsget_alert_classes - Get alert classes/categoriesdismiss_alert - Dismiss a specific alertclear_alerts - Clear all system alertsget_system_events - Get recent system events/logsget_disk_health - Get disk health/SMART statuscheck_for_updates - Check for system updatesreboot_system - Reboot the system (requires confirm=true)shutdown_system - Shutdown the system (requires confirm=true)list_groups - List all groupsget_group - Get group by IDget_group_by_name - Get group by namecreate_group - Create a new groupdelete_group - Delete a grouplist_vms - List all virtual machinesget_vm - Get VM details by IDcreate_vm - Create a new virtual machineupdate_vm - Update VM configurationstart_vm - Start a virtual machinestop_vm - Stop a virtual machinerestart_vm - Restart a virtual machinepowercycle_vm - Power cycle (hard reset) a virtual machineclone_vm - Clone an existing virtual machinedelete_vm - Delete a virtual machinelist_interfaces - List all network interfaceslist_routes - List all network routesget_dns - Get DNS configurationlist_services - List all servicesget_service - Get service detailsstart_service - Start a servicestop_service - Stop a servicerestart_service - Restart a servicelist_disks - List all disksget_disk - Get disk details by namelist_certificates - List all certificatesget_certificate - Get certificate details by IDlist_replication_tasks - List all replication tasksget_replication_task - Get replication task by IDcreate_replication_task - Create a new replication taskdelete_replication_task - Delete a replication taskrun_replication_task - Run a replication tasklist_cloudsync_tasks - List all cloud sync tasksget_cloudsync_task - Get cloud sync task by IDcreate_cloudsync_task - Create a new cloud sync taskdelete_cloudsync_task - Delete a cloud sync taskrun_cloudsync_task - Run a cloud sync tasklist_tasks - List all running and recent tasksget_task_status - Get status of a specific taskabort_task - Abort a running taskget_kubernetes_status - Get Kubernetes cluster statusget_kubernetes_nodes - List Kubernetes nodesget_kubernetes_pods - List Kubernetes podsget_kubernetes_services - List Kubernetes serviceslist_docker_images - List all Docker imagespull_docker_image - Pull a Docker imagebatch - Execute multiple operations in a single callget_enclosure - Get enclosure informationget_support - Get support informationlist_jails - List all jailsget_jail - Get jail details by IDget_jail_by_name - Get jail details by namecreate_jail - Create a new jailupdate_jail - Update jail configurationdelete_jail - Delete a jailstart_jail - Start a jailstop_jail - Stop a jailrestart_jail - Restart a jailclone_jail - Clone a jaillist_jail_fstabs - List jail fstab entriesget_enclosure - Get enclosure informationget_support - Get support informationcargo test
cargo fmt
cargo clippy
cargo build --release
A Dockerfile is provided for containerized deployment:
# Build the image
docker build -t truenas-master-mcp .
# Run the container
docker run -d \
-p 3000:3000 \
-e TRUENAS_SERVER_URL=https://truenas.local \
-e TRUENAS_API_KEY=your-api-key \
--name truenas-mcp \
truenas-master-mcp
# Build for specific platform
docker buildx build --platform linux/amd64,linux/arm64 -t truenas-master-mcp --push .
This server supports both TrueNAS SCALE and TrueNAS CORE via the REST API v2.0. Set TRUENAS_VERSION=scale (default) for TrueNAS SCALE or TRUENAS_VERSION=core for TrueNAS CORE.
The server provides 80+ tools covering:
MIT
Contributions are welcome! Please open an issue or submit a pull request.