Skip to main content

TrueNAS MCP Server

Python Version MCP Version License PyPI Version

A production-ready Model Context Protocol (MCP) server for TrueNAS Core systems. Control and manage your TrueNAS storage through natural language with Claude or other MCP-compatible clients.

🚀 Features

Core Capabilities

  • User Management - Create, update, delete users and manage permissions
  • Storage Management - Manage pools, datasets, volumes with full ZFS support
  • File Sharing - Configure SMB, NFS, and iSCSI shares
  • Snapshot Management - Create, delete, rollback snapshots with automation
  • System Monitoring - Check system health, pool status, and resource usage

Enterprise Features

  • Type-Safe Operations - Full Pydantic models for request/response validation
  • Comprehensive Error Handling - Detailed error messages and recovery guidance
  • Production Logging - Structured logging with configurable levels
  • Connection Pooling - Efficient HTTP connection management with retry logic
  • Rate Limiting - Built-in rate limiting to prevent API abuse
  • Environment-Based Config - Flexible configuration via environment variables

📦 Installation

The easiest way to run TrueNAS MCP Server is with uvx:

# Run directly without installation
uvx truenas-mcp-server

# Or install globally with uv
uv tool install truenas-mcp-server

Traditional Installation

# With pip
pip install truenas-mcp-server

# Or with pipx for isolated environment
pipx install truenas-mcp-server

From Source

git clone https://github.com/vespo92/TrueNasCoreMCP.git
cd TrueNasCoreMCP
pip install -e .

🔧 Configuration

Environment Variables

Create a .env file or set environment variables:

# Required
TRUENAS_URL=https://your-truenas-server.local
TRUENAS_API_KEY=your-api-key-here

# Optional
TRUENAS_VERIFY_SSL=true                    # Verify SSL certificates
TRUENAS_LOG_LEVEL=INFO                     # Logging level
TRUENAS_ENV=production                     # Environment (development/staging/production)
TRUENAS_HTTP_TIMEOUT=30                    # HTTP timeout in seconds
TRUENAS_ENABLE_DESTRUCTIVE_OPS=false      # Enable delete operations
TRUENAS_ENABLE_DEBUG_TOOLS=false          # Enable debug tools

