@iobroker/mcp-server 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/build/devices.d.ts +127 -0
- package/build/devices.js +752 -0
- package/build/devices.js.map +1 -0
- package/build/inProcessClient.d.ts +49 -0
- package/build/inProcessClient.js +76 -0
- package/build/inProcessClient.js.map +1 -0
- package/build/index.d.ts +202 -0
- package/build/index.js +1807 -0
- package/build/index.js.map +1 -0
- package/build/iob-uri.d.ts +20 -0
- package/build/iob-uri.js +108 -0
- package/build/iob-uri.js.map +1 -0
- package/build/types.d.ts +17 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ioBroker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @iobroker/mcp-server
|
|
2
|
+
|
|
3
|
+
MCP server for ioBroker
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
This adapter exposes ioBroker as an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server, so MCP-capable clients (e.g. Claude Desktop) can read and control your installation through a well-defined set of tools.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- MCP server over the **Streamable HTTP** transport (`/mcp` endpoint)
|
|
12
|
+
- Configurable HTTP/HTTPS web server
|
|
13
|
+
- Configurable port and bind address
|
|
14
|
+
- Optional authentication
|
|
15
|
+
- Optional SSL/TLS support
|
|
16
|
+
- Network diagnostics (ICMP ping / TCP probe) to troubleshoot adapter connections
|
|
17
|
+
- Adapter **repository** search to recommend installable adapters
|
|
18
|
+
|
|
19
|
+
## Operating modes
|
|
20
|
+
|
|
21
|
+
The adapter can run in two ways:
|
|
22
|
+
|
|
23
|
+
1. **Standalone** (default) – it starts its own web server on the configured port. The MCP endpoint is
|
|
24
|
+
`http(s)://<host>:<port>/mcp`.
|
|
25
|
+
2. **Web extension** – it runs inside an existing [`web`](https://github.com/ioBroker/ioBroker.web) adapter
|
|
26
|
+
instance and shares its web server (port, authentication, SSL). Select the target web instance in the
|
|
27
|
+
admin configuration ("Extend WEB adapter"). The MCP endpoint is then served under the web adapter, e.g.
|
|
28
|
+
`http(s)://<host>:8082/mcp/`.
|
|
29
|
+
|
|
30
|
+
When a web instance is selected, the standalone server settings (port, bind address, authentication, SSL)
|
|
31
|
+
are hidden because they are inherited from the chosen `web` instance.
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
The adapter can be configured through the ioBroker admin interface using JSONConfig:
|
|
36
|
+
|
|
37
|
+
### Server Configuration
|
|
38
|
+
- **Extend WEB adapter**: Select a `web` instance to run as its extension. Leave empty to run standalone.
|
|
39
|
+
- **Port**: The port on which the web server will listen (default: 8093) – standalone only
|
|
40
|
+
- **Bind Address**: IP address to bind the server to (0.0.0.0 for all interfaces) – standalone only
|
|
41
|
+
|
|
42
|
+
### Authentication
|
|
43
|
+
- **Enable Authentication**: Enable ioBroker user authentication for the web server
|
|
44
|
+
- **Default User**: The ioBroker user whose permissions every MCP request runs with (default: `admin`).
|
|
45
|
+
All object/state reads and writes performed by the tools are executed in the name of this user, so the
|
|
46
|
+
user's ACLs are enforced. A plain name like `operator` is automatically expanded to `system.user.operator`.
|
|
47
|
+
When running as a web extension and no user is set here, the host `web` instance's default user is used.
|
|
48
|
+
|
|
49
|
+
### Permissions
|
|
50
|
+
- **Allow setting states**: Allow MCP clients to write state values (the `set_state` and `set_states` tools).
|
|
51
|
+
Default: **on**.
|
|
52
|
+
- **Allow object/file changes**: Allow MCP clients to create/modify/delete objects and files (the `set_object`,
|
|
53
|
+
`delete_object`, `create_state`, `create_scene`, `write_file`, `delete_file`, `rename_file` and `mkdir`
|
|
54
|
+
tools). Default: **off**. When off, these tools are not exposed at all.
|
|
55
|
+
|
|
56
|
+
### SSL/TLS Configuration
|
|
57
|
+
- **Enable HTTPS**: Enable HTTPS/SSL for secure connections
|
|
58
|
+
- **Public Certificate**: Path to the public certificate file
|
|
59
|
+
- **Private Key**: Path to the private key file
|
|
60
|
+
- **Chained Certificate**: Path to the chained certificate file (optional)
|
|
61
|
+
|
|
62
|
+
## MCP Endpoint
|
|
63
|
+
|
|
64
|
+
The MCP server is served at `POST/GET/DELETE /mcp` using the Streamable HTTP transport with per-session
|
|
65
|
+
state (tracked via the `Mcp-Session-Id` header). Point your MCP client at:
|
|
66
|
+
|
|
67
|
+
- standalone: `http(s)://<host>:<port>/mcp`
|
|
68
|
+
- web extension: `http(s)://<host>:<webPort>/mcp/`
|
|
69
|
+
|
|
70
|
+
### Available tools
|
|
71
|
+
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
74
|
+
| `get_states` | Retrieve the current value of one or multiple states; IDs may contain wildcards (e.g. `hue.0.*.brightness`) |
|
|
75
|
+
| `get_object` | Read a single object by its ID |
|
|
76
|
+
| `search_objects` | Search objects/states by keyword (matched against ID and name); optional filters for object `type`, `role`, `room` and source `adapter` instance |
|
|
77
|
+
| `list_devices` | List detected devices grouped by room (uses the ioBroker type-detector to expose functional devices with named controls); optional `language` and `room` filter |
|
|
78
|
+
| `list_instances` | List adapter instances with their status |
|
|
79
|
+
| `list_adapters` | List installed adapters with metadata (version, title, description, keywords) |
|
|
80
|
+
| `search_adapter_repository` | Search the ioBroker adapter **repository** (all *installable* adapters, not just installed ones) by keyword; optional `type` category, `onlyNotInstalled` and `language` filters — use it to recommend which adapter to install for a device/service |
|
|
81
|
+
| `list_hosts` | List ioBroker hosts with their status |
|
|
82
|
+
| `list_rooms` | List rooms (`enum.rooms.*`) with localized names and member details; optional `language` and `withIcons` |
|
|
83
|
+
| `list_functions` | List functions (`enum.functions.*`) with localized names and member details; optional `language` and `withIcons` |
|
|
84
|
+
| `history_query` | Query historical values (requires a history adapter); aggregations: `raw`, `min`, `max`, `avg`, `sum`, `count`, `minmax`, `percentile`, `quantile`, `integral` |
|
|
85
|
+
| `read_file` | Read a file from an adapter file storage (optional base64) |
|
|
86
|
+
| `list_files` | List a directory in an adapter file storage |
|
|
87
|
+
| `file_exists` | Check whether a file exists in an adapter file storage |
|
|
88
|
+
| `get_logs` | Retrieve recent ioBroker log lines; optional filters by `level` (error/warn/info/debug), source `adapter` and start time (`from_ts`) |
|
|
89
|
+
| `write_log` | Write a message to the ioBroker log |
|
|
90
|
+
| `system_info` | Get system and js-controller information |
|
|
91
|
+
| `ping_host` | Diagnose connectivity to a network device: ICMP ping to `host` plus an optional TCP connect to `port` — useful to investigate adapter `ETIMEDOUT`/connection errors |
|
|
92
|
+
| `set_state` | Set the value of a state (value coerced to the state type) — requires *Allow setting states* |
|
|
93
|
+
| `set_states` | Set multiple states in one call (for scenes/group actions like "all lights off") — requires *Allow setting states* |
|
|
94
|
+
| `set_object` | Create/update an object (merges common/native) — requires *Allow object/file changes* |
|
|
95
|
+
| `delete_object` | Delete an object, optionally with all children — requires *Allow object/file changes* |
|
|
96
|
+
| `create_state` | Create a new state object with type/role/unit/min/max and optional initial value — requires *Allow object/file changes* |
|
|
97
|
+
| `create_scene` | Create or update a scene for the ioBroker `scenes` adapter (state/value pairs applied together) — requires *Allow object/file changes* |
|
|
98
|
+
| `write_file` | Write a file to an adapter file storage — requires *Allow object/file changes* |
|
|
99
|
+
| `delete_file` | Delete a file from an adapter file storage — requires *Allow object/file changes* |
|
|
100
|
+
| `rename_file` | Rename/move a file within the same adapter file storage — requires *Allow object/file changes* |
|
|
101
|
+
| `mkdir` | Create a directory in an adapter file storage — requires *Allow object/file changes* |
|
|
102
|
+
|
|
103
|
+
All object/state access runs with the permissions of the configured **Default User**. The write tools are only
|
|
104
|
+
registered when their respective permission option is enabled.
|
|
105
|
+
|
|
106
|
+
### Resources & live updates (SSE)
|
|
107
|
+
|
|
108
|
+
States and objects are also exposed as MCP **resources** using the canonical ioBroker URI scheme, so clients
|
|
109
|
+
can read and **subscribe** to them. The server pushes changes over the Streamable HTTP SSE stream
|
|
110
|
+
(`notifications/resources/updated`).
|
|
111
|
+
|
|
112
|
+
- States: `iobstate://<id>` (e.g. `iobstate://javascript.0.temperature`) – `resources/read` returns
|
|
113
|
+
`{ id, val, ack, ts, lc, q }`.
|
|
114
|
+
- Objects: `iobobject://<id>` (e.g. `iobobject://system.adapter.admin.0`) – `resources/read` returns the object.
|
|
115
|
+
- Logs: `ioblog://all` (every source) or `ioblog://<source>` (e.g. `ioblog://admin.0`) – `resources/read`
|
|
116
|
+
returns the recent log lines (`{ source, logs: [{ ts, level, source, message }] }`). Subscribing enables
|
|
117
|
+
log forwarding for the adapter; each new matching line triggers a `notifications/resources/updated`.
|
|
118
|
+
- `resources/subscribe` subscribes to the underlying ioBroker state/object/log; on every change the client
|
|
119
|
+
receives a `notifications/resources/updated` for that URI and re-reads it. `resources/unsubscribe` stops it.
|
|
120
|
+
|
|
121
|
+
Subscriptions are tracked per session and ref-counted, so the adapter subscribes to a state/object only once
|
|
122
|
+
regardless of how many clients/sessions watch it, and unsubscribes when the last one leaves.
|
|
123
|
+
|
|
124
|
+
(Files use `iobfile://<adapter>/<path>` in the same scheme; they are available via the `read_file`/`write_file`
|
|
125
|
+
tools rather than as subscribable resources.)
|
|
126
|
+
|
|
127
|
+
### Health endpoints (non-MCP)
|
|
128
|
+
|
|
129
|
+
- `GET /` - Basic server information
|
|
130
|
+
- `GET /status` - Server status, uptime and active session count
|
|
131
|
+
- `GET /api/info` - Adapter information
|
|
132
|
+
|
|
133
|
+
## Changelog
|
|
134
|
+
<!--
|
|
135
|
+
Placeholder for the next version (at the beginning of the line):
|
|
136
|
+
### **WORK IN PROGRESS**
|
|
137
|
+
-->
|
|
138
|
+
### 0.0.2 (2026-06-17)
|
|
139
|
+
* (@GermanBluefox) Initial development
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT License
|
|
144
|
+
|
|
145
|
+
Copyright (c) 2026 ioBroker
|
|
146
|
+
|
|
147
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
148
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
149
|
+
in the Software without restriction, including without limitation the rights
|
|
150
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
151
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
152
|
+
furnished to do so, subject to the following conditions:
|
|
153
|
+
|
|
154
|
+
The above copyright notice and this permission notice shall be included in all
|
|
155
|
+
copies or substantial portions of the Software.
|
|
156
|
+
|
|
157
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
158
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
159
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
160
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
161
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
162
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
163
|
+
SOFTWARE.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device detection utilities, ported from the ioBroker n8n nodes
|
|
3
|
+
* (`IoBrokerNodes/DevicesUtils.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Uses the ioBroker type detector (https://github.com/ioBroker/ioBroker.type-detector)
|
|
6
|
+
* to turn raw states/channels/devices into "controls" (functional devices) and groups
|
|
7
|
+
* them into an AI-friendly structure of rooms -> devices -> named controls.
|
|
8
|
+
*
|
|
9
|
+
* All object reads accept an optional `{ user }` so the detection respects the ACLs of
|
|
10
|
+
* the configured default user (see McpServer).
|
|
11
|
+
*/
|
|
12
|
+
import { type ExternalDetectorState, Types } from '@iobroker/type-detector';
|
|
13
|
+
/** Read options passed through to `getObjectViewAsync` (currently only the ACL user). */
|
|
14
|
+
export interface ReadOptions {
|
|
15
|
+
user?: `system.user.${string}`;
|
|
16
|
+
}
|
|
17
|
+
export type SmartNameObject = {
|
|
18
|
+
[lang in ioBroker.Languages]?: string;
|
|
19
|
+
} & {
|
|
20
|
+
smartType?: string | null;
|
|
21
|
+
byON?: string | null;
|
|
22
|
+
toggle?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type SmartName = null | false | string | SmartNameObject;
|
|
25
|
+
/** Detector state enriched with the concrete object id, smart name and common metadata. */
|
|
26
|
+
export interface IotExternalDetectorState extends ExternalDetectorState {
|
|
27
|
+
id: string;
|
|
28
|
+
smartName: SmartName | undefined;
|
|
29
|
+
common: {
|
|
30
|
+
min?: number;
|
|
31
|
+
max?: number;
|
|
32
|
+
unit?: string;
|
|
33
|
+
type?: ioBroker.CommonType;
|
|
34
|
+
states?: {
|
|
35
|
+
[value: string]: string;
|
|
36
|
+
};
|
|
37
|
+
role?: string;
|
|
38
|
+
name?: ioBroker.StringOrTranslated;
|
|
39
|
+
icon?: string;
|
|
40
|
+
color?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface IotExternalPatternControl {
|
|
44
|
+
states: IotExternalDetectorState[];
|
|
45
|
+
type: Types;
|
|
46
|
+
enumRequired?: boolean;
|
|
47
|
+
object?: {
|
|
48
|
+
id: string;
|
|
49
|
+
type: ioBroker.ObjectType;
|
|
50
|
+
common: ioBroker.StateCommon | ioBroker.ChannelCommon | ioBroker.DeviceCommon;
|
|
51
|
+
autoDetected: boolean;
|
|
52
|
+
toggle?: boolean;
|
|
53
|
+
smartName?: SmartName;
|
|
54
|
+
};
|
|
55
|
+
groupNames: string[];
|
|
56
|
+
room?: {
|
|
57
|
+
id: string;
|
|
58
|
+
common: ioBroker.EnumCommon;
|
|
59
|
+
};
|
|
60
|
+
functionality?: {
|
|
61
|
+
id: string;
|
|
62
|
+
common: ioBroker.EnumCommon;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks whether the provided value is a valid smart name.
|
|
67
|
+
*
|
|
68
|
+
* @param smartName The value to check
|
|
69
|
+
* @param lang Configured language
|
|
70
|
+
* @returns True if a valid smart name, false - otherwise.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isValidSmartName(smartName: SmartName | undefined, lang: ioBroker.Languages): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Inspects all objects (states, channels and devices) and tries to identify so-called 'controls'
|
|
75
|
+
*
|
|
76
|
+
* To identify the controls, the ioBroker type detector library is used (https://github.com/ioBroker/ioBroker.type-detector).
|
|
77
|
+
*
|
|
78
|
+
* @param adapter The adapter instance
|
|
79
|
+
* @param lang language
|
|
80
|
+
* @param options read options (ACL user)
|
|
81
|
+
* @returns An array containing the detected controls
|
|
82
|
+
*/
|
|
83
|
+
export declare function controls(adapter: ioBroker.Adapter, lang: ioBroker.Languages, options?: ReadOptions): Promise<IotExternalPatternControl[]>;
|
|
84
|
+
type RoomName = string;
|
|
85
|
+
type FunctionalityName = string;
|
|
86
|
+
type ControlType = 'power' | 'dimmer' | 'blindPosition' | 'stop' | 'openedClosed' | 'alarm' | 'color' | 'colorRed' | 'colorGreen' | 'colorBlue' | 'colorWhite' | 'colorTemperature' | 'openClose' | 'open' | 'close' | 'fanSpeed' | 'boostMode' | 'swingPosition' | 'saturation' | 'swingOnOff' | 'actualTemperature' | 'humidity' | 'illuminance' | 'level' | 'volume' | 'targetTemperature' | 'lock' | 'valve';
|
|
87
|
+
type ControlInDevice = {
|
|
88
|
+
stateId: string;
|
|
89
|
+
controlType: ControlType;
|
|
90
|
+
ioBrokerValueType: ioBroker.CommonType;
|
|
91
|
+
writable: boolean;
|
|
92
|
+
readable: boolean;
|
|
93
|
+
min?: number;
|
|
94
|
+
max?: number;
|
|
95
|
+
unit?: string;
|
|
96
|
+
states?: {
|
|
97
|
+
[value: string]: string;
|
|
98
|
+
};
|
|
99
|
+
role?: string;
|
|
100
|
+
};
|
|
101
|
+
export interface Device {
|
|
102
|
+
deviceName: string | ioBroker.StringOrTranslated | undefined;
|
|
103
|
+
deviceType: Types;
|
|
104
|
+
friendlyDeviceNames: string[];
|
|
105
|
+
room?: RoomName;
|
|
106
|
+
functionality?: FunctionalityName;
|
|
107
|
+
controls: {
|
|
108
|
+
[controlType: string]: ControlInDevice;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export interface Room {
|
|
112
|
+
roomName: RoomName;
|
|
113
|
+
devicesInRoom: Device[];
|
|
114
|
+
}
|
|
115
|
+
export interface Functionality {
|
|
116
|
+
functionalityName: FunctionalityName;
|
|
117
|
+
devicesInFunctionality: Device[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Build an AI-friendly structure of rooms -> devices -> named controls.
|
|
121
|
+
*
|
|
122
|
+
* @param adapter The adapter instance
|
|
123
|
+
* @param lang language
|
|
124
|
+
* @param options read options (ACL user)
|
|
125
|
+
*/
|
|
126
|
+
export declare function getAiFriendlyStructure(adapter: ioBroker.Adapter, lang: ioBroker.Languages, options?: ReadOptions): Promise<Room[]>;
|
|
127
|
+
export {};
|