Unraid
STREAMABLE HTTP基于Python的Unraid服务器AI助手交互工具
基于Python的Unraid服务器AI助手交互工具
A powerful MCP (Model Context Protocol) server that provides comprehensive tools to interact with an Unraid server's GraphQL API.
git clone https://github.com/jmagar/unraid-mcp cd unraid-mcp
cp .env.example .env # Edit .env with your Unraid API details
# Start with Docker Compose docker compose up -d # View logs docker compose logs -f unraid-mcp
# Install dependencies uv sync # Run development server ./dev.sh
The easiest way to run the Unraid MCP Server is with Docker:
# Clone repository git clone https://github.com/jmagar/unraid-mcp cd unraid-mcp # Set required environment variables export UNRAID_API_URL="http://your-unraid-server/graphql" export UNRAID_API_KEY="your_api_key_here" # Deploy with Docker Compose docker compose up -d # View logs docker compose logs -f unraid-mcp
# Build and run manually docker build -t unraid-mcp-server . docker run -d --name unraid-mcp \ --restart unless-stopped \ -p 6970:6970 \ -e UNRAID_API_URL="http://your-unraid-server/graphql" \ -e UNRAID_API_KEY="your_api_key_here" \ unraid-mcp-server
For development and testing:
# Clone repository git clone https://github.com/jmagar/unraid-mcp cd unraid-mcp # Install dependencies with uv uv sync # Install development dependencies uv sync --group dev # Configure environment cp .env.example .env # Edit .env with your settings # Run development server ./dev.sh
Create .env file in the project root:
# Core API Configuration (Required) UNRAID_API_URL=https://your-unraid-server-url/graphql UNRAID_API_KEY=your_unraid_api_key # MCP Server Settings UNRAID_MCP_TRANSPORT=streamable-http # streamable-http (recommended), sse (deprecated), stdio UNRAID_MCP_HOST=0.0.0.0 UNRAID_MCP_PORT=6970 # Logging Configuration UNRAID_MCP_LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR UNRAID_MCP_LOG_FILE=unraid-mcp.log # SSL/TLS Configuration UNRAID_VERIFY_SSL=true # true, false, or path to CA bundle # Optional: Log Stream Configuration # UNRAID_AUTOSTART_LOG_PATH=/var/log/syslog # Path for log streaming resource
| Transport | Description | Use Case |
|---|---|---|
streamable-http | HTTP-based (recommended) | Most compatible, best performance |
sse | Server-Sent Events (deprecated) | Legacy support only |
stdio | Standard I/O | Direct integration scenarios |
get_system_info() - Comprehensive system, OS, CPU, memory, hardware infoget_array_status() - Storage array status, capacity, and disk detailsget_unraid_variables() - System variables and settingsget_network_config() - Network configuration and access URLsget_registration_info() - Unraid registration detailsget_connect_settings() - Unraid Connect configurationlist_docker_containers() - List all containers with caching optionsmanage_docker_container(id, action) - Start/stop containers (idempotent)get_docker_container_details(identifier) - Detailed container informationlist_vms() - List all VMs and their statesmanage_vm(id, action) - VM lifecycle (start/stop/pause/resume/reboot)get_vm_details(identifier) - Detailed VM informationget_shares_info() - User shares informationlist_physical_disks() - Physical disk discoveryget_disk_details(disk_id) - SMART data and detailed disk infohealth_check() - Comprehensive system health assessmentget_notifications_overview() - Notification counts by severitylist_notifications(type, offset, limit) - Filtered notification listinglist_available_log_files() - Available system logsget_logs(path, tail_lines) - Log file content retrievallist_rclone_remotes() - List configured remotesget_rclone_config_form(provider) - Configuration schemascreate_rclone_remote(name, type, config) - Create new remotedelete_rclone_remote(name) - Remove existing remotetest_subscription_query(query) - Test GraphQL subscriptionsdiagnose_subscriptions() - Subscription system diagnosticsunraid://logs/stream - Live log streaming from /var/log/syslog with WebSocket subscriptionsNote: MCP Resources provide real-time data streams that can be accessed via MCP clients. The log stream resource automatically connects to your Unraid system logs and provides live updates.
unraid-mcp/
├── unraid_mcp/ # Main package
│ ├── main.py # Entry point
│ ├── config/ # Configuration management
│ │ ├── settings.py # Environment & settings
│ │ └── logging.py # Logging setup
│ ├── core/ # Core infrastructure
│ │ ├── client.py # GraphQL client
│ │ ├── exceptions.py # Custom exceptions
│ │ └── types.py # Shared data types
│ ├── subscriptions/ # Real-time subscriptions
│ │ ├── manager.py # WebSocket management
│ │ ├── resources.py # MCP resources
│ │ └── diagnostics.py # Diagnostic tools
│ ├── tools/ # MCP tool categories
│ │ ├── docker.py # Container management
│ │ ├── system.py # System information
│ │ ├── storage.py # Storage & monitoring
│ │ ├── health.py # Health checks
│ │ ├── virtualization.py # VM management
│ │ └── rclone.py # Cloud storage
│ └── server.py # FastMCP server setup
├── logs/ # Log files (auto-created)
├── dev.sh # Development script
└── docker-compose.yml # Docker Compose deployment
# Format code uv run black unraid_mcp/ # Lint code uv run ruff check unraid_mcp/ # Type checking uv run mypy unraid_mcp/ # Run tests uv run pytest
# Start development server (kills existing processes safely) ./dev.sh # Stop server only ./dev.sh --kill
| Component | Purpose |
|---|---|
| FastMCP Server | MCP protocol implementation and tool registration |
| GraphQL Client | Async HTTP client with timeout management |
| Subscription Manager | WebSocket connections for real-time data |
| Tool Modules | Domain-specific business logic (Docker, VMs, etc.) |
| Configuration System | Environment loading and validation |
| Logging Framework | Structured logging with file rotation |
🔥 Port Already in Use
./dev.sh # Automatically kills existing processes
🔧 Connection Refused
# Check Unraid API configuration curl -k "${UNRAID_API_URL}" -H "X-API-Key: ${UNRAID_API_KEY}"
📝 Import Errors
# Reinstall dependencies uv sync --reinstall
🔍 Debug Mode
# Enable debug logging export UNRAID_MCP_LOG_LEVEL=DEBUG uv run unraid-mcp-server
# Use the built-in health check tool via MCP client # or check logs at: logs/unraid-mcp.log
This project is licensed under the MIT License - see the LICENSE file for details.
git checkout -b feature/amazing-featureuv run pytestgit commit -m 'Add amazing feature'git push origin feature/amazing-featureBuilt with ❤️ for the Unraid community