Getting Your API Key

  1. Log into TrueNAS Web UI
  2. Go to Settings → API Keys
  3. Click Add and create a new API key
  4. Copy the key immediately (it won't be shown again)

Claude Desktop Configuration

Add to your Claude Desktop config (claude_desktop_config.json):

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

Note: This uses uvx to automatically manage the Python environment. Make sure you have uv installed:

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# or
brew install uv

📚 Usage Examples

With Claude Desktop

Once configured, you can interact with TrueNAS using natural language:

"List all storage pools and their health status"
"Create a new dataset called 'backups' in the tank pool with compression"
"Set up an SMB share for the documents dataset"
"Create a snapshot of all datasets in the tank pool"
"Show me users who have sudo privileges"

As a Python Library

from truenas_mcp_server import TrueNASMCPServer

# Create server instance
server = TrueNASMCPServer()

# Run the server
server.run()

Programmatic Usage

import asyncio
from truenas_mcp_server.client import TrueNASClient
from truenas_mcp_server.config import Settings

async def main():
    # Initialize client
    settings = Settings(
        truenas_url="https://truenas.local",
        truenas_api_key="your-api-key"
    )
    
    async with TrueNASClient(settings) as client:
        # List pools
        pools = await client.get("/pool")
        print(f"Found {len(pools)} pools")
        
        # Create a dataset
        dataset = await client.post("/pool/dataset", {
            "name": "tank/mydata",
            "compression": "lz4"
        })
        print(f"Created dataset: {dataset['name']}")

asyncio.run(main())

🛠️ Available Tools

User Management

  • list_users - List all users with details
  • get_user - Get specific user information
  • create_user - Create new user account
  • update_user - Modify user properties
  • delete_user - Remove user account

Storage Management

  • list_pools - Show all storage pools
  • get_pool_status - Detailed pool health and statistics
  • list_datasets - List all datasets
  • create_dataset - Create new dataset with options
  • update_dataset - Modify dataset properties
  • delete_dataset - Remove dataset

File Sharing

  • list_smb_shares - Show SMB/CIFS shares
  • create_smb_share - Create Windows share
  • list_nfs_exports - Show NFS exports
  • create_nfs_export - Create NFS export
  • list_iscsi_targets - Show iSCSI targets
  • create_iscsi_target - Create iSCSI target

Snapshot Management

  • list_snapshots - Show snapshots
  • create_snapshot - Create manual snapshot
  • delete_snapshot - Remove snapshot
  • rollback_snapshot - Revert to snapshot
  • clone_snapshot - Clone to new dataset
  • create_snapshot_task - Setup automated snapshots

Debug Tools (Development Mode)

  • debug_connection - Check connection settings
  • test_connection - Verify API connectivity
  • get_server_stats - Server statistics

🏗️ Architecture

truenas_mcp_server/
├── __init__.py           # Package initialization
├── server.py             # Main MCP server
├── config/               # Configuration management
│   ├── __init__.py
│   └── settings.py       # Pydantic settings
├── client/               # HTTP client
│   ├── __init__.py
│   └── http_client.py    # Async HTTP with retry
├── models/               # Data models
│   ├── __init__.py
│   ├── base.py          # Base models
│   ├── user.py          # User models
│   ├── storage.py       # Storage models
│   └── sharing.py       # Share models
├── tools/                # MCP tools
│   ├── __init__.py
│   ├── base.py          # Base tool class
│   ├── users.py         # User tools
│   ├── storage.py       # Storage tools
│   ├── sharing.py       # Share tools
│   └── snapshots.py     # Snapshot tools
└── exceptions.py         # Custom exceptions

🧪 Development

Setup Development Environment

# Clone repository
git clone https://github.com/vespo92/TrueNasCoreMCP.git
cd TrueNasCoreMCP

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# With coverage
pytest --cov=truenas_mcp_server

# Specific test file
pytest tests/test_client.py

Code Quality

# Format code
black truenas_mcp_server

# Lint
flake8 truenas_mcp_server

# Type checking
mypy truenas_mcp_server

📖 Documentation

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔒 Security

  • Never commit API keys or credentials
  • Use environment variables for sensitive data
  • Enable SSL verification in production
  • Restrict destructive operations by default
  • Report security issues via GitHub Issues

📞 Support

🙏 Acknowledgments


Made with ❤️ for the TrueNAS community

Metadata

Release files for truenas-mcp-server 3.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for truenas-mcp-server 3.0.2
File Size Uploaded Provenance
truenas_mcp_server-3.0.2.tar.gz 59.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for truenas-mcp-server 3.0.2
File Interpreter ABI Platform
truenas_mcp_server-3.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 96.4 kB

Release files / truenas_mcp_server-3.0.2.tar.gz

Download URL truenas_mcp_server-3.0.2.tar.gz
Size 59.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b99277dbf9295cca1a191fe4da532a598b01042db63abe82b5ac28238b8a7bbb
BLAKE2b-256 checksum
How to use checksums
ccf8405681625270213a2a581b5d2f29485cf908d1882b2ff0c4afb5704c4e39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / truenas_mcp_server-3.0.2-py3-none-any.whl

Download URL truenas_mcp_server-3.0.2-py3-none-any.whl
Size 37.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cea48d47125c0d0cd0050ce2bd7e9bdcc0142e729d46a52b256fe80ecbbfa043
BLAKE2b-256 checksum
How to use checksums
cb96691553258ea975fcf34c0c6d4935c69facb71644672a8ba542a8f875e9b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for truenas-mcp-server 3.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page