Compare commits

..

5 Commits

Author SHA1 Message Date
Martin
ae56716a86 [MOD] New installation method since HACS does not support GITEA 2026-02-10 15:23:14 -05:00
Martin
a826ef80ec [MOD] Remove invalid key 2026-02-10 14:53:17 -05:00
Martin
5e934904c8 Merge branch 'main' of https://www.git.quarantinedstudio.com/mvezina/homeassistant-mcp-bridge 2026-02-10 14:01:47 -05:00
Martin
3e9abaff6e [ADD] Code owner 2026-02-10 14:01:32 -05:00
cc1c0cef8d Delete custom_components/mcp_bridge/README.md 2026-02-10 18:59:39 +00:00
8 changed files with 148 additions and 234 deletions

192
README.md
View File

@@ -1,7 +1,5 @@
# 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
@@ -18,29 +16,79 @@ MCP (Model Context Protocol) is Anthropic's protocol for connecting AI agents to
## Installation ## Installation
### Via HACS (Recommended) **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.
1. **Add Custom Repository** ### Method 1: One-Line Install/Update (Easiest)
- 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"
2. **Install** Run this command in your Home Assistant terminal (requires Terminal & SSH addon or SSH access):
- HACS → Integrations
- Click "+ Explore & Download Repositories"
- Search for "MCP Bridge"
- Click "Download"
- Restart Home Assistant
### Manual Installation ```bash
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
```
1. Copy `custom_components/mcp_bridge` to your Home Assistant config directory **Important:**
2. Restart Home Assistant - Replace `your-gitea.local:3000` with your Gitea server address
- Replace `username` with your Gitea username
- Replace `main` with your branch name if different
See [INSTALLATION_GUIDE.md](INSTALLATION_GUIDE.md) for detailed instructions. After installation completes, restart Home Assistant.
### 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
@@ -108,8 +156,7 @@ 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}}
} }
} }
} }
@@ -125,6 +172,17 @@ 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
``` ```
@@ -160,24 +218,46 @@ 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
## Documentation ## Troubleshooting
- [Installation Guide](INSTALLATION_GUIDE.md) - Detailed setup instructions ### Installation Script Fails
- [Integration README](custom_components/mcp_bridge/README.md) - Technical details
- [Gitea Setup Guide](GITEA_SETUP_GUIDE.md) - For hosting on your own Gitea **Check:**
- 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
### Running Tests ### Repository Structure
```bash
pytest custom_components/mcp_bridge/test_init.py
```
### Project Structure
``` ```
homeassistant-mcp-bridge/ homeassistant-mcp-bridge/
@@ -186,31 +266,46 @@ 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
│ └── README.md # Integration docs │ └── test_init.py # Unit tests
├── hacs.json # HACS configuration ├── quick_install.sh # One-line installer
├── info.md # HACS UI description ├── install_mcp_bridge.sh # Detailed installer
├── ha_shell_command.yaml # HA shell command config
└── README.md # This file └── README.md # This file
``` ```
## Contributing ### Running Tests
This is a personal project for homelab use, but suggestions and improvements are welcome! ```bash
pytest custom_components/mcp_bridge/test_init.py
```
1. Fork the repository ## Versioning
2. Create a feature branch
3. Make your changes Check your installed version:
4. Test thoroughly ```yaml
5. Submit a pull request service: mcp_bridge.get_entity_metadata
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
@@ -218,13 +313,14 @@ MIT License - Use freely in your homelab!
## Support ## Support
- **Issues**: [Gitea Issues](http://your-gitea-server/username/homeassistant-mcp-bridge/issues) - **Issues**: Report on your Gitea instance
- **Logs**: Settings → System → Logs (filter by "mcp_bridge") - **Logs**: Settings → System → Logs (filter by "mcp_bridge")
- **Questions**: Check the detailed guides in the repository
## Acknowledgments ## Related Projects
- Built for use with [Anthropic's MCP](https://modelcontextprotocol.io/) - **MCP Server**: Coming next - connects to this integration
- Designed to work with n8n workflows - **n8n Integration**: Workflow automation with AI agents
--- ---

View File

@@ -1,143 +0,0 @@
# MCP Bridge - Home Assistant Custom Integration
This integration provides services to expose filtered entities and custom scripts to MCP (Model Context Protocol) servers, enabling AI agents to control your Home Assistant instance.
## Installation
### Via HACS (Recommended)
1. **Install HACS** (if not already installed): https://hacs.xyz/docs/setup/download
2. **Add this repository as a custom repository:**
- Open HACS in Home Assistant
- Click the three dots in the top right
- Select "Custom repositories"
- Add your Gitea URL: `http://your-gitea-server/username/homeassistant-mcp-bridge`
- Category: Integration
- Click "Add"
3. **Install the integration:**
- Go to HACS → Integrations
- Click "+ Explore & Download Repositories"
- Search for "MCP Bridge"
- Click "Download"
- Restart Home Assistant
### Manual Installation
1. Copy the `mcp_bridge` folder to your Home Assistant `custom_components` directory:
```
/config/custom_components/mcp_bridge/
```
2. Restart Home Assistant
3. The integration will be automatically loaded (no configuration needed)
## Services
### `mcp_bridge.get_exposed_entities`
Returns all entities that are exposed to voice assistants.
**Returns:**
```json
{
"entities": [...],
"count": 42
}
```
### `mcp_bridge.get_exposed_scripts`
Returns all custom scripts marked with the `mcp_accessible` label.
**Returns:**
```json
{
"scripts": [...],
"count": 1
}
```
### `mcp_bridge.get_entity_metadata`
Get detailed metadata for a specific entity.
**Parameters:**
- `entity_id` (required): The entity to query
**Returns:**
```json
{
"entity_id": "light.living_room",
"state": "on",
...
}
```
## Usage
### Exposing Entities to AI Agent
1. Go to Settings → Voice Assistants → Expose
2. Toggle entities you want the AI agent to control
3. These entities will be returned by `mcp_bridge.get_exposed_entities`
### Exposing Scripts to AI Agent
1. Create your custom script in HA
2. Add the label `mcp_accessible` to the script:
- Go to Settings → Automations & Scenes → Scripts
- Click on your script
- Click the settings icon (top right)
- Under "Labels", add `mcp_accessible`
3. The script will now be returned by `mcp_bridge.get_exposed_scripts`
## Example: Marking a Script as MCP-Accessible
```yaml
# In your scripts.yaml or via UI
set_master_bedroom_fan_speed:
alias: "Set Master Bedroom Fan Speed"
description: "[MCP] Set the speed of the master bedroom fan."
# Add label via UI: Settings → Scripts → (your script) → Labels → mcp_accessible
fields:
fan_state:
name: Fan speed
description: "0=off, 1=low, 2=medium, 3=high"
required: true
selector:
number:
min: 0
max: 3
step: 1
sequence:
# Your script actions here
```
## Testing
You can test the services in Home Assistant's Developer Tools → Services:
1. Select `mcp_bridge.get_exposed_entities`
2. Click "Call Service"
3. View the response in the "Response" tab
## Troubleshooting
**No entities returned:**
- Make sure you've exposed entities via Settings → Voice Assistants → Expose
**No scripts returned:**
- Ensure your scripts have the `mcp_accessible` label
- Check Home Assistant logs for errors: Settings → System → Logs
**Integration not loading:**
- Check the logs for errors
- Ensure the folder structure is correct
- Restart Home Assistant
## Version
0.1.0 - Initial release

View File

@@ -4,7 +4,9 @@
"documentation": "https://www.git.quarantinedstudio.com/mvezina/homeassistant-mcp-bridge", "documentation": "https://www.git.quarantinedstudio.com/mvezina/homeassistant-mcp-bridge",
"issue_tracker": "https://www.git.quarantinedstudio.com/mvezina/homeassistant-mcp-bridge/issues", "issue_tracker": "https://www.git.quarantinedstudio.com/mvezina/homeassistant-mcp-bridge/issues",
"requirements": [], "requirements": [],
"codeowners": [], "codeowners": [
"@mvezina"
],
"version": "0.1.0", "version": "0.1.0",
"iot_class": "local_polling", "iot_class": "local_polling",
"config_flow": false "config_flow": false

0
ha_shell_command.yaml Normal file
View File

View File

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

35
info.md
View File

@@ -1,35 +0,0 @@
# 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.

0
install_mcp_bridge.sh Normal file
View File

0
quick_install.sh Normal file
View File