Homeassistant

MCP开发工具

提供方 tevonsb

开发工具 SSE · 服务端推送 无需鉴权 社区 / 第三方
查看接入方式

A MCP server for Home Assistant

一句话选型结论

按资料字段整理

Homeassistant 属于开发工具类 MCP 服务器,SSE · 服务端推送,无需鉴权,有可直接复制的远程端点配置。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类开发工具 传输方式SSE · 服务端推送 鉴权无需鉴权 部署方式本地部署
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

开发工具
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

适用场景

developer-tools

安装与配置

SSE · 服务端推送 无需鉴权
早期远程传输方式,正在被 HTTP 取代
npx jest --config=jest.config.cjs

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    确认你的客户端支持远程端点,并拿到服务地址。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
代码与仓库操作

在对话里直接查代码、提 issue、走 PR,省掉来回切工具。

本地命令与脚本

把构建、测试、格式化这类重复命令交给模型执行。

接口联调与测试

让模型调你的接口、跑一遍用例,快速定位问题。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 资料标注无需鉴权,装好就能连。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在开发工具场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Homeassistant当前 未标注 SSE · 服务端推送 本地部署 有 2026-05-18
Git 838e2ec1 12 stdio · 本地进程 本地部署 有 2026-05-17
Markitdown MCP 2c653a5f 1 stdio · 本地进程 本地部署 有 2026-05-17
JavaGuide 未标注 stdio · 本地进程 本地部署 有 2026-04-11
awesome-claude-skills 未标注 stdio · 本地进程 本地部署 有 2026-04-26
Context7 831acf40 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

开发工具
字段来自项目仓库与公开索引,中文说明由本站标注
提供方tevonsb上游标注的维护方 tevonsb
分类开发工具本站按上游分类展示
连接方式SSE · 服务端推送早期远程传输方式,正在被 HTTP 取代
鉴权方式无需鉴权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · Node.js本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-18上游最后核验时间

详细介绍

15.7 KB
来自项目仓库与上游目录的原文,未做删改

Model Context Protocol Server for Home Assistant

The server uses the MCP protocol to share access to a local Home Assistant instance with an LLM application.

A powerful bridge between your Home Assistant instance and Language Learning Models (LLMs), enabling natural language control and monitoring of your smart home devices through the Model Context Protocol (MCP). This server provides a comprehensive API for managing your entire Home Assistant ecosystem, from device control to system administration.

Features

  • 🎮 Device Control: Control any Home Assistant device through natural language
  • 🔄 Real-time Updates: Get instant updates through Server-Sent Events (SSE)
  • 🤖 Automation Management: Create, update, and manage automations
  • 📊 State Monitoring: Track and query device states
  • 🔐 Secure: Token-based authentication and rate limiting
  • 📱 Mobile Ready: Works with any HTTP-capable client

Real-time Updates with SSE

The server includes a powerful Server-Sent Events (SSE) system that provides real-time updates from your Home Assistant instance. This allows you to:

  • 🔄 Get instant state changes for any device
  • 📡 Monitor automation triggers and executions
  • 🎯 Subscribe to specific domains or entities
  • 📊 Track service calls and script executions

