A Model Context Protocol (MCP) server for Domoticz home automation
Project description
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)
- Device Control: Toggle switches, set states (On/Off), set dimmer levels, set thermostat temperatures, control blinds, and manage RGB/color lighting (brightness, hue, color temperature). Supports lookup by
idxorname. - Device Management: Create virtual sensors, rename devices, delete/hide devices, and manually update sensor values. Supports lookup by
idxorname. - Rooms and Scenes: Control scenes/groups. Get room devices by
idxorroom_name. - User Variables: Read, add, update, and delete Domoticz user variables. Supports lookup by
idxorname. - History and Logs: Access device history graphs and text/light logs by
idxorname. Retrieve system logs and add custom log messages. - System Information: Get Domoticz instance version, global settings, hardware, sun times, users, and internal event scripts/rules.
- Security: Get and set the Domoticz security panel status.
- Notifications: Send notifications through the Domoticz notification subsystem.
- Event Management: Get, create, and update internal event scripts (Blockly, Lua, dzVents, Python).
- Cameras and Floorplans: Retrieve camera configurations and defined floorplans.
Resources (Context)
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.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 the list of devices belonging to a specific scene.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://log: Read the current Domoticz system log.domoticz://security: Read the current status of the security panel.domoticz://settings: Read global Domoticz settings and configuration.
Prompts (Templates)
summarize_home: A prompt that instructs the AI to read the home state (devices, temperature, open doors) and provide a human-readable summary.troubleshoot_device: A template that asks for a deviceidxornameand instructs the AI to read the device state and system logs to diagnose issues.analyze_automations: Instructs the AI to review your internal event scripts for logic flaws or optimizations.
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-mcp
Docker 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/YOUR_GITHUB_USERNAME/domoticz-mcp:latest
Note: 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 stdio
sse(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 8000
Connection 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 8000
Connection URL for clients:http://localhost:8000/mcp
Configuration
The server can be configured via environment variables or command-line arguments. Environment variables take precedence over command-line arguments, which in turn override the defaults. This is designed to facilitate easy configuration in Docker environments.
General Options
| Option | Environment Variable | Default | Description |
|---|---|---|---|
--transport |
DOMOTICZ_MCP_TRANSPORT, TRANSPORT |
stdio |
Transport to use (stdio, sse, or streamable-http) |
--host |
DOMOTICZ_MCP_HOST, HOST |
127.0.0.1 |
Host to bind to for SSE / HTTP |
--port |
DOMOTICZ_MCP_PORT, PORT |
8000 |
Port to bind to for SSE / HTTP |
--domoticz-url |
DOMOTICZ_URL |
https://xmpp.vanadrighem.eu/domoticz |
Base URL of your Domoticz instance |
--token-file |
DOMOTICZ_MCP_TOKEN_FILE, TOKEN_FILE |
~/.config/domoticz-mcp/token.json |
Path to OAuth token storage file |
Authentication 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 |
|---|---|---|
--domoticz-client-id |
DOMOTICZ_CLIENT_ID, DOMOTICZ_CLIENTID |
Your Application's Client ID |
--domoticz-client-secret |
DOMOTICZ_CLIENT_SECRET, DOMOTICZ_CLIENTSECRET |
Your Application's Client Secret |
--domoticz-oauth-token |
DOMOTICZ_OAUTH_TOKEN |
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 Server - isPublic: Check this if you want to use Key-Pair, or leave unchecked for a Shared Secret.
- Name: e.g.,
- Note the generated Client ID and Client Secret.
Interactive Flow (Desktop/CLI):
When the server runs for the first time natively on your machine, it will print an authorization URL to the console/stderr and attempt to open your browser. After you approve the request, it will save the token to the token-file for future use.
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 |
|---|---|---|
--domoticz-username |
DOMOTICZ_USERNAME |
Your Domoticz username |
--domoticz-password |
DOMOTICZ_PASSWORD |
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.
- Create a virtual environment and install development dependencies using
uv:uv venv uv pip install -e ".[dev]"
- Run the test suite:
uv run pytest
License
This project is licensed under the GNU General Public License v3.0 (GPLv3). See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file domoticz_mcp-1.0.0.tar.gz.
File metadata
- Download URL: domoticz_mcp-1.0.0.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
befa9a25cd362be1e0533e3499702cee8abfff8134171c1eb256f29c688cd6f2
|
|
| MD5 |
b983ea48acd8922db856cff1efd4f5b6
|
|
| BLAKE2b-256 |
af38b910ec96f337771d85dc387210e6a7f420dd83b00d8032a882d8432abe09
|
Provenance
The following attestation bundles were made for domoticz_mcp-1.0.0.tar.gz:
Publisher:
release.yml on adrighem/domoticz-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
domoticz_mcp-1.0.0.tar.gz -
Subject digest:
befa9a25cd362be1e0533e3499702cee8abfff8134171c1eb256f29c688cd6f2 - Sigstore transparency entry: 1198992544
- Sigstore integration time:
-
Permalink:
adrighem/domoticz-mcp@c68cd2e9226d2a16ec9b8f7ac6658b680ee87bbe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/adrighem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c68cd2e9226d2a16ec9b8f7ac6658b680ee87bbe -
Trigger Event:
push
-
Statement type:
File details
Details for the file domoticz_mcp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: domoticz_mcp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d564ae80619ccbc2d7fdd1b22901737df4442df5fb81062e798f4f1f0184eda9
|
|
| MD5 |
94c793d23ef5076ed06ead64ab887a76
|
|
| BLAKE2b-256 |
515806d0324d808f7c79f7e1fdfe8af581ac8791eb8717bbf20dcf5d94a301e9
|
Provenance
The following attestation bundles were made for domoticz_mcp-1.0.0-py3-none-any.whl:
Publisher:
release.yml on adrighem/domoticz-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
domoticz_mcp-1.0.0-py3-none-any.whl -
Subject digest:
d564ae80619ccbc2d7fdd1b22901737df4442df5fb81062e798f4f1f0184eda9 - Sigstore transparency entry: 1198992996
- Sigstore integration time:
-
Permalink:
adrighem/domoticz-mcp@c68cd2e9226d2a16ec9b8f7ac6658b680ee87bbe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/adrighem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c68cd2e9226d2a16ec9b8f7ac6658b680ee87bbe -
Trigger Event:
push
-
Statement type: