homelab-mcp
MCP server for homelab diagnostics + auto-update pipeline, managing Docker hosts via SSH with read-only diagnostics, image-drift visibility, and automated update execution with rollback.
README
homelab-mcp
MCP server for homelab diagnostics + auto-update pipeline. Runs on TrueNAS (or anywhere) as the central control plane; talks to one or more downstream Docker hosts (Unraid, QNAP, etc.) over SSH.
What it does
-
Read-only diagnostics (MCP tools, safe to call any time):
list_stacks_tool— every compose project + single container on a hoststack_status_tool— full state of one stack (containers, digests)recent_events_tool— docker events from the last N secondsget_logs_tool— last N log lines of a container (capped at 5000)check_nfs_shares_tool— mounted NFS exportscheck_dns_tool— name resolution against the host's resolvercheck_vpn_health_tool— gluetun container health
-
Image-drift visibility (MCP tools, populates
pending_updates):trigger_scan_tool— on-demand scan of one or all hostslist_pending_updates_tool— rows from the latest scan / cronpending_update_dismiss_tool— drop a row after deciding not to apply
-
Auto-update pipeline (cron-style; one cycle at a time):
- Fetch release notes — image → GitHub repo heuristic (ghcr.io / quay.io / lscr.io/linuxserver → GitHub Releases API, then CHANGELOG.md fallback). 8KB cap.
- Classify via LLM — OpenAI-compatible chat-completions
endpoint (works with Ollama, vLLM, MiniMax M3). Returns
SAFE/CAUTION/BREAKINGplus migration steps, compose changes, env changes. Any LLM error falls back toCAUTION(better to over-apply than under-classify). - Apply policy:
- default
safe-and-caution— auto-apply SAFE + CAUTION, notify on BREAKING safe-only— auto-apply SAFE only, notify on CAUTION + BREAKING
- default
- Apply —
docker compose pull && docker compose up -dfrom the resolved stack directory. Stack-dir resolution: 4-tier (label override > compose working_dir > Dockge path > CA compose.manager). Probes container health post-restart. - Auto-rollback on apply failure (pull old digest, up -d).
- Notify — ntfy by default (configurable); BREAKING alerts go to the ntfy topic with high priority.
Quick start
# 1. Sync deps (the project is configured to use .venv/)
uv sync --extra dev
source .venv/bin/activate
# 2. Configure
cp .env.example .env
# ... edit .env (set HOMELAB_MCP_HOSTS, ntfy topic, LLM endpoint, etc.)
# 3. Test
pytest
# 4. Run the MCP server (SSE on :18790)
python -m homelab_mcp
# 5. Run one cycle of the auto-apply pipeline (dry-run)
python -m homelab_mcp.auto_apply_main --dry-run
If
uv syncputs the venv in avenv/directory instead of.venv/, setUV_PROJECT_ENVIRONMENT=.venvonce or useuv venv .venv && uv sync --extra devto force the location.
Install on Unraid
# On Unraid:
bash scripts/install-on-unraid.sh
# (pulls the GHCR image, starts the daemon, registers a 6h cron)
Install on TrueNAS (the "main hub" config)
# On TrueNAS, in a Dockge stack directory:
git clone https://github.com/<owner>/homelab-mcp.git
cd homelab-mcp
cp scripts/dockge-stack/.env.example .env
# ... edit .env (set HOMELAB_MCP_HOSTS=["truenas","unraid"],
# HOMELAB_MCP_LOCAL_HOST_ALIAS=truenas, etc.)
docker compose -f scripts/dockge-stack/compose.yaml up -d
bash scripts/deploy-on-truenas.sh
# (runs 5 in-the-field smoke tests)
Configuration
All configuration is via environment variables. See .env.example.
| Env var | Default | Notes |
|---|---|---|
HOMELAB_MCP_HOSTS |
["unraid"] |
JSON list of host aliases |
HOMELAB_MCP_PORT |
18790 |
MCP SSE transport port |
HOMELAB_MCP_STATE_DIR |
~/.local/share/homelab-mcp |
sqlite + last_scan.txt |
HOMELAB_MCP_SSH_CONFIG |
~/.ssh/config |
for RemoteSSH |
HOMELAB_MCP_POLL_ENABLED |
true |
visibility cron on/off |
HOMELAB_MCP_POLL_INTERVAL |
21600 |
seconds between scans (6h) |
HOMELAB_MCP_NTFY_URL |
https://ntfy.sh/ |
notifier base |
HOMELAB_MCP_NTFY_TOPIC |
"" |
required for alerts |
HOMELAB_MCP_NTFY_PRIORITY |
default |
default priority |
HOMELAB_MCP_LLM_ENDPOINT |
http://localhost:11434/v1/chat/completions |
OpenAI-compatible |
HOMELAB_MCP_LLM_API_KEY |
"" |
Bearer token (optional) |
HOMELAB_MCP_LLM_MODEL |
"" |
model name (required) |
HOMELAB_MCP_LLM_TIMEOUT |
30 |
seconds |
HOMELAB_MCP_AUTO_APPLY_POLICY |
safe-and-caution |
or safe-only |
HOMELAB_MCP_LOCAL_HOST_ALIAS |
unraid |
set to truenas for TrueNAS deploys |
HOMELAB_MCP_DOCKGE_STACKS_ROOT |
/mnt/Data/appdata/dockge/stacks |
Dockge stacks path |
Architecture
+------------+
| TrueNAS | <-- MCP daemon here (LocalDocker)
| (main hub) |
+-----+------+
|
SSH | (RemoteSSH for unraid + qnap)
|
+--------------+--------------+
| |
+----+-----+ +------+----+
| Unraid | | QNAP |
| (117 ct) | | (60+ ct) |
+----------+ +-----------+
- LocalDocker backend: the daemon host's docker socket
(
unix:///var/run/docker.sock). - RemoteSSH backend: SSH config alias →
ssh <alias> docker ps. Each host alias inHOMELAB_MCP_HOSTSmust have a correspondingHostblock inHOMELAB_MCP_SSH_CONFIG. - Stack-dir resolution (in order):
auto-update.stack-dirlabel on the container (override)com.docker.compose.project.working_dir(the standard compose label)- If
com.dockge.ownerorauto-update.dockge=trueis set →<HOMELAB_MCP_DOCKGE_STACKS_ROOT>/<project> - Otherwise →
<compose_manager_root>/<project>(CA compose.manager style;compose_manager_rootis auto-detected for the local host)
Tests
uv run pytest -q
Currently 112 tests across:
- config (env-var loading, validation)
- state (SQLite CRUD, idempotent writes, busy_timeout)
- hosts (LocalDocker + RemoteSSH, structural conformance to HostClient)
- updater.registry (image-ref parsing, registry result kinds)
- updater.scanner (drift detection, transient errors, digests)
- updater.pipeline (snapshot, apply+probe, rollback, run_pipeline)
- updater.release_notes (image→GitHub, GH Releases API, CHANGELOG fallback, truncation)
- updater.risk (SAFE/CAUTION/BREAKING classification, error fallbacks)
- updater.notifier (ntfy POST, multi-fan-out, console)
- updater.auto_apply (policy decisions, classifier-fail CAUTION fallback)
- auto_apply_main (cron arg parsing, per-row exception isolation, summary)
- server (FastMCP singleton, tool registration, build_hosts wiring)
Live tests (skipped unless HOMELAB_MCP_LIVE=1) cover SSH connections
to a real host.
Security
- The MCP server runs in SSE mode and is bound to
0.0.0.0:18790by default. Put a reverse proxy in front of it (npmplus, Traefik, Caddy) with OIDC or HTTP basic auth — don't expose 18790 directly. - ntfy topics should be unique and unguessable. Add a token in the
URL (
HOMELAB_MCP_NTFY_URL=https://ntfy.sh/?token=...) for private topics. - LLM API keys never appear in logs or state. The state DB at
HOMELAB_MCP_STATE_DIR/state.dbis not encrypted — host-level ACLs apply. - The
auto-updatemachinery touches docker. Run as a dedicated user with docker-socket access; do not run as root if you can avoid it.
License
MIT.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.