OpenHAB
STDIO连接AI助手与openHAB智能家居系统的MCP服务器
连接AI助手与openHAB智能家居系统的MCP服务器
A MCP (Model Context Protocol) server that interacts with a real openHAB instance.
This project provides an implementation of an MCP server that connects to a real openHAB instance via its REST API. It enables AI assistants like Claude and Cline to interact with your openHAB smart home system.
The server provides comprehensive access to openHAB's core components:
When connected to Claude or Cline in VSCode, you can use natural language to control and manage your openHAB system, making home automation more accessible and intuitive.
The official image is published to the GitHub Container Registry (ghcr.io/tdeckers/openhab-mcp). Pulling this image is the fastest way to get the MCP server running.
(Optional for private registries) Authenticate with GHCR:
podman login ghcr.io # or: docker login ghcr.io
Run the container with Podman (add -e OPENHAB_USERNAME=... and -e OPENHAB_PASSWORD=... if your OpenHAB instance requires basic authentication):
podman run -d --rm -p 8081:8080 \ -e OPENHAB_URL=http://your-openhab-host:8080 \ -e OPENHAB_API_TOKEN=your-api-token \ --name openhab-mcp \ ghcr.io/tdeckers/openhab-mcp:latest
 Using Docker instead?
 ```bash
 docker run -d --rm -p 8081:8080 \
   -e OPENHAB_URL=http://your-openhab-host:8080 \
   -e OPENHAB_API_TOKEN=your-api-token \
   --name openhab-mcp \
   ghcr.io/tdeckers/openhab-mcp:latest
Stop the container when you are done:
podman stop openhab-mcp # or: docker stop openhab-mcp
The container exposes port 8080 internally, but the examples map it to port 8081 on the host to avoid conflicts with an existing OpenHAB installation.
If you need to modify the code, build and tag the image locally instead:
Build the image:
make docker-build # or directly: podman build -t openhab-mcp .
Run your custom image:
make docker-run # or directly: podman run -d --rm -p 8081:8080 \ -e OPENHAB_URL=http://your-openhab-host:8080 \ -e OPENHAB_API_TOKEN=your-api-token \ --name openhab-mcp \ openhab-mcp
Ensure the OPENHAB_URL, OPENHAB_API_TOKEN, and optional OPENHAB_USERNAME/OPENHAB_PASSWORD variables are set in your shell before invoking make docker-run.
Stop the custom container:
make docker-stop # or directly: podman stop openhab-mcp
You can connect this OpenHAB MCP server to Claude or Cline in VSCode to interact with your OpenHAB instance through AI assistants.
Save the following as claude_desktop_config.json in your Claude Desktop configuration directory:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json{ "mcp_servers": [ { "name": "openhab-mcp", "command": "podman", "args": [ "run", "-d", "-p", "8081:8080", "-e", "OPENHAB_URL=http://your-openhab-host:8080", "-e", "OPENHAB_API_TOKEN=your-api-token", "--name", "openhab-mcp", "ghcr.io/tdeckers/openhab-mcp:latest" ] } ] }
Save the following as mcp.json in your Cline configuration directory:
~/.cursor/mcp.json%USERPROFILE%\.cursor\mcp.json{ "mcp_servers": [ { "name": "openhab-mcp", "command": "podman", "args": [ "run", "-d", "-p", "8081:8080", "-e", "OPENHAB_URL=http://your-openhab-host:8080", "-e", "OPENHAB_API_TOKEN=your-api-token", "--name", "openhab-mcp", "ghcr.io/tdeckers/openhab-mcp:latest" ] } ] }
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 server provides the following tools:
list_items - Paginated list of openHAB items with optional tag, type, name, and label filtersget_item - Get a specific openHAB item by namecreate_item - Create a new openHAB itemupdate_item - Update an existing openHAB itemdelete_item - Delete an openHAB itemupdate_item_state - Update just the state of an openHAB itemlist_things - Paginated list of openHAB things with optional UID and label filtersget_thing - Get a specific openHAB thing by UIDcreate_thing - Create a new openHAB thingupdate_thing - Update an existing openHAB thingdelete_thing - Delete an openHAB thingupdate_thing_config - Update an openHAB thing's configurationget_thing_config_status - Get openHAB thing configuration statusset_thing_enabled - Set the enabled status of an openHAB thingget_thing_status - Get openHAB thing statusget_thing_firmware_status - Get openHAB thing firmware statusget_available_firmwares - Get available firmwares for an openHAB thinglist_rules - List all openHAB rules, optionally filtered by tagget_rule - Get a specific openHAB rule by UIDcreate_rule - Create a new openHAB ruleupdate_rule - Update an existing openHAB rule with partial updatesupdate_rule_script_action - Update a script action in an openHAB ruledelete_rule - Delete an openHAB rulerun_rule_now - Run an openHAB rule immediatelylist_scripts - List all openHAB scripts (rules with tag 'Script' and no trigger)get_script - Get a specific openHAB script by IDcreate_script - Create a new openHAB scriptupdate_script - Update an existing openHAB scriptdelete_script - Delete an openHAB scriptlist_links - List all openHAB item-channel links, optionally filtered by channel UID or item nameget_link - Get a specific openHAB item-channel linkcreate_or_update_link - Create or update an openHAB item-channel linkdelete_link - Delete a specific openHAB item-channel linkget_orphan_links - Get orphaned openHAB item-channel links (links to non-existent channels)purge_orphan_links - Remove all orphaned openHAB item-channel linksdelete_all_links_for_object - Delete all openHAB links for a specific item or thingThe server provides the following resources:
openhab://items - List of all items in the openHAB systemopenhab://items/{item_name} - Get a specific item by name{ "name": "LivingRoom_Light", "type": "Switch", "label": "Living Room Light", "state": "OFF", "tags": ["Lighting", "LivingRoom"], "groups": ["gLights", "gLivingRoom"] }
For development purposes, please refer to the DEVELOPER.md file for more information on the Podman-based development workflow.
This implementation connects to a real openHAB instance via its REST API. For production use, you might want to enhance it with:
MIT