ha-xiaozhi-mcp

by c1pher-cn

MCP Client 3 stars
  • other

homeassistant mcpserver的临时中转方案

About

What is ha-xiaozhi-mcp?

ha-xiaozhi-mcp is a temporary relay solution for connecting Home Assistant to the Xiaozhi MCP server. It runs as a Python MCP server on any environment with Python, acting as a bridge so that Xiaozhi can control smart home devices through Home Assistant.

How to use ha-xiaozhi-mcp?

Download all files, install dependencies with pip install -r requirements.txt, then configure three settings in the config file: your Home Assistant long-lived access token (api_key), your Home Assistant base URL (base_url), and the Xiaozhi MCP endpoint (MCP_ENDPOINT). Start the MCP server by running python mcp_pipe.py hass.py. After startup, check that the MCP configuration shows three available tools. Finally, add device information into Xiaozhi’s prompt using the provided template.

Key features of ha-xiaozhi-mcp

- Temporary relay between Home Assistant and Xiaozhi MCP
- Exposes three tools for device control
- Supports any Home Assistant device entity
- Operates locally or on a local network
- Lightweight Python implementation

Use cases of ha-xiaozhi-mcp

- Allow Xiaozhi to control smart lights, switches, and other devices via Home Assistant
- Bridge Home Assistant to a third‑party MCP service quickly without permanent infrastructure
- Experiment with MCP‑based smart home automation
- Control devices in specific rooms (e.g.,书房) using voice or prompts

FAQ from ha-xiaozhi-mcp

What does ha-xiaozhi-mcp do?

It acts as a temporary relay that connects Home Assistant to the Xiaozhi MCP service, enabling Xiaozhi to send device control commands to Home Assistant.

How do I install and set it up?

Download the repository, run pip install -r requirements.txt, edit the configuration file with your Home Assistant token, base URL, and Xiaozhi MCP endpoint, then execute python mcp_pipe.py hass.py.

Does it support all Home Assistant devices?

It supports any device entity that appears in the Home Assistant entity registry, especially lights and switches. You can control devices by specifying their entity IDs and room locations.

Is ha-xiaozhi-mcp free to use?

The code appears to be open source and free. It requires a valid Home Assistant long‑lived access token and a Xiaozhi MCP endpoint provided by the Xiaozhi platform.

Are there any known limitations?

This is a temporary relay solution, not intended for production use. It runs as a single Python process and may require manual reconfiguration if the MCP endpoint changes. Device entity updates must be manually added to the prompt.

Details

Author
c1pher-cn
GitHub stars
3
Category
other
Repository
c1pher-cn/ha-xiaozhi-mcp

ha-xiaozhi-mcp

homeassistant mcpserver的临时中转方案

下载全部文件到你的环境中

1.安装依赖

执行 pip install -r requirements.txt

2.配置conf

api_key ha的长效token

base_url ha的地址,在本地环境就填局域网地址

MCP_ENDPOINT 小智官方提供的mcp地址

3.启动mcpserver

执行 python mcp_pipe.py hass.py

4.检查状态

运行成功后检查mcp配置里是否正常显示三个可用工具

image

5.配置提示词

在小智的提示词里加入你的设备信息,之前在三方server有部署过的可以直接粘贴,没整理过得可以用我这个模板去批量获取一下
(尽量精简,不要贴太多无用的传感器)
我的例子:

×××你的其他提示词×××
你也可以帮我控制家里的智能设备,你所在的位置在书房,未指定区域的情况下优先控制书房的设备。你的以下是设备列表:
- 房间,设备名称,设备id(entity_id)
- 书房,吸顶灯,light.649e3159aa36_light
- 书房,音响,media_player.shu_fang_2
- 书房,显示器挂灯,light.yeelink_lamp22_fd36_light
- 书房,灯带,light.plug_158df955a6167a

批量获取设备的模板:
{% set area_list=['书房','主卧'] %}
{% for area in area_list %}
{% set device_list = area_entities(area) | reject('is_hidden_entity') %}
{% for device in device_list %}
{% if 'light' in device or 'switch' in device %}
{{area}},{{device}},{{state_attr(device, 'friendly_name')}}
{% endif %}
{% endfor%}
{% endfor%}