A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to an openHAB smart home system.
This project implements an MCP server that connects to an openHAB instance via its REST API, enabling AI assistants to interact with and manage your smart home system using natural language.
- List, view, create, and delete items
- Batch update labels, categories, metadata and group memberships (
update_items) - Get and update item states, send commands
- Manage item metadata and tags
- Handle item persistence data
- Support for group items and members
- List all things with pagination
- View detailed information about specific things
- Full structural context of a thing including linked items and semantic position (
get_thing_context) - Migrate all channel links when replacing hardware (
replace_thing) - Manage thing channels and links
- Handle inbox items (approve, ignore, delete)
- In-memory inventory with rich cross-item filtering (
query_inventory) - Impact analysis for a single item across rules, sitemaps and groups (
diagnose_item) - Safe atomic item rename with reference updates (
rename_item) - High-level home overview: item counts, thing status, offline devices (
get_home_overview) - Adjust openHAB logger levels at runtime (
manage_logs)
- Statistical analysis of the semantic item model (
analyze_model_health)- TF-IDF group anomaly detection
- Equipment completeness checks
- Majority-vote type/name/label consistency
- Leave-one-out outlier scoring
- Full CRUD operations for rules
- Update rule script actions
- Run rules on demand
- Enable/disable rules
- Script management (specialized rules with no triggers)
- Manage semantic tags and categories
- Assign semantic and non-semantic tags to items
- Hierarchical tag structure support
- Python 3.9+
- Docker (for containerized deployment)
- OpenHAB 3.4+ instance
The easiest way to get started is using the pre-built image from GHCR:
-
Download the compose file and example environment:
curl -O https://raw.githubusercontent.com/DrRSatzteil/openhab-mcp/main/docker/docker-compose.prod.yml curl -O https://raw.githubusercontent.com/DrRSatzteil/openhab-mcp/main/docker/.env.example mv .env.example .env # Edit .env with your settings -
Start the service:
docker compose -f docker-compose.prod.yml up -d
- Python 3.9+
- pip
- virtualenv (recommended)
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt pip install -e . -
Configure environment variables (see Configuration section below)
-
Run the server:
python -m openhab_mcp.openhab_mcp_server
The server can be configured using environment variables or a .env file in the docker directory.
OPENHAB_URL: URL of your openHAB instance (e.g.,http://openhab:8080)
OPENHAB_API_TOKEN: API token for authentication (recommended)OPENHAB_USERNAMEandOPENHAB_PASSWORD: Basic auth credentials
MCP_HOST: Host to bind the server to (default:0.0.0.0)MCP_PORT: Port to run the server on (default:8000)LOG_LEVEL: Logging level (default:INFO)OPENHAB_MCP_TRANSPORT: Transport mode (stdio,streamable-http, orsse) (default:stdio)
The OpenHAB MCP Server can be used with various AI assistants that support the MCP protocol, including Claude and Cline.
- For Claude: Claude Desktop app or compatible client
- For Cline: Cline VSCode extension
- Update the
docker-compose.ymlwith your configuration - Start the service:
docker-compose -f docker/docker-compose.yml up -d
For manual configuration with Claude Desktop, create a configuration file at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Example configuration:
{
"mcp_servers": [
{
"name": "openhab-mcp",
"command": "docker",
"args": [
"run",
"--rm",
"-p", "8000:8000",
"-e", "OPENHAB_URL=http://openhab:8080",
"-e", "OPENHAB_API_TOKEN=your-api-token",
"-e", "MCP_HOST=0.0.0.0",
"-e", "MCP_PORT=8000",
"-e", "LOG_LEVEL=INFO",
"openhab-mcp"
]
}
]
}- Build and run the Docker container as described in the "Running the MCP with Docker" section.
- Create a configuration file for Cline:
Save the following as mcp.json in your Cline configuration directory:
- macOS/Linux:
~/.cursor/mcp.json - Windows:
%USERPROFILE%\.cursor\mcp.json
{
"mcp_servers": [
{
"name": "openhab-mcp",
"command": "docker",
"args": [
"run",
"-d",
"-p",
"8081:8080",
"-e",
"OPENHAB_URL=http://your-openhab-host:8080",
"-e",
"OPENHAB_API_TOKEN=your-api-token",
"--name",
"openhab-mcp",
"openhab-mcp"
]
}
]
}- After creating the configuration file, restart Claude Desktop or VSCode
- Open a new conversation with Claude or Cline
- You should now be able to interact with your OpenHAB instance through the AI assistant
Example prompt to test the connection:
Can you list all the items in my OpenHAB system?
If configured correctly, Claude/Cline will use the MCP server to fetch and display your OpenHAB items.
The MCP server provides a comprehensive set of tools for managing your openHAB system. Here's a categorized list of available tools:
list_items- List items with pagination and filteringget_item- Get detailed information about a specific itemcreate_item- Create a new itemupdate_items- Batch update labels, categories, metadata and group membershipsdelete_item- Remove an itemget_item_state- Get current state of an itemupdate_item_state- Write state directly (virtual items, sensor injection)send_command- Send a command via the event bus (actuators, triggers rules)get_item_persistence- Retrieve historical state data
get_item_metadata_namespaces- List metadata namespacesget_item_metadata- Get metadata for an itemadd_or_update_item_metadata- Manage item metadataremove_item_metadata- Remove metadatalist_semantic_tags- Browse semantic tagsget_semantic_tag- Get tag detailscreate_semantic_tag- Create new semantic tagsdelete_semantic_tag- Remove semantic tagsadd_item_semantic_tag- Tag items semanticallyremove_item_semantic_tag- Remove semantic tagsadd_item_non_semantic_tag- Add regular tagsremove_item_non_semantic_tag- Remove regular tags
list_things- Browse things with paginationget_thing- Get thing detailscreate_thing- Add new thingsupdate_thing- Modify existing thingsdelete_thing- Remove thingsget_thing_channels- List thing channelsget_thing_context- Full structural context: channels, linked items, semantic positionreplace_thing- Migrate all channel links to a new thing (hardware replacement)list_links- View item-thing linksget_link- Get link detailscreate_or_update_link- Manage linksdelete_link- Remove links
list_rules- Browse rulesget_rule- Get rule detailscreate_rule- Create new rulesupdate_rule- Modify rulesdelete_rule- Remove rulesupdate_rule_script_action- Update rule scriptsrun_rule_now- Execute rules immediatelyset_rule_enabled- Toggle rule statelist_scripts- List available scriptsget_script- Get script detailscreate_script- Create new scriptsupdate_script- Modify scriptsdelete_script- Remove scripts
list_inbox_things- View discovered devicesapprove_inbox_thing- Approve new devicesignore_inbox_thing- Ignore devicesunignore_inbox_thing- Reconsider ignored devicesdelete_inbox_thing- Remove from inbox
refresh_inventory- Build in-memory item index (required before query/diagnose/health)query_inventory- Rich cross-item filtering by type, location, tag, semantic presence, and morediagnose_item- Impact analysis: rules, sitemaps, groups and links for a single itemrename_item- Atomic rename with reference updates across rules, UI pages and groupsget_home_overview- High-level home snapshot: counts, thing status, offline devicesmanage_logs- View and adjust openHAB logger levelsanalyze_model_health- Statistical model health analysis (anomalies, completeness, outliers)
The OpenHAB MCP server can be securely exposed via Teleport without requiring a VPN or direct network access from your AI assistant client. Teleport supports registering it as a native MCP application (via the mcp+http:// URI scheme), which gives you a full audit trail of individual MCP tool calls — not just raw HTTP requests.
Claude Code / AI Client
→ tbot application-tunnel (local port)
→ Teleport Proxy
→ Teleport App Service
→ openhab-mcp container (HTTP mode)
Important: Teleport's
application-tunnelonly works with HTTP apps. The container must run instreamable-httpmode, notstdio. This is not a limitation — registering the app with themcp+http://scheme (see below) makes it a real Teleport MCP app with full tool-call auditing, so there is no reason to reach for stdio.
Run the container with HTTP transport enabled:
services:
openhab-mcp:
image: ghcr.io/drrsatzteil/openhab-mcp:latest
restart: unless-stopped
ports:
- "127.0.0.1:8082:8000"
environment:
- OPENHAB_URL=https://your-openhab-instance
- OPENHAB_API_TOKEN=your-api-token
- OPENHAB_MCP_TRANSPORT=streamable-httpThe MCP endpoint will be available at http://localhost:8082/mcp.
Register the container as a native Teleport MCP application using the mcp+http:// URI scheme — not as a generic HTTP app and not as a stdio MCP app. This makes Teleport parse the underlying MCP traffic and log individual tool calls in the audit log, instead of just opaque HTTP requests:
app_service:
enabled: true
apps:
- name: openhab-mcp
labels:
role: mcp
uri: "mcp+http://localhost:8082"On the machine running your AI assistant, configure tbot to create a local tunnel in /etc/tbot.yaml:
services:
- type: application-tunnel
name: openhab-mcp-tunnel
listen: tcp://127.0.0.1:8989
app_name: openhab-mcptbot maintains the tunnel and automatically renews credentials, making the MCP server available locally at http://127.0.0.1:8989.
In ~/.claude.json, configure the MCP server as an HTTP endpoint:
{
"mcpServers": {
"openhab-mcp": {
"type": "http",
"url": "http://127.0.0.1:8989/mcp"
}
}
}Teleport's tbot application-tunnel requires an HTTP app, and the alternative tsh mcp connect uses stdio transport but requires certificate reissuance, which bot credentials disallow (disallow-reissue=true). Running the container in streamable-http mode and registering it as a native mcp+http:// app avoids both limitations — and comes with the added benefit of a full MCP tool-call audit trail, which a plain stdio setup wouldn't give you either.
# Install test dependencies
pip install -r tests/requirements.txt
# Run tests
pytest tests/docker build -t openhab-mcp . # Run in docker folderMIT
Contributions are welcome! Please feel free to submit a Pull Request.