Home Assistant MCP Server

by oleander
Verified
MIT License
1
  • Apple

Integrations

  • Uses .env files for configuration management, storing connection details and authentication tokens for Home Assistant integration.

  • Provides tools for querying and controlling Home Assistant entities through natural language, including state management, service calls, historical data access, and device control in a smart home environment.

  • Provides specific installation and configuration paths for macOS systems when integrating with Claude Desktop.

ホームアシスタントMCPサーバー

Home Assistantと統合し、LLM がスマート ホームを制御およびクエリできるようにするModel Context Protocol (MCP)サーバー。

特徴

  • 自然言語でHome Assistantエンティティをクエリおよび制御する
  • MCP 互換クライアント(Claude Desktop など)で動作します
  • 状態管理、サービス呼び出し、履歴などのツールを提供します
  • Home Assistantの長期アクセストークンを使用した安全な認証
  • 複数のトランスポート オプション (ローカル プロセスの場合は stdio、リモート クライアントの場合は SSE)
  • Home Assistant が利用できない場合のテストとデモンストレーション用の模擬データを備えたデモ モード

インストール

# Install globally using bun bun install -g home-assistant-mcp-server # Or install from source git clone https://github.com/oleander/home-assistant-mcp-server.git cd home-assistant-mcp-server bun install bun run build bun link

構成

次の変数を使用して、現在のディレクトリに.envファイルを作成します。

# Required configurations HASS_URL=http://your-home-assistant:8123 # URL to your Home Assistant instance HASS_TOKEN=your_long_lived_access_token # Long-lived access token for authentication # Optional configurations PORT=3000 # Port for the HTTP server (default: 3000) HASS_MOCK=false # Enable mock data mode when Home Assistant is unavailable (default: false)

環境変数

変数必須デフォルト説明
HASS_URLはい-Home Assistant インスタンスへの URL (例: http://homeassistant.local:8123 )
HASS_TOKENはい-Home Assistant で認証するための長期アクセス トークン
PORTいいえ3000HTTP/SSEトランスポートを使用する場合のHTTPサーバーのポート番号
HASS_MOCKいいえ間違い「true」に設定すると、Home Assistant接続なしでテストするための模擬データモードが有効になります

長期間有効なアクセス トークンを取得するには:

  1. Home Assistantインスタンスにログインする
  2. プロフィール(左下)をクリックします
  3. 「長期アクセストークン」までスクロールします。
  4. わかりやすい名前で新しいトークンを作成する
  5. トークンの値をコピーします(再度表示されません)

使用法

スタンドアロンサーバーとして実行

# Standard mode (requires a running Home Assistant instance) home-assistant-mcp-server # Start with HTTP/SSE transport home-assistant-mcp-server --stdio # Start with stdio transport for direct process communication # Demo mode (with mock data when Home Assistant is unavailable) home-assistant-mcp-server --mock # Start with HTTP/SSE transport and mock data home-assistant-mcp-server --stdio --mock # Start with stdio transport and mock data

Claude Desktopとの統合

Claude Desktop で使用するには:

  1. Claude Desktop の設定ファイルを編集します。
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. サーバー構成を追加します。
{ "mcpServers": { "homeassistant": { "command": "home-assistant-mcp-server" "env": { "HASS_URL": "http://your-home-assistant:8123", "HASS_TOKEN": "your_token_here", "HASS_MOCK": "true" } } } }

Home Assistant を実行している場合は、 --mockフラグを削除し、 HASS_MOCK falseに設定するだけです。

  1. Claudeデスクトップを再起動します

利用可能なツール

サーバーは、Home Assistant と対話するためのいくつかのツールを公開します。

  • states - エンティティの状態を照会する
  • lights - ライトの一覧
  • light - ライトを制御する
  • service - ホームアシスタントサービスに電話する
  • history - 履歴エンティティデータを取得する
  • services - 利用可能なサービスを一覧表示する
  • config - Home Assistantの設定を取得する
  • domains - 利用可能なドメインの一覧
  • error_log - Home Assistant のエラーログを取得する
  • devices - Home Assistantですべてのデバイスを取得する

詳細な使用例については、 docs/hass-mcp.md を参照してください。

安全

このサーバーには、フルアクセス権限を持つHome Assistantアクセストークンが必要です。以下のセキュリティ推奨事項にご留意ください。

  • 信頼できるネットワーク上でのみサーバーを実行する
  • サーバーをリモートで公開する場合はHTTPSを使用する
  • .envファイルを安全に保ち、ソース管理にコミットしないでください。
  • 可能な場合は、権限が制限されたトークンの使用を検討してください

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

-
security - not tested
A
license - permissive license
-
quality - not tested

大規模な言語モデルが自然言語による対話を通じて Home Assistant スマート ホーム システムを制御およびクエリできるようにするモデル コンテキスト プロトコル サーバー。

  1. Features
    1. Installation
      1. Configuration
        1. Environment Variables
      2. Usage
        1. Running as a standalone server
        2. Integration with Claude Desktop
      3. Available Tools
        1. Security
          1. License
            ID: 6iz02g2h28