MCP tools
Every tool, resource and prompt of the Senzor MCP server, with arguments, results and errors.
senzor-cli mcp and the GUI with MCP on serve the same tools. For setup, see Controlling Senzor from an AI agent.
Conventions
- Results are JSON objects. Clients that read only text get the same JSON as text.
- Errors come back as a tool result marked as an error, with a one-line message, and nothing changes. Arguments that do not match a tool's input schema fail the same way, with
failed to deserialize parameters: <reason>. Examples are a missing required argument, a key the project file does not know, ornullas a pin value. Other arguments a tool does not know are ignored, so check the spelling:get_messageswithinstance_idinstead ofinstancereturns every instance's messages. - Times are RFC 3339 in UTC with milliseconds, for example
2026-11-04T14:02:11.123Z. - Durations in project-file keys are strings with a unit, for example
"10s"or"500ms", as in the project file. - Passwords: every result shows the broker password as
<redacted>. Whenset_project,set_brokerorset(atbroker.password) receives<redacted>as the password, the stored password is kept. - Waiting for the host. A tool that changes something waits up to 10 seconds for Senzor to apply it. In the GUI, the window applies changes while it draws frames. When the time runs out, the tool fails with
the Senzor window did not respond within 10s; the request was cancelled and will not be applied(fromsenzor-cli mcp:Senzor did not respond within 10s; …). While Senzor shuts down, tools fail withSenzor is shutting down, and right after start withSenzor is still starting; try again.
Status values
status is an object whose state is one of:
state | Other keys | Meaning |
|---|---|---|
stopped | Not running. | |
connecting | First connection attempt of this run. | |
online | Connected; publishing on its interval. | |
reconnecting | attempt, last_error | Retrying after a network error. |
failed | reason | The broker refused the connection, or the instance crashed. Start it again to retry. |
Instance summary
get_status and get_instance describe an instance with these keys:
| Key | Meaning |
|---|---|
id | Instance ID, e.g. office-3. |
device | The [[devices]] entry it belongs to. |
status | See Status values. |
published | Messages published since the project was opened or the instance was added. Stopping and restarting do not reset it. |
received | Messages received on the instance's subscriptions, counted the same way as published. |
errors | Messages that could not be rendered or published, failed availability online messages and failed scripts, counted the same way as published. |
last_publish | Time of the last published message, or null. |
pinned | Fields forced to a value with pin. |
needs_restart | Running with older broker settings or availability than the project's, which need a new connection; restart applies them. |
orphaned | Running, but no longer in the project; it disappears once stopped. |
Edit result
The tools that change the project return:
| Key | Meaning |
|---|---|
changed | Whether the project changed. Replacing something with an identical copy changes nothing. |
problems | Every validation problem of the project now, each with location (e.g. device `office`) and message. |
blocked | Devices that cannot start because of problems. |
needs_restart | Running instances that now need a restart to use the project's broker settings or availability. |
orphaned | Running instances that are no longer in the project. |
Each edit that changes the project is one step that undo takes back. Edits never start, stop or restart an instance, and they do not write the file: use save_project. A running instance takes an edit at once and stays connected, unless the edit changes its broker settings or availability; then it is listed in needs_restart. See Editing while running.
Observing
get_status
The project and every instance. No arguments.
| Key | Meaning |
|---|---|
path | The project file, or null for a project that was never saved. |
dirty | The project has changes that are not saved. |
broker_host, broker_port | The broker the project connects to. |
problems | How many validation problems the project has; get_project lists them. |
open_error | Why the project file could not be opened when senzor-cli mcp started, or when you last used Open in the GUI, or null. A failed open_project returns its error instead. |
instances | Every instance of the devices that can start, plus running orphans, as an instance summary, sorted by ID. Devices blocked by problems have no instances here. |
get_instance
One instance with its values.
| Argument | Type | Meaning |
|---|---|---|
instance | string | Instance ID. Required. |
Returns the instance summary and:
| Key | Meaning |
|---|---|
template | The template the instance runs, or null for an orphan. |
fields | Every field the instance publishes. |
values | The latest value of each field: a number, true/false or a string. Empty before the first publish. |
Errors: there is no instance `<id>`.
get_messages
Published messages, oldest first. These are the messages your templates define, as in the GUI's message log. The log keeps the last 1,000 messages and does not include the online and offline availability messages.
| Argument | Type | Default | Meaning |
|---|---|---|---|
after_seq | integer | 0 | Only messages with a higher sequence number. Pass the last_seq of the previous call to get only new messages. |
instance | string | Only messages of this instance. | |
device | string | Only messages of this device's instances. | |
topic_contains | string | Only messages whose topic contains this text (case-sensitive). | |
limit | integer | 100 | At most this many, from 1 to 1000; other values are clamped to that range. When more match, the newest are returned. |
wait_seconds | number | 0 | When no message matches yet, wait up to this long (at most 30; larger values count as 30, negative ones as 0) for one. The call returns as soon as one arrives. |
| Key | Meaning |
|---|---|
messages | Each with seq, time, instance, topic, payload, qos and retain, plus the MQTT 5 properties the message was sent with: message_expiry (seconds), content_type and user_properties (an object of rendered values). Properties the message did not set are left out. A message with a binary encoding has no payload; it has encoding (hex, base64, cbor or protobuf), payload_base64 (the bytes sent, in standard base64) and rendered (the text they were encoded from) instead. |
last_seq | The highest sequence number assigned so far. Sequence numbers keep growing when another project is opened. |
truncated | Messages after after_seq left the 1,000-message log before they could be read. |
list_templates
The built-in templates, then the project's own. No arguments.
| Key | Meaning |
|---|---|
templates | Each with id, builtin, interval (e.g. 10s), topics, fields (field name to generator, e.g. random_walk) and used_by (the devices that use it). |
get_project
The project as TOML. No arguments.
| Key | Meaning |
|---|---|
toml | The project as Save writes it, with the password shown as <redacted>. |
path | The project file, or null. |
dirty | The project has changes that are not saved. |
problems | Every validation problem, each with location and message. |
blocked | Devices that cannot start because of problems. |
Running devices
start, stop, kill and restart take the same arguments. Give exactly one of all, devices and instances.
| Argument | Type | Default | Meaning |
|---|---|---|---|
all | boolean | true for every instance. | |
devices | list of strings | Device IDs: every instance of each. | |
instances | list of strings | Instance IDs. | |
wait_seconds | number | 5 | Wait up to this long (at most 60; larger values count as 60, negative ones as 0) for the instances to settle. 0 returns at once. |
They return:
| Key | Meaning |
|---|---|
instances | Each affected instance with its id and status. The status is null for an orphan that left once it stopped. |
timed_out | Some instances had not settled when the wait ran out. Always false with wait_seconds = 0. |
Errors, shared by all four:
a target is required: give exactly one of all = true, devices or instancesunknown device id(s): <ids>orunknown instance id(s): <ids>. Nothing is sent when any ID is unknown. Forstop,killandrestart, running orphans and their device IDs count as known.
start
Starts stopped and failed instances; running ones are left alone. It waits until each instance is online, failed or reconnecting, so check the returned statuses.
Errors: device `<id>` has validation errors and cannot start; get_project lists them. This error is returned only when you name the blocked device in devices. An instance of a blocked device, named in instances, is reported as unknown, and all = true skips blocked devices.
stop
Stops running instances gracefully. Each publishes its offline message, if its template has availability, and disconnects, so the broker does not publish its Last Will. It waits until they are stopped.
kill
Drops the connections of running instances without a goodbye, as a device that loses power. The broker publishes the Last Will of each instance whose template has availability. It waits until they are stopped. See Simulating a device dropping off.
restart
Stops running instances gracefully and starts them again with the project's current settings. Stopped instances are started. Orphans are only stopped. It waits until the new run is online, failed or reconnecting.
Errors: the same as start for devices with validation errors.
pin
Forces a field of a running instance to a value, as Pin does in the instance view. The instance publishes that value until it is unpinned or stops.
| Argument | Type | Meaning |
|---|---|---|
instance | string | Instance ID. Required. |
field | string | Field name, e.g. co2. Required. |
value | number, boolean or string | The value to publish. Required. |
Returns instance and pinned, the instance's pinned fields.
Errors:
there is no instance `<id>`instance `<id>` is not running; start it firstinstance `<id>` has no field `<field>`; its fields are: <fields>
unpin
Lets pinned fields follow their generators again.
| Argument | Type | Meaning |
|---|---|---|
instance | string | Instance ID. Required. |
field | string | The field to unpin. Without it, every pinned field of the instance. |
Returns and errors as pin.
Editing the project
All of these return the edit result.
set_project
Replaces the whole project with TOML text.
| Argument | Type | Default | Meaning |
|---|---|---|---|
toml | string | The whole project file. Required. | |
dry_run | boolean | false | Only report the problems the text would have; change nothing. |
Text with a TOML syntax error, an unknown or missing key, or a value of the wrong type is refused, and the project stays as it was. The error names the problem and its position, for example line 2, column 1: unknown field `hots`, expected one of …. Text that parses but has validation problems is applied; the problems come back in the result.
set
Changes one value anywhere in the project, without passing the whole device, template or broker.
| Argument | Type | Meaning |
|---|---|---|
path | string | Where the value goes, as a key path. Required. |
value | any JSON except null | The new value, of the type the key takes: a string, number or boolean, or an object or list for a key that holds a table or list. Durations are strings, e.g. "30s". Required. |
{ "path": "templates.office-air.fields.co2.max", "value": 900 }Tables missing on the way are created: devices.lab.params.room works on a device without params. The number after the last message adds a message: with two messages, set templates.office-air.messages.3 to an object with topic and payload. A value that is already there changes nothing (changed is false).
A path to a device or template sets all of it, as put_device or put_template would, and keeps its id. To change an id, use rename_device or rename_template.
Errors, after which nothing has changed:
- A value of the wrong type, or an unknown key, with the path and what the key takes:
cannot set `devices.office.count`: invalid type: string "many", expected u32,cannot set `devices.office.colour`: unknown field `colour`, expected one of …. - A path that names nothing:
the project has no device `<id>` (put_device adds one),the project has no template `<id>` (put_template adds one), the built-in template error ofrename_template,`<path>` is a list: number its entries from 1 to <n>, or <n+1> to add one,`<path>` holds an integer, which has no key `<key>`. - An id:
`devices.<id>.id` is the device's id; change it with rename_device, and the same for templates. null:null is not a value in the project file; unset removes a key.- A path that cannot be read:
`<path>` is not a path: <why>; a path is …, followed by examples.
unset
Removes one key, so its default applies, or removes one message.
| Argument | Type | Meaning |
|---|---|---|
path | string | The key to remove, as a key path. Required. |
For example, devices.office.count goes back to 1, templates.office-air.interval to 10s and broker.port to 1883, and devices.office.params.room leaves the device without that parameter. templates.office-air.messages.2 removes the second message.
Errors, after which nothing has changed:
- A key the project file requires:
cannot unset `devices.office.template`: missing field `template`. - A key that is not set:
`<path>` is not set, so there is nothing to unset (get_project shows the project). - A whole device or template:
unset removes a key; remove_device removes the device `<id>`, and the same for templates. - The path errors of
set.
Key paths
set and unset address a value by the keys of the project file joined by dots:
- Devices and templates by their
id:devices.office.count,templates.office-air.interval. - Messages by number, starting at 1, as validation problems count them:
templates.office-air.messages.1.payload.messages[1], as the problems write it, works too. - Everything else by key:
broker.port,broker.tls.ca_file,simulation.seed,devices.office.params.room,devices.office.fields.co2.max(a field override),templates.office-air.fields.co2.max,templates.office-air.messages.1.user_properties.room. - A key with a dot or a space goes in double quotes:
devices.office.params."floor.level".
Built-in templates cannot be changed; copy one with copy_builtin_template first.
put_device
Adds a device, or replaces the device with the same id. The arguments are the keys of a [[devices]] table: id, template, count, instance_id, params, autostart, interval and fields, with the same defaults as in the project file. A field override in fields merges as in a field override of the project file: it can set generator parameters, unit and name.
{ "id": "lab", "template": "temperature", "count": 3, "autostart": false }rename_device
| Argument | Type | Meaning |
|---|---|---|
from | string | Current device ID. Required. |
to | string | New device ID. Required. |
Errors: the project has no device `<id>`, a device `<id>` already exists, the name must not be empty.
remove_device
| Argument | Type | Meaning |
|---|---|---|
id | string | Device ID. Required. |
Running instances of the device become orphans: they keep running until stopped. Errors: the project has no device `<id>`.
put_template
Adds a template to the project, or replaces the project template with the same id. The arguments are the keys of a [[templates]] table: id, interval, qos, retain, home_assistant, availability, messages, fields and subscriptions. Messages can set the MQTT 5 keys message_expiry, content_type and user_properties, and availability can set will_delay, as in the project file. Each field is its generator table and can add a unit and a name, as in the project file; a field can run a script. Each subscription is an object with topic, qos and script, as in the project file.
{
"id": "door",
"interval": "5s",
"messages": [{ "topic": "home/{{ device_id }}/contact", "payload": "{{ open }}" }],
"fields": { "open": { "generator": "sequence", "values": [true, false], "name": "Door open" } }
}Errors: `<id>` is a built-in template id; use another id, or copy_builtin_template.
rename_template
| Argument | Type | Meaning |
|---|---|---|
from | string | Current template ID. Required. |
to | string | New template ID. Required. |
The devices that use the template are changed to the new ID.
Errors: the project has no template `<id>`, `<id>` is a built-in template; built-ins cannot be changed (copy_builtin_template copies one into the project), a template `<id>` already exists, `<id>` is a built-in template id, the name must not be empty.
remove_template
| Argument | Type | Meaning |
|---|---|---|
id | string | Project template ID. Required. |
Devices that still use the template get a validation problem and cannot start. Errors as rename_template for unknown and built-in IDs.
copy_builtin_template
Copies a built-in template into the project, so it can be changed.
| Argument | Type | Meaning |
|---|---|---|
builtin | string | co2, temperature or humidity. Required. |
new_id | string | The copy's ID. Required. |
Errors: unknown built-in template `<id>`, a template `<id>` already exists, `<id>` is a built-in template id, the name must not be empty.
set_broker
Replaces the broker settings. The arguments are the keys of the [broker] table: host, port, client_id_prefix, keep_alive, mqtt_version, transport, path, session_expiry, username, password, password_env and tls. Omitted keys take their defaults, as in the project file: an omitted mqtt_version is "5", and an omitted username, password, password_env or tls is removed. To change one setting, pass every key get_project shows under [broker]; pass password = "<redacted>" to keep the stored password. Every running instance needs a restart to use the new settings.
Undo and redo
undo and redo step through the project's history in whichever program serves the tools. In the GUI it is the window's own history, the one Undo and Ctrl+Z use: an agent's undo can take back an edit the user made in the window, and the user's Ctrl+Z an agent's edit. Each tool call that changes the project is one step. Opening a project or starting a new one starts a new history, which keeps the last 100 steps.
Running instances take an undo or redo as they take an edit; see the edit result.
undo
Takes back the latest change to the project. No arguments.
Returns the edit result, with changed always true, and:
| Key | Meaning |
|---|---|
broker | The step changed the broker settings. |
simulation | The step changed the [simulation] settings. |
devices | Devices the step added, removed or changed. A rename lists both IDs. |
templates | Project templates the step added, removed or changed. |
can_undo | Another undo is possible. |
can_redo | A redo is possible. |
Errors: there is nothing to undo: the history starts when the project is opened or created.
redo
Applies again the change the latest undo took back. This is possible until the next edit. No arguments. Returns as undo.
Errors: there is nothing to redo: redo applies again what undo took back, until the next edit.
Files
new_project
Replaces the project with an empty, untitled one. The current instances stop gracefully.
| Argument | Type | Default | Meaning |
|---|---|---|---|
discard_unsaved | boolean | false | Throw away unsaved changes. |
Returns path (null), problems, blocked and instances (the instance IDs of the project).
Errors: the project has unsaved changes; save it first, or pass discard_unsaved = true. In the GUI, while a dialog is open: the Senzor window is waiting for the user to answer a dialog; try again once it is closed.
open_project
Opens a project file. The current instances stop gracefully, and the new project's devices with autostart = true start once they have stopped, as when you open a project in the GUI.
| Argument | Type | Default | Meaning |
|---|---|---|---|
path | string | Project file. Required. A relative path starts at Senzor's working directory. | |
discard_unsaved | boolean | false | Throw away unsaved changes. |
autostart | boolean | true | Start the devices with autostart = true. |
Returns as new_project. A file with validation problems opens; its problems come back in the result.
Errors: those of new_project, cannot read <path>: <reason>, and the problem of a file that does not parse (a TOML syntax error, an unknown or missing key, or a wrong type). In that case the current project keeps running.
save_project
Writes the project as canonical TOML, the same way Save does in the GUI (see Files).
| Argument | Type | Default | Meaning |
|---|---|---|---|
path | string | Save as this file, which then becomes the project's file. .toml is added when the name does not end with it. A relative path starts at Senzor's working directory. Without path, the project's own file. | |
overwrite | boolean | false | Replace an existing file other than the project's own. |
Returns path, the absolute path written.
Errors:
the project has no file yet; pass a path to save it as<path> already exists; pass overwrite = true to replace itcannot write <path>: <reason>- In the GUI, while a dialog is open:
the Senzor window is waiting for the user to answer a dialog; try again once it is closed
Resources and subscriptions
Three resources show what changes while Senzor runs, as JSON:
| URI | Content | Changes when |
|---|---|---|
senzor://project | What get_project returns: toml, path, dirty, problems and blocked. | The project is edited (by the agent or in the window), saved, opened or replaced. |
senzor://instances | instances: each with id, device, status, pinned, needs_restart and orphaned. The counters and values are in get_status and get_instance. | An instance starts, connects, drops off, stops or fails, a pin changes, or an edit adds or removes instances. |
senzor://messages | The newest 100 messages and last_seq, as get_messages without arguments returns them. | An instance publishes. |
These read-only references never change, so an agent can write templates without guessing:
| URI | Content |
|---|---|
senzor://reference/project-file | The project file reference. |
senzor://reference/generators | The generators reference. |
senzor://reference/template-variables | The template variables reference. |
senzor://reference/scripts | Scripts and commands: field scripts, subscriptions, state and the functions scripts can call. |
senzor://reference/builtin-templates | The built-in templates co2, temperature and humidity as TOML. |
An agent can subscribe to a resource instead of polling. Clients of MCP versions before 2026-07-28 send resources/subscribe and resources/unsubscribe. Newer clients list the URIs in a subscriptions/listen request and cancel it to stop. Senzor then sends notifications/resources/updated with the URI after each change, and the agent reads the resource or calls a tool to see what changed:
- An update comes at most every 250 ms per resource. Changes inside that time are sent together in one update when it ends, so the last change of a burst is never missed. With 500 instances publishing,
senzor://messagessends four updates a second. - An update says only that the resource changed. Call
get_messageswithafter_seqto get every new message, not only the newest 100. - Subscribing to an unknown URI fails with
no resource `<uri>`. Asubscriptions/listenrequest accepts only the URIs it knows, and its acknowledgment lists them. Subscribing to a reference page works, but it never sends an update. - Subscriptions end with the connection.
Prompts
Prompts are ready-made first messages that set the agent to work. A client shows them as commands; Claude Code names them /mcp__<server>__<prompt>, for example /mcp__senzor__simulate-device when the server is registered as senzor.
| Prompt | Argument (required) | What the agent is asked to do |
|---|---|---|
simulate-device | device: the real device to imitate, with what it measures, how often it reports, and its topics and payload format if you know them. | Read the references, create a template with put_template (or start from a built-in one), add a device with put_device, start it and check its messages. It says which details it guessed and does not save. |
test-consumer | expectation: what the program that consumes the messages should do in reaction to the values. | Start the instances, force values with pin, confirm with get_messages that they went out, take devices away with kill or stop, check how the consumer reacted, then unpin and report each case. |
explain-problems | None. | Read the problems with get_project, explain each one, fix them with the editing tools and check that none are left. It does not save. |
A missing or empty required argument fails with prompt `<name>` needs the argument `<argument>`, and an unknown name with there is no prompt `<name>`.