openhab
MCP server for OpenHAB v5+ that exposes the entire REST API as tools for AI models, enabling complete control over items, things, rules, persistence, and semantic model.
README
OpenHAB MCP Server
A Fast and Concise Model Context Protocol (MCP) server for OpenHAB (v5+).
This server exposes the entire OpenHAB REST API as a set of tools for AI models like Claude or VS Code assistants. It allows for complete control over Items, Things, Rules, Persistence, Semantic Tags, and more.
Prerequisites
- Node.js (v18 or higher)
- An OpenHAB API Token (Generate in User Profile -> API Tokens)
Configuration
The server requires two environment variables:
OPENHAB_URL: The URL of your OpenHAB instance (e.g.,http://openhab:8080)OPENHAB_API_TOKEN: Your generated long-lived API token.
Setup instructions
-
Install dependencies:
npm install -
Build the server:
npm run build -
Test locally (Optional):
OPENHAB_URL=http://openhab:8080 OPENHAB_API_TOKEN=your_token_here npm start
Client Integration
Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"openhab": {
"command": "node",
"args": ["/path/to/oh-mcp/dist/index.js"],
"env": {
"OPENHAB_URL": "http://openhab:8080",
"OPENHAB_API_TOKEN": "your_openhab_token_here"
}
}
}
}
Antigravity
Add the following to your Antigravity MCP settings:
{
"mcpServers": {
"openhab": {
"command": "node",
"args": ["/path/to/oh-mcp/dist/index.js"],
"env": {
"OPENHAB_URL": "http://openhab:8080",
"OPENHAB_API_TOKEN": "your_openhab_token_here"
}
}
}
}
VS Code (Roo/Cline)
Add an MCP server entry to your VS Code workspace settings (open Settings (JSON) or create .vscode/settings.json):
{
"servers": {
"openhab": {
"command": "node",
"args": ["${workspaceFolder}/dist/index.js"],
"env": {
"OPENHAB_URL": "http://openhab:8080",
"OPENHAB_API_TOKEN": "your_openhab_token_here"
}
}
}
}
Quick steps to run from VS Code:
- Install deps and build the project:
npm install
npm run build
- Start the server (Linux/macOS):
OPENHAB_URL=http://openhab:8080 OPENHAB_API_TOKEN=your_openhab_token_here npm start
- For iterative development, run TypeScript in watch mode and restart the server after builds (in two terminals):
npm run dev # keeps tsc watching
npm start # runs node dist/index.js (in a second terminal)
- Run as a VS Code Task (example
.vscode/tasks.json):
{
"version": "2.0.0",
"tasks": [
{
"label": "Run OpenHAB MCP",
"type": "shell",
"command": "OPENHAB_URL=http://openhab:8080 OPENHAB_API_TOKEN=your_openhab_token_here npm start",
"group": "build",
"presentation": { "reveal": "always" }
}
]
}
Note for Windows (PowerShell): set env vars before running:
$env:OPENHAB_URL = 'http://openhab:8080'; $env:OPENHAB_API_TOKEN = 'your_openhab_token_here'; npm start
Tips:
- Use
${workspaceFolder}/dist/index.jsin theargsso the server is launched from your opened workspace. - Add the server config to Workspace settings (not User) if you share the repo with collaborators.
- Use the
npm: buildtask in the Command Palette (Tasks → Run Task) to compile before starting.
🛠 Available Tools
This server exposes over 80 tools for comprehensive OpenHAB management.
🚀 Smart & Advanced Tools
Tools designed to automate complex workflows and provide AI-friendly context.
get_system_summary: High-density overview of the entire system (rooms, items, things, health).get_prompt_context: Condensed priming context for an AI agent.get_schema: Minimal mapping of all items (name, type, label).search_items: Fuzzy search for items by name, label, or location.create_equipment_from_thing: Automatically creates an Equipment group and Point items from a Thing's channels.explain_item_state: Forensic review of an item (state + history + linked hardware + affecting rules).predictive_rule_generator: Generates a validated Javascript rule from natural language intent.shadow_run: Simulates a sequence of commands and predicts resulting states without hardware impact.generate_topology: Generates a Mermaid graph of the home's spatial/logical hierarchy.analyze_system_health: Scans for hardware issues, connectivity drift, and low batteries.audit_semantic_model: Structural audit to find loose items or missing equipment hierarchy.bulk_item_remediation: Mass-update tags, categories, and groups for a list of items.discover_automation_patterns: Correlation engine to suggest automations based on persistence history.detect_rule_conflicts: Identifies potential race conditions or conflicting logic between rules.standardize_naming_convention: Proposes a unified Location_Equipment_Point naming format.optimize_persistence_strategy: Recommends optimal recording intervals to prevent database bloat.sitemap_to_main_ui: Converts legacy .sitemap definitions to modern MainUI YAML.optimize_mcp_focus: Locks the MCP to a specific Room or Group to save tokens and increase AI accuracy.export_system_snapshot: Generates a portable JSON snapshot for rapid backup and restore.get_mcp_health: Returns real-time health metrics (SSE status, cache hit rates, buffer size).summarize_persistence_range: Returns statistical summary of historical data to save context tokens.get_mcp_capabilities: Returns a list of currently active advanced capabilities.simulate_system_state: Predicts command outcomes (including triggers) without affecting hardware.generate_home_blueprint: Auto-generates a structured Markdown manual of your entire home model.audit_system_safety: Proactive scanner for security items (Locks, Alarms) with safety check logic.calculate_energy_insights: Aggregates energy/power data into a high-level consumption report.get_semantic_path: Returns the full semantic path for an item (e.g., Lounge > Sofa > Light).find_neighboring_equipment: AI-driven search for other devices in the same physical location.schedule_command: Schedules a command for the future (e.g., "turn off in 10 minutes").get_stale_items: Identifies sensors or items that haven't updated in a specified period.test_transformation: Evaluate REGEX or JSONPATH patterns locally.get_recent_logs: Real-time tail of the OpenHAB event stream (items, commands, things).get_visual_chart: Generates ASCII sparkline charts for an item's recent history.validate_rule_logic: Sanitizes scripts for syntax errors and safety (infinite loops/guards).
🔹 Items & State
get_items: List all items with advanced filters (tags,type,metadata).get_item: Detailed definition and current state of an item.send_command: Send a command (e.g.,ON,50,OFF) to an item.update_state: Manually set an item's state.create_or_update_item: Lifecycle management for items.delete_item: Remove an item.get_room_status: Summary of all items tagged in a specific room.add_tag/remove_tag: Manage functional and semantic tags.set_metadata/remove_metadata: Fine-grained configuration management.
🔹 Hardware & Connectivity
get_things: List all logical/physical Things.get_thing: Detailed hardware configuration and UID mapping.get_thing_status: Check if hardware isONLINE,OFFLINE, etc.update_thing_config: Modify hardware parameters.enable_thing: Restart or disable a specific Thing.create_thing/update_thing/delete_thing: Manage hardware lifecycle.get_inbox: Review discovered devices waiting to be added.approve_inbox_item: Promote a discovered device to a system Thing.trigger_discovery_scan: Manually trigger a hardware scan for a specific binding (e.g., Hue, Sonos).
🔹 Automation & Rules
get_rules: List all rule definitions.get_rule: Inspect triggers, conditions, and actions.create_rule/update_rule/delete_rule: Rule lifecycle.run_rule: Manually trigger an automation.enable_rule: Toggle automation logic.
🔹 Persistence & Analysis
get_item_persistence_data: Fetch historical raw data points.get_item_statistics: Calculate peaks, averages, and duty cycles over time.store_item_persistence_data: Manually insert state history.get_persistence_services: List storage backends (RRD4j, InfluxDB, etc.).
🔹 Links & Semantic Model
get_links: View relationships between Items and Hardware Channels.link_item_to_channel: Bind an item to a specific channel.unlink_item_from_channel: Remove a binding.configure_link_profile: Apply profiles likesystem:followortransform:JSto a link.get_semantic_tags: Retrieve standard Location/Equipment/Point tags.suggest_semantic_tags: AI-driven tagging suggestions based on item naming.
🔹 Media, Voice & Scenes
control_media: Context-aware controls (play, pause, next, volume) for any media item.capture_scene: Save a snapshot of multiple item states as a Scene.activate_scene: Restore a saved Scene state.voice_say: Send text-to-speech to a specific speaker.voice_interpret: Resolve natural language commands via OpenHAB's interpreter.chat_with_habot: NLP interaction with the HABot interface.get_voices/get_audio_sinks/get_audio_sources: Discover audio capabilities.
🔹 UI & System Maintenance
get_ui_components/get_ui_tiles: Access MainUI layout data.generate_ui_widget: Create MainUI YAML for custom dashboard widgets.get_system_info: CPU, Memory, Java version, and OS details.get_loggers/set_logger_level: Monitor and change log verbosity on the fly.get_addons/install_addon/uninstall_addon: Manage system extensions.get_sitemaps: Access legacy sitemap UI definitions.generate_system_boilerplate: Create Typescript interfaces for your entire home.
License
MIT
Release 1.3.2
This release (1.3.2) contains performance optimisations across several hot-path methods and a correctness fix for detectRuleConflicts. See CHANGELOG.md for full details.
Contributing
Contributions are welcome. Please follow the Conventional Commits specification for commit messages so changelogs and automation remain consistent.
- Commit message format:
type(scope): short description(e.g.,fix(openhab-client): handle null response). - Common types:
feat,fix,docs,style,refactor,perf,test,chore.
Example:
docs(readme): add contributing guidelines and conventional commits example
If you're submitting a change that affects behavior, include tests under src/__tests__/ when appropriate.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。