HomeAssistant MCP
MCP Server for Home Assistant ๐ ๐ค
Overview ๐
MCP (Model Context Protocol) Server is my lightweight integration tool for Home Assistant, providing a flexible interface for device management and automation. It's designed to be fast, secure, and easy to use. Built with Bun for maximum performance.
Why Bun? ๐
I chose Bun as the runtime for several key benefits:
- โก Blazing Fast Performance
- Up to 4x faster than Node.js
- Built-in TypeScript support
- Optimized file system operations
- ๐ฏ All-in-One Solution
- Package manager (faster than npm/yarn)
- Bundler (no webpack needed)
- Test runner (built-in testing)
- TypeScript transpiler
- ๐ Built-in Features
- SQLite3 driver
- .env file loading
- WebSocket client/server
- File watcher
- Test runner
- ๐พ Resource Efficient
- Lower memory usage
- Faster cold starts
- Better CPU utilization
- ๐ Node.js Compatibility
- Runs most npm packages
- Compatible with Express/Fastify
- Native Node.js APIs
Core Features โจ
- ๐ Basic device control via REST API
- ๐ก WebSocket/Server-Sent Events (SSE) for state updates
- ๐ค Simple automation rule management
- ๐ JWT-based authentication
- ๐ค Optional speech features:
- ๐ฃ๏ธ Wake word detection ("hey jarvis", "ok google", "alexa")
- ๐ฏ Speech-to-text using fast-whisper
- ๐ Multiple language support
- ๐ GPU acceleration support
System Architecture ๐
Prerequisites ๐
- ๐ Bun runtime (v1.0.26+)
- ๐ก Home Assistant instance
- ๐ณ Docker (optional, recommended for deployment)
- ๐ฅ๏ธ Node.js 18+ (optional, for speech features)
- ๐ฎ NVIDIA GPU with CUDA support (optional, for faster speech processing)
Quick Start ๐
- Clone my repository:
- Set up the environment:
- Configure your settings:
- Edit
.env
file with your Home Assistant details - Required: Add your
HASS_TOKEN
(long-lived access token)
- Build and launch with Docker:
Docker Build Options ๐ณ
My Docker build script (docker-build.sh
) supports different configurations:
1. Standard Build
- Basic MCP server functionality
- REST API and WebSocket support
- No speech features
2. Speech-Enabled Build
- Includes wake word detection
- Speech-to-text capabilities
- Pulls required images:
onerahmet/openai-whisper-asr-webservice
rhasspy/wyoming-openwakeword
3. GPU-Accelerated Build
- All speech features
- CUDA GPU acceleration
- Optimized for faster processing
- Float16 compute type for better performance
Build Features
- ๐ Automatic resource allocation
- ๐พ Memory-aware building
- ๐ CPU quota management
- ๐งน Automatic cleanup
- ๐ Detailed build logs
- ๐ Build summary and status
Environment Configuration ๐ง
I've implemented a hierarchical configuration system:
File Structure ๐
.env.example
- My template with all options.env
- Your configuration (copy from .env.example)- Environment overrides:
.env.dev
- Development settings.env.prod
- Production settings.env.test
- Test settings
Loading Priority โก
Files load in this order:
.env
(base config)- Environment-specific file:
NODE_ENV=development
โ.env.dev
NODE_ENV=production
โ.env.prod
NODE_ENV=test
โ.env.test
Later files override earlier ones.
Speech Features Setup ๐ค
Prerequisites
- ๐ณ Docker installed and running
- ๐ฎ NVIDIA GPU with CUDA (optional)
- ๐พ 4GB+ RAM (8GB+ recommended)
Configuration
- Enable speech in
.env
:
- Choose your STT engine:
Available Models ๐ค
Choose based on your needs:
tiny.en
: Fastest, basic accuracybase.en
: Good balance (recommended)small.en
: Better accuracy, slowermedium.en
: High accuracy, resource intensivelarge-v2
: Best accuracy, very resource intensive
Development ๐ป
Performance Comparison ๐
Operation | Bun | Node.js |
---|---|---|
Install Dependencies | ~2s | ~15s |
Cold Start | 300ms | 1000ms |
Build Time | 150ms | 4000ms |
Memory Usage | ~150MB | ~400MB |
Documentation ๐
Core Documentation
Advanced Features
- Natural Language Processing - AI-powered automation analysis and control
- Custom Prompts Guide - Create and customize AI behavior
- Extras & Tools - Additional utilities and advanced features
Extra Tools ๐ ๏ธ
I've included several powerful tools in the extra/
directory to enhance your Home Assistant experience:
- Home Assistant Analyzer CLI (
ha-analyzer-cli.ts
)- Deep automation analysis using AI models
- Security vulnerability scanning
- Performance optimization suggestions
- System health metrics
- Speech-to-Text Example (
speech-to-text-example.ts
)- Wake word detection
- Speech-to-text transcription
- Multiple language support
- GPU acceleration support
- Claude Desktop Setup (
claude-desktop-macos-setup.sh
)- Automated Claude Desktop installation for macOS
- Environment configuration
- MCP integration setup
See Extras Documentation for detailed usage instructions and examples.
Client Integration ๐
Cursor Integration ๐ฑ๏ธ
Add to .cursor/config/config.json
:
Claude Desktop ๐ฌ
Add to your Claude config:
Command Line ๐ป
Windows users can use the provided script:
- Go to
scripts
directory - Run
start_mcp.cmd
License ๐
MIT License. See LICENSE for details.
Author ๐จโ๐ป
Created by jango-blockchained
This server cannot be installed
Smart Device Control ๐ฎ ๐ก Lights: Brightness, color, RGB ๐ก๏ธ Climate: Temperature, HVAC, humidity ๐ช Covers: Position and tilt ๐ Switches: On/off ๐จ Sensors: State monitoring
Intelligent Organization ๐ Grouping with context awareness.
Robust Architecture ๐ ๏ธ Error handling, state validation ...