ctrlpi-mcp

v0.9.52
io.github.ctrlpi/ctrlpi-mcp Checked 13 hours ago Published 1 day ago

MCP server to control Raspberry Pi, Pico W and ESP32 GPIO agents from an AI assistant.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

mcp_agents_list List agents

List configured agents (Pi, Pico or ESP32). Returns name, ip, port, online (live /hello probe), type (pi/pico/esp32), version, has_default_key, and last_updated_at (UTC "YYYY-MM-DD HH:MM:SS", when the agent list was last saved; every sweep saves it). Unreachable agents are included (online=false). The LAN is swept automatically every hour. Pass rescan=true to sweep it now, but only when the user asks to find new hardware: a sweep takes 10 seconds or more. If has_default_key is true for any agent, tell the user that agent is on the insecure default key and ask whether to change it.

ParameterTypeDescription
rescanboolean

mcp_gpio_read Read a pin

Read a GPIO pin value on `agent` by number or name, or 'all' to read all pins.

ParameterTypeDescription
agent *string
name_or_gpio *string

mcp_gpio_write Write a pin

Write a value to a GPIO pin on `agent` ('0', '1', 'on', 'off', or 'toggle'). Optional duration in seconds, after which the pin reverts to its previous state. If the pin has a configured 'max' pulse duration, the effective duration is clamped to it - and if no duration is given but 'max' is set, 'max' is used as the duration automatically.

ParameterTypeDescription
agent *string
name_or_gpio *string
value *string
durationnumber

mcp_gpio_scan Scan all pins

Scan all hardware GPIO pins on `agent` and return each pin's level (the physical state), type, pull resistor and name; a reversed pin also reports `value` (its logical state) and `reversed`. Pins: BCM 2-27 on a Raspberry Pi, GP0-GP28 (minus the WiFi-reserved GP23/24/25/29) on a Pico, and every usable pin of the chip on an ESP32 (flash, PSRAM and USB pins are left out).

ParameterTypeDescription
agent *string

mcp_gpio_config Configure a pin

Configure a GPIO pin on `agent` by number. type: input/output/vcc/gnd/remove. init: 0/1/last. pullup: up/down/none (input only). max: max pulse duration in seconds (output only). reversed: active-low logic (input/output only). watched: trigger webhook on state change (logged on the agent if no notifications.webhook is configured). script: a script from the agent's scripts folder to run when the pin's value changes (input/output only), "[on:|off:]<file> [args]": "on:" runs it only when the pin goes to 1, "off:" only when it goes to 0 (no value is passed), and with no prefix it runs on both and…

ParameterTypeDescription
agent *string
gpio *string
initstring
maxnumber
namestring
pullupstring
reversedboolean
scriptstring
typestring
watchedboolean

mcp_gpio_watched List watched pins

List the GPIO pins that are currently being actively watched (the ones emitting hardware interrupts/webhooks).

ParameterTypeDescription
agent *string

mcp_sensor_config Configure a sensor

Configure a named sensor on `agent`. A sensor runs a script and its output is the reading. `script` is "<script-file> [args...]": a bare filename in the agent's scripts/ folder (no paths - that folder is the only allowed location), with letters/digits-only arguments. On a Raspberry Pi a .py runs with the agent's Python and anything else with `sh`; on a Pico or ESP32 the .py file is exec'd in-process and its read(*args) or `result` is the reading. Pass remove=true to delete the sensor.

ParameterTypeDescription
agent *string
name *string
removeboolean
scriptstring

mcp_sensor_read Read sensors

Read sensors on `agent`. With no `name`, reads every configured sensor and returns them merged into one JSON object; with a `name`, reads just that sensor. Every reading is nested under its sensor's own name: a script emitting a JSON object with several fields nests whole, one emitting a single-field object contributes just that field's value, and any other output is wrapped the same way.

ParameterTypeDescription
agent *string
namestring

mcp_script_list List scripts

List the files in `agent`'s scripts/ folder (the folder sensors run from): `scripts` ([{name, size, modified}]) and `write`: "enabled", "default_key" (writes are refused until the agent's api_key is changed from the default) or "locked" (a write.lock file there blocks every write).

ParameterTypeDescription
agent *string

mcp_script_read Read a script

Read one file from `agent`'s scripts/ folder. Returns {name, content}.

ParameterTypeDescription
agent *string
name *string

mcp_script_write Write or delete a script

