Skip to main content
Glama

Home Assistant MCP Server

家庭助理 MCP 服务器

用于与Home Assistant集成的模型上下文协议 (MCP)服务器,允许 LLM 控制和查询您的智能家居。

特征

  • 通过自然语言查询和控制 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 进行身份验证的长期访问令牌
PORT3000使用 HTTP/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

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

模型上下文协议服务器允许大型语言模型通过自然语言交互来控制和查询 Home Assistant 智能家居系统。

  1. 特征
    1. 安装
      1. 配置
        1. 环境变量
      2. 用法
        1. 作为独立服务器运行
        2. 与 Claude Desktop 集成
      3. 可用工具
        1. 安全
          1. 执照

            Related MCP Servers

            • -
              security
              A
              license
              -
              quality
              Expose all Home Assistant voice intents through a Model Context Protocol Server allowing home control.
              Last updated -
              30
              Python
              Apache 2.0
            • A
              security
              A
              license
              A
              quality
              A server that enables interaction with Home Assistant devices and automations through the Model Context Protocol, allowing users to monitor device states, control devices, trigger automations, and list entities.
              Last updated -
              4
              29
              JavaScript
              MIT License
              • Apple
            • -
              security
              F
              license
              -
              quality
              A versatile Model Context Protocol server that enables AI assistants to manage calendars, track tasks, handle emails, search the web, and control smart home devices.
              Last updated -
              2
              Python
              • Apple
              • Linux
            • -
              security
              A
              license
              -
              quality
              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.
              Last updated -
              Python
              MIT License
              • Apple

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/oleander/home-assistant-mcp-server'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server