Compare commits

..

No commits in common. "ae56716a86e9352e7f8046d2c79614ffd6379882" and "5e934904c8eb98ef97544fb6d372614d715761d7" have entirely different histories.

6 changed files with 90 additions and 145 deletions

194
README.md
View File

@ -1,5 +1,7 @@
# MCP Bridge - Home Assistant Integration # MCP Bridge - Home Assistant Integration
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-orange.svg)](https://github.com/custom-components/hacs)
Bridge integration between Home Assistant and MCP (Model Context Protocol) servers, enabling AI agents to control your smart home. Bridge integration between Home Assistant and MCP (Model Context Protocol) servers, enabling AI agents to control your smart home.
## Features ## Features
@ -16,79 +18,29 @@ MCP (Model Context Protocol) is Anthropic's protocol for connecting AI agents to
## Installation ## Installation
**Note:** This integration is hosted on Gitea (not GitHub), so it's not available via HACS. Instead, use one of the automated installation methods below. ### Via HACS (Recommended)
### Method 1: One-Line Install/Update (Easiest) 1. **Add Custom Repository**
- Open HACS in Home Assistant
- Click the three dots (⋮) in top right
- Select "Custom repositories"
- Repository: `http://your-gitea-server/username/homeassistant-mcp-bridge`
- Category: **Integration**
- Click "Add"
Run this command in your Home Assistant terminal (requires Terminal & SSH addon or SSH access): 2. **Install**
- HACS → Integrations
- Click "+ Explore & Download Repositories"
- Search for "MCP Bridge"
- Click "Download"
- Restart Home Assistant
```bash ### Manual Installation
curl -sSL http://your-gitea.local:3000/username/homeassistant-mcp-bridge/raw/branch/main/quick_install.sh | \
GITEA_URL=http://your-gitea.local:3000 \
REPO=username/homeassistant-mcp-bridge \
bash
```
**Important:** 1. Copy `custom_components/mcp_bridge` to your Home Assistant config directory
- Replace `your-gitea.local:3000` with your Gitea server address 2. Restart Home Assistant
- Replace `username` with your Gitea username
- Replace `main` with your branch name if different
After installation completes, restart Home Assistant. See [INSTALLATION_GUIDE.md](INSTALLATION_GUIDE.md) for detailed instructions.
### Method 2: Home Assistant Auto-Update Button
Add this to your `configuration.yaml` to create an update button/service:
```yaml
shell_command:
update_mcp_bridge: >
curl -fsSL http://your-gitea.local:3000/username/homeassistant-mcp-bridge/raw/branch/main/quick_install.sh |
GITEA_URL=http://your-gitea.local:3000
REPO=username/homeassistant-mcp-bridge
bash
script:
update_mcp_bridge:
alias: "Update MCP Bridge Integration"
sequence:
- service: shell_command.update_mcp_bridge
- delay:
seconds: 5
- service: persistent_notification.create
data:
title: "MCP Bridge Updated"
message: "Integration updated from Gitea. Please restart Home Assistant."
```
**Usage:**
- Go to Developer Tools → Services
- Select `script.update_mcp_bridge`
- Click "Call Service"
- Restart Home Assistant after update
**Optional Dashboard Button:**
```yaml
type: button
name: Update MCP Bridge
icon: mdi:download
tap_action:
action: call-service
service: script.update_mcp_bridge
```
### Method 3: Manual Installation
1. Download these files from your Gitea repository:
- `custom_components/mcp_bridge/__init__.py`
- `custom_components/mcp_bridge/manifest.json`
- `custom_components/mcp_bridge/services.yaml`
2. Copy to `/config/custom_components/mcp_bridge/`
3. Restart Home Assistant
See [INSTALLATION_GUIDE.md](INSTALLATION_GUIDE.md) for detailed manual steps.
## Quick Start ## Quick Start
@ -156,7 +108,8 @@ Returns scripts marked with `mcp_accessible` label, including their parameters.
"speed": { "speed": {
"name": "Speed", "name": "Speed",
"description": "0=off, 1=low, 2=medium, 3=high", "description": "0=off, 1=low, 2=medium, 3=high",
"required": true "required": true,
"selector": {"number": {"min": 0, "max": 3}}
} }
} }
} }
@ -172,17 +125,6 @@ Get detailed metadata for a specific entity.
**Parameters:** **Parameters:**
- `entity_id`: The entity to query - `entity_id`: The entity to query
## Updating the Integration
**Using Auto-Update Script/Button:**
- Just run the install command again or call the `script.update_mcp_bridge` service
- Restart Home Assistant after update
**Manual Update:**
- Download the latest files from Gitea
- Replace files in `/config/custom_components/mcp_bridge/`
- Restart Home Assistant
## Architecture ## Architecture
``` ```
@ -218,46 +160,24 @@ No configuration required! The integration automatically loads on Home Assistant
## Compatibility ## Compatibility
- **Home Assistant**: 2024.1.0 or newer - **Home Assistant**: 2024.1.0 or newer
- **HACS**: Any version
- **Python**: 3.11+ - **Python**: 3.11+
- **Installation**: Requires SSH/Terminal access or manual file management
## Troubleshooting ## Documentation
### Installation Script Fails - [Installation Guide](INSTALLATION_GUIDE.md) - Detailed setup instructions
- [Integration README](custom_components/mcp_bridge/README.md) - Technical details
**Check:** - [Gitea Setup Guide](GITEA_SETUP_GUIDE.md) - For hosting on your own Gitea
- Home Assistant can reach your Gitea server
- Terminal addon has network access
- URLs are correct (server address, username, repo name)
**Test connectivity:**
```bash
curl http://your-gitea.local:3000/username/homeassistant-mcp-bridge
```
### Integration Not Loading
**Check logs:**
- Settings → System → Logs
- Filter by "mcp_bridge"
**Common issues:**
- Files not in correct location (`/config/custom_components/mcp_bridge/`)
- Python syntax errors (check logs)
- Didn't restart Home Assistant after installation
### Services Not Showing
**Verify installation:**
```bash
ls -la /config/custom_components/mcp_bridge/
```
Should show: `__init__.py`, `manifest.json`, `services.yaml`
## Development ## Development
### Repository Structure ### Running Tests
```bash
pytest custom_components/mcp_bridge/test_init.py
```
### Project Structure
``` ```
homeassistant-mcp-bridge/ homeassistant-mcp-bridge/
@ -266,46 +186,31 @@ homeassistant-mcp-bridge/
│ ├── __init__.py # Core integration logic │ ├── __init__.py # Core integration logic
│ ├── manifest.json # Integration metadata │ ├── manifest.json # Integration metadata
│ ├── services.yaml # Service definitions │ ├── services.yaml # Service definitions
│ └── test_init.py # Unit tests │ └── README.md # Integration docs
├── quick_install.sh # One-line installer ├── hacs.json # HACS configuration
├── install_mcp_bridge.sh # Detailed installer ├── info.md # HACS UI description
├── ha_shell_command.yaml # HA shell command config └── README.md # This file
└── README.md # This file
``` ```
### Running Tests ## Contributing
```bash This is a personal project for homelab use, but suggestions and improvements are welcome!
pytest custom_components/mcp_bridge/test_init.py
```
## Versioning 1. Fork the repository
2. Create a feature branch
Check your installed version: 3. Make your changes
```yaml 4. Test thoroughly
service: mcp_bridge.get_entity_metadata 5. Submit a pull request
data:
entity_id: sensor.any_sensor # Any entity
```
The response will show the integration version in logs.
Or check `manifest.json`:
```bash
cat /config/custom_components/mcp_bridge/manifest.json | grep version
```
## Roadmap ## Roadmap
- [x] Basic entity exposure - [x] Basic entity exposure
- [x] Script discovery with labels - [x] Script discovery with labels
- [x] Complete metadata support - [x] Complete metadata support
- [x] Automated install/update script
- [ ] Real-time state updates via WebSocket - [ ] Real-time state updates via WebSocket
- [ ] Custom entity tags beyond voice assistant exposure - [ ] Custom entity tags beyond voice assistant exposure
- [ ] Integration config flow (UI-based setup) - [ ] Integration config flow (UI-based setup)
- [ ] Service call history/logging - [ ] Service call history/logging
- [ ] Version checking and update notifications
## License ## License
@ -313,14 +218,13 @@ MIT License - Use freely in your homelab!
## Support ## Support
- **Issues**: Report on your Gitea instance - **Issues**: [Gitea Issues](http://your-gitea-server/username/homeassistant-mcp-bridge/issues)
- **Logs**: Settings → System → Logs (filter by "mcp_bridge") - **Logs**: Settings → System → Logs (filter by "mcp_bridge")
- **Questions**: Check the detailed guides in the repository
## Related Projects ## Acknowledgments
- **MCP Server**: Coming next - connects to this integration - Built for use with [Anthropic's MCP](https://modelcontextprotocol.io/)
- **n8n Integration**: Workflow automation with AI agents - Designed to work with n8n workflows
--- ---

View File

6
hacs.json Normal file
View File

@ -0,0 +1,6 @@
{
"name": "MCP Bridge",
"content_in_root": false,
"render_readme": true,
"homeassistant": "2024.1.0"
}

35
info.md Normal file
View File

@ -0,0 +1,35 @@
# MCP Bridge
Bridge integration between Home Assistant and MCP (Model Context Protocol) servers for AI agent control.
## Features
- ✅ Expose entities to AI agents via voice assistant settings
- ✅ Control which scripts are accessible using labels
- ✅ Complete entity metadata including area, device class, and attributes
- ✅ Secure: Only exposes what you explicitly mark
## Services
- `mcp_bridge.get_exposed_entities` - Get all exposed entities
- `mcp_bridge.get_exposed_scripts` - Get MCP-accessible scripts
- `mcp_bridge.get_entity_metadata` - Get detailed entity info
## Configuration
No configuration needed! The integration auto-loads after installation.
### Exposing Entities
Go to: **Settings → Voice Assistants → Expose**
Toggle the entities you want the AI agent to control.
### Exposing Scripts
1. Create or edit a script
2. Click the settings icon ⚙️
3. Add the label: `mcp_accessible`
4. Save
That's it! The script is now accessible to AI agents.

View File

View File