homelab-codex-ws/services
oskar 0650eb857a feat(ha-mcp): read-only MCP server (faza 2a)
Own minimal MCP server exposing the live state of the HA instances in
services/home-assistant/instances.yaml to Claude Code over stdio — the
phase-2 "MCP read-only" gate in services/home-assistant/DESIGN.md.
Operator decision 2026-07-30: build our own rather than adopt hass-mcp,
so the tools reuse scripts/ha/lib/{ha_api,ha_ws}.py (one token-handling
story for the whole HA toolchain) and can answer from the repo and from
instances.yaml, which a generic server cannot.

Seven tools, all read-only, default instance `ken`: list_entities,
get_state, get_areas, find_entities_by_description, read_automation,
list_automations, instance_status.

Read-only by construction, not by policy: REST goes through ha_api.Client
(get/get_raw_text only — no POST method exists), WebSocket commands are
checked against a three-entry *_list allowlist before being sent, and
read_automation reads services/home-assistant/config/<instance>/ rather
than /api/config. Tests assert all three, including a grep guard that
fails if requests.post/call_service ever appears in the package. The
write path stays repo + scripts/ha/deploy.sh.

Details that follow from how this instance actually behaves:

- unavailable is never silent — every entity view carries unavailable +
  unavailable_since, every list a count. The 2026-07-23 audit traced ~15
  silently dead automations to conditions sitting on dead sensors.
- chelsty-ha (status: offline in instances.yaml) is answered from the
  file, never dialed — no 5s timeout for a known-offline LTE site.
- areas come from the WS registries (entity area_id > device area_id) with
  a storage-export fallback; area_source/area_note say which was used and
  what the offline export cannot resolve.
- PL->EN fuzzy matching, since the house is Polish and the entity_ids are
  transliterated English: "czujnik temperatury salon" ->
  sensor.thsalon_temperature, each hit explaining why it matched.
- 5s timeouts and errors returned as {"error": ...} inside a normal tool
  result — a missing token or an unreachable instance never crashes the
  server or hangs the agent.

Registered for Claude Code in the repo-root .mcp.json (new file) as `ha`,
via services/ha-mcp/run.sh (prefers the venv, falls back to system
python3). The mcp SDK lives in services/ha-mcp/.venv — rationale for venv
over --break-system-packages is in the README.

Tests: 42 offline (no network, no HA, no token) + a live read-only smoke
against ken — HA 2026.7.2, 1647 entities, 377 unavailable, 115
automations, 13 areas.
2026-07-30 16:47:27 +02:00
..
agent-system fix(actions): mirror pending z VPS na panel PIHA + mutate proxy do VPS — Action Queue byla slepa 2026-07-20 19:55:54 +02:00
brain-watchdog feat(brain-watchdog): poll Prometheus /api/v1/alerts as second alert source (Telegram) 2026-06-30 18:51:34 +02:00
control-plane fix(supervisor): route healthcheck_failed to container_restart 2026-07-29 19:24:01 +02:00
fleet-prometheus feat(kb): faza 3 krok 5 — cykliczny ingest (systemd timer) + alerting 2026-07-17 15:54:13 +02:00
forgejo fix(inventory): correct owner_node — forgejo→piha, mosquitto→vps (per 2026-07-02 verify) 2026-07-02 16:48:12 +02:00
gokapi feat(gokapi): config publicznego file-share na VPS (share.okit.pl, E2E, Tailscale-bind za npm@VPS, disk-protection) — do deployu 2026-07-09 17:29:28 +02:00
ha-diag-agent fix(ha-diag): node_name from env + fail-fast on unknown — evt-unknown-* files poisoned observer checkpoint (see d5139c9) 2026-07-15 19:48:58 +02:00
ha-mcp feat(ha-mcp): read-only MCP server (faza 2a) 2026-07-30 16:47:27 +02:00
home-assistant feat(ha-mcp): read-only MCP server (faza 2a) 2026-07-30 16:47:27 +02:00
kb-postgres feat(kb): faza 3 krok 2 — migracja 004 (document_summary) + pilot streszczeń A/B 2026-07-17 13:30:47 +02:00
kb-query test(kb-query): luki T1–T3 z test_fallback.py + status kalibracji ollama-piha (salvage S3+S4) 2026-07-30 16:40:24 +02:00
llm-gateway feat(llm-gateway): wciagniecie shadow-serwisu z PIHA do GitOps 2026-07-03 15:08:33 +02:00
mosquitto fix(hosts): align manifests with observed reality (recon B6/B7/C8/F20.5) 2026-07-29 19:15:55 +02:00
nextcloud feat(kb): configi Paperless/Nextcloud wg 9 decyzji — NC na PIHA, domeny kapala, Redis requirepass, backup SOLARIA, NC pin 34 2026-07-09 16:17:27 +02:00
node-agent feat(remediation): node-agent wykonuje zlecone akcje lokalnie — koniec SSH z executora 2026-07-22 18:08:01 +02:00
node_exporter feat(kb): faza 3 krok 5 — cykliczny ingest (systemd timer) + alerting 2026-07-17 15:54:13 +02:00
npm Add node capability model 2026-05-11 20:46:50 +02:00
ollama fix(ollama): restore GPU reservation on SOLARIA, close 07-15 cutover docs 2026-07-16 14:43:29 +02:00
ollama-piha test(kb-query): luki T1–T3 z test_fallback.py + status kalibracji ollama-piha (salvage S3+S4) 2026-07-30 16:40:24 +02:00
paperless fix(paperless-worker): celery command bypassed manage.py + missing shared scratch dir 2026-07-12 20:51:04 +02:00
paperless-worker fix(paperless-worker): celery command bypassed manage.py + missing shared scratch dir 2026-07-12 20:51:04 +02:00
planner-agent fix+debug(planner-agent): use base_url (not api_base) for litellm.acompletion, add print [TEMP] 2026-05-28 13:07:58 +02:00
stability-agent fix(stability-agent): tag containers_not_running events with compose service 2026-07-29 19:22:07 +02:00
vikunja fix(vikunja): PUBLICURL na vikunja.kapala.org 2026-07-02 17:28:56 +02:00
zigbee2mqtt docs: compress CLAUDE.md + fix zigbee2mqtt coordinator docs 2026-05-29 14:17:23 +02:00
.gitkeep Add infrastructure standards and deployment conventions 2026-05-07 21:16:03 +02:00