About Saihub
Saihub is an MCP server published by xqe2011 in the Blockchain category: give your agent a hand: MIT-licensed ESP32-C5 IO board that speaks MCP, so Cursor, Claude Code & Codex can drive GPIO, PWM, UART and power on real hardware. Conduid read 44 tools from its source: check_system_ota, configure_dap, configure_i2c, configure_pins, configure_spi, configure_uart and 38 more. No package is published for it, so it installs from a source checkout.
The repository has 11 stars and 2 forks, and its last commit was on 22 Nov 2026. Conduid has no tagged release on record for it. Its topics include esp-idf, esp32, gpio-pins, logic-analyzer, lua and pwm-controller.
Install
git clone https://github.com/xqe2011/saihubTools (44)
check_system_otaCheck the published update manifest for a newer firmware image for this device. Side-effect-free; does not store the result. When an update is available, returns version, changelog, url, and sha256 for upgrade_system_ota.configure_dapConfigure CMSIS-DAP. When enable is true, pins.swclk and pins.swdio are required and the TCP service starts. pins.nreset may be null.| Parameter | Type | Description |
|---|---|---|
| enable * | boolean | |
| lockId | string | Required when another lock holds the pins. |
| pins * | object |
configure_i2cConfigure one I2C controller by id. role is master or slave. pullUp and addressBits (7 or 10) are required. clockHz and sclWaitUs are required for master and must be omitted for slave. address is required for slave and must be omitted for master. sda and scl are required when enable is true.configure_pinsConfigure one or more pins. Always pass pins (e.g. pins:[1]).| Parameter | Type | Description |
|---|---|---|
| lockId | any | |
| mode * | any | |
| openDrain | boolean | Allowed for digitalOutput, digitalInputOutput, and pwmOutput |
| pins * | any | |
| pullDown * | boolean | |
| pullUp * | boolean |
configure_spiConfigure one SPI controller by id. role is master or slave. cpol and cpha are each 0 or 1. bitOrder is msb or lsb. clockHz is required for master and must be omitted for slave. clk and cs are required when enable is true. mosi and miso may be null.configure_uartConfigure one UART by id. mode native (default) requires baudRate, dataBits, parity, stopBits, and encoding. In rfc2217 mode, pass only id, enable, pins, and mode. The TCP client sets framing. When enable is true, at least one of pins.rx or pins.tx is required.| Parameter | Type | Description |
|---|---|---|
| baudRate | integer | |
| dataBits | integer | |
| enable * | boolean | |
| encoding | any | |
| id * | any | |
| lockId | any | |
| mode | string | Default native. rfc2217 rejects baudRate, dataBits, parity, stopBits, and encoding. |
| parity | any | |
| pins * | any | |
| stopBits | integer |
create_lockCreate a soft multi-agent exclusion lock so concurrent agents do not race on the same resources. expiresAt only auto-frees abandoned locks inside the lock manager; other APIs do not key behavior off that timestamp beyond whether the resource is currently held. Each resource is type pin with pins, type power with rails, type uart with ids, type spi with ids, or type i2c with ids.| Parameter | Type | Description |
|---|---|---|
| resources * | array |
delete_lockDelete a lock by id (idempotent).| Parameter | Type | Description |
|---|---|---|
| id * | string |
get_cloud_statusReturn whether the device is connected and authenticated to the cloud relay, the public landingPageUrl (empty when cloud relay is disabled), and a reason when not connected.get_dap_statusRead the CMSIS-DAP status. prompt explains how to connect.get_output_power_stateRead 3v3 or 5v rail enable state. Overcurrent, overtemperature, or reverse-voltage turns the rail off and sets reason; the next enable clears it.| Parameter | Type | Description |
|---|---|---|
| lockId | any | |
| rail * | any |
get_pin_levelsRead digital levels for pins. Returns levels array in pins order.| Parameter | Type | Description |
|---|---|---|
| lockId | any | |
| pins * | any |
get_pin_pwmsRead PWM frequency and duty for pins (pwmOutput only).| Parameter | Type | Description |
|---|---|---|
| lockId | any | |
| pins * | any |
get_system_infoReturn Authentication Digest, firmware version, compiled date, CPU usage percent, free heap, and minimum free heap since boot.get_system_otaReturn live firmware update status: idle, upgrading, or failed (with optional progressPercent and reason). Does not include last check results.get_system_timeReturn the device wall clock as unix seconds with millisecond fraction immediately. The clock is NTP-synced; compare with the client clock to estimate round-trip latency.get_uart_rfc2217_statusRead RFC2217 status for one UART. prompt explains how to connect. Fails when that UART is not enabled in rfc2217 mode.| Parameter | Type | Description |
|---|---|---|
| id * | any |
i2c_master_transceiveTransfer on an enabled master. address range follows bus addressBits (0-127 for 7, 0-1023 for 10). write is even-length hex (0-255 bytes). readLen is 0-255. timeoutMs is optional (default 1000, range 1-60000). Empty write with readLen 0 probes the address. write then read uses a repeated start.| Parameter | Type | Description |
|---|---|---|
| address * | integer | Device address. Max 127 when bus addressBits is 7, max 1023 when addressBits is 10. |
| id * | any | |
| lockId | any | |
| readLen * | integer | |
| timeoutMs | integer | Transfer wait timeout in milliseconds. Default 1000 when omitted. |
| write * | string | Even-length hexadecimal bytes. An empty string is zero bytes. |
i2c_slave_receiveDrain events from an enabled slave. Each event has startTime, endTime, receive, and send. When the buffer is full, the oldest events are discarded.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any |
i2c_slave_transmitReplace the slave response map. type is exact or prefix. Match exact first, then the longest prefix. An empty prefix matches every receive. Requires an enabled slave.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any | |
| mapping * | array |
list_i2csList I2C ids with enable, role, pullUp, addressBits, pins, clockHz and sclWaitUs when role is master, and address when role is slave.list_pinsList logical pins 0-7 with mode, pulls, and level.list_spisList SPI ids with enable, role, cpol, cpha, bitOrder, pins, and clockHz when role is master.list_uartsList UART ids with enable, mode, baud, framing, encoding, and pins.play_buzzerPlay a Morse-style sequence on the onboard buzzer and wait until it finishes. `.` is a short beep, `-` is a long beep, space is an extra gap. One sequence at a time.| Parameter | Type | Description |
|---|---|---|
| sequence * | string | Morse-style pattern. `.` short, `-` long, space extra gap. |
pulse_pinsPulse one or more pins for width microseconds.| Parameter | Type | Description |
|---|---|---|
| level * | any | |
| lockId | any | |
| pins * | any | |
| width * | integer | Microseconds |
reboot_systemRestart SAIHub System itself(the host of this MCP and REST API, NOT the board under test). SAIHub goes offline for a while; all sessions and runtime state are lost.renew_lockRenew a lock TTL by id.| Parameter | Type | Description |
|---|---|---|
| id * | string |
run_scriptRun a sandboxed Lua 5.4 script on-device. The script can call the same pin/power/UART/SPI/lock tools as MCP (not run_script). Optional maxCalls and timeout (microseconds) must not exceed firmware ceilings. One script at a time.
Lua 5.4. Allowed libraries: base, table, string, math, utf8. require, dofile, loadfile, load, and collectgarbage are nil. No io, os, package, debug, or coroutine.
Each tool is a global that takes one argument table with the same keys as MCP (always pass pins even for one pin). JSON arrays become 1-based Lua tables. sleep(us) delays in microseconds and counts toward timeout, not maxCalls. print() is captured as output. The first return value is result (JSON).
Errors raise a table {reason="..."}. Catch with pcall and read err.reason. Uncaught errors fail the request with that reason; print output is discarded.
Catchable with pcall:
- Tool failure: system sentence (no "The script reported" prefix), e.g. pin/lock/mode errors
- error("msg"): "The script reported an error: msg. Catch it with pcall or fix the script."
- error() or error(""): "The script called error with no message. Catch it with pcall or fix the script."
Not catchable (abort the whole run even if pcall returns):
- timeout: "Script exceeded timeout."
- maxCalls: "Script exceeded maxCalls."
- out of memory: "Script ran out of memory."
- syntax or uncaught Lua runtime: "The script failed: <message>. Catch it with pcall or fix the script."
Example:
configure_pins{pins={0}, mode="digitalOutput", pullUp=false, pullDown=false}
set_pin_levels{pins={0}, level=1}
sleep(5000)
local r = get_pin_levels{pins={0}}
print("level", r.levels[1])
return r
Error handling:
local ok, err = pcall(function()
set_pin_levels{pins={0}, level=1}
end)
if not ok then
return {ok=false, reason=err.reason}
end| Parameter | Type | Description |
|---|---|---|
| lockId | any | |
| maxCalls | integer | Max tool invocations this run |
| script * | string | Lua 5.4 source. Allowed libraries: base, table, string, math, utf8. |
| timeout | integer | Wall-clock budget in microseconds |
set_output_power_stateSet 3v3 or 5v rail enable state.| Parameter | Type | Description |
|---|---|---|
| enable * | boolean | |
| lockId | any | |
| rail * | any |
set_pin_levelsWrite digital level for one or more pins.| Parameter | Type | Description |
|---|---|---|
| level * | any | |
| lockId | any | |
| pins * | any |
set_pin_pwmsSet PWM frequency and duty for pins (pwmOutput only).| Parameter | Type | Description |
|---|---|---|
| duty * | number | Percent, decimals allowed |
| frequency * | number | Hz. Very low frequencies may be rejected. |
| lockId | any | |
| pins * | any |
spi_master_transceiveClock bytes on an enabled master. data is an even-length hex string of 0-255 bytes. Non-empty data requires pins.mosi. When pins.miso is unset, data in the result is "".| Parameter | Type | Description |
|---|---|---|
| data * | string | Even-length hexadecimal bytes. An empty string is zero bytes. |
| id * | any | |
| lockId | any |
spi_slave_receiveDrain events from an enabled slave with pins.miso set. Each event has startTime, endTime, receive, and send. When the buffer is full, the oldest events are discarded.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any |
spi_slave_transmitReplace the slave response map. type is exact or prefix. Match exact first, then the longest prefix. An empty prefix matches every receive. Requires an enabled slave with pins.mosi set.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any | |
| mapping * | array |
trace_pinsCapture edge events on one or more pins.| Parameter | Type | Description |
|---|---|---|
| duration | integer | Microseconds (max 60 seconds). Default 1000000. |
| edge | any | |
| lockId | any | |
| pins * | any |
uart_flushDiscard the UART receive buffer without returning it.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any |
uart_get_dtrRead the active-low UART DTR state.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any |
uart_get_rtsRead the active-low UART RTS state.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any |
uart_receiveDrain the UART receive buffer and return data using the configured encoding.| Parameter | Type | Description |
|---|---|---|
| id * | any | |
| lockId | any |
uart_set_dtrSet the active-low UART DTR state.| Parameter | Type | Description |
|---|---|---|
| active * | boolean | True asserts DTR (pin low). False releases DTR (pin high). |
| id * | any | |
| lockId | any |
uart_set_rtsSet the active-low UART RTS state.| Parameter | Type | Description |
|---|---|---|
| active * | boolean | True asserts RTS (pin low). False releases RTS (pin high). |
| id * | any | |
| lockId | any |
uart_transmitTransmit data on a UART. data is a UTF-8 string when encoding is utf8, or an even-length hex string when encoding is byte.| Parameter | Type | Description |
|---|---|---|
| data * | string | UTF-8 text when encoding is utf8; even-length hex when encoding is byte. |
| id * | any | |
| lockId | any |
upgrade_system_otaStart a background firmware upgrade. Requires url and sha256 from check_system_ota. Verifies the image digest before writing. Non-system APIs return 503 while upgrading. Device reboots on success.| Parameter | Type | Description |
|---|---|---|
| sha256 * | string | Expected app image digest (64 hex chars) |
| url * | string | HTTPS URL of the app firmware image |
Security checks
6 checks have not been run yet.