Create or overwrite a file in `agent`'s scripts/ folder with `content`, or delete it with remove=true. `name` is a bare filename of up to 32 characters (letters, digits, . _ -, no leading dot or dash, no paths). Refused while the agent still has the default api_key, and once a write.lock file is in the folder. Writing write.lock (any content) locks every script write, and this tool can then no longer change or remove it. The lock does not stop runs: a script run with mcp_script_run that deletes files can remove write.lock, as can a shell (Pi) or USB (Pico, ESP32).

ParameterTypeDescription
agent *string
name *string
contentstring
removeboolean

mcp_script_run Run a script

Run a file from `agent`'s scripts/ folder and return {name, exit_code, output}. On a Raspberry Pi a .py runs with the agent's Python and anything else with `sh`; output is its stdout (first 2 KB) and a run over 15 s is killed. On a Pico or ESP32 the file is exec'd in-process: output is what its read(*args) returns, or its `result`, and exit_code is 1 if it raised. `args` are letters and digits only.

ParameterTypeDescription
agent *string
name *string
argsarray

mcp_config_read Read agent config

Read `agent`'s global application configuration (`agent` is a name from mcp_agents_list), grouped: `notifications` (`webhook` + `webhook_key`), `bridges` (matter/homekit/homebridge callbacks), `settings` (docs_enabled, logs_enabled, log_days), `sensors`, and configured pins (`gpios`). The `agent` block (platform, os, ip, cpu_temperature, version) is computed live on every read and is not stored. Change the name, key, webhook and settings with mcp_config_write; mcp_config_load replaces the whole config.

ParameterTypeDescription
agent *string

mcp_config_write Update agent config

Update `agent`'s global configuration dynamically. These are the ungrouped (root) field names; the agent routes each into its group (webhook_url -> notifications.webhook, webhook_key -> notifications.webhook_key, docs_enabled/logs_enabled/log_days -> settings), so a read afterwards shows them nested. log_days controls how long log entries are kept (0-30, clamped; 0 clears the log immediately and keeps only the last hour). docs_enabled is Pi-only. Changing api_key changes the agent's authentication key immediately, and also updates the local agents-config.json file to match automatically.

ParameterTypeDescription
agent *string
api_keystring
docs_enabledboolean
log_daysnumber
logs_enabledboolean
namestring
webhook_keystring
webhook_urlstring

mcp_config_load Replace agent config

Load a full config onto `agent` from a dict (the agent saves a backup first). Pass an empty dict {} to reset all settings on the agent keeping only its API key.

ParameterTypeDescription
agent *string
config *object

mcp_agent_restart Restart or reboot an agent

Restart `agent`'s server process. Pass reboot=true to reboot the whole device instead (a Pi, Pico or ESP32); an agent running on a Mac ignores it and restarts the process.

ParameterTypeDescription
agent *string
rebootboolean

mcp_agent_upgrade Upgrade an agent

Upgrade `agent` to the latest release, then restart it. A Pi runs `install.sh --upgrade` (re-downloads the release files and reinstalls dependencies); a Pico or ESP32 downloads the new files over WiFi, swaps them in and resets.

ParameterTypeDescription
agent *string

mcp_agent_logs Read agent log

Read the last 50 lines of `agent`'s server log (30 on a Pico or ESP32; `agent` is a name from mcp_agents_list). Use it to see why a call to the agent failed.

ParameterTypeDescription
agent *string

mcp_bridge_config_read Read bridge config

Read the config of a smart home bridge on the host ctrlpi-mcp runs on. `bridge`: `matter` (ctrlpi-matter, `matter-config.json`) or `homekit` (ctrlpi-homekit, `homekit-config.json`), both in ctrlpi-mcp's config folder, or `homebridge` (the plugin's `ctrlPi` platform entry in Homebridge's `config.json`, nothing else of that file). `what`: `config` (default) returns the config with every key masked as `********` and a `hash` to pass to mcp_bridge_config_write; `pairing` returns the pairing codes (`matter.json` / `homekit.json`, or Homebridge's bridge name and PIN); `fields` returns the reference…

ParameterTypeDescription
bridge *string
whatstring

mcp_bridge_config_write Write bridge config

Replace the config of a smart home bridge on this host (`bridge` as in mcp_bridge_config_read). `config` is the whole new config (for `homebridge`, the whole `ctrlPi` platform entry; the rest of Homebridge's file stays as it is), and `hash` the one mcp_bridge_config_read returned: the write is refused if the file changed since (no hash is needed when the file does not exist yet). Read first, change what is needed, send it all back; a key left as `********` keeps the stored one. The old file is kept as `<file>.bak`. ctrlpi-matter and ctrlpi-homekit restart with the new config by themselves abou…

ParameterTypeDescription
bridge *string
config *object
hashstring