Quick SSE Example```javascript

const eventSource = new EventSource(
'http://localhost:3000/subscribe_events?token=YOUR_TOKEN&domain=light'
);

eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Update received:', data);
};


See SSE_API.md for complete documentation of the SSE system.

## Table of Contents

- Key Features
- Prerequisites
- Installation
  - Basic Setup
  - Docker Setup (Recommended)
- Configuration
- Development
- API Reference
  - Device Control
  - Add-on Management
  - Package Management
  - Automation Management
- Natural Language Integration
- Troubleshooting
- Project Status
- Contributing
- Resources
- License

## Key Features

### Core Functionality 🎮
- **Smart Device Control**
  - 💡 **Lights**: Brightness, color temperature, RGB color
  - 🌡️ **Climate**: Temperature, HVAC modes, fan modes, humidity
  - 🚪 **Covers**: Position and tilt control
  - 🔌 **Switches**: On/off control
  - 🚨 **Sensors & Contacts**: State monitoring
  - 🎵 **Media Players**: Playback control, volume, source selection
  - 🌪️ **Fans**: Speed, oscillation, direction
  - 🔒 **Locks**: Lock/unlock control
  - 🧹 **Vacuums**: Start, stop, return to base
  - 📹 **Cameras**: Motion detection, snapshots

### System Management 🛠️
- **Add-on Management**
  - Browse available add-ons
  - Install/uninstall add-ons
  - Start/stop/restart add-ons
  - Version management
  - Configuration access

- **Package Management (HACS)**
  - Integration with Home Assistant Community Store
  - Multiple package types support:
    - Custom integrations
    - Frontend themes
    - Python scripts
    - AppDaemon apps
    - NetDaemon apps
  - Version control and updates
  - Repository management

- **Automation Management**
  - Create and edit automations
  - Advanced configuration options:
    - Multiple trigger types
    - Complex conditions
    - Action sequences
    - Execution modes
  - Duplicate and modify existing automations
  - Enable/disable automation rules
  - Trigger automation manually

### Architecture Features 🏗️
- **Intelligent Organization**
  - Area and floor-based device grouping
  - State monitoring and querying
  - Smart context awareness
  - Historical data access

- **Robust Architecture**
  - Comprehensive error handling
  - State validation
  - Secure API integration
  - TypeScript type safety
  - Extensive test coverage

## Prerequisites

- **Node.js** 20.10.0 or higher
- **NPM** package manager
- **Docker Compose** for containerization
- Running **Home Assistant** instance
- Home Assistant long-lived access token (How to get token)
- **HACS** installed for package management features
- **Supervisor** access for add-on management

## Installation

### Basic Setup```bash
# Clone the repository
git clone https://github.com/tevonsb/homeassistant-mcp.git
cd homeassistant-mcp

# Install dependencies
npm install

# Build the project
npm run build

Docker Setup (Recommended)

The project includes Docker support for easy deployment and consistent environments across different platforms.

  1. Clone the repository:bash git clone https://github.com/tevonsb/homeassistant-mcp.git cd homeassistant-mcp

  2. Configure environment:bash cp .env.example .env
    Edit the .env file with your Home Assistant configuration:```env
    # Home Assistant Configuration
    HASS_HOST=http://homeassistant.local:8123
    HASS_TOKEN=your_home_assistant_token
    HASS_SOCKET_URL=ws://homeassistant.local:8123/api/websocket

    Server Configuration

    PORT=3000
    NODE_ENV=production
    DEBUG=false
    ```

  3. Build and run with Docker Compose:```bash
    # Build and start the containers
    docker compose up -d

    View logs

    docker compose logs -f

    Stop the service

    docker compose down
    ```

  4. Verify the installation:
    The server should now be running at http://localhost:3000. You can check the health endpoint at http://localhost:3000/health.

  5. Update the application:```bash
    # Pull the latest changes
    git pull

    Rebuild and restart the containers

    docker compose up -d --build
    ```

Docker Configuration

The Docker setup includes:
- Multi-stage build for optimal image size
- Health checks for container monitoring
- Volume mounting for environment configuration
- Automatic container restart on failure
- Exposed port 3000 for API access

Docker Compose Environment Variables

All environment variables can be configured in the .env file. The following variables are supported:
- HASS_HOST: Your Home Assistant instance URL
- HASS_TOKEN: Long-lived access token for Home Assistant
- HASS_SOCKET_URL: WebSocket URL for Home Assistant
- PORT: Server port (default: 3000)
- NODE_ENV: Environment (production/development)
- DEBUG: Enable debug mode (true/false)

Configuration

Environment Variables```env

Home Assistant Configuration

HASS_HOST=http://homeassistant.local:8123 # Your Home Assistant instance URL
HASS_TOKEN=your_home_assistant_token # Long-lived access token
HASS_SOCKET_URL=ws://homeassistant.local:8123/api/websocket # WebSocket URL

Server Configuration

PORT=3000 # Server port (default: 3000)
NODE_ENV=production # Environment (production/development)
DEBUG=false # Enable debug mode

Test Configuration

TEST_HASS_HOST=http://localhost:8123 # Test instance URL
TEST_HASS_TOKEN=test_token # Test token


### Configuration Files

1. **Development**: Copy `.env.example` to `.env.development`
2. **Production**: Copy `.env.example` to `.env.production`
3. **Testing**: Copy `.env.example` to `.env.test`

### Adding to Claude Desktop (or other clients)

To use your new Home Assistant MCP server, you can add Claude Desktop as a client. Add the following to the configuration. Note this will run the MCP within claude and does not work with the Docker method.```
{
  "homeassistant": {
    "command": "node",
    "args": [<path/to/your/dist/folder>]
    "env": {
      NODE_ENV=development
      HASS_HOST=http://homeassistant.local:8123
      HASS_TOKEN=your_home_assistant_token
      PORT=3000
      HASS_SOCKET_URL=ws://homeassistant.local:8123/api/websocket
      LOG_LEVEL=debug
    }
  }
}

