Modbus TCP/RTU Device

v0.1.3
io.github.K-Dense-AI/labmcp-modbus Checked 1 day ago Published 2 months ago

MCP server for Modbus TCP/RTU devices with typed, scaled register maps and per-point limits.

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

get_connection_info Get Connection Info

Report which instrument is connected (identity, address, simulated or real), whether the server is read-only, and the active safety limits. Call this first.

get_command_log Get Command Log

Return the most recent raw commands sent to / replies received from the instrument (newest last). Useful for debugging and for recording what was done.

ParameterTypeDescription
limitinteger

reconnect Reconnect

Close and re-open the connection to the instrument (e.g. after it was power cycled or a cable was re-plugged).

list_points List Points

Describe the loaded register map: device, every named point (table, 0-based address, type, scaling, unit, writable, min/max, enum) and the safe-state steps. Works without a connection.

read_points Read Points

Read named points from the register map, decoded and scaled into engineering units (e.g. process_temperature = 25.1 °C). A point that cannot be read gets an `error` instead of failing the whole call.

ParameterTypeDescription
namesPoint names from list_points; omit for all points

read_registers Read Registers

Read raw holding or input registers (unsigned 16-bit), optionally decoded as int16, 32-bit or 64-bit values. For exploring a device; prefer read_points when a register map describes it.

ParameterTypeDescription
address *integer0-based start address
byte_orderstringbig = standard Modbus byte order
countintegerNumber of registers
decode_asstringAlso decode the registers as this type
tablestringholding (FC03) or input (FC04)
word_orderstring32/64-bit: big = high word first

read_coils Read Coils

Read coils (FC01): single-bit outputs such as run/stop or relay states.

ParameterTypeDescription
address *integer0-based start address
countintegerNumber of coils

read_discrete_inputs Read Discrete Inputs

Read discrete inputs (FC02): single-bit, read-only status such as alarms or limit switches.

ParameterTypeDescription
address *integer0-based start address
countintegerNumber of inputs

write_point Write Point

Write a named point from the register map (setpoint, mode, output enable...). The value is checked against the point's writable flag, min/max or enum BEFORE sending, converted to raw registers, written, then read back. Changing setpoints and outputs acts on real equipment. If the write succeeds but the read-back fails, `read_back_error` says why.

ParameterTypeDescription
name *stringA writable point from list_points
value *Engineering value (e.g. 37.5 for °C), true/false, or an enum label

write_register Write Register

Write one raw holding register (FC06). No scaling or limits are applied, so only use it for addresses the register map does not describe (mapped addresses are refused: use write_point). Returns a read-back if the register is readable.

ParameterTypeDescription
address *integer0-based holding-register address
value *integerRaw value (negative = int16 two's complement)

write_registers Write Registers

Write consecutive raw holding registers (FC16), e.g. both halves of a 32-bit value. No scaling or limits are applied; mapped addresses are refused (use write_point).

ParameterTypeDescription
address *integer0-based start address
values *arrayRaw 16-bit values

write_coil Write Coil

Switch one raw coil (FC05). Coils often start or stop equipment (heaters, pumps, motors); mapped coils are refused here (use write_point).

ParameterTypeDescription
address *integer0-based coil address
value *booleantrue = ON (0xFF00), false = OFF