Labsco
zorak1103 logo

ha-mcp

β˜… 5

from zorak1103

A Model Context Protocol (MCP) server that provides AI assistants with access to Home Assistant, enabling smart home control and automation management.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

ha-mcp

GitHub release License CI Go Report Card Go Version Go Reference Docker Hub Docker Pulls Release Renovate

A Model Context Protocol (MCP) server that provides AI assistants with access to Home Assistant, enabling smart home control and automation management.

Features

  • 40 Specialized Tools: Entity queries, automation CRUD, helper management, scripts, scenes, devices, areas, labels, floors, zones, persons, tags, traces, blueprints, updates, todos, calendars, cameras, dashboards, system log, and more
  • Hybrid Architecture: WebSocket for most operations, REST API for automation/script/scene CRUD
  • Complete CRUD: Create, read, update, delete automations/scripts/scenes/helpers
  • Deep System Access: Query registries, analyze dependencies, access logbook, validate config
  • Flexible Output: Natural language (LLM-optimized) and JSON formats
  • Access Control: Read-only mode, whitelist/blacklist, fine-grained action-level control
  • Auto-Reconnect: Automatic reconnection with exponential backoff
  • Post-Mutation Confirmation: Automatic state polling after create/update/delete confirms changes

vs. Other MCP Servers for Home Assistant

Two alternatives exist: the official HA MCP integration (built-in, ~10 intent-based tools) and the community homeassistant-ai/ha-mcp (Python/FastMCP, 95+ tools).

Choose ha-mcp if you need:

  • Full automation/script/scene/helper lifecycle management (create, edit, delete)
  • Advanced analysis (dependencies, cross-references, automation coverage)
  • System administration (registry queries, config validation, logbook, history)
  • Media management (browser, camera streams), HACS, and dashboard access
  • Reliable LLM tool selection β€” 40 consolidated tools reduce selection errors compared to 95+ fine-grained alternatives

Choose the official integration if you need entity-level security or no external infrastructure.

See docs/feature-comparison.md for a detailed three-way feature matrix.

Available Tools

40 tools organized by domain. Full reference at docs/tools.md.

Seven guidance topics are also available as MCP resources under skill://ha-mcp/<slug> URIs (format-selection, automation-patterns, template-resilience, helper-selection, dashboard-safety, entity-renaming, debugging-workflow).

CategoryCountHighlights
Entity5query_entities (history/stats/health), get_state, analyze_entity
Registry10get_registry, manage_area/label/floor/zone/person/tag/entity/device
Automation1manage_automation (CRUD, toggle, coverage, JSON Patch + semantic patch)
Helpers2manage_helper (26 types), helper_action
Scripts & Scenes2manage_script, manage_scene (CRUD + execute/activate + JSON Patch + semantic patch)
Analysis3analyze_entity, get_entity_dependencies, analyze_target
Services2call_service, list_services
History/Logbook2query_entities modes, get_logbook (entries + correlation)
Dashboards/Media4manage_dashboard (JSON Patch + semantic patch), browse_media, manage_camera, sign_media_path
Calendars & Todos2manage_calendar, manage_todo
System/Admin7get_system_info, validate_config, manage_update, manage_blueprint
Logs1manage_system_log (list WARN/ERROR entries, clear ring buffer)
HACS1manage_hacs (list, download, install, custom repos)
Guidance1get_skill (action=list to discover skills, action=read to fetch content)

Access Control

ha-mcp provides read-only mode, whitelist, and blacklist filtering at the tool and action level:

Copy & paste β€” that's it
# config.yaml β€” read-only monitoring
server:
  read_only: true

# Or block specific operations
server:
  tool_filter:
    blacklist:
      - "call_service"
      - "manage_*:delete"

See docs/access-control.md for glob patterns, category filtering (*:write), and example scenarios.

Architecture

Copy & paste β€” that's it
AI Client β†’ HTTP/JSON-RPC β†’ ha-mcp MCP Server
                                    β”‚
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚ WebSocket (primary)                      β”‚ REST API
               β”‚ - State queries, service calls           β”‚ - Automation CRUD
               β”‚ - Helper CRUD, Registry access           β”‚ - Script/Scene CRUD
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                             Home Assistant

See docs/architecture.md for project structure, build commands, and integration test setup.

Development

Prerequisites: Go 1.26+, golangci-lint v2, Docker (optional)

Copy & paste β€” that's it
go build -o ha-mcp ./cmd/ha-mcp    # Build
go test ./...                       # Unit tests
golangci-lint run --timeout=5m ./...  # Lint

See docs/architecture.md for integration test setup and docs/integration-tests.md for the full test suite documentation.

Contributing

  1. Fork the repository and create a feature branch
  2. Make your changes with tests
  3. Ensure CI passes:
    Copy & paste β€” that's it
    golangci-lint run ./...
    go test -race ./...
  4. Open a Pull Request

Pull Request Guidelines

  • Ensure CI checks pass (lint, test, security scans)
  • Update documentation if needed
  • Add tests for new functionality
  • Keep commits focused and atomic

License

GPL-3.0 License - see LICENSE for details.

Acknowledgments