API Reference

Device Control

Common Entity Controls```json

{
"tool": "control",
"command": "turn_on", // or "turn_off", "toggle"
"entity_id": "light.living_room"
}


#### Light Control```json
{
  "tool": "control",
  "command": "turn_on",
  "entity_id": "light.living_room",
  "brightness": 128,
  "color_temp": 4000,
  "rgb_color": [255, 0, 0]
}

Add-on Management

List Available Add-ons```json

{
"tool": "addon",
"action": "list"
}


#### Install Add-on```json
{
  "tool": "addon",
  "action": "install",
  "slug": "core_configurator",
  "version": "5.6.0"
}

Manage Add-on State```json

{
"tool": "addon",
"action": "start", // or "stop", "restart"
"slug": "core_configurator"
}


### Package Management

#### List HACS Packages```json
{
  "tool": "package",
  "action": "list",
  "category": "integration"  // or "plugin", "theme", "python_script", "appdaemon", "netdaemon"
}

Install Package```json

{
"tool": "package",
"action": "install",
"category": "integration",
"repository": "hacs/integration",
"version": "1.32.0"
}


### Automation Management

#### Create Automation```json
{
  "tool": "automation_config",
  "action": "create",
  "config": {
    "alias": "Motion Light",
    "description": "Turn on light when motion detected",
    "mode": "single",
    "trigger": [
      {
        "platform": "state",
        "entity_id": "binary_sensor.motion",
        "to": "on"
      }
    ],
    "action": [
      {
        "service": "light.turn_on",
        "target": {
          "entity_id": "light.living_room"
        }
      }
    ]
  }
}

Duplicate Automation```json

{
"tool": "automation_config",
"action": "duplicate",
"automation_id": "automation.motion_light"
}


### Core Functions

#### State Management```http
GET /api/state
POST /api/state

Manages the current state of the system.

Example Request:```json
POST /api/state
{
"context": "living_room",
"state": {
"lights": "on",
"temperature": 22
}
}


#### Context Updates```http
POST /api/context

Updates the current context with new information.

Example Request:```json
POST /api/context
{
"user": "john",
"location": "kitchen",
"time": "morning",
"activity": "cooking"
}


### Action Endpoints

#### Execute Action```http
POST /api/action

Executes a specified action with given parameters.

Example Request:```json
POST /api/action
{
"action": "turn_on_lights",
"parameters": {
"room": "living_room",
"brightness": 80
}
}


#### Batch Actions```http
POST /api/actions/batch

Executes multiple actions in sequence.

Example Request:```json
POST /api/actions/batch
{
"actions": [
{
"action": "turn_on_lights",
"parameters": {
"room": "living_room"
}
},
{
"action": "set_temperature",
"parameters": {
"temperature": 22
}
}
]
}


### Query Functions

#### Get Available Actions```http
GET /api/actions

Returns a list of all available actions.

Example Response:```json
{
"actions": [
{
"name": "turn_on_lights",
"parameters": ["room", "brightness"],
"description": "Turns on lights in specified room"
},
{
"name": "set_temperature",
"parameters": ["temperature"],
"description": "Sets temperature in current context"
}
]
}


#### Context Query```http
GET /api/context?type=current

Retrieves context information.

Example Response:```json
{
"current_context": {
"user": "john",
"location": "kitchen",
"time": "morning",
"activity": "cooking"
}
}


### WebSocket Events

The server supports real-time updates via WebSocket connections.```javascript
// Client-side connection example
const ws = new WebSocket('ws://localhost:3000/ws');

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Received update:', data);
};

Supported Events

  • state_change: Emitted when system state changes
  • context_update: Emitted when context is updated
  • action_executed: Emitted when an action is completed
  • error: Emitted when an error occurs

