Skip to main content
Glama
Home Assistant MCP

Home Assistant MCP

by hpohlmann

ホームアシスタントMCP

AI アシスタントを使用して Home Assistant デバイスを制御するためのモデル コンテキスト プロトコル (MCP) 統合。

概要

このMCPを使用すると、AIアシスタントがHome Assistantデバイスを制御できるようになります。以下のツールが提供されます。

  1. Home Assistantインスタンス内のエンティティを検索する

  2. デバイスを制御する(オン/オフにする)

  3. 光の色と明るさを制御する

Related MCP server: Hass-MCP

前提条件

  • Python 3.11以上

  • Home Assistant インスタンスが実行中であり、API 経由でアクセス可能

  • ホームアシスタント長期アクセストークン

インストール

  1. このリポジトリをクローンする

  2. Python 環境をセットアップします。

cd home-assistant
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -U pip
pip install uv
uv pip install -e .

構成

Home Assistantの長期アクセストークンを取得する

  1. Home Assistantインスタンスに移動する

  2. プロフィールに移動します(サイドバーのユーザー名をクリックします)

  3. 「長期アクセストークン」までスクロールします。

  4. 「MCP統合」のようなわかりやすい名前で新しいトークンを作成します

  5. トークンをコピーします(一度だけ表示されます)

カーソルAIで設定

Cursor の MCP 構成に次の構成を追加します。

{
  "mcpServers": {
    "home_assistant": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/your/home-assistant-mcp",
        "run",
        "main.py"
      ],
      "env": {
        "HOME_ASSISTANT_TOKEN": "your_home_assistant_token_here"
      },
      "inheritEnv": true
    }
  }
}

交換する:

  • /path/to/your/home-assistantこのディレクトリへの実際のパスに置き換えます

  • your_home_assistant_token_hereに Home Assistant 長期アクセストークンを入力します。

ホームアシスタントのURL設定

デフォルトでは、MCP はhttp://homeassistant.local:8123で Home Assistant に接続しようとします。

Home Assistant が別の URL にある場合は、 app/config.pyのHA_URL変数を変更できます。

使用法

設定が完了すると、Cursor AI を使用して Home Assistant デバイスを制御できるようになります。

  • デバイスを検索:「リビングルームの照明を探す」

  • 制御デバイス:「キッチンのライトをつけて」

  • ライトの色を制御する: 「リビングルームのライトを赤に設定して」

  • 明るさを調整する: 「ダイニングルームの照明を青、明るさ 50% に設定」

照明制御機能

MCP は、高度な照明制御機能をサポートするようになりました。

  1. カラーコントロール: 互換性のあるライトのRGBカラーを設定します

    • RGB値(各コンポーネント0~255)を使用して色を指定します

    • 例: 赤の場合はset_device_color("light.living_room", 255, 0, 0)

  2. 明るさコントロール:ライトの明るさを調整します

    • オプションの明るさパラメータ(0~255)

    • 色の変更と組み合わせることができます

    • 例: 中程度の明るさの青の場合set_device_color("light.dining_room", 0, 0, 255, brightness=128)

トラブルシューティング

  • 認証エラーが発生した場合は、トークンが正しく、期限切れになっていないことを確認してください。

  • 設定されたURLでHome Assistantインスタンスにアクセスできることを確認します

  • 色の制御に関する問題について:

    • ライトエンティティがRGBカラーコントロールをサポートしていることを確認する

    • 色を変える前にライトが点灯していることを確認してください

将来の機能

動的エンティティエクスポージャー

現在の実装では、デバイスを制御するために 2 段階のプロセスが必要です。

  1. 自然言語を使用してエンティティを検索する

  2. 特定のentity_idを使用してエンティティを制御する

計画されている機能強化では、エンティティを制御デバイス ツールに公開するためのより動的な方法を作成し、AI が次のことを実行できるようにします。

  • より自然なコマンドでデバイスを直接制御する(例:「キッチンのライトを消して」)

  • 頻繁に使用するエンティティをキャッシュしてアクセスを高速化する

  • 明るさ、温度、その他の属性の調整など、より複雑な操作をサポートします

  • エンティティグループとシーンをより直感的に操作する

これにより、AI アシスタントを介して Home Assistant デバイスを制御する際の操作時間が大幅に短縮され、よりシームレスなユーザー エクスペリエンスが実現します。

Available Tools

3 tools
control_deviceB

Control a Home Assistant entity by turning it on or off.

Args:
    entity_id: The Home Assistant entity ID to control (format: domain.entity)
    state: The desired state ('on' or 'off')

Inputs: entity_id (required), state (required).

search_entitiesA

Search for Home Assistant entities matching a natural language description.

Args:
    description: Natural language description of the entity (e.g., "office light", "kitchen fan")

Returns:
    A list of matching entity IDs with their friendly names, or an error message

Inputs: description (required).

set_device_colorA

Set the color and optionally brightness of a light entity.

Args:
    entity_id: The Home Assistant entity ID to control (format: light.entity)
    red: Red component (0-255)
    green: Green component (0-255)
    blue: Blue component (0-255)
    brightness: Optional brightness level (0-255)

Inputs: entity_id (required), red (required), green (required), blue (required), +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap. control_device handles basic on/off states, search_entities finds devices by description, and set_device_color manages color/brightness for lights. An agent can easily distinguish when to use each tool based on the specific operation needed.

    Naming Consistency5/5

    All three tools follow a consistent verb_noun pattern with snake_case throughout: control_device, search_entities, and set_device_color. The naming is predictable and follows the same grammatical structure, making the tool set easy to understand at a glance.

    Tool Count3/5

    With only 3 tools, this feels thin for a Home Assistant integration that presumably manages many device types and operations. While the tools cover basic control, search, and color settings, the scope suggests more operations would be needed for comprehensive home automation coverage. The count is borderline minimal for the domain.

    Completeness2/5

    There are significant gaps in the tool surface for home automation. Missing operations include getting device status/state, adjusting non-color attributes (like temperature for thermostats or speed for fans), managing scenes/automations, and handling other entity types beyond lights. The current tools provide only partial coverage of the Home Assistant domain.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that integrates with Home Assistant to provide smart home control capabilities through natural language, supporting devices like lights, climate systems, locks, alarms, and humidifiers.
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      A Model Context Protocol server that enables AI assistants like Claude to interact directly with Home Assistant, allowing them to query device states, control smart home entities, and perform automation tasks.
      29
      353
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to control Home Assistant devices and services through the Model Context Protocol.
      106
      MIT