Back to MCP directory
verified_userVerifieddnsLocal runtime

Homeassistant-server-mcp

一个基于MCP协议的Home Assistant服务端,提供设备控制与状态监控功能

article

README

🚀 家庭助手 MCP 服务器

家庭助手 MCP 服务器是一个用于与家庭助手交互的模型上下文协议(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 设置文件中添加以下内容来配置服务器(通常位于 ~/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 替换为您的家庭助手实例 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: "your_automation_id"
  }
});

4. 列出可用实体

// 示例用法
use_mcp_tool({
  server_name: "homeassistant",
  tool_name: "list_entities",
  arguments: {}
});

🔧 技术细节

为了安全使用此服务器,请遵循以下安全建议:

  1. 始终使用 HTTPS 对您的家庭助手实例。
  2. 保护访问令牌的安全,绝不在版本控制中提交。
  3. 定期轮换访问令牌。
  4. 使用环境变量存储敏感信息。

📚 详细文档

如果您遇到任何问题或有疑问,请按以下步骤操作:

  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