Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47f11b3d95 | ||
|
|
f24be8ff53 | ||
|
|
dfff432321 | ||
|
|
d59bf02d08 | ||
|
|
345a5888d9 | ||
|
|
d6a5771e01 | ||
|
|
5f4ddfbd88 |
64
.github/workflows/deploy-docs.yml
vendored
Normal file
64
.github/workflows/deploy-docs.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: Deploy Documentation to GitHub Pages
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'docs/**'
|
||||||
|
- '.github/workflows/deploy-docs.yml'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
# Allow only one concurrent deployment
|
||||||
|
concurrency:
|
||||||
|
group: "pages"
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Ruby
|
||||||
|
uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: '3.2'
|
||||||
|
bundler-cache: true
|
||||||
|
cache-version: 0
|
||||||
|
|
||||||
|
- name: Setup Pages
|
||||||
|
uses: actions/configure-pages@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
cd docs
|
||||||
|
bundle install
|
||||||
|
|
||||||
|
- name: Build site
|
||||||
|
run: |
|
||||||
|
cd docs
|
||||||
|
bundle exec jekyll build
|
||||||
|
env:
|
||||||
|
JEKYLL_ENV: production
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
with:
|
||||||
|
path: docs/_site
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
||||||
207
README.md
207
README.md
@@ -1,11 +1,141 @@
|
|||||||
# Model Context Protocol (MCP) Server for Home Assistant
|
# 🚀 Model Context Protocol (MCP) Server for Home Assistant
|
||||||
|
|
||||||
The Model Context Protocol (MCP) Server is a robust, secure, and high-performance bridge that integrates Home Assistant with Language Learning Models (LLMs), enabling natural language control and real-time monitoring of your smart home devices. Unlock advanced automation, control, and analytics for your Home Assistant ecosystem.
|
The **Model Context Protocol (MCP) Server** is a robust, secure, and high-performance bridge that integrates Home Assistant with Language Learning Models (LLMs), enabling natural language control and real-time monitoring of your smart home devices. Unlock advanced automation, control, and analytics for your Home Assistant ecosystem.
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
[](https://jango-blockchained.github.io/homeassistant-mcp/)
|
||||||
|

|
||||||
|
|
||||||
|
## 🌟 Key Benefits
|
||||||
|
|
||||||
|
### 🎮 Device Control & Monitoring
|
||||||
|
- **Voice-like Control:** "Dim living room lights to 50%" 🌇
|
||||||
|
- **Real-time Updates:** WebSocket/SSE with <100ms latency ⚡
|
||||||
|
- **Cross-Device Automation:** Create scene-based rules 🎭
|
||||||
|
|
||||||
|
### 🤖 AI-Powered Features
|
||||||
|
- Natural language processing for commands
|
||||||
|
- Predictive automation suggestions
|
||||||
|
- Anomaly detection in device behavior
|
||||||
|
|
||||||
|
## 🏗 Architecture Overview
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph TD
|
||||||
|
A[User Interface] --> B{MCP Server}
|
||||||
|
B --> C[Home Assistant]
|
||||||
|
B --> D[LLM Integration]
|
||||||
|
B --> E[Cache Layer]
|
||||||
|
E --> F[Redis]
|
||||||
|
B --> G[Security Middleware]
|
||||||
|
C --> H[Smart Devices]
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🛠 Installation
|
||||||
|
|
||||||
|
### 🐳 Docker Setup (Recommended)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Clone repo with caching
|
||||||
|
git clone --depth 1 https://github.com/jango-blockchained/homeassistant-mcp.git
|
||||||
|
|
||||||
|
# 2. Configure environment
|
||||||
|
cp .env.example .env # Edit with your HA details 🔧
|
||||||
|
|
||||||
|
# 3. Start with compose
|
||||||
|
docker compose up -d --build # Auto-scaling enabled 📈
|
||||||
|
|
||||||
|
# View real-time logs 📜
|
||||||
|
docker compose logs -f --tail=50
|
||||||
|
```
|
||||||
|
|
||||||
|
### 📦 Bare Metal Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install Bun (if missing)
|
||||||
|
curl -fsSL https://bun.sh/install | bash # 🐇 Fast runtime
|
||||||
|
|
||||||
|
# Install dependencies with cache
|
||||||
|
bun install --frozen-lockfile # ♻️ Reliable dep tree
|
||||||
|
|
||||||
|
# Start in dev mode with hot-reload 🔥
|
||||||
|
bun run dev --watch
|
||||||
|
``` |
|
||||||
|
|
||||||
|
## 💡 Example Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Real-time device monitoring 🌐
|
||||||
|
const ws = new WebSocket('wss://mcp.yourha.com/ws');
|
||||||
|
|
||||||
|
ws.onmessage = ({ data }) => {
|
||||||
|
const update = JSON.parse(data);
|
||||||
|
if(update.entity_id === 'light.kitchen') {
|
||||||
|
smartBulb(update.state); // 🎛️ Update UI
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔄 Update Strategy
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Zero-downtime updates 🕒
|
||||||
|
docker compose pull
|
||||||
|
docker compose up -d --build
|
||||||
|
docker system prune # Clean old images 🧹
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🛡 Security Features
|
||||||
|
|
||||||
|
- JWT authentication with refresh tokens 🔑
|
||||||
|
- Automatic request sanitization 🧼
|
||||||
|
- IP-based rate limiting with fail2ban integration 🚫
|
||||||
|
- End-to-end encryption support 🔒
|
||||||
|
|
||||||
|
## 🌍 Community & Support
|
||||||
|
|
||||||
|
| Platform | Link | Response Time |
|
||||||
|
|----------------|-------------------------------|---------------|
|
||||||
|
| 📚 Docs | [API Reference](docs/api.md) | Instant |
|
||||||
|
| 🐛 GitHub | [Issues](#) | <24hr |
|
||||||
|
|
||||||
|
## 🚧 Troubleshooting Guide
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check service health 🩺
|
||||||
|
docker compose ps
|
||||||
|
|
||||||
|
# Test API endpoints 🔌
|
||||||
|
curl -I http://localhost:3000/healthcheck # Should return 200 ✅
|
||||||
|
|
||||||
|
# Inspect cache status 💾
|
||||||
|
docker exec mcp_redis redis-cli info memory
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔮 Roadmap Highlights
|
||||||
|
|
||||||
|
- [ ] **AI Assistant Integration** (Q4 2024) 🤖
|
||||||
|
- [ ] **Predictive Automation** (Q1 2025) 🔮
|
||||||
|
- [x] **Real-time Analytics** (Shipped! 🚀)
|
||||||
|
- [ ] **Energy Optimization** (Q3 2024) 🌱
|
||||||
|
|
||||||
|
## 🤝 Contributing
|
||||||
|
|
||||||
|
I love community input! Here's how to help:
|
||||||
|
|
||||||
|
1. 🍴 Fork the repository
|
||||||
|
2. 🌿 Create a feature branch
|
||||||
|
3. 💻 Make your changes
|
||||||
|
4. 🧪 Run tests: `bun test --coverage`
|
||||||
|
5. 📦 Commit using [Conventional Commits](https://www.conventionalcommits.org)
|
||||||
|
6. 🔀 Open a Pull Request
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**📢 Note:** This project adheres to [Semantic Versioning](https://semver.org). Always check breaking changes in release notes before upgrading! ⚠️
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
@@ -50,57 +180,6 @@ The MCP Server is built with scalability, resilience, and security in mind:
|
|||||||
|
|
||||||
For a deeper dive into the system architecture, please refer to our [Architecture Documentation](docs/architecture.md).
|
For a deeper dive into the system architecture, please refer to our [Architecture Documentation](docs/architecture.md).
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### Basic Setup
|
|
||||||
|
|
||||||
1. **Install Bun:** If Bun is not installed:
|
|
||||||
```bash
|
|
||||||
curl -fsSL https://bun.sh/install | bash
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Clone the Repository:**
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/jango-blockchained/homeassistant-mcp.git
|
|
||||||
cd homeassistant-mcp
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Install Dependencies:**
|
|
||||||
```bash
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Build the Project:**
|
|
||||||
```bash
|
|
||||||
bun run build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Docker Setup (Recommended)
|
|
||||||
|
|
||||||
1. **Clone the Repository:**
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/jango-blockchained/homeassistant-mcp.git
|
|
||||||
cd homeassistant-mcp
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Configure Environment:**
|
|
||||||
```bash
|
|
||||||
cp .env.example .env
|
|
||||||
```
|
|
||||||
Customize the `.env` file with your Home Assistant configuration.
|
|
||||||
|
|
||||||
3. **Deploy with Docker Compose:**
|
|
||||||
```bash
|
|
||||||
docker compose up -d
|
|
||||||
```
|
|
||||||
- View logs: `docker compose logs -f`
|
|
||||||
- Stop the server: `docker compose down`
|
|
||||||
|
|
||||||
4. **Update the Application:**
|
|
||||||
```bash
|
|
||||||
git pull && docker compose up -d --build
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Once the server is running, open your browser at [http://localhost:3000](http://localhost:3000). For real-time device updates, integrate the SSE endpoint in your application:
|
Once the server is running, open your browser at [http://localhost:3000](http://localhost:3000). For real-time device updates, integrate the SSE endpoint in your application:
|
||||||
@@ -164,15 +243,15 @@ For additional details, check out our [Roadmap](docs/roadmap.md).
|
|||||||
|
|
||||||
## Community & Support
|
## Community & Support
|
||||||
|
|
||||||
Join our community to stay updated, share ideas, and get help:
|
Join the community to stay updated, share ideas, and get help:
|
||||||
|
|
||||||
- **GitHub Issues:** Report bugs or suggest features on our [GitHub Issues Page](https://github.com/jango-blockchained/homeassistant-mcp/issues).
|
- **GitHub Issues:** Report bugs or suggest features on the [GitHub Issues Page](https://github.com/jango-blockchained/homeassistant-mcp/issues).
|
||||||
- **Discussion Forums:** Connect with other users and contributors in our community forums.
|
- **Discussion Forums:** Connect with other users and contributors in the community forums.
|
||||||
- **Chat Platforms:** Join our real-time discussions on [Discord](#) or [Slack](#).
|
- **Chat Platforms:** Join real-time discussions on [Discord](#) or [Slack](#).
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
We welcome your contributions! To get started:
|
I welcome your contributions! To get started:
|
||||||
|
|
||||||
1. Fork the repository.
|
1. Fork the repository.
|
||||||
2. Create your feature branch:
|
2. Create your feature branch:
|
||||||
@@ -209,11 +288,11 @@ A: MCP Server runs on Linux, macOS, and Windows (Docker is recommended for Windo
|
|||||||
|
|
||||||
**Q: How do I report a bug or request a feature?**
|
**Q: How do I report a bug or request a feature?**
|
||||||
|
|
||||||
A: Please use our [GitHub Issues Page](https://github.com/jango-blockchained/homeassistant-mcp/issues) to report bugs or request new features.
|
A: Please use the [GitHub Issues Page](https://github.com/jango-blockchained/homeassistant-mcp/issues) to report bugs or request new features.
|
||||||
|
|
||||||
**Q: Can I contribute to the project?**
|
**Q: Can I contribute to the project?**
|
||||||
|
|
||||||
A: Absolutely! We welcome contributions from the community. See the [Contributing](#contributing) section for more details.
|
A: Absolutely! I welcome contributions from the community. See the [Contributing](#contributing) section for more details.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
@@ -221,10 +300,4 @@ This project is licensed under the MIT License. See [LICENSE](LICENSE) for the f
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Full documentation is available at: https://yourusername.github.io/your-repo-name/
|
Full documentation is available at: [https://jango-blockchained.github.io/homeassistant-mcp/](https://jango-blockchained.github.io/homeassistant-mcp/)
|
||||||
|
|
||||||
## Quick Start
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
12
docs/Gemfile
12
docs/Gemfile
@@ -4,10 +4,20 @@ gem "github-pages", group: :jekyll_plugins
|
|||||||
gem "jekyll-theme-minimal"
|
gem "jekyll-theme-minimal"
|
||||||
gem "jekyll-relative-links"
|
gem "jekyll-relative-links"
|
||||||
gem "jekyll-seo-tag"
|
gem "jekyll-seo-tag"
|
||||||
|
gem "jekyll-remote-theme"
|
||||||
|
gem "jekyll-github-metadata"
|
||||||
|
gem "faraday-retry"
|
||||||
|
|
||||||
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
# and associated library.
|
# and associated library.
|
||||||
platforms :mingw, :x64_mingw, :mswin, :jruby do
|
platforms :mingw, :x64_mingw, :mswin, :jruby do
|
||||||
gem "tzinfo", ">= 1"
|
gem "tzinfo", ">= 1"
|
||||||
gem "tzinfo-data"
|
gem "tzinfo-data"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
|
||||||
|
# do not have a Java counterpart.
|
||||||
|
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
|
||||||
|
|
||||||
|
# Add webrick for Ruby 3.0+
|
||||||
|
gem "webrick", "~> 1.7"
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# Home Assistant MCP Documentation
|
|
||||||
|
|
||||||
Welcome to the documentation for the Home Assistant MCP (Model Context Protocol) Server. Here you'll find comprehensive guides on setup, configuration, usage, and contribution.
|
|
||||||
|
|
||||||
## Quick Navigation
|
|
||||||
|
|
||||||
- [Getting Started Guide](getting-started.md)
|
|
||||||
- [API Documentation](api.md)
|
|
||||||
- [Troubleshooting](troubleshooting.md)
|
|
||||||
- [Contributing Guide](contributing.md)
|
|
||||||
|
|
||||||
## Repository Links
|
|
||||||
|
|
||||||
- [GitHub Repository](https://github.com/jango-blockchained/homeassistant-mcp)
|
|
||||||
- [Issue Tracker](https://github.com/jango-blockchained/homeassistant-mcp/issues)
|
|
||||||
- [GitHub Discussions](https://github.com/jango-blockchained/homeassistant-mcp/discussions)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is licensed under the MIT License. See [LICENSE](../LICENSE) for details.
|
|
||||||
@@ -2,9 +2,24 @@ title: Model Context Protocol (MCP)
|
|||||||
description: A bridge between Home Assistant and Language Learning Models
|
description: A bridge between Home Assistant and Language Learning Models
|
||||||
theme: jekyll-theme-minimal
|
theme: jekyll-theme-minimal
|
||||||
markdown: kramdown
|
markdown: kramdown
|
||||||
|
|
||||||
|
# Repository settings
|
||||||
|
repository: jango-blockchained/advanced-homeassistant-mcp
|
||||||
|
github: [metadata]
|
||||||
|
|
||||||
|
# Add base URL and URL settings
|
||||||
|
baseurl: "/advanced-homeassistant-mcp" # the subpath of your site
|
||||||
|
url: "https://jango-blockchained.github.io" # the base hostname & protocol
|
||||||
|
|
||||||
|
# Theme settings
|
||||||
|
logo: /assets/img/logo.png # path to logo (create this if you want a logo)
|
||||||
|
show_downloads: true # show download buttons for your repo
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- jekyll-relative-links
|
- jekyll-relative-links
|
||||||
- jekyll-seo-tag
|
- jekyll-seo-tag
|
||||||
|
- jekyll-remote-theme
|
||||||
|
- jekyll-github-metadata
|
||||||
|
|
||||||
# Enable relative links
|
# Enable relative links
|
||||||
relative_links:
|
relative_links:
|
||||||
@@ -16,11 +31,48 @@ header_pages:
|
|||||||
- index.md
|
- index.md
|
||||||
- getting-started.md
|
- getting-started.md
|
||||||
- api.md
|
- api.md
|
||||||
|
- usage.md
|
||||||
|
- tools/tools.md
|
||||||
|
- development/development.md
|
||||||
|
- troubleshooting.md
|
||||||
- contributing.md
|
- contributing.md
|
||||||
|
- roadmap.md
|
||||||
|
|
||||||
|
# Collections
|
||||||
|
collections:
|
||||||
|
tools:
|
||||||
|
output: true
|
||||||
|
permalink: /:collection/:name
|
||||||
|
development:
|
||||||
|
output: true
|
||||||
|
permalink: /:collection/:name
|
||||||
|
|
||||||
|
# Default layouts
|
||||||
|
defaults:
|
||||||
|
- scope:
|
||||||
|
path: ""
|
||||||
|
type: "pages"
|
||||||
|
values:
|
||||||
|
layout: "default"
|
||||||
|
- scope:
|
||||||
|
path: "tools"
|
||||||
|
type: "tools"
|
||||||
|
values:
|
||||||
|
layout: "default"
|
||||||
|
- scope:
|
||||||
|
path: "development"
|
||||||
|
type: "development"
|
||||||
|
values:
|
||||||
|
layout: "default"
|
||||||
|
|
||||||
# Exclude files from processing
|
# Exclude files from processing
|
||||||
exclude:
|
exclude:
|
||||||
- Gemfile
|
- Gemfile
|
||||||
- Gemfile.lock
|
- Gemfile.lock
|
||||||
- node_modules
|
- node_modules
|
||||||
- vendor
|
- vendor
|
||||||
|
|
||||||
|
# Sass settings
|
||||||
|
sass:
|
||||||
|
style: compressed
|
||||||
|
sass_dir: _sass
|
||||||
191
docs/api.md
191
docs/api.md
@@ -1,6 +1,191 @@
|
|||||||
# API Documentation
|
# 🚀 Home Assistant MCP API Documentation
|
||||||
|
|
||||||
This section details the available API endpoints for the Home Assistant MCP Server.
|
 
|
||||||
|
|
||||||
|
## 🌟 Quick Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Get API schema with caching
|
||||||
|
curl -X GET http://localhost:3000/mcp \
|
||||||
|
-H "Cache-Control: max-age=3600" # Cache for 1 hour
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔌 Core Functions ⚙️
|
||||||
|
|
||||||
|
### State Management (`/api/state`)
|
||||||
|
```http
|
||||||
|
GET /api/state?cache=true # Enable client-side caching
|
||||||
|
POST /api/state
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example Request:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"context": "living_room",
|
||||||
|
"state": {
|
||||||
|
"lights": "on",
|
||||||
|
"temperature": 22
|
||||||
|
},
|
||||||
|
"_cache": { // Optional caching config
|
||||||
|
"ttl": 300, // 5 minutes
|
||||||
|
"tags": ["lights", "climate"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## ⚡ Action Endpoints
|
||||||
|
|
||||||
|
### Execute Action with Cache Validation
|
||||||
|
```http
|
||||||
|
POST /api/action
|
||||||
|
If-None-Match: "etag_value" // Prevent duplicate actions
|
||||||
|
```
|
||||||
|
|
||||||
|
**Batch Processing:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"actions": [
|
||||||
|
{ "action": "🌞 Morning Routine", "params": { "brightness": 80 } },
|
||||||
|
{ "action": "❄️ AC Control", "params": { "temp": 21 } }
|
||||||
|
],
|
||||||
|
"_parallel": true // Execute actions concurrently
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔍 Query Functions
|
||||||
|
|
||||||
|
### Available Actions with ETag
|
||||||
|
```http
|
||||||
|
GET /api/actions
|
||||||
|
ETag: "a1b2c3d4" // Client-side cache validation
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response Headers:**
|
||||||
|
```
|
||||||
|
Cache-Control: public, max-age=86400 // 24-hour cache
|
||||||
|
ETag: "a1b2c3d4"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🌐 WebSocket Events
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const ws = new WebSocket('wss://ha-mcp/ws');
|
||||||
|
ws.onmessage = ({ data }) => {
|
||||||
|
const event = JSON.parse(data);
|
||||||
|
if(event.type === 'STATE_UPDATE') {
|
||||||
|
updateUI(event.payload); // 🎨 Real-time UI sync
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🗃️ Caching Strategies
|
||||||
|
|
||||||
|
### Client-Side Caching
|
||||||
|
```http
|
||||||
|
GET /api/devices
|
||||||
|
Cache-Control: max-age=300, stale-while-revalidate=60
|
||||||
|
```
|
||||||
|
|
||||||
|
### Server-Side Cache-Control
|
||||||
|
```typescript
|
||||||
|
// Example middleware configuration
|
||||||
|
app.use(
|
||||||
|
cacheMiddleware({
|
||||||
|
ttl: 60 * 5, // 5 minutes
|
||||||
|
paths: ['/api/devices', '/mcp'],
|
||||||
|
vary: ['Authorization'] // User-specific caching
|
||||||
|
})
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
## ❌ Error Handling
|
||||||
|
|
||||||
|
**429 Too Many Requests:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"error": {
|
||||||
|
"code": "RATE_LIMITED",
|
||||||
|
"message": "Slow down! 🐢",
|
||||||
|
"retry_after": 30,
|
||||||
|
"docs": "https://ha-mcp/docs/rate-limits"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🚦 Rate Limiting Tiers
|
||||||
|
|
||||||
|
| Tier | Requests/min | Features |
|
||||||
|
|---------------|--------------|------------------------|
|
||||||
|
| Guest | 10 | Basic read-only |
|
||||||
|
| User | 100 | Full access |
|
||||||
|
| Power User | 500 | Priority queue |
|
||||||
|
| Integration | 1000 | Bulk operations |
|
||||||
|
|
||||||
|
## 🛠️ Example Usage
|
||||||
|
|
||||||
|
### Smart Cache Refresh
|
||||||
|
```javascript
|
||||||
|
async function getDevices() {
|
||||||
|
const response = await fetch('/api/devices', {
|
||||||
|
headers: {
|
||||||
|
'If-None-Match': localStorage.getItem('devicesETag')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(response.status === 304) { // Not Modified
|
||||||
|
return JSON.parse(localStorage.devicesCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
localStorage.setItem('devicesETag', response.headers.get('ETag'));
|
||||||
|
localStorage.setItem('devicesCache', JSON.stringify(data));
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🔒 Security Middleware (Enhanced)
|
||||||
|
|
||||||
|
### Cache-Aware Rate Limiting
|
||||||
|
```typescript
|
||||||
|
app.use(
|
||||||
|
rateLimit({
|
||||||
|
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||||
|
max: 100, // Limit each IP to 100 requests per window
|
||||||
|
cache: new RedisStore(), // Distributed cache
|
||||||
|
keyGenerator: (req) => {
|
||||||
|
return `${req.ip}-${req.headers.authorization}`;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Security Headers
|
||||||
|
```http
|
||||||
|
Content-Security-Policy: default-src 'self';
|
||||||
|
Strict-Transport-Security: max-age=31536000;
|
||||||
|
X-Content-Type-Options: nosniff;
|
||||||
|
Cache-Control: public, max-age=600;
|
||||||
|
ETag: "abc123"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📘 Best Practices
|
||||||
|
|
||||||
|
1. **Cache Wisely:** Use `ETag` and `Cache-Control` headers for state data
|
||||||
|
2. **Batch Operations:** Combine requests using `/api/actions/batch`
|
||||||
|
3. **WebSocket First:** Prefer real-time updates over polling
|
||||||
|
4. **Error Recovery:** Implement exponential backoff with jitter
|
||||||
|
5. **Cache Invalidation:** Use tags for bulk invalidation
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph LR
|
||||||
|
A[Client] -->|Cached Request| B{CDN}
|
||||||
|
B -->|Cache Hit| C[Return 304]
|
||||||
|
B -->|Cache Miss| D[Origin Server]
|
||||||
|
D -->|Response| B
|
||||||
|
B -->|Response| A
|
||||||
|
```
|
||||||
|
|
||||||
|
> Pro Tip: Use `curl -I` to inspect cache headers! 🔍
|
||||||
|
|
||||||
## Device Control
|
## Device Control
|
||||||
|
|
||||||
@@ -85,7 +270,7 @@ This section details the available API endpoints for the Home Assistant MCP Serv
|
|||||||
|
|
||||||
## Automation Management
|
## Automation Management
|
||||||
|
|
||||||
For automation management details and endpoints, please refer to the [Tools Documentation](tools/README.md).
|
For automation management details and endpoints, please refer to the [Tools Documentation](tools/tools.md).
|
||||||
|
|
||||||
## Security Considerations
|
## Security Considerations
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Begin your journey with the Home Assistant MCP Server by following these steps:
|
|||||||
|
|
||||||
- **API Documentation:** Read the [API Documentation](api.md) for available endpoints.
|
- **API Documentation:** Read the [API Documentation](api.md) for available endpoints.
|
||||||
- **Real-Time Updates:** Learn about [Server-Sent Events](sse-api.md) for live communication.
|
- **Real-Time Updates:** Learn about [Server-Sent Events](sse-api.md) for live communication.
|
||||||
- **Tools:** Explore available [Tools](tools/README.md) for device control and automation.
|
- **Tools:** Explore available [Tools](tools/tools.md) for device control and automation.
|
||||||
- **Configuration:** Refer to the [Configuration Guide](configuration.md) for setup and advanced settings.
|
- **Configuration:** Refer to the [Configuration Guide](configuration.md) for setup and advanced settings.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
@@ -19,7 +19,7 @@ If you encounter any issues:
|
|||||||
For contributors:
|
For contributors:
|
||||||
1. Fork the repository.
|
1. Fork the repository.
|
||||||
2. Create a feature branch.
|
2. Create a feature branch.
|
||||||
3. Follow the [Development Guide](development/README.md) for contribution guidelines.
|
3. Follow the [Development Guide](development/development.md) for contribution guidelines.
|
||||||
4. Submit a pull request with your enhancements.
|
4. Submit a pull request with your enhancements.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|||||||
@@ -4,6 +4,29 @@ title: Home
|
|||||||
nav_order: 1
|
nav_order: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# 📚 Home Assistant MCP Documentation
|
||||||
|
|
||||||
|
Welcome to the documentation for the Home Assistant MCP (Model Context Protocol) Server.
|
||||||
|
|
||||||
|
## 📑 Documentation Index
|
||||||
|
|
||||||
|
- [Getting Started Guide](getting-started.md)
|
||||||
|
- [API Documentation](api.md)
|
||||||
|
- [Troubleshooting](troubleshooting.md)
|
||||||
|
- [Contributing Guide](contributing.md)
|
||||||
|
|
||||||
|
For project overview, installation, and general information, please see our [main README](../README.md).
|
||||||
|
|
||||||
|
## 🔗 Quick Links
|
||||||
|
|
||||||
|
- [GitHub Repository](https://github.com/jango-blockchained/homeassistant-mcp)
|
||||||
|
- [Issue Tracker](https://github.com/jango-blockchained/homeassistant-mcp/issues)
|
||||||
|
- [GitHub Discussions](https://github.com/jango-blockchained/homeassistant-mcp/discussions)
|
||||||
|
|
||||||
|
## 📝 License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License. See [LICENSE](../LICENSE) for details.
|
||||||
|
|
||||||
# Model Context Protocol (MCP) Server
|
# Model Context Protocol (MCP) Server
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
@@ -56,7 +79,7 @@ The Model Context Protocol (MCP) Server is a cutting-edge bridge between Home As
|
|||||||
- Security Settings
|
- Security Settings
|
||||||
- Performance Tuning
|
- Performance Tuning
|
||||||
|
|
||||||
6. [Development Guide](development/README.md)
|
6. [Development Guide](development/development.md)
|
||||||
- Project Structure
|
- Project Structure
|
||||||
- Contributing Guidelines
|
- Contributing Guidelines
|
||||||
- Testing
|
- Testing
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ A: Adjust SSE_MAX_CLIENTS in configuration or clean up stale connections.
|
|||||||
1. Documentation
|
1. Documentation
|
||||||
- [API Reference](./API.md)
|
- [API Reference](./API.md)
|
||||||
- [Configuration Guide](./configuration/README.md)
|
- [Configuration Guide](./configuration/README.md)
|
||||||
- [Development Guide](./development/README.md)
|
- [Development Guide](./development/development.md)
|
||||||
|
|
||||||
2. Community
|
2. Community
|
||||||
- GitHub Issues
|
- GitHub Issues
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ This guide explains how to use the Home Assistant MCP Server for smart home devi
|
|||||||
- See [API Documentation](api.md) for details.
|
- See [API Documentation](api.md) for details.
|
||||||
|
|
||||||
2. **Tool Integrations:**
|
2. **Tool Integrations:**
|
||||||
- Multiple tools are available (see [Tools Documentation](tools/README.md)), for tasks like automation management and notifications.
|
- Multiple tools are available (see [Tools Documentation](tools/tools.md)), for tasks like automation management and notifications.
|
||||||
|
|
||||||
3. **Security Settings:**
|
3. **Security Settings:**
|
||||||
- Configure token-based authentication and environment variables as per the [Configuration Guide](getting-started/configuration.md).
|
- Configure token-based authentication and environment variables as per the [Configuration Guide](getting-started/configuration.md).
|
||||||
|
|
||||||
4. **Customization and Extensions:**
|
4. **Customization and Extensions:**
|
||||||
- Extend server functionality by developing new tools as outlined in the [Development Guide](development/README.md).
|
- Extend server functionality by developing new tools as outlined in the [Development Guide](development/development.md).
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user