Domoticz MCP Server
The Domoticz MCP Server lets AI assistants view, control, and manage a Domoticz smart home system through a comprehensive set of tools.
Device Discovery & Search
Get a high-level system overview with device counts, search devices by name/status (substring/regex), get all devices and their states, or look up a specific device by IDX or name.
Device Control
Toggle switches/lights, set On/Off states, adjust dimmer levels (0–100), set thermostat temperatures (Celsius), control blinds (Open/Close/Stop), set RGB color/brightness, and set color temperature for white-spectrum lights.
Device Management
Rename, delete, or hide devices; create virtual sensors; and manually update sensor/device values.
Scenes & Rooms
List all scenes/groups, turn a scene On/Off/Toggle, view devices in a scene, list all rooms, and get devices within a specific room.
User Variables
Get, add, update, and delete user variables (integer, float, string, date, time).
Maintenance & Health
List devices with low battery levels, identify devices that haven't checked in within a timeframe, and check hardware gateway health.
Energy Analytics
Summarize today's energy usage across all power-reporting devices.
History & Logs
Retrieve device history/graph data, access system logs (including filtered error logs), and add custom log messages.
Event / Automation Scripts
Get an overview of all event scripts, view source code of a specific script, create new scripts (Lua, dzVents, Python, Blockly), update existing scripts, and search inside script source code.
System Information
Get Domoticz version/build info, global settings, configured hardware/gateways, sunrise/sunset times, user accounts, cameras, and floorplans.
Security
Get and set the security panel status (Disarm, Arm Home, Arm Away).
Notifications
Send custom notifications through Domoticz's notification subsystem.
Advanced
Execute generic Domoticz API calls directly for anything not covered by the above tools.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Domoticz MCP Server turn on the living room lights and set the thermostat to 21 degrees"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Domoticz MCP Server
A Model Context Protocol (MCP) server for integrating with the Domoticz home automation system. This server provides tools to AI assistants (like Claude, Gemini, etc.) to view and control your smart home devices, scenes, user variables, and more.
Features
The server exposes Tools (for active control and modifications), Resources (for read-only contextual awareness), and Prompts (for guided interaction templates).
Tools (Actions)
Search:
search_devices_toolsearches devices by name or current data/status text.search_scripts_toolsearches inside Domoticz event scripts.Authentication:
start_oauth_loginstarts a short-lived login and opens the authorization page locally without returning transaction data.get_oauth_login_statusreports when the login is complete.Energy History:
get_daily_energy_history,get_weekly_energy_history, andget_monthly_energy_historyread counter graph history for energy, gas, and water meters byidxorname.Device Control:
toggle_switch,set_switch_state,get_switch_actions,set_switch_actions,set_dimmer_level,set_temperature_setpoint,control_blinds,set_color_brightness, andset_color_temperaturecontrol supported devices and configure switch action URLs/scripts byidxorname.Device Management:
rename_device,delete_device,create_virtual_sensor, andupdate_device_valuemanage devices and virtual sensors.Scenes and Groups:
switch_sceneactivates configured scenes/groups byidxorname.User Variables:
add_user_variable,update_user_variable, anddelete_user_variablemanage Domoticz user variables.Event Scripts:
create_eventandupdate_eventcreate or update internal Domoticz event scripts.System Actions:
restart_system,add_log_message,send_notification, andset_security_statuscall Domoticz system, log, notification, and security APIs.Advanced:
call_domoticz_apiexecutes a generic Domoticz command API call and returns only its sanitized status/title.
High-impact tools require confirm=True: call_domoticz_api, delete_device, delete_user_variable, set_switch_actions, update_event, restart_system, and set_security_status.
Resources (Context)
domoticz://dashboard: Read a curated view of favorite and currently active devices (lights on, sensors active).domoticz://devices: Read the current state of all Domoticz devices.domoticz://device/{idx},domoticz://device/{type}/{subtype}/{idx}, ordomoticz://device/name/{name}: Read the current state of a specific device. In the typed form,idxis authoritative andtype/subtypeare descriptive path fields.domoticz://rooms: Read configured rooms (Room Plans).domoticz://room/{idx}ordomoticz://room/{room_name}/{idx}: Read the full states of all devices within a specific room.domoticz://scenes: Read configured scenes.domoticz://scene/{idx}ordomoticz://scene/name/{name}: Read a specific scene/group entry.domoticz://user-variables: Read the list of all Domoticz user variables.domoticz://user-variable/{idx}ordomoticz://user-variable/name/{name}: Read a specific Domoticz user variable.domoticz://events&domoticz://event/{event_id}: Read the overview and specific source code of event scripts.domoticz://logsordomoticz://log: Read the current Domoticz system log.domoticz://logs/error: Read a filtered view containing only 'Error' level entries from the log.domoticz://security: Read the current status of the security panel.domoticz://settings: Read a reviewed, non-sensitive subset of global display/version settings.domoticz://hardware: Read only gatewayidx, name, type, and enabled status. Connection details and integration configuration are omitted.domoticz://docs/dzvents_syntax: Cheat sheet for writing dzVents automation scripts.domoticz://docs/blockly_syntax: Syntax rules for Blockly XML automations.
Prompts (Templates)
agent_guidance: Orients an AI agent to start withdomoticz://overview, preferidx, and use health/log resources for troubleshooting.summarize_home: Guides a concise home-state summary fromdomoticz://dashboard.maintenance_report: Guides a health check using battery alerts, system health, and error logs.energy_audit: Guides an energy review usingdomoticz://devicesand the energy history tools.
Related MCP server: Indigo MCP Server Plugin
Performance and Efficiency
Caching: The server implements a 5-minute TTL cache for devices, scenes, user variables, and rooms to significantly reduce API latency and Domoticz load.
HTTP Lifecycle: Reuses a shared
httpx.AsyncClient, applies consistent timeouts, and closes it through the MCP server lifespan.Bounded Authentication: MCP requests fail fast with actionable guidance when OAuth needs attention; browser authentication only runs when explicitly requested.
Output Safety: Domoticz responses are recursively sanitized before crossing the MCP boundary. Credential fields, OAuth transaction data, private endpoints, network addresses, and sensitive free-text patterns are redacted; high-risk configuration resources also use strict allowlists.
Architecture
Type Safety: Full type annotations using Python 3.10+ union syntax for improved IDE support and code clarity.
Error Handling: Structured exception hierarchy (
DomoticzError,DeviceNotFoundError,AuthenticationError, etc.) for precise error handling and debugging.Shared Resolution: Unified
_resolve_idx()helper function for consistent device/scene/variable lookup patterns.
Prerequisites
Python 3.10 or higher
A running Domoticz instance
Network access to the Domoticz API
Installation
Standard Python Installation (Linux, macOS, Windows)
Clone or download this repository.
Navigate to the project directory.
Install the package using
pip:
pip install .This will install the domoticz-mcp command-line tool.
Using uv (Recommended)
If you use uv, you can run the server directly from the source repository without installing it globally:
uv run --directory /path/to/domoticz-mcp domoticz-mcpDocker Installation
You can run the server via Docker. By default, the Docker image runs the server in sse (HTTP) mode on port 8000.
docker run -d \
--name domoticz-mcp \
-p 8000:8000 \
-e DOMOTICZ_URL="http://192.168.1.100:8080" \
-e DOMOTICZ_USERNAME="your_username" \
-e DOMOTICZ_PASSWORD="your_password" \
ghcr.io/adrighem/domoticz-mcp:latestNote: For the OAuth2 token flow to work and persist in Docker without interactive browser prompts, see the OAuth / API Token section below on how to mount the token file or use headless authentication.
Transport Options
The server supports three different transports for clients to connect with:
stdio(Default): Standard input/output. This is what most desktop applications (like Claude Desktop and Gemini CLI) use.domoticz-mcp --transport stdiosse(HTTP Server-Sent Events): Starts a web server that clients can connect to over HTTP. Ideal for web-based UIs and remote connections. Includes wide-open CORS headers.domoticz-mcp --transport sse --port 8000Connection URL for clients:
http://localhost:8000/ssestreamable-http(Alternative HTTP): Starts a web server using an alternative HTTP transport. Required by certain clients (like the llama.cpp WebUI) that expect a single POST endpoint instead of an SSE stream.domoticz-mcp --transport streamable-http --port 8000Connection URL for clients:
http://localhost:8000/mcp
Configuration
The server can be configured via environment variables, a .env file, or command-line arguments. Environment variables take precedence over command-line arguments, which in turn override the defaults. Using a .env file is a convenient way to provide these variables without exposing them in your shell history.
General Options
Option | Environment Variable | Default | Description |
|
|
| Transport to use ( |
|
|
| Host to bind to for SSE / HTTP |
|
|
| Port to bind to for SSE / HTTP |
|
|
| Base URL of your Domoticz instance |
|
|
| Path to OAuth token storage file |
Example .env file:
DOMOTICZ_URL=http://192.168.1.100:8080
DOMOTICZ_CLIENT_ID=your_client_id_here
DOMOTICZ_CLIENT_SECRET=your_client_secret_hereTransport Options
By default, the server uses standard input/output (stdio) for communication with the MCP client. You can also run it as an HTTP Server-Sent Events (SSE) streaming server using the --transport sse argument.
domoticz-mcp --transport sse --host 127.0.0.1 --port 8000Authentication Options
You can authenticate the MCP server with Domoticz using either an OAuth/API Token (Recommended) or Basic Auth.
Option 1: OAuth / API Token (Recommended)
This approach uses an OAuth2 token and is generally more secure.
Option | Environment Variable | Description |
|
| Your Application's Client ID |
|
| Your Application's Client Secret |
|
| Direct OAuth2 access token (skips flow) |
In the Domoticz UI, go to Setup -> More Options -> Applications.
Click Add Application and configure:
Name: e.g.,
MCP ServerisPublic: Check this if you want to use Key-Pair, or leave unchecked for a Shared Secret.
Note the generated Client ID and Client Secret.
Interactive Flow (Desktop/CLI): Run the explicit authentication command in an interactive terminal:
domoticz-mcp --authenticateThe command opens a local browser and waits up to two minutes for the callback without printing the authorization or callback URL. After approval, it stores the token with owner-only file permissions and starts the MCP server. Normal MCP requests never launch a browser; if refresh fails, they return an actionable authentication error instead of waiting indefinitely.
Interactive Flow from Codex or another MCP client:
Call
start_oauth_login.Complete approval in the browser opened on the MCP host.
Call
get_oauth_login_statuswith the returnedflow_iduntil its status iscomplete.Retry the original Domoticz operation.
The start tool bounds the local browser launch to five seconds and reuses an existing pending flow, so it does not wait for browser approval. The callback listener binds only to 127.0.0.1, expires after two minutes, validates OAuth state and PKCE, and never returns authorization URLs, tokens, or authorization codes through MCP.
This tool flow is intended for a local MCP server such as Codex STDIO. Remote containers and execution hosts should use the command-line authentication flow on a browser-capable host or a securely mounted token file.
Headless Flow (Docker / Server Environments): In a Docker container, you have two options:
Password Grant (Easiest): Provide username and password in addition to the Client ID and Secret. The server will automatically perform a headless login to fetch the initial token.
Mount Token File: Run the server locally once to generate the token file, then mount it into the container.
Option 2: Basic Auth
If you prefer traditional username and password authentication:
Option | Environment Variable | Description |
|
| Your Domoticz username |
|
| Your Domoticz password |
In the Domoticz UI, go to Setup -> Settings -> Security.
Ensure "Allow Basic-Auth authentication over plain HTTP" is enabled (if you are not using HTTPS).
MCP Client Configuration
Gemini CLI
Add the following to your ~/.gemini/settings.json under the mcpServers object:
{
"mcpServers": {
"domoticz": {
"command": "uv",
"args": [
"--directory",
"/path/to/domoticz-mcp",
"run",
"domoticz-mcp"
],
"env": {
"DOMOTICZ_URL": "http://192.168.1.x:8080",
"DOMOTICZ_CLIENT_ID": "your_client_id_here",
"DOMOTICZ_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"domoticz": {
"command": "uv",
"args": [
"--directory",
"/path/to/domoticz-mcp",
"run",
"domoticz-mcp"
],
"env": {
"DOMOTICZ_URL": "http://192.168.1.x:8080",
"DOMOTICZ_CLIENT_ID": "your_client_id_here",
"DOMOTICZ_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}If you installed it globally via pip, you can use the command directly:
{
"mcpServers": {
"domoticz": {
"command": "domoticz-mcp",
"args": [],
"env": {
"DOMOTICZ_URL": "http://192.168.1.x:8080",
"DOMOTICZ_CLIENT_ID": "your_client_id_here",
"DOMOTICZ_CLIENT_SECRET": "your_client_secret_here"
}
}
}
}Other MCP Clients
For other clients that support the Model Context Protocol, simply configure them to run the domoticz-mcp binary or the uv run command with the appropriate environment variables.
Development and Testing
To develop and run tests for this project:
Clone the repository.
Install development dependencies using
uv:uv pip install -e ".[dev]"Run the test suite:
uv run --extra dev pytest tests/Build the package locally:
uv run --extra dev python -m build
You can also pass --directory /path/to/domoticz-mcp to either uv run command when running from outside the repository.
License
This project is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for details.
Available Tools
31 toolsadd_log_messageAdd Domoticz log messageB
Log message. level: 1=Normal, 2=Status, 4=Error. Cross-ref: domoticz://logs.
Inputs: message (required), level. Returns: A successful Domoticz command response.
add_user_variableAdd user variableB
Add var. vtype: 0=Int, 1=Float, 2=Str, 3=Date, 4=Time. Cross-ref: domoticz://user-variables.
Inputs: name (required), value (required), vtype (required). Returns: A successful Domoticz command response.
call_domoticz_apiCall raw Domoticz APIADestructive
Raw API call. Use if dedicated tools fail. Requires confirm=True.
Inputs: param (required), kwargs (required), confirm. Returns: A successful Domoticz command response.
control_blindsControl blindsCDestructiveIdempotent
'Open'/'Close'/'Stop'. Preferred: idx.
Inputs: command (required), idx, name. Returns: A successful Domoticz command response.
create_eventCreate event scriptB
Create script. Cross-ref: domoticz://docs/dzvents_syntax.
Inputs: name (required), event_type (required), interpreter (required), xmlstatement (required), +1 more. Returns: A successful Domoticz command response.
create_virtual_sensorCreate virtual sensorC
Create dummy. Cross-ref: domoticz://hardware.
Inputs: hw_idx (required), sensorname (required), sensortype (required). Returns: A successful Domoticz command response.
delete_deviceHide deviceADestructiveIdempotent
Hide device. Preferred: idx. Requires confirm=True.
Inputs: idx, name, confirm. Returns: A successful Domoticz command response.
delete_user_variableDelete user variableADestructiveIdempotent
Delete var. Preferred: idx. Requires confirm=True.
Inputs: idx, name, confirm. Returns: A successful Domoticz command response.
get_daily_energy_historyGet daily energy historyARead-onlyIdempotent
Read today's counter history. Preferred: idx. Set include_instantaneous=False for daily totals.
Inputs: idx, name, include_instantaneous. Returns: Normalized energy, gas, or water history.
get_monthly_energy_historyGet monthly energy historyARead-onlyIdempotent
Read this month's counter history. Preferred: idx.
Inputs: idx, name. Returns: Normalized energy, gas, or water history.
get_oauth_login_statusGet Domoticz OAuth login statusARead-onlyIdempotent
Check a browser login. Retry the original operation only after status is complete.
Inputs: flow_id (required). Returns: Credential-free status for a browser-based OAuth login.
get_switch_actionsGet switch actionsARead-onlyIdempotent
Get On Action and Off Action URLs or scripts for a switch. Preferred: idx. Cross-ref: set_switch_actions.
Inputs: idx, name. Returns: Result of querying or updating switch actions.
get_weekly_energy_historyGet weekly energy historyARead-onlyIdempotent
Read the last 7 days of counter history. Preferred: idx.
Inputs: idx, name. Returns: Normalized energy, gas, or water history.
rename_deviceRename deviceBDestructiveIdempotent
Rename device. Preferred: idx.
Inputs: new_name (required), idx, old_name. Returns: A successful Domoticz command response.
restart_systemRestart DomoticzADestructive
Reboot server. Requires confirm=True.
Inputs: confirm. Returns: A successful Domoticz command response.
search_devices_toolSearch devicesARead-onlyIdempotent
Search devices by name/status. Cross-ref: domoticz://devices.
Inputs: query (required), limit, offset. Returns: count, limit, offset, result, +4 more
search_scripts_toolSearch event scriptsCRead-onlyIdempotent
Search string in scripts. Cross-ref: domoticz://events.
Inputs: query (required), limit, offset. Returns: count, limit, offset, result, +4 more
send_notificationSend notificationD
Send notification.
Inputs: body (required), subject (required). Returns: A successful Domoticz command response.
set_color_brightnessSet color and brightnessCDestructiveIdempotent
Set RGB. Preferred: idx.
Inputs: hue (required), brightness (required), idx, name, +1 more. Returns: A successful Domoticz command response.
set_color_temperatureSet color temperatureADestructiveIdempotent
Set normalized white temperature (0-100). Preferred: idx.
Inputs: kelvin (required), idx, name. Returns: A successful Domoticz command response.
set_dimmer_levelSet dimmer levelBDestructiveIdempotent
Set brightness (0-100). Preferred: idx. Cross-ref: domoticz://device/{idx}.
Inputs: level (required), idx, name. Returns: A successful Domoticz command response.
set_security_statusSet security statusADestructiveIdempotent
Arm panel. 0=Disarm, 1=Home, 2=Away. Requires confirm=True. Cross-ref: domoticz://security.
Inputs: seccode (required), secstatus (required), confirm. Returns: A successful Domoticz command response.
set_switch_actionsSet switch actionsADestructiveIdempotent
Configure switch On Action and Off Action URLs or scripts. Preferred: idx. Requires confirm=True.
Inputs: idx, name, confirm, on_action, +1 more. Returns: Result of querying or updating switch actions.
set_switch_stateSet switch stateADestructiveIdempotent
Set 'On'/'Off'. Preferred: idx. Cross-ref: toggle_switch.
Inputs: state (required), idx, name. Returns: A successful Domoticz command response.
set_temperature_setpointSet temperature setpointCDestructiveIdempotent
Set target temp. Preferred: idx.
Inputs: setpoint (required), idx, name. Returns: A successful Domoticz command response.
start_oauth_loginStart Domoticz OAuth loginAIdempotent
Start or reuse a bounded login in a local browser, then poll get_oauth_login_status.
Inputs: no named parameters. Returns: Credential-free details for a locally opened browser login.
switch_sceneSwitch sceneBDestructive
Activate scene. 'On'/'Off'/'Toggle'. Preferred: idx. Cross-ref: domoticz://scenes.
Inputs: command (required), idx, name. Returns: A successful Domoticz command response.
toggle_switchToggle switchCDestructive
Toggle device. Preferred: idx. Cross-ref: set_switch_state.
Inputs: idx, name. Returns: A successful Domoticz command response.
update_device_valueUpdate device valueCDestructiveIdempotent
Manual update. Preferred: idx.
Inputs: idx, name, nvalue, svalue. Returns: A successful Domoticz command response.
update_eventUpdate event scriptCDestructiveIdempotent
Update script. Cross-ref: domoticz://event/{event_id}. Requires confirm=True.
Inputs: name (required), event_id (required), event_type (required), interpreter (required), +3 more. Returns: A successful Domoticz command response.
update_user_variableUpdate user variableCDestructiveIdempotent
Update var value. Cross-ref: domoticz://user-variables.
Inputs: name (required), value (required), vtype (required). Returns: A successful Domoticz command response.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 31 tools
Most tools have clearly distinct targets and actions, and the descriptions cross-reference each other where confusion could occur. A few close pairs like toggle_switch/set_switch_state and set_switch_state/set_switch_actions require careful reading, but they are not fundamentally ambiguous.
The dominant convention is snake_case verb_noun names such as get_daily_energy_history, add_user_variable, and update_event. The pattern is mostly predictable, but the _tool suffix on search_scripts_tool and search_devices_tool is an unnecessary deviation, and a few names like switch_scene are slightly awkward.
31 tools is above the 25-tool threshold and makes the surface heavy for an agent to select from reliably. Several related tools could reasonably be consolidated, such as the energy history variants or the overlapping switch-control tools, though the breadth is understandable for a home-automation server.
The tool set covers switches, scenes, energy history, user variables, events, security, notifications, and system administration, but noticeable lifecycle gaps exist, such as create/update events without a delete event and no explicit get/list device endpoint beyond search. The raw call_domoticz_api fallback helps, but it is not a clean substitute for dedicated read and delete operations.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Home energy for AI assistants: live Power flow, Energy history, solar forecast, and device control.
Ask about your IoT sensors, devices, anomalies and automations, switch outputs and log values.
Control your existing Philips lights, Sonos speakers, Roborock vacuums and other supported devices through Port OS cloud. Give ChatGPT, Claude and other MCP-compatible assistants access to the devices you connect. Turn off the living room lights, play music on your speakers, adjust the thermostat, run a vacuum in a room, check a camera snapshot or find a connected tracker. Available actions depend on your linked provider accounts and each device’s supported capabilities. Port OS runs in the cloud; no local server is required. You choose the account, device and capability permissions each assistant receives. Device operations require user OAuth; public tool discovery does not grant device access. Port OS is in alpha. Setup: https://portoperatingsystem.com/docs/getting-started/ Support: https://portoperatingsystem.com/contact/
Related MCP Servers
- AlicenseAqualityBmaintenanceA Model Context Protocol server that enables AI assistants like Claude to interact directly with Home Assistant, allowing them to query device states, control smart home entities, and perform automation tasks.29353MIT
- FlicenseNot gradedqualityBmaintenanceA Model Context Protocol server that enables AI assistants like Claude to interact with Indigo home automation systems through natural language queries for searching and controlling devices, variables, and actions.1-
- FlicenseNot gradedqualityDmaintenanceEnables control of OXII smart home devices through the Model Context Protocol, supporting device switching, air conditioner control, cronjobs, and room scenarios. Integrates with chatbots and MCP-compatible clients for natural language home automation.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to control Home Assistant devices and services through the Model Context Protocol.91 PyPI106MIT