Example Event Data:```json
{
"event": "state_change",
"data": {
"previous_state": {
"lights": "off"
},
"current_state": {
"lights": "on"
},
"timestamp": "2024-03-20T10:30:00Z"
}
}


### Error Handling

All endpoints return standard HTTP status codes:

- 200: Success
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 404: Not Found
- 500: Internal Server Error

**Error Response Format:**```json
{
  "error": {
    "code": "INVALID_PARAMETERS",
    "message": "Missing required parameter: room",
    "details": {
      "missing_fields": ["room"]
    }
  }
}

Rate Limiting

The API implements rate limiting to prevent abuse:

  • 100 requests per minute per IP for regular endpoints
  • 1000 requests per minute per IP for WebSocket connections

When rate limit is exceeded, the server returns:```json
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests",
"reset_time": "2024-03-20T10:31:00Z"
}
}


### Example Usage

#### Using curl```bash
# Get current state
curl -X GET \
  http://localhost:3000/api/state \
  -H 'Authorization: ApiKey your_api_key_here'

# Execute action
curl -X POST \
  http://localhost:3000/api/action \
  -H 'Authorization: ApiKey your_api_key_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "action": "turn_on_lights",
    "parameters": {
      "room": "living_room",
      "brightness": 80
    }
  }'

Using JavaScript```javascript

// Execute action
async function executeAction() {
const response = await fetch('http://localhost:3000/api/action', {
method: 'POST',
headers: {
'Authorization': 'ApiKey your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'turn_on_lights',
parameters: {
room: 'living_room',
brightness: 80
}
})
});

const data = await response.json();
console.log('Action result:', data);
}


## Development```bash
# Development mode with hot reload
npm run dev

# Build project
npm run build

# Production mode
npm run start

# Run tests
npx jest --config=jest.config.cjs

# Run tests with coverage
npx jest --coverage

# Lint code
npm run lint

# Format code
npm run format

Troubleshooting

Common Issues

  1. Node.js Version (toSorted is not a function)
    - Solution: Update to Node.js 20.10.0+bash nvm install 20.10.0 nvm use 20.10.0

  2. Connection Issues
    - Verify Home Assistant is running
    - Check HASS_HOST accessibility
    - Validate token permissions
    - Ensure WebSocket connection for real-time updates

  3. Add-on Management Issues
    - Verify Supervisor access
    - Check add-on compatibility
    - Validate system resources

  4. HACS Integration Issues
    - Verify HACS installation
    - Check HACS integration status
    - Validate repository access

  5. Automation Issues
    - Verify entity availability
    - Check trigger conditions
    - Validate service calls
    - Monitor execution logs

Project Status

✅ Complete
- Entity, Floor, and Area access
- Device control (Lights, Climate, Covers, Switches, Contacts)
- Add-on management system
- Package management through HACS
- Advanced automation configuration
- Basic state management
- Error handling and validation
- Docker containerization
- Jest testing setup
- TypeScript integration
- Environment variable management
- Home Assistant API integration
- Project documentation

🚧 In Progress
- WebSocket implementation for real-time updates
- Enhanced security features
- Tool organization optimization
- Performance optimization
- Resource context integration
- API documentation generation
- Multi-platform desktop integration
- Advanced error recovery
- Custom prompt testing
- Enhanced macOS integration
- Type safety improvements
- Testing coverage expansion

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

Resources

  • MCP Documentation
  • Home Assistant Docs
  • HA REST API
  • HACS Documentation
  • TypeScript Documentation

License

MIT License - See LICENSE file

常见问题

7 问
答案由本站依据条目字段整理,不引用上游原文
Homeassistant 怎么安装?

在客户端按下面的安装命令接入:npx jest --config=jest.config.cjs。装完在客户端配置里引用同一个包或端点。

Homeassistant 怎么在客户端里配置?

它的传输方式未标注,在客户端 MCP 配置里按官方文档填写启动命令和参数,保存后重启客户端生效。

Homeassistant 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Homeassistant 需要 API Key 吗?

资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

Homeassistant 能提供哪些能力?

资料显示能力标签包括 实时监控、JavaScript、智能家居、自动化管理。具体工具清单以官方文档为准。

Homeassistant 需要什么运行环境?

运行时为 Node.js;属于本地进程,需要在本机装好运行环境。

Homeassistant 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为SSE · 服务端推送。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-18。