Back to MCP directory
publicPublicdnsLocal runtime

hekmon8_Homeassistant-server-mcp

一个用于与Home Assistant交互的MCP服务器,提供设备状态监控、控制、自动化触发等功能,属于AI模型上下文协议(MCP)生态系统的一部分。

article

README

🚀 家庭助手 MCP 服务器

这是一个用于与 Home Assistant 进行交互的 Model Context Protocol (MCP) 服务器。借助此服务器,你可以通过支持 MCP 的应用程序,对家庭设备进行控制和监控。

该项目是 AI 模型上下文协议 (MCP) 生态系统的一部分。想了解更多关于 MCP 工具的信息和技术文档,可访问 www.aimcp.info

🚀 快速开始

本服务器能助力你轻松控制和监控家庭设备,下面为你介绍使用前的准备步骤。

✨ 主要特性

  • 获取设备状态
  • 控制设备状态(开/关)
  • 触发自动化
  • 列出可用实体

📦 安装指南

按照以下步骤安装本项目:

  1. 克隆此仓库:
git clone https://github.com/yourusername/homeassistant-server-mcp.git
cd homeassistant-server-mcp
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build
  1. 配置 MCP 服务器,在您的 MCP 设置文件中添加以下内容(通常位于 ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json 对于 VSCode):
{
  "mcpServers": {
    "homeassistant": {
      "command": "node",
      "args": ["/path/to/homeassistant-mcp/homeassistant-server/build/index.js"],
      "env": {
        "HA_URL": "http://your-homeassistant-url:8123",
        "HA_TOKEN": "your-long-lived-access-token"
      }
    }
  }
}

请将 your-homeassistant-urlyour-long-lived-access-token 替换为您自己的 Home Assistant 实例 URL 和访问令牌。

💻 使用示例

基础用法

本服务器提供了多种工具,以下是一些基础使用示例:

1. 获取设备状态

// 示例用法
use_mcp_tool({
  server_name: "homeassistant",
  tool_name: "get_state",
  arguments: {
    entity_id: "light.living_room"
  }
});

2. 切换设备状态

// 示例用法
use_mcp_tool({
  server_name: "homeassistant",
  tool_name: "toggle_entity",
  arguments: {
    entity_id: "switch.bedroom",
    state: "on"  // 或 "off"
  }
});

3. 触发自动化

// 示例用法
use_mcp_tool({
  server_name: "homeassistant",
  tool_name: "trigger_automation",
  arguments: {
    automation_id: "automation.morning_routine"
  }
});

4. 列出实体

// 示例用法
use_mcp_tool({
  server_name: "homeassistant",
  tool_name: "list_entities",
  arguments: {
    domain: "light"  // 可选,按领域过滤
  }
});

🤝 贡献

欢迎大家为项目贡献力量!你可以按照以下步骤进行操作:

  1. 叉克隆仓库
  2. 创建功能分支(git checkout -b feature/your-feature-name
  3. 提交更改并创建拉取请求

请在提交前检查代码格式并编写单元测试。

🔧 技术细节

本项目使用了以下技术和工具:

📄 许可证

本项目根据 MIT License 发布。

🆘 支持

若你在使用过程中遇到问题或有疑问,可按以下步骤操作:

  1. 检查仓库中的现有问题
  2. 若问题未被报告,请创建新问题
  3. 提供尽可能多的上下文以帮助解决问题
  4. 访问 www.aimcp.info 以获取更多支持资源
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client