TrueNAS Scale MCP Server
A Model Context Protocol (MCP) server that enables AI assistants to manage TrueNAS Scale Custom Apps using natural language commands, with tools for deploying, managing, and monitoring Docker Compose applications.
README
TrueNAS Scale MCP Server
A Model Context Protocol (MCP) server for managing TrueNAS Scale Custom Apps through Docker-based deployments.
Overview
This MCP server enables AI assistants like Claude to manage TrueNAS Scale Custom Apps using natural language commands. It provides tools for deploying, managing, and monitoring Docker Compose applications on TrueNAS Scale systems.
Features
- 11 MCP Tools for comprehensive Custom App management
- Docker Compose Conversion to TrueNAS Custom App format
- Security Validation with input sanitization
- Mock Development Mode for testing without TrueNAS access
- Comprehensive Test Suite with >80% coverage
- WebSocket API Integration with TrueNAS Electric Eel
Quick Start
Prerequisites
- Python 3.10+
- Poetry for dependency management
- TrueNAS Scale 24.10+ (Electric Eel) with API access
Installation
# Clone the repository
git clone https://github.com/yourusername/truenas-mcp-server.git
cd truenas-mcp-server
# Install dependencies
poetry install
# Install pre-commit hooks (optional)
poetry run pre-commit install
Configuration
Set up environment variables for your TrueNAS system:
export TRUENAS_HOST="nas.pvnkn3t.lan"
export TRUENAS_API_KEY="your-api-key-here"
export TRUENAS_PORT="443"
export TRUENAS_PROTOCOL="wss"
export TRUENAS_SSL_VERIFY="false" # Use "true" for production
export DEBUG_MODE="false"
Testing the Server
# Test with mock TrueNAS (no real TrueNAS required)
MOCK_TRUENAS=true poetry run python src/truenas_mcp/mcp_server.py
# Test with real TrueNAS
poetry run python src/truenas_mcp/mcp_server.py
Claude Code Integration
Add this server to your Claude Code MCP configuration:
Option 1: Direct Python Execution
Add to your ~/.claude/mcp-servers/production.json:
{
"mcpServers": {
"truenas-scale": {
"type": "stdio",
"command": "python",
"args": ["/path/to/truenas-mcp-server/src/truenas_mcp/mcp_server.py"],
"env": {
"TRUENAS_HOST": "nas.pvnkn3t.lan",
"TRUENAS_API_KEY": "your-api-key-here",
"TRUENAS_PORT": "443",
"TRUENAS_PROTOCOL": "wss",
"TRUENAS_SSL_VERIFY": "false"
}
}
}
}
Option 2: Poetry Execution
{
"mcpServers": {
"truenas-scale": {
"type": "stdio",
"command": "poetry",
"args": ["run", "python", "src/truenas_mcp/mcp_server.py"],
"cwd": "/path/to/truenas-mcp-server",
"env": {
"TRUENAS_HOST": "nas.pvnkn3t.lan",
"TRUENAS_API_KEY": "your-api-key-here",
"TRUENAS_PORT": "443",
"TRUENAS_PROTOCOL": "wss",
"TRUENAS_SSL_VERIFY": "false"
}
}
}
}
Usage Examples
Once configured, you can use these natural language commands with Claude:
# List all Custom Apps
claude "List all my TrueNAS Custom Apps and their status"
# Deploy a new app
claude "Deploy this docker-compose.yml as a Custom App named 'my-app'"
# Manage existing apps
claude "Stop the Custom App named 'plex'"
claude "Start the Custom App named 'nextcloud'"
claude "Show detailed status of Custom App 'jellyfin'"
# Get logs
claude "Show me the last 50 lines of logs from Custom App 'nginx'"
# Delete an app
claude "Delete the Custom App 'old-app' including its volumes"
Available MCP Tools
Connection Management
test_connection- Test TrueNAS API connectivity
Custom App Management
list_custom_apps- List all Custom Apps with statusget_custom_app_status- Get detailed app informationstart_custom_app- Start a stopped appstop_custom_app- Stop a running app
Deployment Tools
deploy_custom_app- Deploy new app from Docker Composeupdate_custom_app- Update existing app configurationdelete_custom_app- Remove app and optionally its volumes
Validation & Monitoring
validate_compose- Validate Docker Compose for TrueNAS compatibilityget_app_logs- Retrieve application logs
Development
Running Tests
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=src/truenas_mcp --cov-report=html
# Run specific test categories
poetry run pytest -m unit # Unit tests only
poetry run pytest -m integration # Integration tests only
Code Quality
# Format code
poetry run black .
# Lint code
poetry run ruff check . --fix
# Type checking
poetry run mypy .
# Run all quality checks
poetry run pre-commit run --all-files
Mock Development
For development without a TrueNAS system:
# Enable mock mode
export MOCK_TRUENAS=true
# Run the server
poetry run python src/truenas_mcp/mcp_server.py
Docker Compose Conversion
The server automatically converts Docker Compose files to TrueNAS Custom App format:
Supported Features
- Volume mounts (named volumes → IX volumes, bind mounts → host paths)
- Port forwarding (container ports → host ports)
- Environment variables
- Network configuration (bridge/host modes)
- Restart policies
Security Validations
- Prevents privileged container mode
- Blocks dangerous system directory mounts
- Validates port conflicts
- Enforces resource limits
Troubleshooting
Connection Issues
# Test API connectivity
curl -k -H "Authorization: Bearer YOUR_API_KEY" https://nas.pvnkn3t.lan/api/v2.0/system/info
# Check WebSocket connection
export TRUENAS_HOST=nas.pvnkn3t.lan TRUENAS_API_KEY=your-key
poetry run python -c "
import asyncio
from src.truenas_mcp.truenas_client import TrueNASClient
asyncio.run(TrueNASClient().test_connection())
"
Common Issues
- "Connection refused": Check
TRUENAS_HOSTandTRUENAS_PORT - "Authentication failed": Verify
TRUENAS_API_KEYis correct - "SSL verification failed": Set
TRUENAS_SSL_VERIFY=falsefor self-signed certificates
Architecture
┌─────────────────┐ MCP Protocol ┌──────────────────┐ WebSocket API ┌─────────────────┐
│ AI Assistant │ ◄──────────────────► │ TrueNAS MCP │ ◄──────────────────► │ TrueNAS Scale │
│ (Claude.ai) │ JSON-RPC 2.0 │ Server │ auth + app.* │ Electric Eel │
└─────────────────┘ └──────────────────┘ └─────────────────┘
Core Components
- MCP Protocol Handler: Manages client communication and capability exchange
- TrueNAS API Client: Handles WebSocket connection and authentication
- Docker Compose Converter: Transforms Docker Compose to TrueNAS Custom App format
- Validation Engine: Validates inputs and security constraints
- Tool Registry: Manages available tools and their schemas
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
poetry run pytest - Run quality checks:
poetry run pre-commit run --all-files - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Requirements
This implementation fulfills the complete TrueNAS MCP Requirements v2.0 specification with:
- ✅ 11 MCP tools with JSON schema validation
- ✅ WebSocket API integration with TrueNAS Electric Eel
- ✅ Docker Compose to Custom App conversion
- ✅ Comprehensive security validation
- ✅ >80% test coverage
- ✅ Production-ready error handling and logging
Support
For issues, questions, or contributions, please open an issue on GitHub.
Status: Production Ready ✅
MCP Protocol: 2.0 Compatible
TrueNAS: Electric Eel (24.10+) Compatible
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。